[krita] libs/ui: On switching a workspace unlock all dockers
Boudewijn Rempt
null at kde.org
Wed Mar 28 13:40:04 UTC 2018
Git commit 52c0f20f60afe97568609bb161170bae98757aa2 by Boudewijn Rempt.
Committed on 28/03/2018 at 13:39.
Pushed by rempt into branch 'master'.
On switching a workspace unlock all dockers
The workspace selector widget tried to restore the lock status
after changing a workspace for all visible dockers, the workspace
menu didn't do that. In any case, it is far too easy to lock
invisible dockers, and that confuses far too many people and takes
far too much of our time to explain.
Tt is better to define that changing a workspace will reset the
lockedness of all dockers. The lock property of a docker is not
part of the workspace.
BUG:392235
CCMAIL:kimageshop at kde.org
Maybe we should remove the lock and collapse feature for dockers
altogether.
M +1 -1 libs/ui/KisApplication.cpp
M +12 -7 libs/ui/KisMainWindow.cpp
M +3 -3 libs/ui/KisMainWindow.h
M +1 -20 libs/ui/widgets/kis_workspace_chooser.cpp
https://commits.kde.org/krita/52c0f20f60afe97568609bb161170bae98757aa2
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 85ba562fd0f..0ad6720e919 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -464,7 +464,7 @@ bool KisApplication::start(const KisApplicationArguments &args)
KoResourceServer<KisWorkspaceResource> * rserver = KisResourceServerProvider::instance()->workspaceServer();
KisWorkspaceResource* workspace = rserver->resourceByName(args.workspace());
if (workspace) {
- m_mainWindow->restoreWorkspace(workspace->dockerState());
+ m_mainWindow->restoreWorkspace(workspace);
}
}
diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cpp
index 3e50b4add5e..8e9af7c43fa 100644
--- a/libs/ui/KisMainWindow.cpp
+++ b/libs/ui/KisMainWindow.cpp
@@ -1485,13 +1485,16 @@ int KisMainWindow::viewCount() const
return d->mdiArea->subWindowList().size();
}
-bool KisMainWindow::restoreWorkspace(const QByteArray &state)
+bool KisMainWindow::restoreWorkspace(KisWorkspaceResource *workspace)
{
+ QByteArray state = workspace->dockerState();
QByteArray oldState = saveState();
const bool showTitlebars = KisConfig().showDockerTitleBars();
// needed because otherwise the layout isn't correctly restored in some situations
Q_FOREACH (QDockWidget *dock, dockWidgets()) {
+ dock->setProperty("Locked", false); // Unlock invisible dockers
+ dock->toggleViewAction()->setEnabled(true);
dock->hide();
dock->titleBarWidget()->setVisible(showTitlebars);
}
@@ -1508,7 +1511,6 @@ bool KisMainWindow::restoreWorkspace(const QByteArray &state)
return false;
}
-
Q_FOREACH (QDockWidget *dock, dockWidgets()) {
if (dock->titleBarWidget()) {
const bool isCollapsed = (dock->widget() && dock->widget()->isHidden()) || !dock->widget();
@@ -1516,6 +1518,10 @@ bool KisMainWindow::restoreWorkspace(const QByteArray &state)
}
}
+ if (activeKisView()) {
+ activeKisView()->resourceProvider()->notifyLoadingWorkspace(workspace);
+ }
+
return success;
}
@@ -2038,8 +2044,9 @@ void KisMainWindow::updateWindowMenu()
auto m_this = this;
for (auto &w : workspaces) {
auto action = workspaceMenu->addAction(w->name());
- auto ds = w->dockerState();
- connect(action, &QAction::triggered, this, [=]() { m_this->restoreWorkspace(ds); });
+ connect(action, &QAction::triggered, this, [=]() {
+ m_this->restoreWorkspace(w);
+ });
}
workspaceMenu->addSeparator();
connect(workspaceMenu->addAction(i18nc("@action:inmenu", "&Import Workspace...")),
@@ -2257,7 +2264,7 @@ void KisMainWindow::showAboutApplication()
dlg.exec();
}
-QPointer<KisView>KisMainWindow::activeKisView()
+QPointer<KisView> KisMainWindow::activeKisView()
{
if (!d->mdiArea) return 0;
QMdiSubWindow *activeSubWindow = d->mdiArea->activeSubWindow();
@@ -2474,8 +2481,6 @@ void KisMainWindow::initializeGeometry()
move(x,y);
setGeometry(geometry().x(), geometry().y(), w, h);
}
- restoreWorkspace(QByteArray::fromBase64(cfg.readEntry("State", QByteArray())));
-
d->fullScreenMode->setChecked(isFullScreen());
}
diff --git a/libs/ui/KisMainWindow.h b/libs/ui/KisMainWindow.h
index ee23b8d9b65..05e6a4e44c4 100644
--- a/libs/ui/KisMainWindow.h
+++ b/libs/ui/KisMainWindow.h
@@ -45,7 +45,7 @@ class QDockWidget;
class KisView;
class KisViewManager;
class KoCanvasController;
-
+class KisWorkspaceResource;
/**
* @brief Main window for Krita
@@ -147,7 +147,7 @@ public:
* @param state the saved state
* @return TRUE on success
*/
- bool restoreWorkspace(const QByteArray &state);
+ bool restoreWorkspace(KisWorkspaceResource *workspace);
KisViewManager *viewManager() const;
@@ -421,7 +421,7 @@ private:
void saveWindowSettings();
- QPointer<KisView>activeKisView();
+ QPointer<KisView> activeKisView();
void applyDefaultSettings(QPrinter &printer);
diff --git a/libs/ui/widgets/kis_workspace_chooser.cpp b/libs/ui/widgets/kis_workspace_chooser.cpp
index 35a0acc865d..d9a74e5f479 100644
--- a/libs/ui/widgets/kis_workspace_chooser.cpp
+++ b/libs/ui/widgets/kis_workspace_chooser.cpp
@@ -154,26 +154,7 @@ void KisWorkspaceChooser::resourceSelected(KoResource* resource)
return;
}
KisWorkspaceResource* workspace = static_cast<KisWorkspaceResource*>(resource);
-
- QMap<QDockWidget *, bool> dockWidgetMap;
- Q_FOREACH (QDockWidget *docker, m_view->mainWindow()->dockWidgets()) {
- dockWidgetMap[docker] = docker->property("Locked").toBool();
- }
-
KisMainWindow *mainWindow = qobject_cast<KisMainWindow*>(m_view->qtMainWindow());
- mainWindow->restoreWorkspace(workspace->dockerState());
- m_view->resourceProvider()->notifyLoadingWorkspace(workspace);
-
- Q_FOREACH (QDockWidget *docker, dockWidgetMap.keys()) {
- if (docker->isVisible()) {
- docker->setProperty("Locked", dockWidgetMap[docker]);
- docker->updateGeometry();
- }
- else {
- docker->setProperty("Locked", false); // Unlock invisible dockers
- docker->toggleViewAction()->setEnabled(true);
- }
-
- }
+ mainWindow->restoreWorkspace(workspace);
}
More information about the kimageshop
mailing list