|
39 | 39 | #include <QDebug>
|
40 | 40 | #include <QPointer>
|
41 | 41 |
|
| 42 | +#include "DockAreaTitleBar_p.h" |
42 | 43 | #include "ads_globals.h"
|
43 | 44 | #include "FloatingDockContainer.h"
|
44 | 45 | #include "FloatingDragPreview.h"
|
|
55 | 56 |
|
56 | 57 | namespace ads
|
57 | 58 | {
|
58 |
| -using tTitleBarButton = QToolButton; |
59 |
| - |
60 | 59 |
|
61 | 60 | /**
|
62 | 61 | * Private data class of CDockAreaTitleBar class (pimpl)
|
@@ -130,86 +129,6 @@ struct DockAreaTitleBarPrivate
|
130 | 129 | IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState);
|
131 | 130 | };// struct DockAreaTitleBarPrivate
|
132 | 131 |
|
133 |
| - |
134 |
| -/** |
135 |
| - * Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour |
136 |
| - * according to various config flags such as: |
137 |
| - * CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible |
138 |
| - * CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled |
139 |
| - */ |
140 |
| -class CTitleBarButton : public tTitleBarButton |
141 |
| -{ |
142 |
| - Q_OBJECT |
143 |
| - bool Visible = true; |
144 |
| - bool HideWhenDisabled = false; |
145 |
| -public: |
146 |
| - using Super = tTitleBarButton; |
147 |
| - CTitleBarButton(bool visible = true, QWidget* parent = nullptr) |
148 |
| - : tTitleBarButton(parent), |
149 |
| - Visible(visible), |
150 |
| - HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons)) |
151 |
| - {} |
152 |
| - |
153 |
| - |
154 |
| - /** |
155 |
| - * Adjust this visibility change request with our internal settings: |
156 |
| - */ |
157 |
| - virtual void setVisible(bool visible) override |
158 |
| - { |
159 |
| - // 'visible' can stay 'true' if and only if this button is configured to generaly visible: |
160 |
| - visible = visible && this->Visible; |
161 |
| - |
162 |
| - // 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled: |
163 |
| - if(visible && HideWhenDisabled) |
164 |
| - { |
165 |
| - visible = isEnabled(); |
166 |
| - } |
167 |
| - |
168 |
| - Super::setVisible(visible); |
169 |
| - } |
170 |
| - |
171 |
| -protected: |
172 |
| - /** |
173 |
| - * Handle EnabledChanged signal to set button invisible if the configured |
174 |
| - */ |
175 |
| - bool event(QEvent *ev) override |
176 |
| - { |
177 |
| - if(QEvent::EnabledChange == ev->type() && HideWhenDisabled) |
178 |
| - { |
179 |
| - // force setVisible() call |
180 |
| - // Calling setVisible() directly here doesn't work well when button is expected to be shown first time |
181 |
| - QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled())); |
182 |
| - } |
183 |
| - |
184 |
| - return Super::event(ev); |
185 |
| - } |
186 |
| -}; |
187 |
| - |
188 |
| - |
189 |
| -/** |
190 |
| - * This spacer widget is here because of the following problem. |
191 |
| - * The dock area title bar handles mouse dragging and moving the floating widget. |
192 |
| - * The problem is, that if the title bar becomes invisible, i.e. if the dock |
193 |
| - * area contains only one single dock widget and the dock area is moved |
194 |
| - * into a floating widget, then mouse events are not handled anymore and dragging |
195 |
| - * of the floating widget stops. |
196 |
| - */ |
197 |
| -class CSpacerWidget : public QWidget |
198 |
| -{ |
199 |
| - Q_OBJECT |
200 |
| -public: |
201 |
| - using Super = QWidget; |
202 |
| - CSpacerWidget(QWidget* Parent = 0) |
203 |
| - : Super(Parent) |
204 |
| - { |
205 |
| - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
206 |
| - setStyleSheet("border: none; background: none;"); |
207 |
| - } |
208 |
| - virtual QSize sizeHint() const override {return QSize(0, 0);} |
209 |
| - virtual QSize minimumSizeHint() const override {return QSize(0, 0);} |
210 |
| -}; |
211 |
| - |
212 |
| - |
213 | 132 | //============================================================================
|
214 | 133 | DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
215 | 134 | _this(_public)
|
@@ -674,10 +593,50 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const
|
674 | 593 | return d->Layout->indexOf(widget);
|
675 | 594 | }
|
676 | 595 |
|
| 596 | +//============================================================================ |
| 597 | +CTitleBarButton::CTitleBarButton(bool visible /*= true*/, QWidget* parent /*= nullptr*/) : tTitleBarButton(parent), |
| 598 | +Visible(visible), |
| 599 | +HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons)) |
| 600 | +{ |
677 | 601 |
|
678 |
| -} // namespace ads |
| 602 | +} |
679 | 603 |
|
680 |
| -#include "DockAreaTitleBar.moc" |
| 604 | +//============================================================================ |
| 605 | +void CTitleBarButton::setVisible(bool visible) |
| 606 | +{ |
| 607 | + // 'visible' can stay 'true' if and only if this button is configured to generaly visible: |
| 608 | + visible = visible && this->Visible; |
| 609 | + |
| 610 | + // 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled: |
| 611 | + if (visible && HideWhenDisabled) |
| 612 | + { |
| 613 | + visible = isEnabled(); |
| 614 | + } |
| 615 | + |
| 616 | + Super::setVisible(visible); |
| 617 | +} |
| 618 | + |
| 619 | +//============================================================================ |
| 620 | +bool CTitleBarButton::event(QEvent *ev) |
| 621 | +{ |
| 622 | + if (QEvent::EnabledChange == ev->type() && HideWhenDisabled) |
| 623 | + { |
| 624 | + // force setVisible() call |
| 625 | + // Calling setVisible() directly here doesn't work well when button is expected to be shown first time |
| 626 | + QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled())); |
| 627 | + } |
| 628 | + |
| 629 | + return Super::event(ev); |
| 630 | +} |
| 631 | + |
| 632 | +//============================================================================ |
| 633 | +CSpacerWidget::CSpacerWidget(QWidget* Parent /*= 0*/) : Super(Parent) |
| 634 | +{ |
| 635 | + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 636 | + setStyleSheet("border: none; background: none;"); |
| 637 | +} |
| 638 | + |
| 639 | +} // namespace ads |
681 | 640 |
|
682 | 641 | //---------------------------------------------------------------------------
|
683 | 642 | // EOF DockAreaTitleBar.cpp
|
0 commit comments