mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 00:12:15 -07:00
Include default background theme.
Took 49 minutes
This commit is contained in:
parent
3d1e525bdd
commit
2dedb0e808
4 changed files with 16 additions and 1 deletions
BIN
cockatrice/resources/backgrounds/home.png
Normal file
BIN
cockatrice/resources/backgrounds/home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 MiB |
|
|
@ -29,6 +29,9 @@ QString HomeStyledButton::generateButtonStylesheet(const QPair<QColor, QColor> &
|
||||||
QColor pressed1 = base1.darker(130); // 30% darker
|
QColor pressed1 = base1.darker(130); // 30% darker
|
||||||
QColor pressed2 = base2.darker(130);
|
QColor pressed2 = base2.darker(130);
|
||||||
|
|
||||||
|
qInfo() << base1.name();
|
||||||
|
qInfo() << base2.toRgb();
|
||||||
|
|
||||||
return QString(R"(
|
return QString(R"(
|
||||||
QPushButton {
|
QPushButton {
|
||||||
font-size: 34px;
|
font-size: 34px;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ void HomeWidget::initializeBackgroundFromSource()
|
||||||
switch (backgroundSourceType) {
|
switch (backgroundSourceType) {
|
||||||
case BackgroundSources::Theme:
|
case BackgroundSources::Theme:
|
||||||
background = QPixmap("theme:backgrounds/home");
|
background = QPixmap("theme:backgrounds/home");
|
||||||
|
updateButtonsToBackgroundColor();
|
||||||
update();
|
update();
|
||||||
break;
|
break;
|
||||||
case BackgroundSources::RandomCardArt:
|
case BackgroundSources::RandomCardArt:
|
||||||
|
|
@ -122,12 +123,17 @@ void HomeWidget::updateRandomCard()
|
||||||
void HomeWidget::updateBackgroundProperties()
|
void HomeWidget::updateBackgroundProperties()
|
||||||
{
|
{
|
||||||
background = backgroundSourceCard->getProcessedBackground(size());
|
background = backgroundSourceCard->getProcessedBackground(size());
|
||||||
|
updateButtonsToBackgroundColor();
|
||||||
|
update(); // Triggers repaint
|
||||||
|
}
|
||||||
|
|
||||||
|
void HomeWidget::updateButtonsToBackgroundColor()
|
||||||
|
{
|
||||||
gradientColors = extractDominantColors(background);
|
gradientColors = extractDominantColors(background);
|
||||||
for (HomeStyledButton *button : findChildren<HomeStyledButton *>()) {
|
for (HomeStyledButton *button : findChildren<HomeStyledButton *>()) {
|
||||||
button->updateStylesheet(gradientColors);
|
button->updateStylesheet(gradientColors);
|
||||||
button->update();
|
button->update();
|
||||||
}
|
}
|
||||||
update(); // Triggers repaint
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QGroupBox *HomeWidget::createButtons()
|
QGroupBox *HomeWidget::createButtons()
|
||||||
|
|
@ -210,6 +216,11 @@ void HomeWidget::updateConnectButton(const ClientStatus status)
|
||||||
|
|
||||||
QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap)
|
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
|
// Step 1: Downscale image for performance
|
||||||
QImage image = pixmap.toImage()
|
QImage image = pixmap.toImage()
|
||||||
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public slots:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void initializeBackgroundFromSource();
|
void initializeBackgroundFromSource();
|
||||||
void updateBackgroundProperties();
|
void updateBackgroundProperties();
|
||||||
|
void updateButtonsToBackgroundColor();
|
||||||
QGroupBox *createButtons();
|
QGroupBox *createButtons();
|
||||||
void updateConnectButton(const ClientStatus status);
|
void updateConnectButton(const ClientStatus status);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue