mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
Add common session handling infrastructure for dialogs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22061 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
15601573d2
commit
41681e7185
@ -13,6 +13,7 @@
|
|||||||
#include "Dialog.h"
|
#include "Dialog.h"
|
||||||
|
|
||||||
#include "GuiView.h"
|
#include "GuiView.h"
|
||||||
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
@ -21,6 +22,9 @@
|
|||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -241,5 +245,27 @@ void Dialog::checkStatus()
|
|||||||
enableView(false);
|
enableView(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Dialog::sessionKey() const
|
||||||
|
{
|
||||||
|
return "view-" + QString::number(lyxview_->id())
|
||||||
|
+ "/" + toqstr(name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Dialog::saveSession() const
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue(sessionKey() + "/geometry", asQWidget()->saveGeometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Dialog::restoreSession()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
asQWidget()->restoreGeometry(
|
||||||
|
settings.value(sessionKey() + "/geometry").toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class QString;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -56,6 +57,26 @@ public:
|
|||||||
virtual QWidget * asQWidget() = 0;
|
virtual QWidget * asQWidget() = 0;
|
||||||
virtual QWidget const * asQWidget() const = 0;
|
virtual QWidget const * asQWidget() const = 0;
|
||||||
|
|
||||||
|
/// Session key.
|
||||||
|
/**
|
||||||
|
* This key must be used for any session setting.
|
||||||
|
**/
|
||||||
|
QString sessionKey() const;
|
||||||
|
|
||||||
|
/// Save session settings.
|
||||||
|
/**
|
||||||
|
* This default implementation saves the geometry state.
|
||||||
|
* Reimplement to save more settings.
|
||||||
|
**/
|
||||||
|
virtual void saveSession() const;
|
||||||
|
|
||||||
|
/// Restore session settings.
|
||||||
|
/**
|
||||||
|
* This default implementation restores the geometry state.
|
||||||
|
* Reimplement to restore more settings.
|
||||||
|
**/
|
||||||
|
virtual void restoreSession();
|
||||||
|
|
||||||
/** \name Container Access
|
/** \name Container Access
|
||||||
* These methods are publicly accessible because they are invoked
|
* These methods are publicly accessible because they are invoked
|
||||||
* by the parent container acting on commands from the LyX kernel.
|
* by the parent container acting on commands from the LyX kernel.
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QSettings>
|
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
||||||
|
|
||||||
@ -33,24 +32,6 @@ void DialogView::setViewTitle(docstring const & title)
|
|||||||
setWindowTitle("LyX: " + toqstr(title));
|
setWindowTitle("LyX: " + toqstr(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DialogView::showEvent(QShowEvent * e)
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
QString key = toqstr(name()) + "/geometry";
|
|
||||||
restoreGeometry(settings.value(key).toByteArray());
|
|
||||||
QDialog::showEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DialogView::closeEvent(QCloseEvent * e)
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
QString key = toqstr(name()) + "/geometry";
|
|
||||||
settings.setValue(key, saveGeometry());
|
|
||||||
QDialog::closeEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -39,14 +39,9 @@ public:
|
|||||||
virtual QWidget * asQWidget() { return this; }
|
virtual QWidget * asQWidget() { return this; }
|
||||||
virtual QWidget const * asQWidget() const { return this; }
|
virtual QWidget const * asQWidget() const { return this; }
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
///
|
///
|
||||||
void setViewTitle(docstring const & title);
|
void setViewTitle(docstring const & title);
|
||||||
|
|
||||||
///
|
|
||||||
void closeEvent(QCloseEvent *);
|
|
||||||
///
|
|
||||||
void showEvent(QShowEvent *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include "Dialog.h"
|
#include "Dialog.h"
|
||||||
#include "GuiView.h"
|
#include "GuiView.h"
|
||||||
#include "qt_helpers.h"
|
|
||||||
#include "support/debug.h"
|
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
|
||||||
@ -23,8 +21,11 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
/// Dock Widget container for LyX dialogs.
|
/// Dock Widget container for LyX dialogs.
|
||||||
/// This template class that encapsulates a given Widget inside a
|
/**
|
||||||
/// QDockWidget and presents a Dialog interface
|
* This template class that encapsulates a given Widget inside a
|
||||||
|
* QDockWidget and presents a Dialog interface
|
||||||
|
* FIXME: create a DockView.cpp file
|
||||||
|
**/
|
||||||
class DockView : public QDockWidget, public Dialog
|
class DockView : public QDockWidget, public Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "GuiProgress.h"
|
#include "GuiProgress.h"
|
||||||
|
|
||||||
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include "support/Systemcall.h"
|
#include "support/Systemcall.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -27,7 +29,7 @@ GuiProgress::GuiProgress(GuiView & parent, Qt::DockWidgetArea area,
|
|||||||
{
|
{
|
||||||
setWindowTitle(qt_("LaTeX Progress"));
|
setWindowTitle(qt_("LaTeX Progress"));
|
||||||
setWidget(&text_edit);
|
setWidget(&text_edit);
|
||||||
lyx::support::Systemcall::registerProgressInterface(this);
|
support::Systemcall::registerProgressInterface(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,6 +421,10 @@ void GuiView::closeEvent(QCloseEvent * close_event)
|
|||||||
#endif
|
#endif
|
||||||
settings.setValue(key + "/icon_size", iconSize());
|
settings.setValue(key + "/icon_size", iconSize());
|
||||||
d.toolbars_->saveToolbarInfo();
|
d.toolbars_->saveToolbarInfo();
|
||||||
|
// Now take care of all other dialogs:
|
||||||
|
std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
||||||
|
for (; it!= d.dialogs_.end(); ++it)
|
||||||
|
it->second->saveSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
guiApp->unregisterView(id_);
|
guiApp->unregisterView(id_);
|
||||||
@ -1619,8 +1623,11 @@ Dialog * GuiView::find_or_build(string const & name)
|
|||||||
if (it != d.dialogs_.end())
|
if (it != d.dialogs_.end())
|
||||||
return it->second.get();
|
return it->second.get();
|
||||||
|
|
||||||
d.dialogs_[name].reset(build(name));
|
Dialog * dialog = build(name);
|
||||||
return d.dialogs_[name].get();
|
d.dialogs_[name].reset(dialog);
|
||||||
|
if (lyxrc.allow_geometry_session)
|
||||||
|
dialog->restoreSession();
|
||||||
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user