@@ -101,34 +101,6 @@ struct DockAreaTitleBarPrivate
101101 {
102102 return CDockManager::configFlags ().testFlag (Flag);
103103 }
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- }
132104};// struct DockAreaTitleBarPrivate
133105
134106
@@ -143,19 +115,19 @@ class CTitleBarButton : public tTitleBarButton
143115 bool Visible = true ;
144116 bool HideWhenDisabled = false ;
145117public:
118+ using Super = tTitleBarButton;
146119 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+ {}
153124
154125
126+ /* *
127+ * Adjust this visibility change request with our internal settings:
128+ */
155129 virtual void setVisible (bool visible) override
156130 {
157- // Adjust this visibility change request with our internal settings:
158-
159131 // 'visible' can stay 'true' if and only if this button is configured to generaly visible:
160132 visible = visible && this ->Visible ;
161133
@@ -165,10 +137,13 @@ class CTitleBarButton : public tTitleBarButton
165137 visible = isEnabled ();
166138 }
167139
168- tTitleBarButton ::setVisible (visible);
140+ Super ::setVisible (visible);
169141 }
170142
171143protected:
144+ /* *
145+ * Handle EnabledChanged signal to set button invisible if the configured
146+ */
172147 bool event (QEvent *ev) override
173148 {
174149 if (QEvent::EnabledChange == ev->type () && HideWhenDisabled)
@@ -177,7 +152,7 @@ class CTitleBarButton : public tTitleBarButton
177152 setVisible (isEnabled ());
178153 }
179154
180- return tTitleBarButton ::event (ev);;
155+ return Super ::event (ev);;
181156 }
182157};
183158
@@ -200,7 +175,7 @@ void DockAreaTitleBarPrivate::createButtons()
200175 TabsMenuButton->setObjectName (" tabsMenuButton" );
201176 TabsMenuButton->setAutoRaise (true );
202177 TabsMenuButton->setPopupMode (QToolButton::InstantPopup);
203- setTitleBarButtonIcon (TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
178+ internal::setButtonIcon (TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
204179 QMenu* TabsMenu = new QMenu (TabsMenuButton);
205180#ifndef QT_NO_TOOLTIP
206181 TabsMenu->setToolTipsVisible (true );
@@ -219,7 +194,7 @@ void DockAreaTitleBarPrivate::createButtons()
219194 UndockButton->setObjectName (" undockButton" );
220195 UndockButton->setAutoRaise (true );
221196 internal::setToolTip (UndockButton, QObject::tr (" Detach Group" ));
222- setTitleBarButtonIcon (UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
197+ internal::setButtonIcon (UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
223198 UndockButton->setSizePolicy (ButtonSizePolicy);
224199 TopLayout->addWidget (UndockButton, 0 );
225200 _this->connect (UndockButton, SIGNAL (clicked ()), SLOT (onUndockButtonClicked ()));
@@ -228,7 +203,7 @@ void DockAreaTitleBarPrivate::createButtons()
228203 CloseButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasCloseButton));
229204 CloseButton->setObjectName (" closeButton" );
230205 CloseButton->setAutoRaise (true );
231- setTitleBarButtonIcon (CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
206+ internal::setButtonIcon (CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
232207 if (testConfigFlag (CDockManager::DockAreaCloseButtonClosesTab))
233208 {
234209 internal::setToolTip (CloseButton, QObject::tr (" Close Active Tab" ));
0 commit comments