2 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "dolphindockwidget.h"
13 // Disable the 'Floatable' feature, i.e., the possibility to drag the
14 // dock widget out of the main window. This works around problems like
15 // https://bugs.kde.org/show_bug.cgi?id=288629
16 // https://bugs.kde.org/show_bug.cgi?id=322299
17 const QDockWidget::DockWidgetFeatures DefaultDockWidgetFeatures
= QDockWidget::DockWidgetMovable
| QDockWidget::DockWidgetClosable
;
20 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
21 class DolphinDockTitleBar
: public QWidget
26 explicit DolphinDockTitleBar(QWidget
*parent
= nullptr)
30 ~DolphinDockTitleBar() override
34 QSize
minimumSizeHint() const override
36 const int border
= style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin
);
37 return QSize(border
, border
);
40 QSize
sizeHint() const override
42 return minimumSizeHint();
46 DolphinDockWidget::DolphinDockWidget(const QString
&title
, QWidget
*parent
, Qt::WindowFlags flags
)
47 : QDockWidget(title
, parent
, flags
)
49 , m_dockTitleBar(nullptr)
51 setFeatures(DefaultDockWidgetFeatures
);
54 DolphinDockWidget::~DolphinDockWidget()
58 void DolphinDockWidget::setLocked(bool lock
)
60 if (lock
!= m_locked
) {
64 if (!m_dockTitleBar
) {
65 m_dockTitleBar
= new DolphinDockTitleBar(this);
67 setTitleBarWidget(m_dockTitleBar
);
68 setFeatures(QDockWidget::NoDockWidgetFeatures
);
70 setTitleBarWidget(nullptr);
71 setFeatures(DefaultDockWidgetFeatures
);
76 bool DolphinDockWidget::isLocked() const
81 #include "dolphindockwidget.moc"
82 #include "moc_dolphindockwidget.cpp"