diff --git a/cockatrice/resources/backgrounds/home.png b/cockatrice/resources/backgrounds/home.png new file mode 100644 index 000000000..68f48e2c2 Binary files /dev/null and b/cockatrice/resources/backgrounds/home.png differ diff --git a/cockatrice/src/client/ui/widgets/general/home_styled_button.cpp b/cockatrice/src/client/ui/widgets/general/home_styled_button.cpp index 796712fb4..99f74b682 100644 --- a/cockatrice/src/client/ui/widgets/general/home_styled_button.cpp +++ b/cockatrice/src/client/ui/widgets/general/home_styled_button.cpp @@ -29,6 +29,9 @@ QString HomeStyledButton::generateButtonStylesheet(const QPair & 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; diff --git a/cockatrice/src/client/ui/widgets/general/home_widget.cpp b/cockatrice/src/client/ui/widgets/general/home_widget.cpp index 35ebdcaa8..9a522a9c0 100644 --- a/cockatrice/src/client/ui/widgets/general/home_widget.cpp +++ b/cockatrice/src/client/ui/widgets/general/home_widget.cpp @@ -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()) { button->updateStylesheet(gradientColors); button->update(); } - update(); // Triggers repaint } QGroupBox *HomeWidget::createButtons() @@ -210,6 +216,11 @@ void HomeWidget::updateConnectButton(const ClientStatus status) QPair HomeWidget::extractDominantColors(const QPixmap &pixmap) { + if (SettingsCache::instance().getThemeName() == "Default" && + SettingsCache::instance().getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) { + return QPair(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) diff --git a/cockatrice/src/client/ui/widgets/general/home_widget.h b/cockatrice/src/client/ui/widgets/general/home_widget.h index 32ba871c3..3a465bcdc 100644 --- a/cockatrice/src/client/ui/widgets/general/home_widget.h +++ b/cockatrice/src/client/ui/widgets/general/home_widget.h @@ -23,6 +23,7 @@ public slots: void paintEvent(QPaintEvent *event) override; void initializeBackgroundFromSource(); void updateBackgroundProperties(); + void updateButtonsToBackgroundColor(); QGroupBox *createButtons(); void updateConnectButton(const ClientStatus status);