diff --git a/toonz/sources/toonz/toolbar.cpp b/toonz/sources/toonz/toolbar.cpp old mode 100644 new mode 100755 index d5b738b..be25276 --- a/toonz/sources/toonz/toolbar.cpp +++ b/toonz/sources/toonz/toolbar.cpp @@ -10,16 +10,23 @@ #include "toonzqt/menubarcommand.h" #include "menubarcommandids.h" +// TnzBase includes +#include "tenv.h" + #include #include #include #include +TEnv::IntVar ShowAllToolsToggle("ShowAllToolsToggle", 0); + //============================================================================= // Toolbar //----------------------------------------------------------------------------- -Toolbar::Toolbar(QWidget *parent, bool isVertical) : QToolBar(parent) { +Toolbar::Toolbar(QWidget *parent, bool isVertical) + : QToolBar(parent) + , m_isExpanded(ShowAllToolsToggle !=0) { // Fondamentale per lo style sheet setObjectName("toolBar"); @@ -103,23 +110,23 @@ Toolbar::Toolbar(QWidget *parent, bool isVertical) : QToolBar(parent) { m_expandButton = new QToolButton(this); m_expandButton->setCheckable(true); - m_expandButton->setChecked(false); + m_expandButton->setChecked(m_isExpanded); m_expandButton->setArrowType((isVertical) ? Qt::DownArrow : Qt::RightArrow); addWidget(m_expandButton); - // toolbar is shrinked at the beginning - updateToolbar(false); - + // toolbar is expanded or shrinked according to env at the beginning + updateToolbar(); + connect(m_expandButton, SIGNAL(toggled(bool)), this, - SLOT(updateToolbar(bool))); + SLOT(setIsExpanded(bool))); } //----------------------------------------------------------------------------- /*! Layout the tool buttons according to the state of the expandButton */ -void Toolbar::updateToolbar(bool expand) { - if (expand) { +void Toolbar::updateToolbar() { + if (m_isExpanded) { insertAction(CommandManager::instance()->getAction(T_Fill), CommandManager::instance()->getAction(T_Type)); insertAction(CommandManager::instance()->getAction(T_Hand), @@ -167,6 +174,14 @@ void Toolbar::updateToolbar(bool expand) { update(); } +//---------------------------------------------------------------------------- + +void Toolbar::setIsExpanded(bool expand) { + m_isExpanded = expand; + ShowAllToolsToggle = (expand) ? 1 : 0; + updateToolbar(); +} + //----------------------------------------------------------------------------- Toolbar::~Toolbar() {} diff --git a/toonz/sources/toonz/toolbar.h b/toonz/sources/toonz/toolbar.h old mode 100644 new mode 100755 index 1f07ea6..5632008 --- a/toonz/sources/toonz/toolbar.h +++ b/toonz/sources/toonz/toolbar.h @@ -12,11 +12,13 @@ class Toolbar : public QToolBar { QToolButton *m_expandButton; QAction *m_sep1, *m_sep2; + bool m_isExpanded; + void updateToolbar(); public: Toolbar(QWidget *parent, bool isVertical = true); ~Toolbar(); - + protected: bool addAction(QAction *act); @@ -25,7 +27,7 @@ protected: protected slots: void onToolChanged(); - void updateToolbar(bool expand); + void setIsExpanded(bool expand); }; #endif // TOOLBAR_H