Commit 6970bfca authored by Halla Rempt's avatar Halla Rempt
Browse files

Restore the ui after crashing in canvasonly mode

BUG:402710
parent 5fe95d19
......@@ -523,6 +523,20 @@ KisMainWindow::KisMainWindow(QUuid uuid)
d->tabSwitchCompressor.reset(
new KisSignalCompressorWithParam<int>(500, callback, KisSignalCompressor::FIRST_INACTIVE));
}
if (cfg.readEntry("CanvasOnlyActive", false)) {
QString currentWorkspace = cfg.readEntry<QString>("CurrentWorkspace", "Default");
KoResourceServer<KisWorkspaceResource> * rserver = KisResourceServerProvider::instance()->workspaceServer();
KisWorkspaceResource* workspace = rserver->resourceByName(currentWorkspace);
if (workspace) {
restoreWorkspace(workspace);
}
cfg.writeEntry("CanvasOnlyActive", false);
menuBar()->setVisible(true);
}
}
KisMainWindow::~KisMainWindow()
......
......@@ -321,9 +321,6 @@ KisViewManager::KisViewManager(QWidget *parent, KActionCollection *_actionCollec
d->canvasResourceProvider.setFGColor(cfg.readKoColor("LastForeGroundColor",foreground));
KoColor background(Qt::white, cs);
d->canvasResourceProvider.setBGColor(cfg.readKoColor("LastBackGroundColor",background));
}
......@@ -336,7 +333,7 @@ KisViewManager::~KisViewManager()
}
cfg.writeEntry("baseLength", KoResourceItemChooserSync::instance()->baseLength());
cfg.writeEntry("CanvasOnlyActive", false); // We never restart in CavnasOnlyMode
delete d;
}
......@@ -1144,13 +1141,15 @@ void KisViewManager::showStatusBar(bool toggled)
void KisViewManager::switchCanvasOnly(bool toggled)
{
KisConfig cfg(false);
KisMainWindow* main = mainWindow();
KisMainWindow *main = mainWindow();
if(!main) {
dbgUI << "Unable to switch to canvas-only mode, main window not found";
return;
}
cfg.writeEntry("CanvasOnlyActive", toggled);
if (toggled) {
d->canvasState = qtMainWindow()->saveState();
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
......
......@@ -178,6 +178,8 @@ void KisWorkspaceChooser::workspaceSelected(KoResource *resource)
if (!m_view->qtMainWindow()) {
return;
}
KisConfig cfg(false);
cfg.writeEntry("CurrentWorkspace", resource->name());
KisWorkspaceResource* workspace = static_cast<KisWorkspaceResource*>(resource);
KisMainWindow *mainWindow = qobject_cast<KisMainWindow*>(m_view->qtMainWindow());
mainWindow->restoreWorkspace(workspace);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment