]> git.lyx.org Git - features.git/commitdiff
Reset the geometry and ui settings whenever a change in the ui files is selected...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 21 Sep 2008 21:28:37 +0000 (21:28 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 21 Sep 2008 21:28:37 +0000 (21:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26484 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialog.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiView.cpp

index f608e75d40c47d48da7f9dd5d2280131caf1f722..ee2557abb3f71da3cf176f01f000e6b93bba3c2f 100644 (file)
@@ -257,7 +257,7 @@ void Dialog::checkStatus()
 
 QString Dialog::sessionKey() const
 {
-       return "view-" + QString::number(lyxview_->id())
+       return "views/" + QString::number(lyxview_->id())
                + "/" + name();
 }
 
index 13475a28cb8b42f8215e59ae41d054733d15793b..d19f0a2083367e3c6538d3cd4f592fb90a14ff81 100644 (file)
@@ -67,6 +67,7 @@
 #include <QDir>
 #include <QEventLoop>
 #include <QFileOpenEvent>
+#include <QFileInfo>
 #include <QHash>
 #include <QIcon>
 #include <QImageReader>
@@ -81,6 +82,7 @@
 #include <QPixmapCache>
 #include <QRegExp>
 #include <QSessionManager>
+#include <QSettings>
 #include <QSocketNotifier>
 #include <QSortFilterProxyModel>
 #include <QStandardItemModel>
@@ -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;
 }
 
index aa73e6fc00ea3d0d347c78f2e8dd3ee5ce02433b..50579bc1e3f461f8d78257c5734b3d5e8eec656d 100644 (file)
@@ -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;
index aead589113561a01fa9148ebdba9a04fb4de1e76..01948449d3fd44b14c35a8a4e85cbca25c87570a 100644 (file)
@@ -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();
 }
 
 
index 29c3e5843d3556d15983958e24ca6fb682a2148a..2c7fcfa51ca18f5f3032a1d179c8b74b049fbdfb 100644 (file)
@@ -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)))