Commit 8673d24e authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Add option to detach canvas area to a separate window

parent 01e3e1bf
......@@ -73,6 +73,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<text>&amp;View</text>
<Action name="view_show_canvas_only"/>
<Action name="fullscreen"/>
<Action name="view_detached_canvas"/>
<Action name="wrap_around_mode"/>
<Action name="level_of_detail_mode"/>
<Action name="softProof"/>
......
......@@ -594,6 +594,18 @@
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="view_detached_canvas">
<icon></icon>
<text>Detach canvas</text>
<whatsThis></whatsThis>
<toolTip>Show the canvas on a separate window</toolTip>
<iconText>Detach canvas</iconText>
<activationFlags>0</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="wrap_around_mode">
<icon></icon>
<text>&amp;Wrap Around Mode</text>
......
......@@ -225,6 +225,7 @@ public:
KisAction *mdiPreviousWindow {0};
KisAction *toggleDockers {0};
KisAction *toggleDockerTitleBars {0};
KisAction *toggleDetachCanvas {0};
KisAction *fullScreenMode {0};
KisAction *showSessionManager {0};
......@@ -254,6 +255,7 @@ public:
QMdiSubWindow *activeSubWindow {0};
QSignalMapper *windowMapper;
QSignalMapper *documentMapper;
QWidget *canvasWindow {0};
QByteArray lastExportedFormat;
QScopedPointer<KisSignalCompressorWithParam<int> > tabSwitchCompressor;
......@@ -373,6 +375,14 @@ KisMainWindow::KisMainWindow(QUuid uuid)
connect(d->windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
connect(d->documentMapper, SIGNAL(mapped(QObject*)), this, SLOT(newView(QObject*)));
d->canvasWindow = new QWidget();
d->canvasWindow->setWindowFlags(Qt::Window);
actionCollection()->addAssociatedWidget(d->canvasWindow);
QLayout *cwLayout = new QHBoxLayout(d->canvasWindow);
d->canvasWindow->setLayout(cwLayout);
cwLayout->addWidget(new QWidget(this));
createActions();
setAutoSaveSettings(d->windowStateConfig, false);
......@@ -663,6 +673,23 @@ void KisMainWindow::slotThemeChanged()
emit themeChanged();
}
void KisMainWindow::slotDetachCanvas(bool detach)
{
QWidget *outgoingWidget = takeCentralWidget();
QWidget *incomingWidget = d->canvasWindow->layout()->takeAt(0)->widget();
setCentralWidget(incomingWidget);
d->canvasWindow->layout()->addWidget(outgoingWidget);
if (detach) {
KIS_SAFE_ASSERT_RECOVER_NOOP(outgoingWidget == d->mdiArea);
d->canvasWindow->show();
} else {
KIS_SAFE_ASSERT_RECOVER_NOOP(incomingWidget == d->mdiArea);
d->canvasWindow->hide();
}
}
void KisMainWindow::updateReloadFileAction(KisDocument *doc)
{
Q_UNUSED(doc);
......@@ -1222,8 +1249,8 @@ void KisMainWindow::closeEvent(QCloseEvent *e)
if (!closeAllowed) {
e->setAccepted(false);
return;
}
return;
}
}
......@@ -1234,6 +1261,7 @@ void KisMainWindow::closeEvent(QCloseEvent *e)
if (childrenList.isEmpty()) {
d->deferredClosingEvent = e;
saveWindowState(true);
d->canvasWindow->close();
} else {
e->setAccepted(false);
}
......@@ -2490,6 +2518,10 @@ void KisMainWindow::createActions()
d->toggleDockerTitleBars->setChecked(cfg.showDockerTitleBars());
connect(d->toggleDockerTitleBars, SIGNAL(toggled(bool)), SLOT(showDockerTitleBars(bool)));
d->toggleDetachCanvas = actionManager->createAction("view_detached_canvas");
d->toggleDockerTitleBars->setChecked(false);
connect(d->toggleDetachCanvas, SIGNAL(toggled(bool)), SLOT(slotDetachCanvas(bool)));
actionCollection()->addAction("settings_dockers_menu", d->dockWidgetMenu);
actionCollection()->addAction("window", d->windowMenu);
......
......@@ -363,6 +363,8 @@ private Q_SLOTS:
*/
void slotThemeChanged();
void slotDetachCanvas(bool detached);
void undo();
void redo();
void updateWindowMenu();
......
Markdown is supported
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