From 6e825ef6a69c5aadffc2bccc91c7db464ecbf006 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Wed, 13 May 2026 22:18:46 +0200 Subject: [PATCH 1/3] Persist QColorDialog custom color selections in ModOrganizer.ini --- src/modlistviewactions.cpp | 4 ++++ src/settings.cpp | 19 ++++++++++++++++++- src/settings.h | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 1f043ae74..6afd929bd 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -1216,6 +1216,10 @@ void ModListViewActions::setColor(const QModelIndexList& indices, return; settings.colors().setPreviousSeparatorColor(currentColor); + for (int i = 0; i < QColorDialog::customCount(); ++i) { + const auto customColor = dialog.customColor(i); + settings.colors().setCustomColor(i, customColor); + } for (auto& idx : indices) { ModInfo::Ptr info = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt()); diff --git a/src/settings.cpp b/src/settings.cpp index 849f64ec7..359840d4c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1259,7 +1259,13 @@ void WidgetSettings::resetQuestionButtons() removeSection(m_Settings, "DialogChoices"); } -ColorSettings::ColorSettings(QSettings& s) : m_Settings(s) {} +ColorSettings::ColorSettings(QSettings& s) : m_Settings(s) +{ + for (int i = 0; i < QColorDialog::customCount(); ++i) { + const auto color = customColor(i); + QColorDialog::setCustomColor(i, color); + } +} QColor ColorSettings::modlistOverwrittenLoose() const { @@ -1356,6 +1362,17 @@ void ColorSettings::removePreviousSeparatorColor() remove(m_Settings, "General", "previousSeparatorColor"); } +QColor ColorSettings::customColor(const int index) const +{ + return get(m_Settings, "Settings", QString("customColor%1").arg(index), + QColor(255, 255, 255)); +} + +void ColorSettings::setCustomColor(const int index, const QColor& c) +{ + set(m_Settings, "Settings", QString("customColor%1").arg(index), c); +} + bool ColorSettings::colorSeparatorScrollbar() const { return get(m_Settings, "Settings", "colorSeparatorScrollbars", true); diff --git a/src/settings.h b/src/settings.h index 28eeb1fd9..e726f3259 100644 --- a/src/settings.h +++ b/src/settings.h @@ -265,6 +265,10 @@ class ColorSettings void setPreviousSeparatorColor(const QColor& c) const; void removePreviousSeparatorColor(); + // custom colors set in QColorDialog (e.g. for separators) + QColor customColor(const int index) const; + void setCustomColor(const int index, const QColor& c); + // whether the scrollbar of the mod list should have colors for custom // separator colors // From 90e73cedad0ab16f623acae00975c3bc87bf4272 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Fri, 22 May 2026 19:50:09 +0200 Subject: [PATCH 2/3] Migrate custom colors from global settings to ModOrganizer.ini after upgrade --- src/settings.cpp | 20 ++++++++++++++++++++ src/settings.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/settings.cpp b/src/settings.cpp index 359840d4c..7d3af3cba 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -185,6 +185,10 @@ void Settings::processUpdates(const QVersionNumber& currentVersion, remove(m_Settings, "Settings", "load_mechanism"); }); + version({2, 6, 0}, [&] { + m_Colors.copyGlobalCustomColors(); + }); + // save version in all case set(m_Settings, "General", "version", currentVersion.toString()); @@ -1373,6 +1377,22 @@ void ColorSettings::setCustomColor(const int index, const QColor& c) set(m_Settings, "Settings", QString("customColor%1").arg(index), c); } +void ColorSettings::copyGlobalCustomColors() +{ + // see: + // https://codereview.qt-project.org/c/qt/qtbase/+/626629/3/src/gui/kernel/qplatformdialoghelper.cpp#b263 + QSettings globalSettings(QSettings::UserScope, QStringLiteral("QtProject")); + for (int i = 0; i < QColorDialog::customCount(); ++i) { + const QVariant v = globalSettings.value(QLatin1StringView("Qt/customColors/") + + QString::number(i)); + + if (v.isValid()) { + const QRgb rgba = v.toUInt(); + setCustomColor(i, QColor::fromRgba(rgba)); + } + } +} + bool ColorSettings::colorSeparatorScrollbar() const { return get(m_Settings, "Settings", "colorSeparatorScrollbars", true); diff --git a/src/settings.h b/src/settings.h index e726f3259..0f56c6783 100644 --- a/src/settings.h +++ b/src/settings.h @@ -269,6 +269,10 @@ class ColorSettings QColor customColor(const int index) const; void setCustomColor(const int index, const QColor& c); + // since MO v2.6.0, custom colors are no longer stored globally in Qt; this ensures + // custom colors set in older versions are retained when updating + void copyGlobalCustomColors(); + // whether the scrollbar of the mod list should have colors for custom // separator colors // From fc10887ad58e25e664ca716e824a0918d36140f2 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Mon, 25 May 2026 09:50:43 +0200 Subject: [PATCH 3/3] Don't overwrite custom colors when updating if they're already set --- src/settings.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/settings.cpp b/src/settings.cpp index 7d3af3cba..7879e6a65 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1379,6 +1379,9 @@ void ColorSettings::setCustomColor(const int index, const QColor& c) void ColorSettings::copyGlobalCustomColors() { + if (m_Settings.contains("Settings/customColor0")) + return; // already set, don't overwrite + // see: // https://codereview.qt-project.org/c/qt/qtbase/+/626629/3/src/gui/kernel/qplatformdialoghelper.cpp#b263 QSettings globalSettings(QSettings::UserScope, QStringLiteral("QtProject"));