|
55 | 55 |
|
56 | 56 | namespace ads |
57 | 57 | { |
58 | | -using tTitleBarButton = QToolButton; |
59 | | - |
60 | 58 |
|
61 | 59 | /** |
62 | 60 | * Private data class of CDockAreaTitleBar class (pimpl) |
@@ -130,86 +128,6 @@ struct DockAreaTitleBarPrivate |
130 | 128 | IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState); |
131 | 129 | };// struct DockAreaTitleBarPrivate |
132 | 130 |
|
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 | 131 | //============================================================================ |
214 | 132 | DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) : |
215 | 133 | _this(_public) |
@@ -674,10 +592,50 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const |
674 | 592 | return d->Layout->indexOf(widget); |
675 | 593 | } |
676 | 594 |
|
| 595 | +//============================================================================ |
| 596 | +CTitleBarButton::CTitleBarButton(bool visible /*= true*/, QWidget* parent /*= nullptr*/) : tTitleBarButton(parent), |
| 597 | +Visible(visible), |
| 598 | +HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons)) |
| 599 | +{ |
677 | 600 |
|
678 | | -} // namespace ads |
| 601 | +} |
679 | 602 |
|
680 | | -#include "DockAreaTitleBar.moc" |
| 603 | +//============================================================================ |
| 604 | +void CTitleBarButton::setVisible(bool visible) |
| 605 | +{ |
| 606 | + // 'visible' can stay 'true' if and only if this button is configured to generaly visible: |
| 607 | + visible = visible && this->Visible; |
| 608 | + |
| 609 | + // 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled: |
| 610 | + if (visible && HideWhenDisabled) |
| 611 | + { |
| 612 | + visible = isEnabled(); |
| 613 | + } |
| 614 | + |
| 615 | + Super::setVisible(visible); |
| 616 | +} |
| 617 | + |
| 618 | +//============================================================================ |
| 619 | +bool CTitleBarButton::event(QEvent *ev) |
| 620 | +{ |
| 621 | + if (QEvent::EnabledChange == ev->type() && HideWhenDisabled) |
| 622 | + { |
| 623 | + // force setVisible() call |
| 624 | + // Calling setVisible() directly here doesn't work well when button is expected to be shown first time |
| 625 | + QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled())); |
| 626 | + } |
| 627 | + |
| 628 | + return Super::event(ev); |
| 629 | +} |
| 630 | + |
| 631 | +//============================================================================ |
| 632 | +CSpacerWidget::CSpacerWidget(QWidget* Parent /*= 0*/) : Super(Parent) |
| 633 | +{ |
| 634 | + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 635 | + setStyleSheet("border: none; background: none;"); |
| 636 | +} |
| 637 | + |
| 638 | +} // namespace ads |
681 | 639 |
|
682 | 640 | //--------------------------------------------------------------------------- |
683 | 641 | // EOF DockAreaTitleBar.cpp |
0 commit comments