[Home] Add option to disable the home tab background dim

Adds a 'Dim the home tab background' checkbox to the Home tab settings
page (Appearance). When unchecked, HomeWidget skips the translucent
black overlay it paints over the whole background. Default is on,
preserving current behavior; the home tab repaints live on change.
This commit is contained in:
Lukas Brübach 2026-09-11 21:36:03 +02:00
parent d8e488c713
commit 305df2d724
6 changed files with 48 additions and 8 deletions

View file

@ -54,6 +54,8 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
// Lambda is cleaner to read than overloading this // Lambda is cleaner to read than overloading this
connect(&SettingsCache::instance().appearance(), &AppearanceSettings::homeTabDisplayCardNameChanged, this, connect(&SettingsCache::instance().appearance(), &AppearanceSettings::homeTabDisplayCardNameChanged, this,
[this] { repaint(); }); [this] { repaint(); });
connect(&SettingsCache::instance().appearance(), &AppearanceSettings::homeTabBackgroundDimChanged, this,
[this] { repaint(); });
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this, connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this,
&HomeWidget::initializeBackgroundFromSource); &HomeWidget::initializeBackgroundFromSource);
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this, connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this,
@ -358,13 +360,15 @@ void HomeWidget::paintEvent(QPaintEvent *event)
painter.drawPixmap(topLeft, toDraw); painter.drawPixmap(topLeft, toDraw);
} }
// Draw translucent black overlay with rounded corners if (SettingsCache::instance().appearance().getHomeTabBackgroundDim()) {
QRectF overlayRect(5, 5, width() - 10, height() - 10); // Draw translucent black overlay with rounded corners
QPainterPath roundedRectPath; QRectF overlayRect(5, 5, width() - 10, height() - 10);
roundedRectPath.addRoundedRect(overlayRect, 20, 20); QPainterPath roundedRectPath;
roundedRectPath.addRoundedRect(overlayRect, 20, 20);
QColor semiTransparentBlack(0, 0, 0, static_cast<int>(255 * 0.33)); QColor semiTransparentBlack(0, 0, 0, static_cast<int>(255 * 0.33));
painter.fillPath(roundedRectPath, semiTransparentBlack); painter.fillPath(roundedRectPath, semiTransparentBlack);
}
// Card name overlay (above the attribution, bottom-right) // Card name overlay (above the attribution, bottom-right)
QString cardName; QString cardName;

View file

@ -132,6 +132,10 @@ AppearanceSettingsPage::AppearanceSettingsPage()
connect(&homeTabDisplayCardNameCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings.appearance(), connect(&homeTabDisplayCardNameCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings.appearance(),
&AppearanceSettings::setHomeTabDisplayCardName); &AppearanceSettings::setHomeTabDisplayCardName);
homeTabBackgroundDimCheckBox.setChecked(settings.appearance().getHomeTabBackgroundDim());
connect(&homeTabBackgroundDimCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings.appearance(),
&AppearanceSettings::setHomeTabBackgroundDim);
for (const auto &entry : HomeTabButtonColor::all()) { for (const auto &entry : HomeTabButtonColor::all()) {
homeTabButtonColorSourceBox.addItem(QObject::tr(entry.trKey)); homeTabButtonColorSourceBox.addItem(QObject::tr(entry.trKey));
} }
@ -148,8 +152,9 @@ AppearanceSettingsPage::AppearanceSettingsPage()
homeTabGrid->addWidget(&homeTabBackgroundShuffleFrequencyLabel, 1, 0); homeTabGrid->addWidget(&homeTabBackgroundShuffleFrequencyLabel, 1, 0);
homeTabGrid->addWidget(&homeTabBackgroundShuffleFrequencySpinBox, 1, 1); homeTabGrid->addWidget(&homeTabBackgroundShuffleFrequencySpinBox, 1, 1);
homeTabGrid->addWidget(&homeTabDisplayCardNameCheckBox, 2, 0, 1, 2); homeTabGrid->addWidget(&homeTabDisplayCardNameCheckBox, 2, 0, 1, 2);
homeTabGrid->addWidget(&homeTabButtonColorSourceLabel, 3, 0); homeTabGrid->addWidget(&homeTabBackgroundDimCheckBox, 3, 0, 1, 2);
homeTabGrid->addWidget(&homeTabButtonColorSourceBox, 3, 1); homeTabGrid->addWidget(&homeTabButtonColorSourceLabel, 4, 0);
homeTabGrid->addWidget(&homeTabButtonColorSourceBox, 4, 1);
homeTabGroupBox = new QGroupBox; homeTabGroupBox = new QGroupBox;
homeTabGroupBox->setLayout(homeTabGrid); homeTabGroupBox->setLayout(homeTabGrid);
@ -508,6 +513,9 @@ void AppearanceSettingsPage::retranslateUi()
homeTabBackgroundShuffleFrequencyLabel.setText(tr("Home tab background shuffle frequency:")); homeTabBackgroundShuffleFrequencyLabel.setText(tr("Home tab background shuffle frequency:"));
homeTabBackgroundShuffleFrequencySpinBox.setSpecialValueText(tr("Disabled")); homeTabBackgroundShuffleFrequencySpinBox.setSpecialValueText(tr("Disabled"));
homeTabDisplayCardNameCheckBox.setText(tr("Display card name of background in bottom right")); homeTabDisplayCardNameCheckBox.setText(tr("Display card name of background in bottom right"));
homeTabBackgroundDimCheckBox.setText(tr("Dim the home tab background"));
homeTabBackgroundDimCheckBox.setToolTip(
tr("Draw a translucent overlay over the home tab background so buttons and text stand out"));
homeTabButtonColorSourceLabel.setText(tr("Home tab button color:")); homeTabButtonColorSourceLabel.setText(tr("Home tab button color:"));
homeTabButtonColorSourceBox.setToolTip( homeTabButtonColorSourceBox.setToolTip(
tr("Use the theme's identity accent colors, or extract colors from the background image")); tr("Use the theme's identity accent colors, or extract colors from the background image"));

View file

@ -41,6 +41,7 @@ private:
QLabel homeTabBackgroundShuffleFrequencyLabel; QLabel homeTabBackgroundShuffleFrequencyLabel;
QSpinBox homeTabBackgroundShuffleFrequencySpinBox; QSpinBox homeTabBackgroundShuffleFrequencySpinBox;
QCheckBox homeTabDisplayCardNameCheckBox; QCheckBox homeTabDisplayCardNameCheckBox;
QCheckBox homeTabBackgroundDimCheckBox;
QLabel homeTabButtonColorSourceLabel; QLabel homeTabButtonColorSourceLabel;
QComboBox homeTabButtonColorSourceBox; QComboBox homeTabButtonColorSourceBox;

View file

@ -70,6 +70,17 @@ void AppearanceSettings::setHomeTabDisplayCardName(bool _displayCardName)
emit homeTabDisplayCardNameChanged(); emit homeTabDisplayCardNameChanged();
} }
bool AppearanceSettings::getHomeTabBackgroundDim() const
{
return getValue("homeTabBackgroundDim", QString(), QString(), true).toBool();
}
void AppearanceSettings::setHomeTabBackgroundDim(bool _dimBackground)
{
setValue(_dimBackground, "homeTabBackgroundDim");
emit homeTabBackgroundDimChanged();
}
int AppearanceSettings::getHomeTabButtonColorSourceIndex() const int AppearanceSettings::getHomeTabButtonColorSourceIndex() const
{ {
return getValue("homeTabButtonColorSource", "", "", 0).toInt(); return getValue("homeTabButtonColorSource", "", "", 0).toInt();

View file

@ -27,6 +27,8 @@ public:
void setHomeTabBackgroundShuffleFrequency(int _frequency); void setHomeTabBackgroundShuffleFrequency(int _frequency);
[[nodiscard]] bool getHomeTabDisplayCardName() const; [[nodiscard]] bool getHomeTabDisplayCardName() const;
void setHomeTabDisplayCardName(bool _displayCardName); void setHomeTabDisplayCardName(bool _displayCardName);
[[nodiscard]] bool getHomeTabBackgroundDim() const;
void setHomeTabBackgroundDim(bool _dimBackground);
[[nodiscard]] int getHomeTabButtonColorSourceIndex() const; [[nodiscard]] int getHomeTabButtonColorSourceIndex() const;
void setHomeTabButtonColorSourceIndex(int index); void setHomeTabButtonColorSourceIndex(int index);
@ -36,6 +38,7 @@ signals:
void homeTabBackgroundSourceChanged(); void homeTabBackgroundSourceChanged();
void homeTabBackgroundShuffleFrequencyChanged(); void homeTabBackgroundShuffleFrequencyChanged();
void homeTabDisplayCardNameChanged(); void homeTabDisplayCardNameChanged();
void homeTabBackgroundDimChanged();
void homeTabButtonColorChanged(); void homeTabButtonColorChanged();
public: public:

View file

@ -386,6 +386,19 @@ TEST_F(SettingsDefaultsTest, Appearance_HomeTabDisplayCardName_Default)
ASSERT_EQ(s.getHomeTabDisplayCardName(), true); ASSERT_EQ(s.getHomeTabDisplayCardName(), true);
} }
TEST_F(SettingsDefaultsTest, Appearance_HomeTabBackgroundDim_Default)
{
AppearanceSettings s(settingsPath, nullptr);
ASSERT_EQ(s.getHomeTabBackgroundDim(), true);
}
TEST_F(SettingsDefaultsTest, Appearance_HomeTabBackgroundDim_SetAndGet)
{
AppearanceSettings s(settingsPath, nullptr);
s.setHomeTabBackgroundDim(false);
ASSERT_EQ(s.getHomeTabBackgroundDim(), false);
}
// --- InterfaceSettings --- // --- InterfaceSettings ---
TEST_F(SettingsDefaultsTest, Interface_ShowStatusBar_Default) TEST_F(SettingsDefaultsTest, Interface_ShowStatusBar_Default)