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;
}
}
};
-}
+} // namespace
MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const sticky)
}
-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