|
| 1 | +#ifndef DockAreaTitleBarPH |
| 2 | +#define DockAreaTitleBarPH |
| 3 | +/******************************************************************************* |
| 4 | +** Qt Advanced Docking System |
| 5 | +** Copyright (C) 2017 Uwe Kindler |
| 6 | +** |
| 7 | +** This library is free software; you can redistribute it and/or |
| 8 | +** modify it under the terms of the GNU Lesser General Public |
| 9 | +** License as published by the Free Software Foundation; either |
| 10 | +** version 2.1 of the License, or (at your option) any later version. |
| 11 | +** |
| 12 | +** This library is distributed in the hope that it will be useful, |
| 13 | +** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +** Lesser General Public License for more details. |
| 16 | +** |
| 17 | +** You should have received a copy of the GNU Lesser General Public |
| 18 | +** License along with this library; If not, see <http://www.gnu.org/licenses/>. |
| 19 | +******************************************************************************/ |
| 20 | + |
| 21 | + |
| 22 | +//============================================================================ |
| 23 | +/// \file DockAreaTitleBar_p.h |
| 24 | +/// \author Uwe Kindler |
| 25 | +/// \date 12.10.2018 |
| 26 | +/// \brief Declaration of classes CTitleBarButton and CSpacerWidget |
| 27 | +//============================================================================ |
| 28 | + |
| 29 | + |
| 30 | +//============================================================================ |
| 31 | +// INCLUDES |
| 32 | +//============================================================================ |
| 33 | +#include <QFrame> |
| 34 | +#include <QToolButton> |
| 35 | + |
| 36 | +#include "ads_globals.h" |
| 37 | + |
| 38 | +namespace ads |
| 39 | +{ |
| 40 | +using tTitleBarButton = QToolButton; |
| 41 | + |
| 42 | + /** |
| 43 | + * Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour |
| 44 | + * according to various config flags such as: |
| 45 | + * CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible |
| 46 | + * CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled |
| 47 | + */ |
| 48 | +class CTitleBarButton : public tTitleBarButton |
| 49 | +{ |
| 50 | + Q_OBJECT |
| 51 | + |
| 52 | + bool Visible = true; |
| 53 | + bool HideWhenDisabled = false; |
| 54 | + |
| 55 | +public: |
| 56 | + using Super = tTitleBarButton; |
| 57 | + CTitleBarButton(bool visible = true, QWidget* parent = nullptr); |
| 58 | + |
| 59 | + /** |
| 60 | + * Adjust this visibility change request with our internal settings: |
| 61 | + */ |
| 62 | + virtual void setVisible(bool visible) override; |
| 63 | + |
| 64 | +protected: |
| 65 | + /** |
| 66 | + * Handle EnabledChanged signal to set button invisible if the configured |
| 67 | + */ |
| 68 | + bool event(QEvent *ev) override; |
| 69 | +}; |
| 70 | + |
| 71 | + |
| 72 | +/** |
| 73 | +* This spacer widget is here because of the following problem. |
| 74 | +* The dock area title bar handles mouse dragging and moving the floating widget. |
| 75 | +* The problem is, that if the title bar becomes invisible, i.e. if the dock |
| 76 | +* area contains only one single dock widget and the dock area is moved |
| 77 | +* into a floating widget, then mouse events are not handled anymore and dragging |
| 78 | +* of the floating widget stops. |
| 79 | +*/ |
| 80 | +class CSpacerWidget : public QWidget |
| 81 | +{ |
| 82 | + Q_OBJECT |
| 83 | +public: |
| 84 | + using Super = QWidget; |
| 85 | + CSpacerWidget(QWidget* Parent = 0); |
| 86 | + virtual QSize sizeHint() const override {return QSize(0, 0);} |
| 87 | + virtual QSize minimumSizeHint() const override {return QSize(0, 0);} |
| 88 | +}; |
| 89 | + |
| 90 | +} |
| 91 | + // namespace ads |
| 92 | +//----------------------------------------------------------------------------- |
| 93 | +#endif // DockAreaTitleBarPH |
0 commit comments