]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindockwidget.cpp
CI: Disable Craft Windows
[dolphin.git] / src / dolphindockwidget.cpp
1 /*
2 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "dolphindockwidget.h"
8
9 #include <QStyle>
10
11 namespace
12 {
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;
18 }
19
20 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
21 class DolphinDockTitleBar : public QWidget
22 {
23 Q_OBJECT
24
25 public:
26 explicit DolphinDockTitleBar(QWidget *parent = nullptr)
27 : QWidget(parent)
28 {
29 }
30 ~DolphinDockTitleBar() override
31 {
32 }
33
34 QSize minimumSizeHint() const override
35 {
36 return QSize(0, 0);
37 }
38
39 QSize sizeHint() const override
40 {
41 return minimumSizeHint();
42 }
43 };
44
45 DolphinDockWidget::DolphinDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
46 : QDockWidget(title, parent, flags)
47 , m_locked(false)
48 , m_dockTitleBar(nullptr)
49 {
50 setFeatures(DefaultDockWidgetFeatures);
51 }
52
53 DolphinDockWidget::~DolphinDockWidget()
54 {
55 }
56
57 void DolphinDockWidget::setLocked(bool lock)
58 {
59 if (lock != m_locked) {
60 m_locked = lock;
61
62 if (lock) {
63 if (!m_dockTitleBar) {
64 m_dockTitleBar = new DolphinDockTitleBar(this);
65 }
66 setTitleBarWidget(m_dockTitleBar);
67 setFeatures(QDockWidget::DockWidgetClosable);
68 } else {
69 setTitleBarWidget(nullptr);
70 setFeatures(DefaultDockWidgetFeatures);
71 }
72 }
73 }
74
75 bool DolphinDockWidget::isLocked() const
76 {
77 return m_locked;
78 }
79
80 #include "dolphindockwidget.moc"
81 #include "moc_dolphindockwidget.cpp"