From c192536b64df8fd3455e6f602be7fe858a5f3bb6 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 26 Apr 2023 09:35:52 +0200 Subject: [PATCH] Examples: Use theme colors for section separator + link Change-Id: Ia5706dd81c0494f0a7c1a1df346918462b52ba53 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/welcomepagehelper.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/welcomepagehelper.cpp b/src/plugins/coreplugin/welcomepagehelper.cpp index 1d13b1a8c6b..efcf74070ae 100644 --- a/src/plugins/coreplugin/welcomepagehelper.cpp +++ b/src/plugins/coreplugin/welcomepagehelper.cpp @@ -749,9 +749,21 @@ static QWidget *createSeparator(QWidget *parent) QSizePolicy linePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); linePolicy.setHorizontalStretch(2); line->setSizePolicy(linePolicy); + QPalette pal = line->palette(); + pal.setColor(QPalette::Dark, Qt::transparent); + pal.setColor(QPalette::Light, themeColor(Theme::Welcome_ForegroundSecondaryColor)); + line->setPalette(pal); return line; } +static QLabel *createLinkLabel(const QString &text, QWidget *parent) +{ + const QString linkColor = themeColor(Theme::Welcome_LinkColor).name(); + auto link = new QLabel("" + + text + "", parent); + return link; +} + ListModel *SectionedGridView::addSection(const Section §ion, const QList &items) { auto model = new ListModel(this); @@ -772,8 +784,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList" + Tr::tr("Show All") + " >", this); + QLabel *seeAllLink = createLinkLabel(Tr::tr("Show All") + " >", this); if (gridView->maxRows().has_value()) { seeAllLink->setVisible(true); connect(gridView, &SectionGridView::itemsFitChanged, seeAllLink, [seeAllLink](bool fits) { @@ -783,6 +794,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QListsetVisible(false); } connect(seeAllLink, &QLabel::linkActivated, this, [this, section] { zoomInSection(section); }); + using namespace Layouting; QWidget *sectionLabel = Row{section.name, createSeparator(this), seeAllLink, Space(HSpacing)} .emerge(Layouting::WithoutMargins); m_sectionLabels.append(sectionLabel); @@ -829,13 +841,13 @@ void SectionedGridView::zoomInSection(const Section §ion) layout->setContentsMargins(0, 0, 0, 0); zoomedInWidget->setLayout(layout); - using namespace Layouting; - auto backLink = new QLabel("< " + Tr::tr("Back") + "", zoomedInWidget); + QLabel *backLink = createLinkLabel("< " + Tr::tr("Back"), this); connect(backLink, &QLabel::linkActivated, this, [this, zoomedInWidget] { removeWidget(zoomedInWidget); delete zoomedInWidget; setCurrentIndex(0); }); + using namespace Layouting; QWidget *sectionLabel = Row{section.name, createSeparator(this), backLink, Space(HSpacing)} .emerge(Layouting::WithoutMargins); sectionLabel->setContentsMargins(0, ItemGap, 0, 0);