#include "KeyMap.h"
#include "LyX.h"
#include "LyXRC.h"
+#include "Session.h"
#include "support/debug.h"
#include "support/gettext.h"
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
- owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false)
+ owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false),
+ restored_(false)
{
setIconSize(owner.iconSize());
connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
}
+void GuiToolbar::setVisible(bool visible)
+{
+ // This is a hack to find out which toolbars have been restored by
+ // MainWindow::restoreState and which toolbars should be initialized
+ // by us (i.e., new toolbars)
+ restored_ = true;
+ QToolBar::setVisible(visible);
+}
+
+
+bool GuiToolbar::isRestored() const
+{
+ return restored_;
+}
+
+
void GuiToolbar::fill()
{
if (filled_)
// Get the keys bound to this action, but keep only the
// first one later
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
- if (bindings.size())
+ if (!bindings.empty())
text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
- Action * act = new Action(&owner_, getIcon(item.func_, false),
- text, item.func_, text, this);
+ Action * act = new Action(getIcon(item.func_, false),
+ text, item.func_, text, this);
actions_.append(act);
return act;
}
MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const sticky)
- : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
+ : QToolButton(bar), bar_(bar), tbitem_(item)
{
setPopupMode(QToolButton::InstantPopup);
QString const label = qt_(to_ascii(tbitem_.label_));
this, SLOT(actionTriggered(QAction *)));
connect(bar, SIGNAL(iconSizeChanged(QSize)),
this, SLOT(setIconSize(QSize)));
+ initialize();
}
-void MenuButton::mousePressEvent(QMouseEvent * e)
-{
- if (initialized_) {
- QToolButton::mousePressEvent(e);
- return;
- }
-
- initialized_ = true;
+void MenuButton::initialize()
+{
QString const label = qt_(to_ascii(tbitem_.label_));
ButtonMenu * m = new ButtonMenu(label, this);
m->setWindowTitle(label);
if (!getStatus(it->func_).unknown())
m->add(bar_->addItem(*it));
setMenu(m);
-
- QToolButton::mousePressEvent(e);
}
tb->setToolTip(label);
tb->setStatusTip(label);
tb->setText(label);
- InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
+ InsertTableWidget * iv = new InsertTableWidget(tb);
connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));