Preserve size when selecting a status icon color preset

It is probably not the expected behavior that selecting a preset also
reverts the rendering resolution to the default value.
This commit is contained in:
Martchus 2024-04-26 20:26:55 +02:00
parent 5c1b94e9fc
commit f04d959ef4
2 changed files with 11 additions and 6 deletions

View File

@ -708,17 +708,17 @@ QWidget *IconsOptionPage::setupWidget()
auto *const presetsMenu = new QMenu(widget);
presetsMenu->addAction(QCoreApplication::translate("QtGui::IconsOptionPageBase", "Colorful background with gradient (default)"), widget, [this] {
m_settings = Data::StatusIconSettings();
update();
update(true);
});
presetsMenu->addAction(
QCoreApplication::translate("QtGui::IconsOptionPageBase", "Transparent background and dark foreground (for bright themes)"), widget, [this] {
m_settings = Data::StatusIconSettings(Data::StatusIconSettings::BrightTheme{});
update();
update(true);
});
presetsMenu->addAction(
QCoreApplication::translate("QtGui::IconsOptionPageBase", "Transparent background and bright foreground (for dark themes)"), widget, [this] {
m_settings = Data::StatusIconSettings(Data::StatusIconSettings::DarkTheme{});
update();
update(true);
});
// setup additional buttons
@ -763,9 +763,14 @@ bool IconsOptionPage::apply()
return true;
}
void IconsOptionPage::update()
void IconsOptionPage::update(bool preserveSize)
{
ui()->renderingSizeSlider->setValue(std::max(m_settings.renderSize.width(), m_settings.renderSize.height()));
if (preserveSize) {
const auto size = ui()->renderingSizeSlider->value();
m_settings.renderSize = QSize(size, size);
} else {
ui()->renderingSizeSlider->setValue(std::max(m_settings.renderSize.width(), m_settings.renderSize.height()));
}
ui()->thickStrokeWidthCheckBox->setChecked(m_settings.strokeWidth == StatusIconStrokeWidth::Thick);
for (auto &widgetsForColor : m_widgets) {
widgetsForColor.colorButtons[0]->setColor(widgetsForColor.setting->backgroundStart);

View File

@ -96,7 +96,7 @@ enum class Context { Combined, UI, System };
explicit IconsOptionPage(Context context = Context::Combined, QWidget *parentWidget = nullptr);
DECLARE_SETUP_WIDGETS
private:
void update();
void update(bool preserveSize = false);
Context m_context;
Data::StatusIconSettings m_settings;
struct {