]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindockwidget.cpp
Assure backward compatibility for the sort-role
[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 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
25 class DolphinDockTitleBar : public QWidget
26 {
27 public:
28 DolphinDockTitleBar(QWidget* parent = 0) : QWidget(parent) {}
29 virtual ~DolphinDockTitleBar() {}
30
31 virtual QSize minimumSizeHint() const
32 {
33 const int border = style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin);
34 return QSize(border, border);
35 }
36
37 virtual QSize sizeHint() const
38 {
39 return minimumSizeHint();
40 }
41 };
42
43 DolphinDockWidget::DolphinDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) :
44 QDockWidget(title, parent, flags),
45 m_locked(false),
46 m_dockTitleBar(0)
47 {
48 }
49
50 DolphinDockWidget::DolphinDockWidget(QWidget* parent, Qt::WindowFlags flags) :
51 QDockWidget(parent, flags),
52 m_locked(false),
53 m_dockTitleBar(0)
54 {
55 }
56
57 DolphinDockWidget::~DolphinDockWidget()
58 {
59 }
60
61 void DolphinDockWidget::setLocked(bool lock)
62 {
63 if (lock != m_locked) {
64 m_locked = lock;
65
66 if (lock) {
67 if (!m_dockTitleBar) {
68 m_dockTitleBar = new DolphinDockTitleBar(this);
69 }
70 setTitleBarWidget(m_dockTitleBar);
71 } else {
72 setTitleBarWidget(0);
73 }
74 }
75 }
76
77 bool DolphinDockWidget::isLocked() const
78 {
79 return m_locked;
80 }
81
82 #include "dolphindockwidget.moc"