@@ -101,34 +101,6 @@ struct DockAreaTitleBarPrivate
101
101
{
102
102
return CDockManager::configFlags ().testFlag (Flag);
103
103
}
104
-
105
- /* *
106
- * Helper function to set title bar button icons depending on operating
107
- * system and to avoid duplicated code. On windows the standard icons
108
- * are blurry since Qt 5.11 so we need to do some additional steps.
109
- * If the global IconPovider of the dockmanager provides a custom
110
- * Icon for the given CustomIconId, the this icon will be used.
111
- */
112
- void setTitleBarButtonIcon (tTitleBarButton* Button, QStyle::StandardPixmap StandarPixmap,
113
- ads::eIcon CustomIconId)
114
- {
115
- // First we try to use custom icons if available
116
- QIcon Icon = CDockManager::iconProvider ().customIcon (CustomIconId);
117
- if (!Icon.isNull ())
118
- {
119
- Button->setIcon (Icon);
120
- return ;
121
- }
122
-
123
- #ifdef Q_OS_LINUX
124
- Button->setIcon (_this->style ()->standardIcon (StandarPixmap));
125
- #else
126
- QPixmap normalPixmap = _this->style ()->standardPixmap (StandarPixmap, 0 , Button);
127
- Icon.addPixmap (internal::createTransparentPixmap (normalPixmap, 0.25 ), QIcon::Disabled);
128
- Icon.addPixmap (normalPixmap, QIcon::Normal);
129
- Button->setIcon (Icon);
130
- #endif
131
- }
132
104
};// struct DockAreaTitleBarPrivate
133
105
134
106
@@ -143,19 +115,19 @@ class CTitleBarButton : public tTitleBarButton
143
115
bool Visible = true ;
144
116
bool HideWhenDisabled = false ;
145
117
public:
118
+ using Super = tTitleBarButton;
146
119
CTitleBarButton (bool visible = true , QWidget* parent = nullptr )
147
- : tTitleBarButton(parent)
148
- , Visible(visible)
149
- , HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
150
- {
151
- // this->setVisible(Visible); // this causes flickering and seems not to be needed TODO: investigate further and in case it IS needed fix flickering
152
- }
120
+ : tTitleBarButton(parent),
121
+ Visible (visible),
122
+ HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
123
+ {}
153
124
154
125
126
+ /* *
127
+ * Adjust this visibility change request with our internal settings:
128
+ */
155
129
virtual void setVisible (bool visible) override
156
130
{
157
- // Adjust this visibility change request with our internal settings:
158
-
159
131
// 'visible' can stay 'true' if and only if this button is configured to generaly visible:
160
132
visible = visible && this ->Visible ;
161
133
@@ -165,10 +137,13 @@ class CTitleBarButton : public tTitleBarButton
165
137
visible = isEnabled ();
166
138
}
167
139
168
- tTitleBarButton ::setVisible (visible);
140
+ Super ::setVisible (visible);
169
141
}
170
142
171
143
protected:
144
+ /* *
145
+ * Handle EnabledChanged signal to set button invisible if the configured
146
+ */
172
147
bool event (QEvent *ev) override
173
148
{
174
149
if (QEvent::EnabledChange == ev->type () && HideWhenDisabled)
@@ -177,7 +152,7 @@ class CTitleBarButton : public tTitleBarButton
177
152
setVisible (isEnabled ());
178
153
}
179
154
180
- return tTitleBarButton ::event (ev);;
155
+ return Super ::event (ev);;
181
156
}
182
157
};
183
158
@@ -200,7 +175,7 @@ void DockAreaTitleBarPrivate::createButtons()
200
175
TabsMenuButton->setObjectName (" tabsMenuButton" );
201
176
TabsMenuButton->setAutoRaise (true );
202
177
TabsMenuButton->setPopupMode (QToolButton::InstantPopup);
203
- setTitleBarButtonIcon (TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
178
+ internal::setButtonIcon (TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
204
179
QMenu* TabsMenu = new QMenu (TabsMenuButton);
205
180
#ifndef QT_NO_TOOLTIP
206
181
TabsMenu->setToolTipsVisible (true );
@@ -219,7 +194,7 @@ void DockAreaTitleBarPrivate::createButtons()
219
194
UndockButton->setObjectName (" undockButton" );
220
195
UndockButton->setAutoRaise (true );
221
196
internal::setToolTip (UndockButton, QObject::tr (" Detach Group" ));
222
- setTitleBarButtonIcon (UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
197
+ internal::setButtonIcon (UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
223
198
UndockButton->setSizePolicy (ButtonSizePolicy);
224
199
TopLayout->addWidget (UndockButton, 0 );
225
200
_this->connect (UndockButton, SIGNAL (clicked ()), SLOT (onUndockButtonClicked ()));
@@ -228,7 +203,7 @@ void DockAreaTitleBarPrivate::createButtons()
228
203
CloseButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasCloseButton));
229
204
CloseButton->setObjectName (" closeButton" );
230
205
CloseButton->setAutoRaise (true );
231
- setTitleBarButtonIcon (CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
206
+ internal::setButtonIcon (CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
232
207
if (testConfigFlag (CDockManager::DockAreaCloseButtonClosesTab))
233
208
{
234
209
internal::setToolTip (CloseButton, QObject::tr (" Close Active Tab" ));
0 commit comments