diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index e1fddaaa7e..2369738c5c 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -275,9 +275,8 @@ QString Dialog::sessionKey() const } -void Dialog::saveSession() const +void Dialog::saveSession(QSettings & settings) const { - QSettings settings; settings.setValue(sessionKey() + "/geometry", asQWidget()->saveGeometry()); } diff --git a/src/frontends/qt4/Dialog.h b/src/frontends/qt4/Dialog.h index c5ccd2d292..5f958e79d0 100644 --- a/src/frontends/qt4/Dialog.h +++ b/src/frontends/qt4/Dialog.h @@ -20,6 +20,7 @@ #include +class QSettings; class QWidget; namespace lyx { @@ -72,7 +73,7 @@ public: * This default implementation saves the geometry state. * Reimplement to save more settings. **/ - virtual void saveSession() const; + virtual void saveSession(QSettings & settings) const; /// Restore session settings. /** diff --git a/src/frontends/qt4/GuiCharacter.cpp b/src/frontends/qt4/GuiCharacter.cpp index ff7cc5d10e..1e92db848d 100644 --- a/src/frontends/qt4/GuiCharacter.cpp +++ b/src/frontends/qt4/GuiCharacter.cpp @@ -466,10 +466,9 @@ void GuiCharacter::dispatchParams() } -void GuiCharacter::saveSession() const +void GuiCharacter::saveSession(QSettings & settings) const { - Dialog::saveSession(); - QSettings settings; + Dialog::saveSession(settings); settings.setValue(sessionKey() + "/toggleall", toggleallCB->isChecked()); settings.setValue(sessionKey() + "/autoapply", autoapplyCB->isChecked()); } diff --git a/src/frontends/qt4/GuiCharacter.h b/src/frontends/qt4/GuiCharacter.h index 423bc8a3a5..8328211eb1 100644 --- a/src/frontends/qt4/GuiCharacter.h +++ b/src/frontends/qt4/GuiCharacter.h @@ -76,7 +76,7 @@ private: void dispatchParams(); bool isBufferDependent() const { return true; } FuncCode getLfun() const { return LFUN_TEXTSTYLE_UPDATE; } - void saveSession() const; + void saveSession(QSettings & settings) const; void restoreSession(); //@} diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 1d78da61dd..cecdbca093 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -1049,10 +1049,9 @@ BiblioInfo const & GuiCitation::bibInfo() const } -void GuiCitation::saveSession() const +void GuiCitation::saveSession(QSettings & settings) const { - Dialog::saveSession(); - QSettings settings; + Dialog::saveSession(settings); settings.setValue( sessionKey() + "/regex", regexp_->isChecked()); settings.setValue( diff --git a/src/frontends/qt4/GuiCitation.h b/src/frontends/qt4/GuiCitation.h index 5f093cc21d..008d2d556d 100644 --- a/src/frontends/qt4/GuiCitation.h +++ b/src/frontends/qt4/GuiCitation.h @@ -79,7 +79,7 @@ private: void clearParams(); void dispatchParams(); bool isBufferDependent() const { return true; } - void saveSession() const; + void saveSession(QSettings & settings) const; void restoreSession(); /** Disconnect from the inset when the Apply button is pressed. * Allows easy insertion of multiple citations. diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 0c8e01aaa4..656e70f304 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -384,10 +384,9 @@ bool GuiParagraph::hasLabelwidth() const } -void GuiParagraph::saveSession() const +void GuiParagraph::saveSession(QSettings & settings) const { - Dialog::saveSession(); - QSettings settings; + Dialog::saveSession(settings); settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked()); } diff --git a/src/frontends/qt4/GuiParagraph.h b/src/frontends/qt4/GuiParagraph.h index aee410f607..735d58ca8f 100644 --- a/src/frontends/qt4/GuiParagraph.h +++ b/src/frontends/qt4/GuiParagraph.h @@ -39,7 +39,7 @@ public: void enableView(bool enable); bool isBufferDependent() const { return true; } virtual FuncCode getLfun() const { return LFUN_PARAGRAPH_PARAMS_APPLY; } - void saveSession() const; + void saveSession(QSettings & settings) const; void restoreSession(); //@} diff --git a/src/frontends/qt4/GuiProgressView.cpp b/src/frontends/qt4/GuiProgressView.cpp index 3424d8f451..9a5090832e 100644 --- a/src/frontends/qt4/GuiProgressView.cpp +++ b/src/frontends/qt4/GuiProgressView.cpp @@ -232,10 +232,9 @@ void GuiProgressView::appendText(QString const & text) } -void GuiProgressView::saveSession() const +void GuiProgressView::saveSession(QSettings & settings) const { - Dialog::saveSession(); - QSettings settings; + Dialog::saveSession(settings); settings.setValue( sessionKey() + "/autoclear", widget_->autoClearCB->isChecked()); settings.setValue( diff --git a/src/frontends/qt4/GuiProgressView.h b/src/frontends/qt4/GuiProgressView.h index f7593a2cc1..9498909319 100644 --- a/src/frontends/qt4/GuiProgressView.h +++ b/src/frontends/qt4/GuiProgressView.h @@ -61,7 +61,7 @@ public: void updateView() {} bool wantInitialFocus() const { return false; } void restoreSession(); - void saveSession() const; + void saveSession(QSettings & settings) const; ///@} private Q_SLOTS: diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index d519548e07..db96e0e526 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -351,9 +351,8 @@ QString GuiToolbar::sessionKey() const } -void GuiToolbar::saveSession() const +void GuiToolbar::saveSession(QSettings & settings) const { - QSettings settings; settings.setValue(sessionKey() + "/visibility", visibility_); settings.setValue(sessionKey() + "/movability", isMovable()); } diff --git a/src/frontends/qt4/GuiToolbar.h b/src/frontends/qt4/GuiToolbar.h index 6df840a9bd..badd59930a 100644 --- a/src/frontends/qt4/GuiToolbar.h +++ b/src/frontends/qt4/GuiToolbar.h @@ -20,6 +20,8 @@ #include #include +class QSettings; + namespace lyx { class DocumentClass; @@ -84,7 +86,7 @@ public: **/ QString sessionKey() const; /// Save session settings. - void saveSession() const; + void saveSession(QSettings & settings) const; /// Restore session settings. void restoreSession(); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index b0d7c86fd0..2aee2735d3 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -758,14 +758,16 @@ void GuiView::saveLayout() const void GuiView::saveUISettings() const { + QSettings settings; + // Save the toolbar private states ToolbarMap::iterator end = d.toolbars_.end(); for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it) - it->second->saveSession(); + it->second->saveSession(settings); // Now take care of all other dialogs map::const_iterator it = d.dialogs_.begin(); for (; it!= d.dialogs_.end(); ++it) - it->second->saveSession(); + it->second->saveSession(settings); } diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 80d3c0b459..04c6bf5c34 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -367,9 +367,8 @@ void ViewSourceWidget::resizeEvent (QResizeEvent * event) } -void ViewSourceWidget::saveSession(QString const & session_key) const +void ViewSourceWidget::saveSession(QSettings & settings, QString const & session_key) const { - QSettings settings; settings.setValue(session_key + "/output", toqstr(view_format_)); settings.setValue(session_key + "/contents", contentsCO->currentIndex()); settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked()); @@ -462,10 +461,10 @@ void GuiViewSource::updateTitle() } -void GuiViewSource::saveSession() const +void GuiViewSource::saveSession(QSettings & settings) const { - Dialog::saveSession(); - widget_->saveSession(sessionKey()); + Dialog::saveSession(settings); + widget_->saveSession(settings, sessionKey()); } diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 873f8dbf4f..48f2903b74 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -47,7 +47,7 @@ public: /// returns true if the string has changed bool setText(QString const & qstr = QString()); /// - void saveSession(QString const & session_key) const; + void saveSession(QSettings & settings, QString const & session_key) const; /// void restoreSession(QString const & session_key); /// @@ -112,7 +112,7 @@ public: bool canApplyToReadOnly() const { return true; } void updateView(); void enableView(bool enable); - void saveSession() const; + void saveSession(QSettings & settings) const; void restoreSession(); bool wantInitialFocus() const { return false; } ///@}