[Gui] ToolBarManager: add feature to make toolbars hidden by default
This commit is contained in:
committed by
Chris Hennes
parent
5171079cc4
commit
9e94366f2d
@@ -37,11 +37,11 @@
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
ToolBarItem::ToolBarItem() : forceHide(HideStyle::VISIBLE)
|
||||
ToolBarItem::ToolBarItem() : visibility(HideStyle::VISIBLE)
|
||||
{
|
||||
}
|
||||
|
||||
ToolBarItem::ToolBarItem(ToolBarItem* item, HideStyle forcehide) : forceHide(forcehide)
|
||||
ToolBarItem::ToolBarItem(ToolBarItem* item, HideStyle visibility) : visibility(visibility)
|
||||
{
|
||||
if ( item )
|
||||
item->appendItem(this);
|
||||
@@ -226,9 +226,9 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems)
|
||||
toolbars.removeAt(index);
|
||||
}
|
||||
|
||||
bool visible = hPref->GetBool(toolbarName.c_str(), true) && (*it)->forceHide == ToolBarItem::HideStyle::VISIBLE;
|
||||
bool visible = hPref->GetBool(toolbarName.c_str(), true) && (*it)->visibility == ToolBarItem::HideStyle::VISIBLE;
|
||||
toolbar->setVisible(visible);
|
||||
toolbar->toggleViewAction()->setVisible((*it)->forceHide == ToolBarItem::HideStyle::VISIBLE);
|
||||
toolbar->toggleViewAction()->setVisible((*it)->visibility != ToolBarItem::HideStyle::FORCE_HIDE);
|
||||
|
||||
// setup the toolbar
|
||||
setup(*it, toolbar);
|
||||
@@ -326,7 +326,7 @@ void ToolBarManager::saveState() const
|
||||
QToolBar* toolbar = findToolBar(toolbars, *it);
|
||||
if (toolbar) {
|
||||
if (!toolbar->toggleViewAction()->isVisible())
|
||||
continue; //if toggleViewAction is not visible it means that the toolbar is forceHide. In which case we do not save settings.
|
||||
continue; //if toggleViewAction is not visible it means that the toolbar is FORCE_HIDE. In which case we do not save settings.
|
||||
QByteArray toolbarName = toolbar->objectName().toUtf8();
|
||||
hPref->SetBool(toolbarName.constData(), toolbar->isVisible());
|
||||
}
|
||||
|
||||
@@ -38,11 +38,12 @@ class GuiExport ToolBarItem
|
||||
public:
|
||||
enum class HideStyle {
|
||||
VISIBLE,
|
||||
HIDDEN, // toolbar hidden by default
|
||||
FORCE_HIDE // Force a toolbar to be hidden. For when all elements are disabled at some point in a workbench.
|
||||
};
|
||||
|
||||
ToolBarItem();
|
||||
explicit ToolBarItem(ToolBarItem* item, HideStyle forceHide = HideStyle::VISIBLE);
|
||||
explicit ToolBarItem(ToolBarItem* item, HideStyle visibility = HideStyle::VISIBLE);
|
||||
~ToolBarItem();
|
||||
|
||||
void setCommand(const std::string&);
|
||||
@@ -62,7 +63,7 @@ public:
|
||||
ToolBarItem& operator << (const std::string& command);
|
||||
QList<ToolBarItem*> getItems() const;
|
||||
|
||||
HideStyle forceHide;
|
||||
HideStyle visibility;
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
|
||||
Reference in New Issue
Block a user