Re: toolbars Lock menu
I have created a patch at https://www.lyx.org/trac/ticket/10283. On 23.09.2016 00:47, Guillaume Munch wrote: Le 22/09/2016 à 09:18, racoon a écrit : On 21.09.2016 17:24, Guillaume Munch wrote: * I expected to find the lock toolbar option when right-clicking on the toolbars. Do you know where to add this? Yes, I do. But I think it should be like this: 1. There should be a LFUN for setting the icon size. 2. The four default icon sizes from the widget (LyX main window) context menu should go to the Toolbars menu. 3. The whole Toolbars menu should appear when the widget's context menu is opened. I see what you mean. It really depends on how much effort you are ready to put into this. It might be overkill. I have not touched the context menu yet. I think that a separate issue. And I don't know at the moment how to fix it. GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) -: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), +: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), I think this new variable is redundant with isMovable()/setMovable() from qt and can be made without. I just did a copy of the visibility for movability. I am also not sure how to replace its functionality. GuiToolbar inherits QToolBar::isMovable() whose value happens to coincide with movability_ in your patch. I have fixed this in the patch. +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); + There must be a bug here because it is always shown as "on" for me. I don't understand what is always "on" here. The "Lock Toolbars Positions" menu entry does get checked and unchecked, right? It's always checked for me, I don't really know why. But it correctly switches movable status. It works for me. So I don't know what to do about this really. Actually I wonder whether it's useful to store the flag and update it by hand, since it is not very expensive to compute it every time. Having this flag looks like a premature optimisation. I thought it is needed for the "Lock Toolbars Positions". Don't know how to do without. Instead of a member variable bool toolbarsMovable you could have a function bool toolbarsMovable() const, that would compute the value as you did previously. I don't know at the moment how to do this. But it sounds easy. Daniel
Re: toolbars Lock menu
Le 22/09/2016 à 09:18, racoon a écrit : Hi Guillaume, Thanks a lot. I have added some comments. I tried to fix what I could. I am a total amateur in this. I don't know what bug there should be since it works as expected for me. It would be great if you give me further instructions or just show me how to do the improvements. While I think it is helpful to do exercises to learn it myself, I also need to see a couple of times how to do it first. On 21.09.2016 17:24, Guillaume Munch wrote: Le 11/08/2016 à 14:56, racoon a écrit : * I expected to find the lock toolbar option when right-clicking on the toolbars. Do you know where to add this? Yes, I do. But I think it should be like this: 1. There should be a LFUN for setting the icon size. 2. The four default icon sizes from the widget (LyX main window) context menu should go to the Toolbars menu. 3. The whole Toolbars menu should appear when the widget's context menu is opened. I see what you mean. It really depends on how much effort you are ready to put into this. It might be overkill. GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) -: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), +: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), I think this new variable is redundant with isMovable()/setMovable() from qt and can be made without. I just did a copy of the visibility for movability. I am also not sure how to replace its functionality. GuiToolbar inherits QToolBar::isMovable() whose value happens to coincide with movability_ in your patch. So does this imply that that variable is redundant too? I quickly checked and as I can see that in GuiView::initToolbar, setVisible and setVisibility are called differently, so I cannot conclude that visibility_ is redundant. GuiToolbar * tb = toolbar(cit->name); if (tb && !tb->isRestored()) -initToolbar(cit->name); +initToolbar(cit->name); You have a strange indentation here. I used the defaults tabs in visual studio. I think there is an option called "Smart" indentation. Maybe it is not so smart after all to use it. I have set it now to block. Now I have to manually start new indentation but at least they are now all 4 spaces wide. Ideally one wants automatic indentation, but I could only help you with emacs. +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); + There must be a bug here because it is always shown as "on" for me. I don't understand what is always "on" here. The "Lock Toolbars Positions" menu entry does get checked and unchecked, right? It's always checked for me, I don't really know why. But it correctly switches movable status. Actually I wonder whether it's useful to store the flag and update it by hand, since it is not very expensive to compute it every time. Having this flag looks like a premature optimisation. I thought it is needed for the "Lock Toolbars Positions". Don't know how to do without. Instead of a member variable bool toolbarsMovable you could have a function bool toolbarsMovable() const, that would compute the value as you did previously. Guillaume
Re: toolbars Lock menu
Hi Guillaume, Thanks a lot. I have added some comments. I tried to fix what I could. I am a total amateur in this. I don't know what bug there should be since it works as expected for me. It would be great if you give me further instructions or just show me how to do the improvements. While I think it is helpful to do exercises to learn it myself, I also need to see a couple of times how to do it first. On 21.09.2016 17:24, Guillaume Munch wrote: Le 11/08/2016 à 14:56, racoon a écrit : Hi, Thanks and sorry for the delay. Here is an updated version. (I hope I have not forgotten to include all files in the patch.) This time the Lock Toolbars Positions is locked if and only if each toolbar is locked. I guess that makes more sense. Hi Daniel, at last, a few comments. Some general ones first: * Although your patch has extension .patch, it is only a diff. (The best way to produce a patch is to use the command git format-patch which includes the author, the timestamp and the commit log.) Well, I have to figure out how to do a proper patch then. (I just used git gui's "Make patch" function (Repository > Visualize master's History, right click on "Local changes checked in to the index but not committed" and choose "Make patch"). I also entered my name in git gui under Options. But that's about it.) * At some point the indentation is not correct (one tab too much). Have you set up your editor properly so that it inserts the proper amount of indentation automatically? I have now I think. * I expected to find the lock toolbar option when right-clicking on the toolbars. Do you know where to add this? Yes, I do. But I think it should be like this: 1. There should be a LFUN for setting the icon size. 2. The four default icon sizes from the widget (LyX main window) context menu should go to the Toolbars menu. 3. The whole Toolbars menu should appear when the widget's context menu is opened. Some more specific comments below. Me too. diff --git a/src/FuncCode.h b/src/FuncCode.h index 04f1671..3fd0319 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -466,6 +466,7 @@ enum FuncCode LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408 LFUN_TABULAR_FEATURE, // gm, 20151210 LFUN_BRANCH_INVERT, // rgheck, 20160712 +LFUN_TOOLBAR_MOVABLE, // daniel, 20160712 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 77864db..a974afa 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2728,6 +2728,17 @@ void LyXAction::init() */ { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer }, /*! +* \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE +* \li Action: Toggles movability of a given toolbar between true/false. +* \li Syntax: toolbar-movable +* \li Params: : *|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_MENU_OPEN * \li Action: Opens the menu given by its name. * \li Syntax: menu-open diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 77471c9..56dca72 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -53,7 +53,7 @@ namespace lyx { namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) -: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), +: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), I think this new variable is redundant with isMovable()/setMovable() from qt and can be made without. I just did a copy of the visibility for movability. I am also not sure how to replace its functionality. So does this imply that that variable is redundant too? owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false), restored_(false) { @@ -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)); @@ -111,6 +109,13 @@ void GuiToolbar::setVisibility(int visibility) } +void GuiToolbar::setMovability(bool movability) +{ +movability_ = movability; +} + + + Action * GuiToolbar::addItem(ToolbarItem const & item) { QString text = toqstr(item.label_); @@ -358,6 +363,7 @@ void GuiToolbar::saveSession() const { QSettings settings; settings.setValue(sessionKey() + "/visibility", visibility_); +settings.setValue(sessionKey() + "/movability", movability_); } @@ -374,6 +380,11 @@ void GuiToolbar::restoreSession() guiAp
Re: toolbars Lock menu
Le 11/08/2016 à 14:56, racoon a écrit : Hi, Thanks and sorry for the delay. Here is an updated version. (I hope I have not forgotten to include all files in the patch.) This time the Lock Toolbars Positions is locked if and only if each toolbar is locked. I guess that makes more sense. Hi Daniel, at last, a few comments. Some general ones first: * Although your patch has extension .patch, it is only a diff. (The best way to produce a patch is to use the command git format-patch which includes the author, the timestamp and the commit log.) * At some point the indentation is not correct (one tab too much). Have you set up your editor properly so that it inserts the proper amount of indentation automatically? * I expected to find the lock toolbar option when right-clicking on the toolbars. Do you know where to add this? Some more specific comments below. diff --git a/src/FuncCode.h b/src/FuncCode.h index 04f1671..3fd0319 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -466,6 +466,7 @@ enum FuncCode LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408 LFUN_TABULAR_FEATURE, // gm, 20151210 LFUN_BRANCH_INVERT, // rgheck, 20160712 + LFUN_TOOLBAR_MOVABLE, // daniel, 20160712 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 77864db..a974afa 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2728,6 +2728,17 @@ void LyXAction::init() */ { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer }, /*! +* \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE +* \li Action: Toggles movability of a given toolbar between true/false. +* \li Syntax: toolbar-movable +* \li Params: : *|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_MENU_OPEN * \li Action: Opens the menu given by its name. * \li Syntax: menu-open diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 77471c9..56dca72 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -53,7 +53,7 @@ namespace lyx { namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) - : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), + : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), I think this new variable is redundant with isMovable()/setMovable() from qt and can be made without. owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false), restored_(false) { @@ -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)); @@ -111,6 +109,13 @@ void GuiToolbar::setVisibility(int visibility) } +void GuiToolbar::setMovability(bool movability) +{ + movability_ = movability; +} + + + Action * GuiToolbar::addItem(ToolbarItem const & item) { QString text = toqstr(item.label_); @@ -358,6 +363,7 @@ void GuiToolbar::saveSession() const { QSettings settings; settings.setValue(sessionKey() + "/visibility", visibility_); + settings.setValue(sessionKey() + "/movability", movability_); } @@ -374,6 +380,11 @@ void GuiToolbar::restoreSession() guiApp->toolbars().defaultVisibility(fromqstr(objectName())); } setVisibility(visibility); + + int movability = + settings.value(sessionKey() + "/movability", true).toBool(); + setMovability(movability); + setMovable(movability); Here you see that movability_ has no real purpose since it just duplicates the movable state. } @@ -409,6 +420,32 @@ void GuiToolbar::toggle() qstring_to_ucs4(windowTitle()), state)); } +void GuiToolbar::movable(bool silent) +{ + // toggle movability + setMovability(!isMovable()); + setMovable(!isMovable()); + + // manual repaint avoids bug in qt that the drag handle is not removed + // properly, e.g. in windows + if (isVisible()) + repaint(); I am not sure what is the good solution, but what you did seems to work correctly here. + + // silence for toggling of many toolbars for performance + if (!silent) { + docstring state; + if (isMovable()) { + state = _("movable"); + + } + else { + state = _("
Re: toolbars Lock menu
On 11.08.2016 14:56, racoon wrote: On 20.07.2016 16:41, Guillaume Munch wrote: Le 12/07/2016 13:30, racoon a écrit : I have attached a first attempt at implementing a toolbar lock. (Unfortunately, it is a bit intermingled with a lfun implementation for changing the icon-size.) Hi, I can have a look. Do you have an updated patch in the meanwhile? Hi, Thanks and sorry for the delay. Here is an updated version. (I hope I have not forgotten to include all files in the patch.) This time the Lock Toolbars Positions is locked if and only if each toolbar is locked. I guess that makes more sense. And if you want to try the locking of individual toolbars and the interaction with the Lock (All) Toolbars Positions you can replace the "toolbars" menu in stdmenus.inc by Menu "toolbars" Toolbars Submenu "Lock" "lock_toolbars" End Menu "lock_toolbars" Item "Standard" "toolbar-movable standard" Item "View/Update" "toolbar-movable view/update" Item "Exatra" "toolbar-movable extra" End Daniel
Re: toolbars Lock menu
On 20.07.2016 16:41, Guillaume Munch wrote: Le 12/07/2016 13:30, racoon a écrit : I have attached a first attempt at implementing a toolbar lock. (Unfortunately, it is a bit intermingled with a lfun implementation for changing the icon-size.) Hi, I can have a look. Do you have an updated patch in the meanwhile? Hi, Thanks and sorry for the delay. Here is an updated version. (I hope I have not forgotten to include all files in the patch.) This time the Lock Toolbars Positions is locked if and only if each toolbar is locked. I guess that makes more sense. Daniel diff --git a/src/FuncCode.h b/src/FuncCode.h index 04f1671..3fd0319 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -466,6 +466,7 @@ enum FuncCode LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408 LFUN_TABULAR_FEATURE, // gm, 20151210 LFUN_BRANCH_INVERT, // rgheck, 20160712 + LFUN_TOOLBAR_MOVABLE, // daniel, 20160712 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 77864db..a974afa 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2728,6 +2728,17 @@ void LyXAction::init() */ { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer }, /*! +* \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE +* \li Action: Toggles movability of a given toolbar between true/false. +* \li Syntax: toolbar-movable +* \li Params: : *|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_MENU_OPEN * \li Action: Opens the menu given by its name. * \li Syntax: menu-open diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 77471c9..56dca72 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -53,7 +53,7 @@ namespace lyx { namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) - : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), + : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false), restored_(false) { @@ -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)); @@ -111,6 +109,13 @@ void GuiToolbar::setVisibility(int visibility) } +void GuiToolbar::setMovability(bool movability) +{ + movability_ = movability; +} + + + Action * GuiToolbar::addItem(ToolbarItem const & item) { QString text = toqstr(item.label_); @@ -358,6 +363,7 @@ void GuiToolbar::saveSession() const { QSettings settings; settings.setValue(sessionKey() + "/visibility", visibility_); + settings.setValue(sessionKey() + "/movability", movability_); } @@ -374,6 +380,11 @@ void GuiToolbar::restoreSession() guiApp->toolbars().defaultVisibility(fromqstr(objectName())); } setVisibility(visibility); + + int movability = + settings.value(sessionKey() + "/movability", true).toBool(); + setMovability(movability); + setMovable(movability); } @@ -409,6 +420,32 @@ void GuiToolbar::toggle() qstring_to_ucs4(windowTitle()), state)); } +void GuiToolbar::movable(bool silent) +{ + // toggle movability + setMovability(!isMovable()); + 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 diff --git a/src/frontends/qt4/GuiToolbar.h b/src/frontends/qt4/GuiToolbar.h index caad355..4463c06 100644 --- a/src/frontends/qt4/GuiToolbar.h +++ b/src/frontends/qt4/GuiToolbar.h @@ -74,6 +74,8 @@ public: /// void setVisibility(int visibility); + /// + void setMovability(bool movability); /// Add a button
Re: toolbars Lock menu
Le 12/07/2016 13:30, racoon a écrit : I have attached a first attempt at implementing a toolbar lock. (Unfortunately, it is a bit intermingled with a lfun implementation for changing the icon-size.) Hi, I can have a look. Do you have an updated patch in the meanwhile?
Re: toolbars Lock menu
I have attached a first attempt at implementing a toolbar lock. (Unfortunately, it is a bit intermingled with a lfun implementation for changing the icon-size.) Toolbars can be (un)locked individually via the lfun command toolbar-movable , e.g. toolbar-movable standard Toolbars can be (un)locked altogether via the lfun command toolbar-movable * or via the menu View > Toolbars > Lock Toolbars Positions The toolbar's locked state is saved per toolbar via QSettings. I save the state of "all toolbars locked" in an extra QSetting. But probably this would just better derived from the state of individual toolbars, i.e. Lock Toolbars Position is checked iff all toolbar positions are locked. I must confess that I was not always 100% certain what I was doing. I am happy for any critical comments. :) Daniel diff --git a/src/FuncCode.h b/src/FuncCode.h index 40ec9d3..36c5ea5 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -362,6 +362,8 @@ enum FuncCode LFUN_LISTING_INSERT,// Herbert 2000, bpeng 20070502 // 275 LFUN_TOOLBAR_TOGGLE,// Edwin 20070521 + LFUN_TOOLBAR_MOVABLE, // Daniel, 20160712 + LFUN_ICON_SIZE, // Daniel, 20160712 LFUN_BUFFER_WRITE_ALL, // rgh, gpothier 200707XX LFUN_PARAGRAPH_PARAMS, LFUN_LAYOUT_MODULES_CLEAR, diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 3702810..9594699 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2728,6 +2728,26 @@ void LyXAction::init() */ { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer }, /*! +* \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE +* \li Action: Toggles movability of a given toolbar between true/false. +* \li Syntax: toolbar-toggle +* \li Params: : standard|extra|table|math|mathmacrotemplate|\n +minibuffer|review|view/update|math_panels|vcs| +view-others|update-others +* \li Origin: 11 July 2016 +* \endvar +*/ + { LFUN_TOOLBAR_MOVABLE, "toolbar-movable", NoBuffer, Buffer }, +/*! +* \var lyx::FuncCode lyx::LFUN_ICON_SIZE +* \li Action: Sets icon size of toolbars. +* \li Syntax: icon-size +* \li Params: : int +* \li Origin: 11 July 2016 +* \endvar +*/ + { LFUN_ICON_SIZE, "icon-size", NoBuffer, Buffer }, +/*! * \var lyx::FuncCode lyx::LFUN_MENU_OPEN * \li Action: Opens the menu given by its name. * \li Syntax: menu-open diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 77471c9..abba387 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -53,7 +53,7 @@ namespace lyx { namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) - : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), + : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), movability_(0), owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false), restored_(false) { @@ -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)); @@ -110,6 +108,11 @@ void GuiToolbar::setVisibility(int visibility) visibility_ = visibility; } +void GuiToolbar::setMovability(bool movability) +{ + movability_ = movability; +} + Action * GuiToolbar::addItem(ToolbarItem const & item) { @@ -358,6 +361,7 @@ void GuiToolbar::saveSession() const { QSettings settings; settings.setValue(sessionKey() + "/visibility", visibility_); + settings.setValue(sessionKey() + "/movability", movability_); } @@ -374,6 +378,12 @@ void GuiToolbar::restoreSession() guiApp->toolbars().defaultVisibility(fromqstr(objectName())); } setVisibility(visibility); + + // restore movability + bool movability = + settings.value(sessionKey() + "/movability", false).toBool(); + setMovability(movability); + setMovable(movability); } @@ -409,6 +419,20 @@ void GuiToolbar::toggle() qstring_to_ucs4(windowTitle()), state)); } +void GuiToolbar::movable() +{ + setMovability(!isMovable()); + setMovable(!isMovable()); + 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 diff --git a/src/frontends/qt4/GuiToolbar.h b/src/frontends/qt4/GuiToolbar.h index caad355..5d50734 100644 --- a/src/frontends/qt4/GuiToolbar.
Re: toolbars Lock menu
On 11.07.2016 09:23, racoon wrote: I have proposed the new feature here: #10283 (and #10282) Outside of trac these numbers don't work that nicely as links. http://www.lyx.org/trac/ticket/10283 http://www.lyx.org/trac/ticket/10282 --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus
Re: toolbars Lock menu
On 10.07.2016 04:42, Scott Kostyshak wrote: On Sat, Jul 09, 2016 at 03:19:51PM +0100, José Abílio Matos wrote: On Saturday, July 9, 2016 2:42:11 PM WEST racoon wrote: By the way, since I have never worked on a project like LyX, if anyone has tips on how to work effectively, I am pleased to know. I guess using git is one. The first step is to read: http://www.lyx.org/Development where there are documents like: http://www.lyx.org/DevFAQ There are places that can help but those are a good first step. Thanks, I read them before. Though maybe not patient enough. In addition to José's advice, my advice is the following: before you spend time doing any work, first check in with lyx-devel and make a proposal. Because you are proposing a feature (as opposed to a feature), the most important part is motivation: why do you want to lock the toolbar? Why would a significant amount of users want to lock the toolbar? A good way to improve your argument (but by no means sufficient) for why your feature would be a good idea is to make parallels to other programs that are similar to LyX. Does Libre Office have such a feature? I have proposed the new feature here: #10283 (and #10282) After you have motivated the general idea, describe your feature as detailed as possible. The most important aspect of this is actually the interface (not the implementation). How will users use this feature? e.g. will it be in the context menu (the right-click menu)? Will it be in the menus at the top (File, Edit, ...)? Check. Then, and this is more optional, you can ask for comments on a basic outline of implementation. I have already checked with others on stackoverflow for details on the general implementation and have a small working toy example. Then, eventually post a patch. You will get bonus points if you mention that if your patch is given a preliminary "thumbs up", you'd be happy to work on documentation for the feature, and you even have an idea for the exact place in the manuals where the documentation would go. Note that in your particular feature proposal, I don't know if we usually document such features, but this paragraph is meant to be more general. Have to fix the compilation of LyX first. The above steps are not just for beginners. Even experienced developers go through them. But I think that newcommers do not realize that often the first step is not a patch. I see. And yes, get familiar with git. You should view this as a long-term investment so spend the time to learn it well. Many software projects are moving to Git. You will likely use Git for your own individual programming projects, and even for non-programming projects (I use it to organize my teaching notes). After a year or so, you will start to criticize your friends who rely on the old backup mechanism of copying the folder MyProject to MyProject10234 (but please try to be nice to them, they don't know any better). I'll make myself familiar. And it is an interesting idea to use it for teaching notes as well. I guess the main feature of git is that one can keep track of the "progress" then. Daniel --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus
Re: toolbars Lock menu
On Sat, Jul 09, 2016 at 03:19:51PM +0100, José Abílio Matos wrote: > On Saturday, July 9, 2016 2:42:11 PM WEST racoon wrote: > > By the way, since I have never worked on a project like LyX, if anyone > > has tips on how to work effectively, I am pleased to know. I guess using > > git is one. > > The first step is to read: > http://www.lyx.org/Development > > where there are documents like: > http://www.lyx.org/DevFAQ > > There are places that can help but those are a good first step. > > Regards, > -- > José Abílio In addition to José's advice, my advice is the following: before you spend time doing any work, first check in with lyx-devel and make a proposal. Because you are proposing a feature (as opposed to a feature), the most important part is motivation: why do you want to lock the toolbar? Why would a significant amount of users want to lock the toolbar? A good way to improve your argument (but by no means sufficient) for why your feature would be a good idea is to make parallels to other programs that are similar to LyX. Does Libre Office have such a feature? After you have motivated the general idea, describe your feature as detailed as possible. The most important aspect of this is actually the interface (not the implementation). How will users use this feature? e.g. will it be in the context menu (the right-click menu)? Will it be in the menus at the top (File, Edit, ...)? Then, and this is more optional, you can ask for comments on a basic outline of implementation. Then, eventually post a patch. You will get bonus points if you mention that if your patch is given a preliminary "thumbs up", you'd be happy to work on documentation for the feature, and you even have an idea for the exact place in the manuals where the documentation would go. Note that in your particular feature proposal, I don't know if we usually document such features, but this paragraph is meant to be more general. The above steps are not just for beginners. Even experienced developers go through them. But I think that newcommers do not realize that often the first step is not a patch. And yes, get familiar with git. You should view this as a long-term investment so spend the time to learn it well. Many software projects are moving to Git. You will likely use Git for your own individual programming projects, and even for non-programming projects (I use it to organize my teaching notes). After a year or so, you will start to criticize your friends who rely on the old backup mechanism of copying the folder MyProject to MyProject10234 (but please try to be nice to them, they don't know any better). Good luck! Scott signature.asc Description: PGP signature
Re: toolbars Lock menu
On Saturday, July 9, 2016 2:42:11 PM WEST racoon wrote: > By the way, since I have never worked on a project like LyX, if anyone > has tips on how to work effectively, I am pleased to know. I guess using > git is one. The first step is to read: http://www.lyx.org/Development where there are documents like: http://www.lyx.org/DevFAQ There are places that can help but those are a good first step. Regards, -- José Abílio
Re: toolbars Lock menu
On 09.07.2016 14:36, racoon wrote: On 09.07.2016 13:48, Guillaume Munch wrote: Le 08/07/2016 15:10, racoon a écrit : On 08.07.2016 08:17, racoon wrote: On 07.07.2016 14:41, racoon wrote: Can someone give me a hint where LyX stores the individual toolbars' properties, i.e. position and visibility. Okay, got it (via QSettings). I was just a bit confused because the visibility is also (somewhat) stored in the preferences file. Okay, so here are my first thoughts on a toolbars position lock menu entry. I know this is not an essential feature but I thought I could use it to learn something about the LyX code without a deadline :). But since it is non-essential don't worry if no one has time to help me with this. Also I am not sure how much time I can invest in this in the future. That might be another thought whether it is worth your time or not. Anyway, I am a beginner (both in C++ and Qt) and maybe someone can point out my mistakes to me. Furthermore, I can't compile the source, so it's all just on paper (http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg195015.html). Hi Daniel, We can help you, but I would advise that you fix your compilation issues first and that you send code in the patch format (e.g. git diff or git format-patch). I do not think that any of us can do much with approximate code that has does not compile. Hi Guillaume, Well, I was hoping it does compile. ;) But I see that normally it will not - especially given my abilities. Okay, I'll try to take care of the compilation first and then learn how to use git properly. I guess in the (Windows?) git GUI the latter is just 1. fix the code directly in the directory where it was downloaded from git, and 2. copy the stuff in the upper right text box (with yellow bar) which is the "diff". By the way, since I have never worked on a project like LyX, if anyone has tips on how to work effectively, I am pleased to know. I guess using git is one.
Re: toolbars Lock menu
On 09.07.2016 13:48, Guillaume Munch wrote: Le 08/07/2016 15:10, racoon a écrit : On 08.07.2016 08:17, racoon wrote: On 07.07.2016 14:41, racoon wrote: Can someone give me a hint where LyX stores the individual toolbars' properties, i.e. position and visibility. Okay, got it (via QSettings). I was just a bit confused because the visibility is also (somewhat) stored in the preferences file. Okay, so here are my first thoughts on a toolbars position lock menu entry. I know this is not an essential feature but I thought I could use it to learn something about the LyX code without a deadline :). But since it is non-essential don't worry if no one has time to help me with this. Also I am not sure how much time I can invest in this in the future. That might be another thought whether it is worth your time or not. Anyway, I am a beginner (both in C++ and Qt) and maybe someone can point out my mistakes to me. Furthermore, I can't compile the source, so it's all just on paper (http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg195015.html). Hi Daniel, We can help you, but I would advise that you fix your compilation issues first and that you send code in the patch format (e.g. git diff or git format-patch). I do not think that any of us can do much with approximate code that has does not compile. Hi Guillaume, Well, I was hoping it does compile. ;) But I see that normally it will not - especially given my abilities. Okay, I'll try to take care of the compilation first and then learn how to use git properly. I guess in the (Windows?) git GUI the latter is just 1. fix the code directly in the directory where it was downloaded from git, and 2. copy the stuff in the upper right text box (with yellow bar) which is the "diff". Daniel
Re: toolbars Lock menu
Le 08/07/2016 15:10, racoon a écrit : On 08.07.2016 08:17, racoon wrote: On 07.07.2016 14:41, racoon wrote: Can someone give me a hint where LyX stores the individual toolbars' properties, i.e. position and visibility. Okay, got it (via QSettings). I was just a bit confused because the visibility is also (somewhat) stored in the preferences file. Okay, so here are my first thoughts on a toolbars position lock menu entry. I know this is not an essential feature but I thought I could use it to learn something about the LyX code without a deadline :). But since it is non-essential don't worry if no one has time to help me with this. Also I am not sure how much time I can invest in this in the future. That might be another thought whether it is worth your time or not. Anyway, I am a beginner (both in C++ and Qt) and maybe someone can point out my mistakes to me. Furthermore, I can't compile the source, so it's all just on paper (http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg195015.html). Hi Daniel, We can help you, but I would advise that you fix your compilation issues first and that you send code in the patch format (e.g. git diff or git format-patch). I do not think that any of us can do much with approximate code that has does not compile. Guillaume
Re: toolbars Lock menu
Okay, next maybe a new LFUN? Not sure I understand fully what I am doing... and it should be "movable" and not "moveable". In LyXAction.cpp: ... void LyXAction::init() { ... ev_item const items[] = { #endif ... /*! * \var lyx::FuncCode lyx::LFUN_TOOLBAR_MOVABLE // did not really understand this part, I guess some documentation? * \li Action: Toggles movability of a given toolbar between on/off. * \li Syntax: toolbar-movable * \li Params: : standard|extra|table|math|mathmacrotemplate|\n minibuffer|review|view/update|math_panels|vcs| view-others|update-others * \endvar */ { LFUN_TOOLBAR_MOVABLE, "toolbar-movable", NoBuffer }, /*! ... #ifndef DOXYGEN_SHOULD_SKIP_THIS }; ... } ... In GuiView.cpp: ... bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) { ... switch(cmd.action()) { ... case LFUN_TOOLBAR_MOVABLE: { string const name = cmd.getArg(0); 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; } ... } ... Daniel
Re: toolbars Lock menu
On 08.07.2016 08:17, racoon wrote: On 07.07.2016 14:41, racoon wrote: Can someone give me a hint where LyX stores the individual toolbars' properties, i.e. position and visibility. Okay, got it (via QSettings). I was just a bit confused because the visibility is also (somewhat) stored in the preferences file. Okay, so here are my first thoughts on a toolbars position lock menu entry. I know this is not an essential feature but I thought I could use it to learn something about the LyX code without a deadline :). But since it is non-essential don't worry if no one has time to help me with this. Also I am not sure how much time I can invest in this in the future. That might be another thought whether it is worth your time or not. Anyway, I am a beginner (both in C++ and Qt) and maybe someone can point out my mistakes to me. Furthermore, I can't compile the source, so it's all just on paper (http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg195015.html). I'll start with the lock state (isMoveable/setMoveable) of the toolbars being saved and restored using QSettings. I am not sure I have understood the "cit" correctly. In GuiView.cpp ("..." signifies left out code that is untouched): ... void GuiView::saveLayout() const { QSettings settings; ... // setting > toolbars ... settings.beginGroup("toolbars"); // ... > movable settings.beginGroup("moveable"); // extracts the toolbars from the backend Toolbars::Infos::const_iterator cit = guiApp->toolbars().begin(); Toolbars::Infos::const_iterator end = guiApp->toolbars().end(); // store moveable setting per toolbar for (; cit != end; ++cit) { GuiToolbar * tb = toolbar(cit->name); settings.setValue(tb->objectName(), tb->isMovable()); } settings.endGroup(); settings.endGroup(); } ... bool GuiView::restoreLayout() { QSettings settings; ... /* The following part is replaced by the code below: if (!restoreState(settings.value("layout").toByteArray(), 0)) initToolbars(); // init the toolbars that have not been restored 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->isRestored()) initToolbar(cit->name); } */ if (!restoreState(settings.value("layout").toByteArray(), 0)) initToolbars(); else { // toolbar property moveable isn't part of "state" so it has to be done manually ... // ... setting > toolbars ... settings.beginGroup("toolbars"); // ... > movable settings.beginGroup("moveable"); // extracts the toolbars from the backend Toolbars::Infos::iterator cit = guiApp->toolbars().begin(); Toolbars::Infos::iterator end = guiApp->toolbars().end(); for (; cit != end; ++cit) { if (tb && !tb->isRestored()) { // init the toolbar that has not been restored initToolbar(cit->name); } else { GuiToolbar * tb = toolbar(cit->name); // restore moveable from setting tb->setMovable(settings.value(tb->objectName(), false).toBool()); } } settings.endGroup(); settings.endGroup(); } updateDialogs(); return true; } ... Daniel
Re: toolbars Lock menu
On 07.07.2016 14:41, racoon wrote: Can someone give me a hint where LyX stores the individual toolbars' properties, i.e. position and visibility. Okay, got it (via QSettings). I was just a bit confused because the visibility is also (somewhat) stored in the preferences file. Daniel