From 2105800b94edcae55c6e226d8dc3ec6e1c204ab2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 6 May 2018 12:02:19 +0200 Subject: Tabifying dock widgets --- src/mainwindow/widgets/dockwidget.cpp | 25 +++++++++++++++++++++++++ src/mainwindow/widgets/dockwidget.h | 23 +++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/mainwindow/widgets/dockwidget.cpp create mode 100644 src/mainwindow/widgets/dockwidget.h (limited to 'src/mainwindow/widgets') diff --git a/src/mainwindow/widgets/dockwidget.cpp b/src/mainwindow/widgets/dockwidget.cpp new file mode 100644 index 0000000..f70e26f --- /dev/null +++ b/src/mainwindow/widgets/dockwidget.cpp @@ -0,0 +1,25 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include "dockwidget.h" +#include + +DockWidget::DockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) + : QDockWidget(title, parent, flags) +{ + setAttribute(Qt::WA_DeleteOnClose, true); +} + +DockWidget::~DockWidget() +{ + // dock widget takes ownership of its widget, so closing the dock widget + // causes it to delete the widget as well + // clear the widget's parent to prevent this + if(widget()) + widget()->setParent(nullptr); +} diff --git a/src/mainwindow/widgets/dockwidget.h b/src/mainwindow/widgets/dockwidget.h new file mode 100644 index 0000000..35a4cc7 --- /dev/null +++ b/src/mainwindow/widgets/dockwidget.h @@ -0,0 +1,23 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#ifndef SMOLBOTE_DOCKWIDGET_H +#define SMOLBOTE_DOCKWIDGET_H + +#include + + +class DockWidget : public QDockWidget +{ +public: + DockWidget(const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + ~DockWidget(); + +}; + +#endif // SMOLBOTE_DOCKWIDGET_H -- cgit v1.2.1