Include default background theme.

Took 49 minutes
This commit is contained in:
Lukas Brübach 2025-09-11 13:37:55 +02:00
parent 3d1e525bdd
commit 2dedb0e808
4 changed files with 16 additions and 1 deletions

View file

@ -29,6 +29,9 @@ QString HomeStyledButton::generateButtonStylesheet(const QPair<QColor, QColor> &
QColor pressed1 = base1.darker(130); // 30% darker
QColor pressed2 = base2.darker(130);
qInfo() << base1.name();
qInfo() << base2.toRgb();
return QString(R"(
QPushButton {
font-size: 34px;

View file

@ -62,6 +62,7 @@ void HomeWidget::initializeBackgroundFromSource()
switch (backgroundSourceType) {
case BackgroundSources::Theme:
background = QPixmap("theme:backgrounds/home");
updateButtonsToBackgroundColor();
update();
break;
case BackgroundSources::RandomCardArt:
@ -122,12 +123,17 @@ void HomeWidget::updateRandomCard()
void HomeWidget::updateBackgroundProperties()
{
background = backgroundSourceCard->getProcessedBackground(size());
updateButtonsToBackgroundColor();
update(); // Triggers repaint
}
void HomeWidget::updateButtonsToBackgroundColor()
{
gradientColors = extractDominantColors(background);
for (HomeStyledButton *button : findChildren<HomeStyledButton *>()) {
button->updateStylesheet(gradientColors);
button->update();
}
update(); // Triggers repaint
}
QGroupBox *HomeWidget::createButtons()
@ -210,6 +216,11 @@ void HomeWidget::updateConnectButton(const ClientStatus status)
QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap)
{
if (SettingsCache::instance().getThemeName() == "Default" &&
SettingsCache::instance().getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) {
return QPair<QColor, QColor>(QColor::fromRgb(20, 140, 60), QColor::fromRgb(120, 200, 80));
}
// Step 1: Downscale image for performance
QImage image = pixmap.toImage()
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)

View file

@ -23,6 +23,7 @@ public slots:
void paintEvent(QPaintEvent *event) override;
void initializeBackgroundFromSource();
void updateBackgroundProperties();
void updateButtonsToBackgroundColor();
QGroupBox *createButtons();
void updateConnectButton(const ClientStatus status);