Skip to content

Commit

Permalink
Fixed formatting in qt6ct files
Browse files Browse the repository at this point in the history
  • Loading branch information
AdenKoperczak committed Nov 29, 2024
1 parent e9d91c3 commit 1780041
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
71 changes: 37 additions & 34 deletions scwx-qt/source/scwx/qt/util/qt6ct_palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scwx-qt/source/scwx/qt/util/qt6ct_palette.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1780041

Please sign in to comment.