]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindockwidget.cpp
Add missing Q_DECL_OVERRIDE
[dolphin.git] / src / dolphindockwidget.cpp
1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "dolphindockwidget.h"
21
22 #include <QStyle>
23
24 namespace {
25 // Disable the 'Floatable' feature, i.e., the possibility to drag the
26 // dock widget out of the main window. This works around problems like
27 // https://bugs.kde.org/show_bug.cgi?id=288629
28 // https://bugs.kde.org/show_bug.cgi?id=322299
29 const QDockWidget::DockWidgetFeatures DefaultDockWidgetFeatures = QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable;
30 }
31
32 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
33 class DolphinDockTitleBar : public QWidget
34 {
35 Q_OBJECT
36
37 public:
38 DolphinDockTitleBar(QWidget* parent = 0) : QWidget(parent) {}
39 virtual ~DolphinDockTitleBar() {}
40
41 QSize minimumSizeHint() const Q_DECL_OVERRIDE
42 {
43 const int border = style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin);
44 return QSize(border, border);
45 }
46
47 QSize sizeHint() const Q_DECL_OVERRIDE
48 {
49 return minimumSizeHint();
50 }
51 };
52
53 DolphinDockWidget::DolphinDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) :
54 QDockWidget(title, parent, flags),
55 m_locked(false),
56 m_dockTitleBar(0)
57 {
58 setFeatures(DefaultDockWidgetFeatures);
59 }
60
61 DolphinDockWidget::DolphinDockWidget(QWidget* parent, Qt::WindowFlags flags) :
62 QDockWidget(parent, flags),
63 m_locked(false),
64 m_dockTitleBar(0)
65 {
66 setFeatures(DefaultDockWidgetFeatures);
67 }
68
69 DolphinDockWidget::~DolphinDockWidget()
70 {
71 }
72
73 void DolphinDockWidget::setLocked(bool lock)
74 {
75 if (lock != m_locked) {
76 m_locked = lock;
77
78 if (lock) {
79 if (!m_dockTitleBar) {
80 m_dockTitleBar = new DolphinDockTitleBar(this);
81 }
82 setTitleBarWidget(m_dockTitleBar);
83 setFeatures(QDockWidget::NoDockWidgetFeatures);
84 } else {
85 setTitleBarWidget(0);
86 setFeatures(DefaultDockWidgetFeatures);
87 }
88 }
89 }
90
91 bool DolphinDockWidget::isLocked() const
92 {
93 return m_locked;
94 }
95
96 #include "dolphindockwidget.moc"