]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/QLToolbar.cpp
* src/frontends/LyXView.h:
[features.git] / src / frontends / qt4 / QLToolbar.cpp
index db2f6570ee0f229c3c3dc85473dea743cf8d98ae..f1bab092b5e17a111662d61b40ac6ef5140dd1af 100644 (file)
@@ -40,7 +40,6 @@
 #include <QAction>
 #include <QPixmap>
 
-
 namespace lyx {
 
 using std::string;
@@ -207,19 +206,22 @@ void QLToolbar::add(ToolbarItem const & item)
                }
        case ToolbarItem::ICONPALETTE: {
                QToolButton * tb = new QToolButton(this);
-               tb->setCheckable(true);
                tb->setToolTip(qt_(to_ascii(item.label_)));
                tb->setStatusTip(qt_(to_ascii(item.label_)));
                tb->setText(qt_(to_ascii(item.label_)));
                connect(this, SIGNAL(iconSizeChanged(const QSize &)),
                        tb, SLOT(setIconSize(const QSize &)));
-
                IconPalette * panel = new IconPalette(tb);
+               panel->setWindowTitle(qt_(to_ascii(item.label_)));
                connect(this, SIGNAL(updated()), panel, SLOT(updateParent()));
-               ToolbarInfo const & tbinfo = toolbarbackend.getToolbar(item.name_);
-               ToolbarInfo::item_iterator it = tbinfo.items.begin();
-               ToolbarInfo::item_iterator const end = tbinfo.items.end();
-               for (; it != end; ++it) 
+               ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
+               if (!tbinfo) {
+                       lyxerr << "Unknown toolbar " << item.name_ << endl;
+                       break;
+               }
+               ToolbarInfo::item_iterator it = tbinfo->items.begin();
+               ToolbarInfo::item_iterator const end = tbinfo->items.end();
+               for (; it != end; ++it)
                        if (!getStatus(it->func_).unknown()) {
                                Action * action = new Action(owner_,
                                        getIcon(it->func_),
@@ -229,9 +231,10 @@ void QLToolbar::add(ToolbarItem const & item)
                                panel->addButton(action);
                                ActionVector.push_back(action);
                                // use the icon of first action for the toolbar button
-                               if (it == tbinfo.items.begin())
+                               if (it == tbinfo->items.begin())
                                        tb->setIcon(QPixmap(getIcon(it->func_).c_str()));
                        }
+               tb->setCheckable(true);
                connect(tb, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
                connect(panel, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
                addWidget(tb);
@@ -249,10 +252,16 @@ void QLToolbar::add(ToolbarItem const & item)
                        tb, SLOT(setIconSize(const QSize &)));
 
                ButtonMenu * m = new ButtonMenu(qt_(to_ascii(item.label_)), tb);
+               m->setWindowTitle(qt_(to_ascii(item.label_)));
+               m->setTearOffEnabled(true);
                connect(this, SIGNAL(updated()), m, SLOT(updateParent()));
-               ToolbarInfo const & tbinfo = toolbarbackend.getToolbar(item.name_);
-               ToolbarInfo::item_iterator it = tbinfo.items.begin();
-               ToolbarInfo::item_iterator const end = tbinfo.items.end();
+               ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
+               if (!tbinfo) {
+                       lyxerr << "Unknown toolbar " << item.name_ << endl;
+                       break;
+               }
+               ToolbarInfo::item_iterator it = tbinfo->items.begin();
+               ToolbarInfo::item_iterator const end = tbinfo->items.end();
                for (; it != end; ++it)
                        if (!getStatus(it->func_).unknown()) {
                                Action * action = new Action(owner_,
@@ -298,6 +307,12 @@ void QLToolbar::show(bool)
 }
 
 
+bool QLToolbar::isVisible() const
+{
+       return QToolBar::isVisible();
+}
+
+
 void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
 {
        // if tbinfo.state == auto *do not* set on/off
@@ -307,7 +322,7 @@ void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
                else
                        tbinfo.state = ToolbarSection::ToolbarInfo::OFF;
        }
-       //      
+       //
        // no need to save it here.
        Qt::ToolBarArea loc = owner_.toolBarArea(this);
 
@@ -321,8 +336,8 @@ void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
                tbinfo.location = ToolbarSection::ToolbarInfo::LEFT;
        else
                tbinfo.location = ToolbarSection::ToolbarInfo::NOTSET;
-       
-       // save toolbar position. They are not used to restore toolbar position 
+
+       // save toolbar position. They are not used to restore toolbar position
        // now because move(x,y) does not work for toolbar.
        tbinfo.posx = pos().x();
        tbinfo.posy = pos().y();