mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Lock toolbars (#10283)
- LFUNs to (un)lock toolbars positions (both individually and all at once) - corresponding menu entry to "Lock Toolbars" menu.
This commit is contained in:
parent
1fb6a0ac3e
commit
e2f864efe4
@ -673,6 +673,8 @@ Menuset
|
||||
Menu "context-toolbars"
|
||||
Toolbars
|
||||
Separator
|
||||
Item "Lock All Toolbars|L" "toolbar-movable *"
|
||||
Separator
|
||||
Item "Small-sized Icons" "icon-size small"
|
||||
Item "Normal-sized Icons" "icon-size normal"
|
||||
Item "Big-sized Icons" "icon-size big"
|
||||
|
@ -353,6 +353,8 @@ Menuset
|
||||
Menu "toolbars"
|
||||
Toolbars
|
||||
Separator
|
||||
Item "Lock All Toolbars|L" "toolbar-movable *"
|
||||
Separator
|
||||
Item "Small-sized Icons" "icon-size small"
|
||||
Item "Normal-sized Icons" "icon-size normal"
|
||||
Item "Big-sized Icons" "icon-size big"
|
||||
|
@ -472,6 +472,7 @@ enum FuncCode
|
||||
// 365
|
||||
LFUN_BUFFER_EXTERNAL_MODIFICATION_CLEAR,// gm, 20170302
|
||||
LFUN_BUFFER_ZOOM, // daniel, 20161028
|
||||
LFUN_TOOLBAR_MOVABLE, // daniel, 20160712
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
||||
|
@ -3747,6 +3747,18 @@ void LyXAction::init()
|
||||
*/
|
||||
{ LFUN_THESAURUS_ENTRY, "thesaurus-entry", ReadOnly, Edit },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE
|
||||
* \li Action: Toggles movability of a given toolbar between true/false.
|
||||
* \li Syntax: toolbar-movable <NAME>
|
||||
* \li Params: <NAME>: *|standard|extra|table|math|mathmacrotemplate|\n
|
||||
minibuffer|review|view/update|math_panels|vcs|
|
||||
view-others|update-others
|
||||
* \li Origin: daniel, 12 July 2016
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_TOOLBAR_MOVABLE, "toolbar-movable", NoBuffer, Buffer },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_TOOLBAR_TOGGLE
|
||||
* \li Action: Toggles visibility of a given toolbar between on/off/auto.
|
||||
|
@ -61,8 +61,6 @@ GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
||||
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));
|
||||
@ -357,6 +355,7 @@ void GuiToolbar::saveSession() const
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(sessionKey() + "/visibility", visibility_);
|
||||
settings.setValue(sessionKey() + "/movability", isMovable());
|
||||
}
|
||||
|
||||
|
||||
@ -373,6 +372,9 @@ void GuiToolbar::restoreSession()
|
||||
guiApp->toolbars().defaultVisibility(fromqstr(objectName()));
|
||||
}
|
||||
setVisibility(visibility);
|
||||
|
||||
int movability = settings.value(sessionKey() + "/movability", true).toBool();
|
||||
setMovable(movability);
|
||||
}
|
||||
|
||||
|
||||
@ -408,6 +410,29 @@ void GuiToolbar::toggle()
|
||||
qstring_to_ucs4(windowTitle()), state));
|
||||
}
|
||||
|
||||
void GuiToolbar::movable(bool silent)
|
||||
{
|
||||
// toggle movability
|
||||
setMovable(!isMovable());
|
||||
|
||||
// manual repaint avoids bug in qt that the drag handle is not removed
|
||||
// properly, e.g. in Windows
|
||||
if (isVisible())
|
||||
repaint();
|
||||
|
||||
// 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
|
||||
|
||||
|
@ -97,6 +97,9 @@ public:
|
||||
///
|
||||
void toggle();
|
||||
|
||||
/// toggles movability
|
||||
void movable(bool silent = false);
|
||||
|
||||
///
|
||||
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
|
||||
|
||||
|
@ -793,6 +793,9 @@ bool GuiView::restoreLayout()
|
||||
initToolbar(cit->name);
|
||||
}
|
||||
|
||||
// update lock (all) toolbars positions
|
||||
updateLockToolbars();
|
||||
|
||||
updateDialogs();
|
||||
return true;
|
||||
}
|
||||
@ -809,6 +812,17 @@ GuiToolbar * GuiView::toolbar(string const & name)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::updateLockToolbars()
|
||||
{
|
||||
toolbarsMovable = false;
|
||||
for (ToolbarInfo const & info : guiApp->toolbars()) {
|
||||
GuiToolbar * tb = toolbar(info.name);
|
||||
if (tb && tb->isMovable())
|
||||
toolbarsMovable = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiView::constructToolbars()
|
||||
{
|
||||
ToolbarMap::iterator it = d.toolbars_.begin();
|
||||
@ -876,6 +890,8 @@ void GuiView::initToolbar(string const & name)
|
||||
|
||||
if (visibility & Toolbars::ON)
|
||||
tb->setVisible(true);
|
||||
|
||||
tb->setMovable(true);
|
||||
}
|
||||
|
||||
|
||||
@ -1895,6 +1911,23 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_TOOLBAR_MOVABLE: {
|
||||
string const name = cmd.getArg(0);
|
||||
// use negation since locked == !movable
|
||||
if (name == "*") {
|
||||
// toolbar name * locks all toolbars
|
||||
flag.setOnOff(!toolbarsMovable);
|
||||
} else if (GuiToolbar * t = toolbar(name)) {
|
||||
flag.setOnOff(!(t->isMovable()));
|
||||
} else {
|
||||
enable = false;
|
||||
docstring const msg =
|
||||
bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
|
||||
flag.message(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_ICON_SIZE:
|
||||
flag.setOnOff(d.iconSize(cmd.argument()) == iconSize());
|
||||
break;
|
||||
@ -3815,6 +3848,35 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_TOOLBAR_MOVABLE: {
|
||||
string const name = cmd.getArg(0);
|
||||
if (name == "*") {
|
||||
// toggle (all) toolbars movablility
|
||||
toolbarsMovable = !toolbarsMovable;
|
||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
||||
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
||||
for (; cit != end; ++cit) {
|
||||
GuiToolbar * tb = toolbar(cit->name);
|
||||
if (tb && tb->isMovable() != toolbarsMovable) {
|
||||
// toggle toolbar movablity if it does not fit lock (all) toolbars positions state
|
||||
// silent = true, since status bar notifications are slow
|
||||
tb->movable(true);
|
||||
}
|
||||
}
|
||||
if (toolbarsMovable) {
|
||||
dr.setMessage(_("All toolbars unlocked."));
|
||||
} else {
|
||||
dr.setMessage(_("All toolbars locked."));
|
||||
}
|
||||
} else if (GuiToolbar * t = toolbar(name)) {
|
||||
// toggle current toolbar movablity
|
||||
t->movable();
|
||||
// update lock (all) toolbars positions
|
||||
updateLockToolbars();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_ICON_SIZE: {
|
||||
QSize size = d.iconSize(cmd.argument());
|
||||
setIconSize(size);
|
||||
|
@ -210,6 +210,9 @@ public:
|
||||
/// Current ratio between physical pixels and device-independent pixels
|
||||
double pixelRatio() const;
|
||||
|
||||
// movability flag of all toolbars
|
||||
bool toolbarsMovable;
|
||||
|
||||
Q_SIGNALS:
|
||||
void closing(int);
|
||||
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
|
||||
@ -357,6 +360,8 @@ private:
|
||||
void initToolbars();
|
||||
///
|
||||
void initToolbar(std::string const & name);
|
||||
/// Update lock (all) toolbars position
|
||||
void updateLockToolbars();
|
||||
///
|
||||
bool lfunUiToggle(std::string const & ui_component);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user