This commit is contained in:
Guillaume MM 2017-05-07 14:18:17 +02:00
parent e2f864efe4
commit 1acb42911a
5 changed files with 25 additions and 31 deletions

View File

@ -673,7 +673,7 @@ Menuset
Menu "context-toolbars" Menu "context-toolbars"
Toolbars Toolbars
Separator Separator
Item "Lock All Toolbars|L" "toolbar-movable *" Item "Lock Toolbars|L" "toolbar-movable *"
Separator Separator
Item "Small-sized Icons" "icon-size small" Item "Small-sized Icons" "icon-size small"
Item "Normal-sized Icons" "icon-size normal" Item "Normal-sized Icons" "icon-size normal"

View File

@ -353,7 +353,7 @@ Menuset
Menu "toolbars" Menu "toolbars"
Toolbars Toolbars
Separator Separator
Item "Lock All Toolbars|L" "toolbar-movable *" Item "Lock Toolbars|L" "toolbar-movable *"
Separator Separator
Item "Small-sized Icons" "icon-size small" Item "Small-sized Icons" "icon-size small"
Item "Normal-sized Icons" "icon-size normal" Item "Normal-sized Icons" "icon-size normal"

View File

@ -415,19 +415,17 @@ void GuiToolbar::movable(bool silent)
// toggle movability // toggle movability
setMovable(!isMovable()); setMovable(!isMovable());
// manual repaint avoids bug in qt that the drag handle is not removed // manual update avoids bug in qt that the drag handle is not removed
// properly, e.g. in Windows // properly, e.g. in Windows
if (isVisible()) Q_EMIT update();
repaint();
// silence for toggling of many toolbars for performance // silence for toggling of many toolbars for performance
if (!silent) { if (!silent) {
docstring state; docstring state;
if (isMovable()) { if (isMovable())
state = _("movable"); state = _("movable");
} else { else
state = _("immovable"); state = _("immovable");
}
owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"), owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
qstring_to_ucs4(windowTitle()), state)); qstring_to_ucs4(windowTitle()), state));
} }

View File

@ -814,11 +814,11 @@ GuiToolbar * GuiView::toolbar(string const & name)
void GuiView::updateLockToolbars() void GuiView::updateLockToolbars()
{ {
toolbarsMovable = false; toolbarsMovable_ = false;
for (ToolbarInfo const & info : guiApp->toolbars()) { for (ToolbarInfo const & info : guiApp->toolbars()) {
GuiToolbar * tb = toolbar(info.name); GuiToolbar * tb = toolbar(info.name);
if (tb && tb->isMovable()) if (tb && tb->isMovable())
toolbarsMovable = true; toolbarsMovable_ = true;
} }
} }
@ -1914,12 +1914,12 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
case LFUN_TOOLBAR_MOVABLE: { case LFUN_TOOLBAR_MOVABLE: {
string const name = cmd.getArg(0); string const name = cmd.getArg(0);
// use negation since locked == !movable // use negation since locked == !movable
if (name == "*") { if (name == "*")
// toolbar name * locks all toolbars // toolbar name * locks all toolbars
flag.setOnOff(!toolbarsMovable); flag.setOnOff(!toolbarsMovable_);
} else if (GuiToolbar * t = toolbar(name)) { else if (GuiToolbar * t = toolbar(name))
flag.setOnOff(!(t->isMovable())); flag.setOnOff(!(t->isMovable()));
} else { else {
enable = false; enable = false;
docstring const msg = docstring const msg =
bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)); bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
@ -3852,22 +3852,19 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
string const name = cmd.getArg(0); string const name = cmd.getArg(0);
if (name == "*") { if (name == "*") {
// toggle (all) toolbars movablility // toggle (all) toolbars movablility
toolbarsMovable = !toolbarsMovable; toolbarsMovable_ = !toolbarsMovable_;
Toolbars::Infos::iterator cit = guiApp->toolbars().begin(); for (ToolbarInfo const & ti : guiApp->toolbars()) {
Toolbars::Infos::iterator end = guiApp->toolbars().end(); GuiToolbar * tb = toolbar(ti.name);
for (; cit != end; ++cit) { if (tb && tb->isMovable() != toolbarsMovable_)
GuiToolbar * tb = toolbar(cit->name); // toggle toolbar movablity if it does not fit lock
if (tb && tb->isMovable() != toolbarsMovable) { // (all) toolbars positions state silent = true, since
// toggle toolbar movablity if it does not fit lock (all) toolbars positions state // status bar notifications are slow
// silent = true, since status bar notifications are slow
tb->movable(true); tb->movable(true);
}
}
if (toolbarsMovable) {
dr.setMessage(_("All toolbars unlocked."));
} else {
dr.setMessage(_("All toolbars locked."));
} }
if (toolbarsMovable_)
dr.setMessage(_("Toolbars unlocked."));
else
dr.setMessage(_("Toolbars locked."));
} else if (GuiToolbar * t = toolbar(name)) { } else if (GuiToolbar * t = toolbar(name)) {
// toggle current toolbar movablity // toggle current toolbar movablity
t->movable(); t->movable();

View File

@ -210,9 +210,6 @@ public:
/// Current ratio between physical pixels and device-independent pixels /// Current ratio between physical pixels and device-independent pixels
double pixelRatio() const; double pixelRatio() const;
// movability flag of all toolbars
bool toolbarsMovable;
Q_SIGNALS: Q_SIGNALS:
void closing(int); void closing(int);
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset); void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
@ -468,6 +465,8 @@ private:
/// Minimum zoom percentage /// Minimum zoom percentage
static int const zoom_min_ = 10; static int const zoom_min_ = 10;
// movability flag of all toolbars
bool toolbarsMovable_;
}; };
} // namespace frontend } // namespace frontend