forked from qt-creator/qt-creator
Examples: Use theme colors for section separator + link
Change-Id: Ia5706dd81c0494f0a7c1a1df346918462b52ba53 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -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("<a href=\"link\" style=\"color: " + linkColor + ";\">"
|
||||
+ text + "</a>", parent);
|
||||
return link;
|
||||
}
|
||||
|
||||
ListModel *SectionedGridView::addSection(const Section §ion, const QList<ListItem *> &items)
|
||||
{
|
||||
auto model = new ListModel(this);
|
||||
@@ -772,8 +784,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList<Lis
|
||||
m_sectionModels.insert(section, model);
|
||||
const auto it = m_gridViews.insert(section, gridView);
|
||||
|
||||
using namespace Layouting;
|
||||
auto seeAllLink = new QLabel("<a href=\"link\">" + Tr::tr("Show All") + " ></a>", 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 QList<Lis
|
||||
seeAllLink->setVisible(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("<a href=\"link\">< " + Tr::tr("Back") + "</a>", 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);
|
||||
|
||||
Reference in New Issue
Block a user