Commit Graph

25 Commits

Author SHA1 Message Date
Abdullah Tahiri
ef70f2e53d Gui: Unavailable toolbars default to visible when made available
================================================================

https://github.com/FreeCAD/FreeCAD/issues/9208#issuecomment-1567469254

Issue:
- Unavailable toolbars default to not visible (as they are unavailable)
- However, when made available, they remain not visible. There may be
  cases when this is indeed the wanted behaviour, but they are not the
  ones we are facing.
- In the latter, the user expects the toolbars to show (and the
  configuration file to be saved with all toolbars showing.

Solution:
- Change the default behaviour of Unavailable toolbars when forcing
  them to be available, so that they are visible when made available.
- If then the case arises that we have toolbars where we would prefer
  then to be left not visible when making them available (so they are
  listed in the toolbar context menu to make them visible, but not
  visible per default), then we would need to create another toolbar
  policy class "UnavailableHidden".
- I chose not to add it directly (although it is straightforward) in
  fear that we will never need it, and it would make the code more
  complex to understand and thus maintain.
2023-05-30 16:37:53 +02:00
Abdullah Tahiri
ee1fcb3f3a Sketcher/Gui: Extend toolbar framework and fix toolbar visibility not preserved
=================================================================================

fixes #9208

Essentially:
- The regular mechanism to save toolbar state when changing from one WB to another
is not designed to support changes within one WB (e.g. from edit mode and back).
- At creation time, toolbars can be initialised with default visible or default hidden
state. Additionally, there is third configuration "Unavailable", which refers to a
toolbar that is hidden, and the control to enable it is also hidden by default.
- The ToolBarManager is extended to enable to set the State of one or more toolbars.
- The State refers to changes to be effected on one or more toolbars by client code:
* ForceHidden allows to hide a toolbar and also hide its control (a toolbar not available
in a mode).
* ForceAvailable allows to make a toolbar available by making its control visible, the
toolbar itself is visible or not depending on user settings.
* RestoreDefault allows to bring the control visibility to the default of the toolbar, the
toolbar itself is visible or not depending on user settings.
* SaveState allows to store the current visibility state of a toolbar. It enables client
code to save the state when appropriate. It provides the only option for default "Unavailable"
toolbars, which are fully managed by client code. It provides additional flexibility to save
other toolbar visibility on request.

For the Sketcher this means:
- That edit mode toolbars are not shown outside edit mode.
- That edit mode toolbars and non-edit mode toolbars can be configured independently.
- that edit mode toolbars' state is saved when leaving edit mode if and only if, the
workbench that is selected when leaving edit mode is the Sketcher WB.
- it won't save the state if the user manually selected another WB and then left edit
mode (why? see limitation above).

Limitation:
- When switching to another WB while in edit mode, the other WB is activated before the
current WB (sketcher WB) is deactivated. This means that at sketcher level, the sketcher
has no chance to save states or do other tidy up actions before the tools of the other WB
are activated.
- This, however, is understood as not relevant enough as to warrant changing the mechanisms
in place.
2023-05-30 16:37:53 +02:00
wmayer
191289a595 Sketcher: fix some lint warnings 2023-04-03 17:36:06 +02:00
wmayer
c628c000f5 Sketcher: ignore toolbars if toggle action is invisible or style is FORCE_HIDE
This fully fixes #9135
2023-04-03 17:36:06 +02:00
wmayer
ac2c09b487 Gui: [skip ci] fix whitespaces 2023-03-13 22:38:54 +01:00
Syres916
8a7945c9f2 [Gui] Add TODO reference hack 2023-03-13 22:34:58 +01:00
Syres916
322c1e4ddb [Gui] Improve comments regarding move of widget 2023-03-13 22:34:58 +01:00
Syres916
48ca8d5269 [Gui] Fix regressions from PR7771...
specifically 7458912b33 fixes #7965 #8440
2023-03-13 22:34:58 +01:00
wmayer
8381ea079d Gui: fix regression with the default visibility of toolbars
If the user e.g. activates the Clipboard toolbar then it should not be hidden any more if the user switches to another workbench.
The way it is now the user has to make this toolbar visible over and over again when changing the workbench. This also has the negative effect that
the workbench selector changes its position
2023-03-07 10:43:12 +01:00
Adrian Insaurralde Avalos
9e94366f2d [Gui] ToolBarManager: add feature to make toolbars hidden by default 2023-03-03 22:47:11 -06:00
wmayer
a95aefdb18 Gui: use new-style connect and add curly braces to improve readability 2022-11-10 23:20:18 +01:00
Zheng, Lei
7458912b33 Gui: fix shortcut context handling in ShortcutManager
Related #6097

Qt ignores shortcut of actions in invisible toolbar, but not for actions
in a hidden menu action of menu bar, which is likely a Qt bug. The
desired behavior should be that of toolbar actions, so that actions
belong to different workbenches can have the same shortcut without
conflict.

This commit works around this inconsistency by ensuring only the active
actions are added in menu bar. In addition, all active actions will be
added to a zero sized child widget of the main window, which ensures the
shortcuts of these actions being active regardless whether the action is
in toolbar or menu bar, visible or not.
2022-11-10 23:20:18 +01:00
Paddle
c9aadeec4c Gui: Allow to hide toolbars that are not needed.
In particular this hides edit-mode sketcher toolbars when in non-edit-mode.
    And hides non-edit-mode toolbar when in edit-mode.
    It also hides the structure toolbar when in edit-mode (as it is completely deactivated)
2022-11-04 12:02:16 -05:00
berniev
75acacd1b7 Gui: Use auto and range-based for (#7481)
* On lines where the variable type is obvious from inspection, avoid repeating the type using auto. 
* When possible use a ranged for loop instead of begin() and end() iterators
2022-09-14 13:25:13 -05:00
wmayer
d5921e08ec fix (Qt) issues found by clang's clazy tool:
+ -Wclazy-incorrect-emit
+ -Wclazy-strict-iterators
+ -Wclazy-overloaded-signal
+ -Wclazy-qstring-arg
+ -Wclazy-unused-non-trivial-variable
+ -Wclazy-container-anti-pattern
+ -Wclazy-range-loop-reference
+ -Wclazy-const-signal-or-slot
+ -Wclazy-detaching-temporary
+ -Wclazy-qfileinfo-exists
2022-06-29 21:00:54 +02:00
wmayer
96adb98f46 Gui: modernize C++11
* use nullptr
2022-03-23 18:41:21 +01:00
Uwe
042f0ee8c6 [Gui] Tool* etc.:remove unused includes 2022-03-05 18:08:13 +01:00
Mark Ganson TheMarkster
f17c85fc47 [MainWindow] Add toolbar name as toolbar's tooltip (#5259)
* [MainWindow] Add toolbar name as toolbar's  tooltip

Co-authored-by: Uwe <donovaly@users.noreply.github.com>
2021-12-17 03:16:30 +01:00
Chris Hennes
c1f7407b25 [Gui] Add hidden pref to lock toolbars
When arranged vertically, the bar that allows the dragging of toolbars
can cause problems with the toolbar appearance. This adds a hidden
preference that controls whether the toolbars are movable.
2021-08-26 09:12:25 -05:00
luz.paz
baa6d89328 Typos and whitespace fixes 2018-08-07 11:13:31 -04:00
wmayer
d2cb4e4af9 Qt4/Qt5 neutral changes:
+ remove QCoreApplication::UnicodeUTF8/QApplication::UnicodeUTF8
+ remove QCoreApplication::CodecForTr/QApplication::CodecForTr
2016-12-12 14:52:09 +01:00
Mateusz Skowroński
cd2db00f22 QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
This change is Qt4/Qt5 neutral.
2016-01-05 16:07:25 +01:00
wmayer
30768c9519 + proper encoding of custom toolbar names 2014-01-26 16:02:22 +01:00
wmayer
791aca3c2c + fix changing 3d view when switching from Complete workbench to any other workbench
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5335 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-12-21 17:14:04 +00:00
wmayer
120ca87015 + unify DLL export defines to namespace names
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-10-10 13:44:52 +00:00