1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #include "dolphindockwidget.h"
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
;
32 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
33 class DolphinDockTitleBar
: public QWidget
38 explicit DolphinDockTitleBar(QWidget
* parent
= nullptr) : QWidget(parent
) {}
39 ~DolphinDockTitleBar() override
{}
41 QSize
minimumSizeHint() const override
43 const int border
= style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin
);
44 return QSize(border
, border
);
47 QSize
sizeHint() const override
49 return minimumSizeHint();
53 DolphinDockWidget::DolphinDockWidget(const QString
& title
, QWidget
* parent
, Qt::WindowFlags flags
) :
54 QDockWidget(title
, parent
, flags
),
56 m_dockTitleBar(nullptr)
58 setFeatures(DefaultDockWidgetFeatures
);
61 DolphinDockWidget::~DolphinDockWidget()
65 void DolphinDockWidget::setLocked(bool lock
)
67 if (lock
!= m_locked
) {
71 if (!m_dockTitleBar
) {
72 m_dockTitleBar
= new DolphinDockTitleBar(this);
74 setTitleBarWidget(m_dockTitleBar
);
75 setFeatures(QDockWidget::NoDockWidgetFeatures
);
77 setTitleBarWidget(nullptr);
78 setFeatures(DefaultDockWidgetFeatures
);
83 bool DolphinDockWidget::isLocked() const
88 #include "dolphindockwidget.moc"