]> git.lyx.org Git - features.git/commitdiff
GuiApplication::resetGui(): reset as many things as possible, including menus and...
authorAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 18:03:38 +0000 (18:03 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 18:03:38 +0000 (18:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25390 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Menus.cpp
src/frontends/qt4/Menus.h
src/frontends/qt4/Toolbars.cpp
src/frontends/qt4/Toolbars.h

index 4b452848fb41e20632f4b6d8c506a23431e47c3e..ec4784c55cde9bdfb4556494b2e30ee75cbfb765 100644 (file)
@@ -898,6 +898,19 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
 
 void GuiApplication::resetGui()
 {
+       // Set the language defined by the user.
+       LyX::ref().setRcGuiLanguage();
+
+       // Read menus
+       if (!readUIFile(toqstr(lyxrc.ui_file)))
+               // Gives some error box here.
+               return;
+
+       // init the global menubar on Mac. This must be done after the session
+       // was recovered to know the "last files".
+       if (d->global_menubar_)
+               d->menus_.fillMenuBar(d->global_menubar_, 0, true);
+
        QHash<int, GuiView *>::iterator it;
        for (it = d->views_.begin(); it != d->views_.end(); ++it)
                (*it)->resetDialogs();
@@ -1328,9 +1341,16 @@ bool GuiApplication::readUIFile(QString const & name, bool include)
        // Ensure that a file is read only once (prevents include loops)
        static QStringList uifiles;
        if (uifiles.contains(name)) {
-               LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
-                                   << "Is this an include loop?");
-               return false;
+               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 << "...");
index 25f5b13a60b9e0ee25712e97114ce158bf52f5b1..6ddf0f33ae12d5b2c1c4798f28219a8c5b9aa758 100644 (file)
@@ -404,6 +404,7 @@ void GuiView::constructToolbars()
        for (; it != d.toolbars_.end(); ++it)
                delete it->second;
        d.toolbars_.clear();
+       d.layout_ = 0;
 
        // extracts the toolbars from the backend
        Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
@@ -2150,14 +2151,15 @@ void GuiView::resetDialogs()
 {
        // Make sure that no LFUN uses any LyXView.
        theLyXFunc().setLyXView(0);
-       // FIXME: the "math panels" toolbar takes an awful lot of time to
-       // initialise so we don't do that for the time being.
-       //initToolbars();
-       guiApp->menus().fillMenuBar(menuBar(), this);
+       saveLayout();
+       menuBar()->clear();
+       constructToolbars();
+       guiApp->menus().fillMenuBar(menuBar(), this, true);
        if (d.layout_)
                d.layout_->updateContents(true);
        // Now update controls with current buffer.
        theLyXFunc().setLyXView(this);
+       restoreLayout();
        restartCursor();
 }
 
index c124469e821ea0ed140e9c76e2a3916bb54a4ef8..c6fc7345859aa6debfcf7e622a4ad62cc269cd74 100644 (file)
@@ -1453,11 +1453,20 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
 
 Menus::Menus() : d(new Impl) {}
 
+
 Menus::~Menus()
 {
   delete d;
 }
 
+
+void Menus::reset()
+{
+       delete d;
+       d = new Impl;
+}
+
+
 void Menus::read(Lexer & lex)
 {
        enum {
index 5e438670fa5567d47c83bec84b537c367d43716b..531eb3b40017fc83f672a3c142ab415151ca92ae 100644 (file)
@@ -59,6 +59,9 @@ class Menus
 public:
        Menus();
        ~Menus();
+
+       ///
+       void reset();
        
        ///
        bool searchMenu(FuncRequest const & func,
@@ -78,8 +81,8 @@ public:
 private:
        /// Use the Pimpl idiom to hide the internals.
        struct Impl;
-       /// The pointer never changes although *d's contents may.
-       Impl * const d;
+       ///
+       Impl * d;
 };
 
 } // namespace frontend
index b1d6a41336ae84ab54111691bb4ce890aff5421b..3a335fe4958eb4ecd213c30f6a58256a91df4e40 100644 (file)
@@ -190,6 +190,12 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 //
 /////////////////////////////////////////////////////////////////////////
 
+void Toolbars::reset()
+{
+       toolbar_info_.clear();
+       toolbar_visibility_.clear();
+}
+
 
 void Toolbars::readToolbars(Lexer & lex)
 {
index 0932a6861d14251c0beaac0542168a46f7db11d9..6ecc738ad9b7ffecd5ca1aff2739780dd32362b1 100644 (file)
@@ -112,6 +112,9 @@ public:
 
        Toolbars() {}
 
+       ///
+       void reset();
+
        /// iterator for all toolbars
        Infos::const_iterator begin() const { return toolbar_info_.begin(); }