From 17800414e72e59318e0a33ec19f25db3c4f2a2e4 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Fri, 29 Nov 2024 10:19:00 -0500 Subject: [PATCH] Fixed formatting in qt6ct files --- scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp | 71 ++++++++++--------- scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp | 2 +- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp b/scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp index 2b43f462..dc5e1fa4 100644 --- a/scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp +++ b/scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp @@ -40,45 +40,48 @@ namespace qt namespace util { -QPalette loadColorScheme(const QString &filePath, const QPalette &fallback) +QPalette loadColorScheme(const QString& filePath, const QPalette& fallback) { - QPalette customPalette; - QSettings settings(filePath, QSettings::IniFormat); - settings.beginGroup("ColorScheme"); - QStringList activeColors = settings.value("active_colors").toStringList(); - QStringList inactiveColors = settings.value("inactive_colors").toStringList(); - QStringList disabledColors = settings.value("disabled_colors").toStringList(); - settings.endGroup(); + QPalette customPalette; + QSettings settings(filePath, QSettings::IniFormat); + settings.beginGroup("ColorScheme"); + QStringList activeColors = settings.value("active_colors").toStringList(); + QStringList inactiveColors = + settings.value("inactive_colors").toStringList(); + QStringList disabledColors = + settings.value("disabled_colors").toStringList(); + settings.endGroup(); - -#if (QT_VERSION >= QT_VERSION_CHECK(6,6,0)) - if(activeColors.count() == QPalette::Accent) - activeColors << activeColors.at(QPalette::Highlight); - if(inactiveColors.count() == QPalette::Accent) - inactiveColors << inactiveColors.at(QPalette::Highlight); - if(disabledColors.count() == QPalette::Accent) - disabledColors << disabledColors.at(QPalette::Highlight); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) + if (activeColors.count() == QPalette::Accent) + activeColors << activeColors.at(QPalette::Highlight); + if (inactiveColors.count() == QPalette::Accent) + inactiveColors << inactiveColors.at(QPalette::Highlight); + if (disabledColors.count() == QPalette::Accent) + disabledColors << disabledColors.at(QPalette::Highlight); #endif + if (activeColors.count() >= QPalette::NColorRoles && + inactiveColors.count() >= QPalette::NColorRoles && + disabledColors.count() >= QPalette::NColorRoles) + { + for (int i = 0; i < QPalette::NColorRoles; i++) + { + QPalette::ColorRole role = QPalette::ColorRole(i); + customPalette.setColor( + QPalette::Active, role, QColor(activeColors.at(i))); + customPalette.setColor( + QPalette::Inactive, role, QColor(inactiveColors.at(i))); + customPalette.setColor( + QPalette::Disabled, role, QColor(disabledColors.at(i))); + } + } + else + { + customPalette = fallback; // load fallback palette + } - if(activeColors.count() >= QPalette::NColorRoles && - inactiveColors.count() >= QPalette::NColorRoles && - disabledColors.count() >= QPalette::NColorRoles) - { - for (int i = 0; i < QPalette::NColorRoles; i++) - { - QPalette::ColorRole role = QPalette::ColorRole(i); - customPalette.setColor(QPalette::Active, role, QColor(activeColors.at(i))); - customPalette.setColor(QPalette::Inactive, role, QColor(inactiveColors.at(i))); - customPalette.setColor(QPalette::Disabled, role, QColor(disabledColors.at(i))); - } - } - else - { - customPalette = fallback; //load fallback palette - } - - return customPalette; + return customPalette; } } // namespace util diff --git a/scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp b/scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp index be44f6ef..62417f8e 100644 --- a/scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp +++ b/scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp @@ -18,7 +18,7 @@ namespace util * * @return The loaded palette, or the fallback palette if it could not be loaded */ -QPalette loadColorScheme(const QString &filePath, const QPalette &fallback); +QPalette loadColorScheme(const QString& filePath, const QPalette& fallback); } // namespace util } // namespace qt