#include "Dialog.h"
#include "GuiView.h"
+#include "qt_helpers.h"
#include "Buffer.h"
#include "FuncRequest.h"
#include "support/debug.h"
+#include <QSettings>
+#include <QString>
+
#include <string>
using namespace std;
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 lyx
#include <string>
+class QString;
class QWidget;
namespace lyx {
virtual QWidget * asQWidget() = 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
* These methods are publicly accessible because they are invoked
* by the parent container acting on commands from the LyX kernel.
#include "qt_helpers.h"
#include <QCloseEvent>
-#include <QSettings>
#include <QShowEvent>
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 lyx
virtual QWidget * asQWidget() { return this; }
virtual QWidget const * asQWidget() const { return this; }
-public:
+protected:
///
void setViewTitle(docstring const & title);
-
- ///
- void closeEvent(QCloseEvent *);
- ///
- void showEvent(QShowEvent *);
};
} // namespace frontend
#include "Dialog.h"
#include "GuiView.h"
-#include "qt_helpers.h"
-#include "support/debug.h"
#include <QDockWidget>
namespace frontend {
/// 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
{
public:
#include "GuiProgress.h"
+#include "qt_helpers.h"
+
#include "support/Systemcall.h"
#include <QApplication>
{
setWindowTitle(qt_("LaTeX Progress"));
setWidget(&text_edit);
- lyx::support::Systemcall::registerProgressInterface(this);
+ support::Systemcall::registerProgressInterface(this);
}
#endif
settings.setValue(key + "/icon_size", iconSize());
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_);
if (it != d.dialogs_.end())
return it->second.get();
- d.dialogs_[name].reset(build(name));
- return d.dialogs_[name].get();
+ Dialog * dialog = build(name);
+ d.dialogs_[name].reset(dialog);
+ if (lyxrc.allow_geometry_session)
+ dialog->restoreSession();
+ return dialog;
}