2 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "dolphindockwidget.h"
14 // Disable the 'Floatable' feature, i.e., the possibility to drag the
15 // dock widget out of the main window. This works around problems like
16 // https://bugs.kde.org/show_bug.cgi?id=288629
17 // https://bugs.kde.org/show_bug.cgi?id=322299
18 const QDockWidget::DockWidgetFeatures DefaultDockWidgetFeatures
= QDockWidget::DockWidgetMovable
| QDockWidget::DockWidgetClosable
;
21 // Empty titlebar for the dock widgets when "Lock Layout" has been activated.
22 class DolphinDockTitleBar
: public QWidget
27 explicit DolphinDockTitleBar(QWidget
*parent
= nullptr)
31 ~DolphinDockTitleBar() override
35 QSize
minimumSizeHint() const override
40 QSize
sizeHint() const override
42 return minimumSizeHint();
46 DolphinDockWidget::DolphinDockWidget(const QString
&title
, QWidget
*parent
, Qt::WindowFlags flags
)
47 : QDockWidget(title
, parent
, flags
)
49 , m_dockTitleBar(nullptr)
51 setFeatures(DefaultDockWidgetFeatures
);
54 DolphinDockWidget::~DolphinDockWidget()
58 void DolphinDockWidget::setLocked(bool lock
)
60 if (lock
!= m_locked
) {
64 if (!m_dockTitleBar
) {
65 m_dockTitleBar
= new DolphinDockTitleBar(this);
67 setTitleBarWidget(m_dockTitleBar
);
68 setFeatures(QDockWidget::DockWidgetClosable
);
70 setTitleBarWidget(nullptr);
71 setFeatures(DefaultDockWidgetFeatures
);
76 bool DolphinDockWidget::isLocked() const
81 bool DolphinDockWidget::event(QEvent
*event
)
83 switch (event
->type()) {
86 if (event
->spontaneous()) {
87 // The Dolphin window has been minimized or restored. We do not want this to be interpreted like a user was toggling the visibility of this widget.
88 // We return here so no QDockWidget::visibilityChanged() signal is emitted. This does not seem to happen either way on Wayland.
93 return QDockWidget::event(event
);
97 #include "dolphindockwidget.moc"
98 #include "moc_dolphindockwidget.cpp"