diff --git a/sublime/idealbuttonbarwidget.h b/sublime/idealbuttonbarwidget.h --- a/sublime/idealbuttonbarwidget.h +++ b/sublime/idealbuttonbarwidget.h @@ -59,6 +59,10 @@ void showWidget(QAction *widgetAction, bool checked); bool isEmpty(); + bool isShown(); + void saveShowState(); + bool lastShowState(); + private Q_SLOTS: void showWidget(bool checked); void buttonPressed(bool state); @@ -75,6 +79,7 @@ QHash _buttons; QHash _widgets; QWidget *_corner; + bool _showState; }; } diff --git a/sublime/idealbuttonbarwidget.cpp b/sublime/idealbuttonbarwidget.cpp --- a/sublime/idealbuttonbarwidget.cpp +++ b/sublime/idealbuttonbarwidget.cpp @@ -43,6 +43,7 @@ , _area(area) , _controller(controller) , _corner(0) + , _showState(false) { setContextMenuPolicy(Qt::CustomContextMenu); setToolTip(i18nc("@info:tooltip", "Right click to add new tool views.")); @@ -117,6 +118,22 @@ return actions().isEmpty(); } +bool IdealButtonBarWidget::isShown() +{ + return std::any_of(actions().cbegin(), actions().cend(), + [](const QAction* action){ return action->isChecked(); }); +} + +void IdealButtonBarWidget::saveShowState() +{ + _showState = isShown(); +} + +bool IdealButtonBarWidget::lastShowState() +{ + return _showState; +} + Qt::Orientation IdealButtonBarWidget::orientation() const { if (_area == Qt::LeftDockWidgetArea || _area == Qt::RightDockWidgetArea) diff --git a/sublime/idealcontroller.cpp b/sublime/idealcontroller.cpp --- a/sublime/idealcontroller.cpp +++ b/sublime/idealcontroller.cpp @@ -454,22 +454,17 @@ void IdealController::toggleDocksShown() { - QList allActions; - allActions += leftBarWidget->actions(); - allActions += bottomBarWidget->actions(); - allActions += rightBarWidget->actions(); - - bool show = true; - foreach (QAction *action, allActions) { - if (action->isChecked()) { - show = false; - break; - } + bool anyBarShown = leftBarWidget->isShown() || bottomBarWidget->isShown() || rightBarWidget->isShown(); + + if (anyBarShown) { + leftBarWidget->saveShowState(); + bottomBarWidget->saveShowState(); + rightBarWidget->saveShowState(); } - toggleDocksShown(leftBarWidget, show); - toggleDocksShown(bottomBarWidget, show); - toggleDocksShown(rightBarWidget, show); + toggleDocksShown(leftBarWidget, !anyBarShown && leftBarWidget->lastShowState()); + toggleDocksShown(bottomBarWidget, !anyBarShown && bottomBarWidget->lastShowState()); + toggleDocksShown(rightBarWidget, !anyBarShown && rightBarWidget->lastShowState()); } void IdealController::toggleDocksShown(IdealButtonBarWidget* bar, bool show)