mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +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).
(cherry picked from commit 3b43fbfbb1
)
This commit is contained in:
parent
4947476da8
commit
5a3201a8c4
@ -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());
|
settings.setValue(sessionKey() + "/geometry", asQWidget()->saveGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
class QSettings;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -72,7 +73,7 @@ public:
|
|||||||
* This default implementation saves the geometry state.
|
* This default implementation saves the geometry state.
|
||||||
* Reimplement to save more settings.
|
* Reimplement to save more settings.
|
||||||
**/
|
**/
|
||||||
virtual void saveSession() const;
|
virtual void saveSession(QSettings & settings) const;
|
||||||
|
|
||||||
/// Restore session settings.
|
/// Restore session settings.
|
||||||
/**
|
/**
|
||||||
|
@ -466,10 +466,9 @@ void GuiCharacter::dispatchParams()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiCharacter::saveSession() const
|
void GuiCharacter::saveSession(QSettings & settings) const
|
||||||
{
|
{
|
||||||
Dialog::saveSession();
|
Dialog::saveSession(settings);
|
||||||
QSettings settings;
|
|
||||||
settings.setValue(sessionKey() + "/toggleall", toggleallCB->isChecked());
|
settings.setValue(sessionKey() + "/toggleall", toggleallCB->isChecked());
|
||||||
settings.setValue(sessionKey() + "/autoapply", autoapplyCB->isChecked());
|
settings.setValue(sessionKey() + "/autoapply", autoapplyCB->isChecked());
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ private:
|
|||||||
void dispatchParams();
|
void dispatchParams();
|
||||||
bool isBufferDependent() const { return true; }
|
bool isBufferDependent() const { return true; }
|
||||||
FuncCode getLfun() const { return LFUN_TEXTSTYLE_UPDATE; }
|
FuncCode getLfun() const { return LFUN_TEXTSTYLE_UPDATE; }
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
@ -1049,10 +1049,9 @@ BiblioInfo const & GuiCitation::bibInfo() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiCitation::saveSession() const
|
void GuiCitation::saveSession(QSettings & settings) const
|
||||||
{
|
{
|
||||||
Dialog::saveSession();
|
Dialog::saveSession(settings);
|
||||||
QSettings settings;
|
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
sessionKey() + "/regex", regexp_->isChecked());
|
sessionKey() + "/regex", regexp_->isChecked());
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
|
@ -79,7 +79,7 @@ private:
|
|||||||
void clearParams();
|
void clearParams();
|
||||||
void dispatchParams();
|
void dispatchParams();
|
||||||
bool isBufferDependent() const { return true; }
|
bool isBufferDependent() const { return true; }
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
/** Disconnect from the inset when the Apply button is pressed.
|
/** Disconnect from the inset when the Apply button is pressed.
|
||||||
* Allows easy insertion of multiple citations.
|
* 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();
|
Dialog::saveSession(settings);
|
||||||
QSettings settings;
|
|
||||||
settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked());
|
settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void enableView(bool enable);
|
void enableView(bool enable);
|
||||||
bool isBufferDependent() const { return true; }
|
bool isBufferDependent() const { return true; }
|
||||||
virtual FuncCode getLfun() const { return LFUN_PARAGRAPH_PARAMS_APPLY; }
|
virtual FuncCode getLfun() const { return LFUN_PARAGRAPH_PARAMS_APPLY; }
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
@ -232,10 +232,9 @@ void GuiProgressView::appendText(QString const & text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiProgressView::saveSession() const
|
void GuiProgressView::saveSession(QSettings & settings) const
|
||||||
{
|
{
|
||||||
Dialog::saveSession();
|
Dialog::saveSession(settings);
|
||||||
QSettings settings;
|
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
sessionKey() + "/autoclear", widget_->autoClearCB->isChecked());
|
sessionKey() + "/autoclear", widget_->autoClearCB->isChecked());
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
void updateView() {}
|
void updateView() {}
|
||||||
bool wantInitialFocus() const { return false; }
|
bool wantInitialFocus() const { return false; }
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
private Q_SLOTS:
|
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() + "/visibility", visibility_);
|
||||||
settings.setValue(sessionKey() + "/movability", isMovable());
|
settings.setValue(sessionKey() + "/movability", isMovable());
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class DocumentClass;
|
class DocumentClass;
|
||||||
@ -84,7 +86,7 @@ public:
|
|||||||
**/
|
**/
|
||||||
QString sessionKey() const;
|
QString sessionKey() const;
|
||||||
/// Save session settings.
|
/// Save session settings.
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
/// Restore session settings.
|
/// Restore session settings.
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
|
|
||||||
|
@ -758,14 +758,16 @@ void GuiView::saveLayout() const
|
|||||||
|
|
||||||
void GuiView::saveUISettings() const
|
void GuiView::saveUISettings() const
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
// Save the toolbar private states
|
// Save the toolbar private states
|
||||||
ToolbarMap::iterator end = d.toolbars_.end();
|
ToolbarMap::iterator end = d.toolbars_.end();
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
||||||
it->second->saveSession();
|
it->second->saveSession(settings);
|
||||||
// Now take care of all other dialogs
|
// Now take care of all other dialogs
|
||||||
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
||||||
for (; it!= d.dialogs_.end(); ++it)
|
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 + "/output", toqstr(view_format_));
|
||||||
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
|
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
|
||||||
settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked());
|
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();
|
Dialog::saveSession(settings);
|
||||||
widget_->saveSession(sessionKey());
|
widget_->saveSession(settings, sessionKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
/// returns true if the string has changed
|
/// returns true if the string has changed
|
||||||
bool setText(QString const & qstr = QString());
|
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);
|
void restoreSession(QString const & session_key);
|
||||||
///
|
///
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
bool canApplyToReadOnly() const { return true; }
|
bool canApplyToReadOnly() const { return true; }
|
||||||
void updateView();
|
void updateView();
|
||||||
void enableView(bool enable);
|
void enableView(bool enable);
|
||||||
void saveSession() const;
|
void saveSession(QSettings & settings) const;
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
bool wantInitialFocus() const { return false; }
|
bool wantInitialFocus() const { return false; }
|
||||||
///@}
|
///@}
|
||||||
|
Loading…
Reference in New Issue
Block a user