]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindockwidget.cpp
selection: fix rubberband vertices
[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 const int border = style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin);
37 return QSize(border, border);
38 }
39
40 QSize sizeHint() const override
41 {
42 return minimumSizeHint();
43 }
44 };
45
46 DolphinDockWidget::DolphinDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
47 : QDockWidget(title, parent, flags)
48 , m_locked(false)
49 , m_dockTitleBar(nullptr)
50 {
51 setFeatures(DefaultDockWidgetFeatures);
52 }
53
54 DolphinDockWidget::~DolphinDockWidget()
55 {
56 }
57
58 void DolphinDockWidget::setLocked(bool lock)
59 {
60 if (lock != m_locked) {
61 m_locked = lock;
62
63 if (lock) {
64 if (!m_dockTitleBar) {
65 m_dockTitleBar = new DolphinDockTitleBar(this);
66 }
67 setTitleBarWidget(m_dockTitleBar);
68 setFeatures(QDockWidget::NoDockWidgetFeatures);
69 } else {
70 setTitleBarWidget(nullptr);
71 setFeatures(DefaultDockWidgetFeatures);
72 }
73 }
74 }
75
76 bool DolphinDockWidget::isLocked() const
77 {
78 return m_locked;
79 }
80
81 #include "dolphindockwidget.moc"
82 #include "moc_dolphindockwidget.cpp"