Skip to content

Commit

Permalink
Gui: Unavailable toolbars default to visible when made available
Browse files Browse the repository at this point in the history
================================================================

FreeCAD#9208 (comment)

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.
  • Loading branch information
abdullahtahiriyo committed May 30, 2023
1 parent 94c52fe commit 8c6816c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Gui/ToolBarManager.cpp
Expand Up @@ -536,7 +536,16 @@ void ToolBarManager::setState(const QString& name, State state)

tb->toggleViewAction()->setVisible(true);

showhide(tb, policy);
// Unavailable policy defaults to a Visible toolbars when made available
auto show = visibility( policy == ToolBarItem::DefaultVisibility::Visible ||
policy == ToolBarItem::DefaultVisibility::Unavailable);

if(show) {
tb->show();
}
else {
tb->hide();
}
}
else if (state == State::ForceHidden) {
tb->toggleViewAction()->setVisible(false); // not visible in context menus
Expand Down
3 changes: 2 additions & 1 deletion src/Gui/ToolBarManager.h
Expand Up @@ -44,7 +44,8 @@ class GuiExport ToolBarItem
Hidden, // toolbar hidden by default, visibility toggle action is enabled
Unavailable, // toolbar visibility is managed independently by client code and defaults to
// hidden, visibility toggle action is disabled by default (it is unavailable
// to the UI).
// to the UI). Upon being forced to be available, these toolbars default to
// visible.
};

ToolBarItem();
Expand Down

0 comments on commit 8c6816c

Please sign in to comment.