From: Abdelrazak Younes Date: Sun, 21 Sep 2008 21:28:37 +0000 (+0000) Subject: Reset the geometry and ui settings whenever a change in the ui files is selected... X-Git-Tag: 1.6.10~3391 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8e4d2d66ce8da8acff98a87e2d3bcd03036617ed;p=features.git Reset the geometry and ui settings whenever a change in the ui files is selected. This commit will destroy any current geometry session. The "view-id/" nodes are converted into "view/id/" nodes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26484 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index f608e75d40..ee2557abb3 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -257,7 +257,7 @@ void Dialog::checkStatus() QString Dialog::sessionKey() const { - return "view-" + QString::number(lyxview_->id()) + return "views/" + QString::number(lyxview_->id()) + "/" + name(); } diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 13475a28cb..d19f0a2083 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -720,6 +722,13 @@ GuiApplication::GuiApplication(int & argc, char ** argv) } +void GuiApplication::clearSession() +{ + QSettings settings; + settings.clear(); +} + + docstring GuiApplication::iconName(FuncRequest const & f, bool unknown) { return qstring_to_ucs4(lyx::frontend::iconName(f, unknown)); @@ -1085,6 +1094,7 @@ void GuiApplication::execBatchCommands() lyx::execBatchCommands(); } + QAbstractItemModel * GuiApplication::languageModel() { if (d->language_model_) @@ -1371,21 +1381,6 @@ bool GuiApplication::readUIFile(QString const & name, bool include) { "toolbarset", ui_toolbarset } }; - // Ensure that a file is read only once (prevents include loops) - static QStringList uifiles; - if (uifiles.contains(name)) { - if (!include) { - // We are reading again the top uifile so reset the safeguard: - uifiles.clear(); - d->menus_.reset(); - d->toolbars_.reset(); - } else { - LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. " - << "Is this an include loop?"); - return false; - } - } - LYXERR(Debug::INIT, "About to read " << name << "..."); FileName ui_path; @@ -1405,9 +1400,26 @@ bool GuiApplication::readUIFile(QString const & name, bool include) return false; } - uifiles.push_back(name); + + // Ensure that a file is read only once (prevents include loops) + static QStringList uifiles; + QString const uifile = toqstr(ui_path.absFilename()); + if (uifiles.contains(uifile)) { + if (!include) { + // We are reading again the top uifile so reset the safeguard: + uifiles.clear(); + d->menus_.reset(); + d->toolbars_.reset(); + } else { + LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. " + << "Is this an include loop?"); + return false; + } + } + uifiles.push_back(uifile); LYXERR(Debug::INIT, "Found " << name << " in " << ui_path); + Lexer lex(uitags); lex.setFile(ui_path); if (!lex.isOK()) { @@ -1446,6 +1458,33 @@ bool GuiApplication::readUIFile(QString const & name, bool include) break; } } + + if (include) + return true; + + QSettings settings; + settings.beginGroup("ui_files"); + bool touched = false; + for (int i = 0; i != uifiles.size(); ++i) { + QFileInfo fi(uifiles[i]); + QDateTime const date_value = fi.lastModified(); + QString const name_key = QString::number(i); + qDebug() << "File read " << i << " " << uifiles[i] << " " << date_value.toString("hh:mm:ss.zzz"); + qDebug() << "File saved " << name_key << " " << settings.value(name_key).toString() + << " " << settings.value(name_key + "/date").toDateTime().toString("hh:mm:ss.zzz"); + + if (!settings.contains(name_key) + || settings.value(name_key).toString() != uifiles[i] + || settings.value(name_key + "/date").toDateTime() != date_value) { + touched = true; + settings.setValue(name_key, uifiles[i]); + settings.setValue(name_key + "/date", date_value); + } + } + settings.endGroup(); + if (touched) + settings.remove("views"); + return true; } diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index aa73e6fc00..50579bc1e3 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -52,6 +52,9 @@ public: GuiApplication(int & argc, char ** argv); ~GuiApplication(); + /// Clear all session information. + void clearSession(); + /// Method inherited from \c Application class //@{ bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const; diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index aead589113..01948449d3 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -917,7 +917,7 @@ void GuiToolbar::update(bool in_math, bool in_table, bool in_review, QString GuiToolbar::sessionKey() const { - return "view-" + QString::number(owner_.id()) + "/" + objectName(); + return "views/" + QString::number(owner_.id()) + "/" + objectName(); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 29c3e5843d..2c7fcfa51c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -334,7 +334,7 @@ GuiView::GuiView(int id) initToolbars(); // This enables to clear session data if any. QSettings settings; - settings.clear(); + settings.remove("views"); } @@ -347,7 +347,7 @@ GuiView::~GuiView() void GuiView::saveLayout() const { QSettings settings; - QString const key = "view-" + QString::number(id_); + QString const key = "views/" + QString::number(id_); #ifdef Q_WS_X11 settings.setValue(key + "/pos", pos()); settings.setValue(key + "/size", size()); @@ -362,7 +362,7 @@ void GuiView::saveLayout() const bool GuiView::restoreLayout() { QSettings settings; - QString const key = "view-" + QString::number(id_); + QString const key = "views/" + QString::number(id_); QString const icon_key = key + "/icon_size"; if (!settings.contains(icon_key)) return false; @@ -377,6 +377,9 @@ bool GuiView::restoreLayout() if (!restoreGeometry(settings.value(key + "/geometry").toByteArray())) setGeometry(50, 50, 690, 510); #endif + // Make sure layout is correctly oriented. + setLayoutDirection(qApp->layoutDirection()); + // Allow the toc and view-source dock widget to be restored if needed. Dialog * tmp; if ((tmp = findOrBuild("toc", true)))