Skip to content

Commit

Permalink
Improve one-time checking of default icon theme
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Mar 8, 2024
1 parent a3c0cec commit 4c4113b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// Determine if the default icon theme includes the necessary icons for
// our toolbar. If not, we need to use our own theme.
static void setDefaultIconTheme()
static bool checkDefaultIconTheme()
{
const QString iconNames[] = {
QStringLiteral("document-new"), QStringLiteral("document-open"),
Expand All @@ -47,15 +47,12 @@ static void setDefaultIconTheme()
QStringLiteral("edit-paste"),
QStringLiteral("edit-find"), QStringLiteral("edit-find-replace"),
};
static bool defaultThemeOk = true;
if (defaultThemeOk) {
for (const auto &name : iconNames) {
if (!QIcon::hasThemeIcon(name)) {
defaultThemeOk = false;
break;
}
}
}
return std::all_of(std::begin(iconNames), std::end(iconNames), &QIcon::hasThemeIcon);
}

static void setDefaultIconTheme()
{
static const bool defaultThemeOk = checkDefaultIconTheme();
if (!defaultThemeOk) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const bool darkTheme = (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
Expand Down

0 comments on commit 4c4113b

Please sign in to comment.