diff --git a/shell/mainwindow_p.cpp b/shell/mainwindow_p.cpp --- a/shell/mainwindow_p.cpp +++ b/shell/mainwindow_p.cpp @@ -431,10 +431,27 @@ menu.addActions(actionMap.values()); } + QAction* lockAction = new QAction(this); + lockAction->setCheckable(true); + lockAction->setText(i18n("Lock the Panel from Hiding")); + + KConfigGroup config = KSharedConfig::openConfig()->group("UI"); + lockAction->setChecked(config.readEntry(QStringLiteral("Toolview Bar (%1) Is Locked").arg(area), false)); + + menu.addSeparator(); + menu.addAction(lockAction); + QAction* triggered = menu.exec(position); if ( !triggered ) { return; } + + if (triggered == lockAction) { + KConfigGroup config = KSharedConfig::openConfig()->group("UI"); + config.writeEntry(QStringLiteral("Toolview Bar (%1) Is Locked").arg(area), lockAction->isChecked()); + return; + } + Core::self()->uiControllerInternal()->addToolViewToDockArea( actionToFactory[triggered], area diff --git a/shell/settings/uiconfig.kcfg b/shell/settings/uiconfig.kcfg --- a/shell/settings/uiconfig.kcfg +++ b/shell/settings/uiconfig.kcfg @@ -21,5 +21,11 @@ true + + false + + + true + diff --git a/shell/settings/uiconfig.ui b/shell/settings/uiconfig.ui --- a/shell/settings/uiconfig.ui +++ b/shell/settings/uiconfig.ui @@ -6,15 +6,24 @@ 0 0 - 521 - 399 + 503 + 481 User Interface - + + 0 + + + 0 + + + 0 + + 0 @@ -92,7 +101,7 @@ - + Qt::Vertical @@ -173,6 +182,32 @@ + + + + 'Focus Editor' command behavior + + + + + + Also hide unlocked docks + + + + + + + false + + + Hide docks only if editor is already focused + + + + + + @@ -184,12 +219,12 @@ setEnabled(bool) - 260 - 133 + 268 + 193 - 260 - 158 + 268 + 225 @@ -200,12 +235,28 @@ setEnabled(bool) - 260 - 133 + 268 + 193 + + + 268 + 257 + + + + + kcfg_HideUnlockedDocksOnEditorFocus + toggled(bool) + kcfg_HideUnlockedDocksOnlyIfEditorHasFocus + setEnabled(bool) + + + 119 + 405 - 260 - 183 + 126 + 434 diff --git a/sublime/idealbuttonbarwidget.h b/sublime/idealbuttonbarwidget.h --- a/sublime/idealbuttonbarwidget.h +++ b/sublime/idealbuttonbarwidget.h @@ -73,6 +73,8 @@ void loadOrderSettings(const KConfigGroup& configGroup); void saveOrderSettings(KConfigGroup& configGroup); + bool isLocked(); + signals: void emptyChanged(); diff --git a/sublime/idealbuttonbarwidget.cpp b/sublime/idealbuttonbarwidget.cpp --- a/sublime/idealbuttonbarwidget.cpp +++ b/sublime/idealbuttonbarwidget.cpp @@ -269,6 +269,12 @@ configGroup.writeEntry(QStringLiteral("(%1) Tool Views Order").arg(_area), _buttonsOrder); } +bool IdealButtonBarWidget::isLocked() +{ + KConfigGroup config = KSharedConfig::openConfig()->group("UI"); + return config.readEntry(QStringLiteral("Toolview Bar (%1) Is Locked").arg(_area), false); +} + void IdealButtonBarWidget::applyOrderToLayout() { // If widget already have some buttons in the layout then calling loadOrderSettings() may leads diff --git a/sublime/mainwindow_p.h b/sublime/mainwindow_p.h --- a/sublime/mainwindow_p.h +++ b/sublime/mainwindow_p.h @@ -140,6 +140,7 @@ private: void restoreConcentrationMode(); + void hideUnlockedDocks(); void setBackgroundVisible(bool v); Qt::DockWidgetArea positionToDockArea(Position position); diff --git a/sublime/mainwindow_p.cpp b/sublime/mainwindow_p.cpp --- a/sublime/mainwindow_p.cpp +++ b/sublime/mainwindow_p.cpp @@ -277,11 +277,43 @@ void MainWindowPrivate::focusEditor() { + hideUnlockedDocks(); + if (View* view = m_mainWindow->activeView()) if (view->hasWidget()) view->widget()->setFocus(Qt::ShortcutFocusReason); } +void MainWindowPrivate::hideUnlockedDocks() +{ + KConfigGroup config = KSharedConfig::openConfig()->group("UiSettings"); + bool hideDocks = config.readEntry(QStringLiteral("HideUnlockedDocksOnEditorFocus"), false); + bool hideOnlyWhenFocused = config.readEntry(QStringLiteral("HideUnlockedDocksOnlyIfEditorHasFocus"), true); + + View* view = m_mainWindow->activeView(); + if (!hideDocks || (view && view->hasWidget() && !view->widget()->hasFocus() && hideOnlyWhenFocused)) + return; + + // Due to IdealController::showBottomDock() logic, + // first call focuses Dock, second - hide it + // TODO: add 'force' parameter to showFOODock() ? + + if (!idealController->leftBarWidget->isLocked()) { + idealController->showLeftDock(false); + idealController->showLeftDock(false); + } + + if (!idealController->bottomBarWidget->isLocked()) { + idealController->showBottomDock(false); + idealController->showBottomDock(false); + } + + if (!idealController->rightBarWidget->isLocked()) { + idealController->showRightDock(false); + idealController->showRightDock(false); + } +} + void MainWindowPrivate::toggleDocksShown() { idealController->toggleDocksShown();