mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Speed up exit time
Instantiating a single QSettings and using it for each ui element can significantly shorten the time required to save the various states at exit. The speed up can be better appreciated on *nix, where the settings are saved on disk, rather than on Windows where they are held in memory (in the registry).
This commit is contained in:
parent
88a0666d6c
commit
3b43fbfbb1
@ -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());
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
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.
|
||||
/**
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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();
|
||||
//@}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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.
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
//@}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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:
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
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();
|
||||
|
||||
|
@ -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<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
||||
for (; it!= d.dialogs_.end(); ++it)
|
||||
it->second->saveSession();
|
||||
it->second->saveSession(settings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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; }
|
||||
///@}
|
||||
|
Loading…
Reference in New Issue
Block a user