]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiToolbars.cpp
reduce line noise
[features.git] / src / frontends / qt4 / GuiToolbars.cpp
index 7e3430b08cc6fcff20a919a6b0cc2deef74444d0..e5999ef2d9f30a41e0d6b49661feeb9d6ace6168 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "GuiToolbars.h"
 
+#include "GuiCommandBuffer.h"
 #include "GuiToolbar.h"
 #include "GuiView.h"
 
@@ -27,6 +28,7 @@
 #include "LyX.h"
 #include "LyXFunc.h"
 #include "TextClass.h"
+#include "ToolbarBackend.h"
 
 
 using std::endl;
@@ -38,7 +40,7 @@ namespace frontend {
 #define TurnOnFlag(x)   flags |= ToolbarInfo::x
 #define TurnOffFlag(x)  flags &= ~ToolbarInfo::x
 
-GuiToolbars::GuiToolbars(GuiViewBase & owner)
+GuiToolbars::GuiToolbars(GuiView & owner)
        : owner_(owner),
          layout_(0),
          last_textclass_(TextClassPtr())
@@ -120,28 +122,32 @@ void GuiToolbars::init()
                initFlags(*cit);
 
        // add toolbars according the order in session
-       ToolbarSection::ToolbarList::const_iterator tb = LyX::ref().session().toolbars().begin();
-       ToolbarSection::ToolbarList::const_iterator te = LyX::ref().session().toolbars().end();
-       ToolbarSection::ToolbarInfo::Location last_loc = ToolbarSection::ToolbarInfo::NOTSET;
+       ToolbarSection::ToolbarList::const_iterator tb =
+               LyX::ref().session().toolbars().begin();
+       ToolbarSection::ToolbarList::const_iterator te =
+               LyX::ref().session().toolbars().end();
+       ToolbarSection::ToolbarInfo::Location last_loc =
+               ToolbarSection::ToolbarInfo::NOTSET;
        int last_posx = 0;
        int last_posy = 0;
        for (; tb != te; ++tb) {
-               LYXERR(Debug::INIT) << "Adding " << tb->get<0>() << " at position " << tb->get<1>().posx << " " << tb->get<1>().posy << endl;
+               LYXERR(Debug::INIT, "Adding " << tb->key << " at position "
+                       << tb->info.posx << " " << tb->info.posy);
                // add toolbar break if posx or posy changes
-               bool newline = tb->get<1>().location == last_loc && (
+               bool newline = tb->info.location == last_loc && (
                        // if two toolbars at the same location, assume uninitialized and add toolbar break
-                       (tb->get<1>().posx == last_posx && tb->get<1>().posy == last_posy) ||
-                       (last_loc == ToolbarSection::ToolbarInfo::TOP && tb->get<1>().posy != last_posy) ||
-                       (last_loc == ToolbarSection::ToolbarInfo::BOTTOM && tb->get<1>().posy != last_posy) ||
-                       (last_loc == ToolbarSection::ToolbarInfo::LEFT && tb->get<1>().posx != last_posx) ||
-                       (last_loc == ToolbarSection::ToolbarInfo::RIGHT && tb->get<1>().posx != last_posx) );
+                       (tb->info.posx == last_posx && tb->info.posy == last_posy) ||
+                       (last_loc == ToolbarSection::ToolbarInfo::TOP && tb->info.posy != last_posy) ||
+                       (last_loc == ToolbarSection::ToolbarInfo::BOTTOM && tb->info.posy != last_posy) ||
+                       (last_loc == ToolbarSection::ToolbarInfo::LEFT && tb->info.posx != last_posx) ||
+                       (last_loc == ToolbarSection::ToolbarInfo::RIGHT && tb->info.posx != last_posx) );
                // find the backend item and add
                for (cit = toolbarbackend.begin(); cit != end; ++cit)
-                       if (cit->name == tb->get<0>()) {
+                       if (cit->name == tb->key) {
                                add(*cit, newline);
-                               last_loc = tb->get<1>().location;
-                               last_posx = tb->get<1>().posx;
-                               last_posy = tb->get<1>().posy;
+                               last_loc = tb->info.location;
+                               last_posx = tb->info.posx;
+                               last_posy = tb->info.posy;
                                break;
                        }
        }
@@ -168,8 +174,7 @@ void GuiToolbars::display(string const & name, bool show)
                }
        }
 
-       LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
-               << name << endl;
+       LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
 }
 
 
@@ -184,8 +189,7 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
        ToolbarInfo * tbi = toolbarbackend.getUsedToolbarInfo(name);
 
        if (!tbi) {
-               LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
-                       << name << endl;
+               LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
                return;
        }
 
@@ -289,10 +293,10 @@ void GuiToolbars::setLayout(docstring const & layout)
 }
 
 
-bool GuiToolbars::updateLayoutList(TextClassPtr textclass)
+bool GuiToolbars::updateLayoutList(TextClassPtr textclass, bool force)
 {
        // update the layout display
-       if (last_textclass_ != textclass) {
+       if (last_textclass_ != textclass || force) {
                if (layout_)
                        layout_->updateContents();
                last_textclass_ = textclass;
@@ -362,5 +366,27 @@ void GuiToolbars::updateIcons()
                layout_->setEnabled(enable);
 }
 
+
+void GuiToolbars::showCommandBuffer(bool show_it)
+{
+       ToolbarsMap::const_iterator it = toolbars_.begin();
+       ToolbarsMap::const_iterator const end = toolbars_.end();
+       for (; it != end; ++it) {
+               GuiCommandBuffer * cb = it->second->commandBuffer();
+               if (!cb)
+                       continue;
+               if (!show_it) {
+                       // FIXME: this is a hack, "minibuffer" should not be
+                       // hardcoded.
+                       display("minibuffer", false);
+                       return;
+               }
+               if (!it->second->isVisible())
+                       display("minibuffer", true);
+               cb->setFocus();
+               return;
+       }
+}
+
 } // namespace frontend
 } // namespace lyx