undocking/detaching toolviews to regular windows instead of tool windows

Kevin Funk kfunk at kde.org
Thu Oct 12 14:43:16 BST 2017


On Thursday, 12 October 2017 14:15:43 CEST René J.V. Bertin wrote:
> Hi,
> 
> Anyone else who'd like to be able to undock/detach toolview windows to
> become regular windows that remain visible when application focus changes,
> that can be covered by the mainwindow (and moved partially off screen)? The
> documentation toolview would be a prime candidate in my book.

Makes sense. Patches welcome.

Should be easy enough, you need to reparent the widget contained in the 
QDockWidget, set the Qt::Window flag and show it again. Work from there.

Something I hacked together in 5 mins (basically untested):

```
diff --git a/kdevplatform/sublime/idealdockwidget.cpp b/kdevplatform/sublime/
idealdockwidget.cpp
index d8fcac4be9..31541dd21d 100644
--- a/kdevplatform/sublime/idealdockwidget.cpp
+++ b/kdevplatform/sublime/idealdockwidget.cpp
@@ -140,6 +141,16 @@ void IdealDockWidget::contextMenuRequested(const QPoint 
&point)
     setShortcut->setToolTip(i18n("Use this shortcut to trigger visibility of 
the tool view."));
 
     menu.addSeparator();
+    QAction *separateWindow = menu.addAction(i18n("Turn into separate 
window"));
+    connect(separateWindow, &QAction::triggered, this, [this]() {
+        if (auto w = widget()) {
+            // turn into top-level window
+            w->setParent(nullptr);
+            w->setWindowFlag(Qt::Window, true);
+            w->show();
+    });
+
+    menu.addSeparator();
     QAction* remove = menu.addAction(QIcon::fromTheme(QStringLiteral("dialog-
close")), i18n("Remove Tool View"));
 
     QAction* triggered = menu.exec(senderWidget->mapToGlobal(point));
```

Seems to do the job. But please investigate some more yourself, please make 
sure that doesn't break any other integration within the Sublime architecture. 
Only then file a patch, best with some unit test.

Regards,
Kevin

> FWIW I'm making some progress but could use a hand esp. from someone
> understanding the architecture a bit better - if such a feature would be
> appreciate by others than just myself.

FWIW, René also cross-posted basically the same question to:
  http://lists.qt-project.org/pipermail/interest/2017-October/028275.html

(Just in case someone is reading only either mailing list...)

Regards,
Kevin
  
> Thanks,
> René


-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20171012/4ce560d0/attachment.sig>


More information about the KDevelop mailing list