connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
SLOT(setIconSize(QSize)));
- // Toolbar dragging is allowed.
- setMovable(true);
// This is used by QMainWindow::restoreState for proper main window state
// restauration.
setObjectName(toqstr(tbinfo.name));
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
+ // MainWindow::restoreState and which toolbars should be initialized
// by us (i.e., new toolbars)
restored_ = true;
QToolBar::setVisible(visible);
ToolbarInfo::item_iterator it = tbinfo_.items.begin();
ToolbarInfo::item_iterator end = tbinfo_.items.end();
for (; it != end; ++it)
- add(*it);
+ add(*it);
filled_ = true;
}
QString text = toqstr(item.label_);
// Get the keys bound to this action, but keep only the
// first one later
- KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
+ KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(*item.func_);
if (!bindings.empty())
text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
- Action * act = new Action(getIcon(item.func_, false),
- text, item.func_, text, this);
+ Action * act = new Action(item.func_, getIcon(*item.func_, false), text,
+ text, this);
actions_.append(act);
return act;
}
ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
if (tbinfo)
// use the icon of first action for the toolbar button
- setIcon(getIcon(tbinfo->items.begin()->func_, true));
+ setIcon(getIcon(*tbinfo->items.begin()->func_, true));
}
void mousePressEvent(QMouseEvent * e)
ToolbarInfo::item_iterator it = tbinfo->items.begin();
ToolbarInfo::item_iterator const end = tbinfo->items.end();
for (; it != end; ++it)
- if (!getStatus(it->func_).unknown())
+ if (!getStatus(*it->func_).unknown())
panel->addButton(bar_->addItem(*it));
QToolButton::mousePressEvent(e);
}
};
-}
+} // namespace
MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const sticky)
ToolbarInfo::item_iterator it = tbinfo->items.begin();
ToolbarInfo::item_iterator const end = tbinfo->items.end();
for (; it != end; ++it)
- if (!getStatus(it->func_).unknown())
+ if (!getStatus(*it->func_).unknown())
m->add(bar_->addItem(*it));
setMenu(m);
}
break;
}
case ToolbarItem::COMMAND: {
- if (!getStatus(item.func_).unknown())
+ if (!getStatus(*item.func_).unknown())
addAction(addItem(item));
break;
}
}
-void GuiToolbar::saveSession() const
+void GuiToolbar::saveSession(QSettings & settings) const
{
- QSettings settings;
settings.setValue(sessionKey() + "/visibility", visibility_);
+ settings.setValue(sessionKey() + "/movability", isMovable());
}
if (visibility == error_val || visibility == 0) {
// This should not happen, but in case we use the defaults
LYXERR(Debug::GUI, "Session settings could not be found! Defaults are used instead.");
- visibility =
+ visibility =
guiApp->toolbars().defaultVisibility(fromqstr(objectName()));
}
setVisibility(visibility);
+
+ int movability = settings.value(sessionKey() + "/movability", true).toBool();
+ setMovable(movability);
}
qstring_to_ucs4(windowTitle()), state));
}
+void GuiToolbar::movable(bool silent)
+{
+ // toggle movability
+ setMovable(!isMovable());
+
+ // manual update avoids bug in qt that the drag handle is not removed
+ // properly, e.g. in Windows
+ Q_EMIT update();
+
+ // silence for toggling of many toolbars for performance
+ if (!silent) {
+ docstring state;
+ if (isMovable())
+ state = _("movable");
+ else
+ state = _("immovable");
+ owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
+ qstring_to_ucs4(windowTitle()), state));
+ }
+}
+
} // namespace frontend
} // namespace lyx