Skip to content

Commit 0227bd1

Browse files
Added icon for proper styling of focused close icon
1 parent 227037e commit 0227bd1

File tree

9 files changed

+375
-308
lines changed

9 files changed

+375
-308
lines changed

demo/MainWindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
576576

577577
//CDockManager::setConfigFlag(CDockManager::AlwaysShowTabs, true);
578578
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
579+
CDockManager::setConfigFlag(CDockManager::AllTabsHaveCloseButton, true);
579580

580581
// Now create the dock manager and its content
581582
d->DockManager = new CDockManager(this);

src/DockWidgetTab.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,7 @@ void CDockWidgetTab::setElideMode(Qt::TextElideMode mode)
666666
//============================================================================
667667
void CDockWidgetTab::updateStyle()
668668
{
669-
this->style()->unpolish(this);
670-
this->style()->polish(this);
671-
d->TitleLabel->style()->unpolish(d->TitleLabel);
672-
d->TitleLabel->style()->polish(d->TitleLabel);
669+
internal::repolishStyle(this, internal::RepolishDirectChildren);
673670
}
674671

675672

src/ads.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<file>images/close-button.svg</file>
55
<file>images/close-button-disabled.svg</file>
66
<file>stylesheets/default_linux.css</file>
7-
<file>images/close-button2.svg</file>
7+
<file>images/close-button-focused.svg</file>
88
</qresource>
99
</RCC>

src/ads_globals.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,27 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap
121121

122122

123123
//============================================================================
124-
void repolishStyle(QWidget* w)
124+
void repolishStyle(QWidget* w, eRepolishChildOptions Options)
125125
{
126126
if (!w)
127127
{
128128
return;
129129
}
130130
w->style()->unpolish(w);
131131
w->style()->polish(w);
132+
133+
if (RepolishIgnoreChildren == Options)
134+
{
135+
return;
136+
}
137+
138+
QList<QWidget*> Children = w->findChildren<QWidget*>(QString(),
139+
(RepolishDirectChildren == Options) ? Qt::FindDirectChildrenOnly: Qt::FindChildrenRecursively);
140+
for (auto Widget : Children)
141+
{
142+
Widget->style()->unpolish(Widget);
143+
Widget->style()->polish(Widget);
144+
}
132145
}
133146

134147
} // namespace internal

src/ads_globals.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,18 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap
245245
ads::eIcon CustomIconId);
246246

247247

248+
enum eRepolishChildOptions
249+
{
250+
RepolishIgnoreChildren,
251+
RepolishDirectChildren,
252+
RepolishChildrenRecursively
253+
};
254+
248255
/**
249256
* Calls unpolish() / polish for the style of the given widget to update
250257
* stylesheet if a property changes
251258
*/
252-
void repolishStyle(QWidget* w);
259+
void repolishStyle(QWidget* w, eRepolishChildOptions Options = RepolishIgnoreChildren);
253260

254261

255262
} // namespace internal

src/images/close-button-disabled.svg

Lines changed: 129 additions & 112 deletions
Loading

0 commit comments

Comments
 (0)