refactor: simplify setting the fallback theme search path, does require sub dirs but we should only need the theme root
refactor: set the Icon theme in deskflow-gui insetead of MainWindow
This commit is contained in:
@ -111,8 +111,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
// Sets the fallback icon path
|
||||
setIconFallbackPaths();
|
||||
// Sets the fallback icon path and fallback theme
|
||||
const auto themeName = QStringLiteral("deskflow-%1").arg(iconMode());
|
||||
if (QIcon::themeName().isEmpty())
|
||||
QIcon::setThemeName(themeName);
|
||||
else
|
||||
QIcon::setFallbackThemeName(themeName);
|
||||
QIcon::setFallbackSearchPaths({QStringLiteral(":/icons/%1").arg(themeName)});
|
||||
|
||||
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
||||
qInfo("%s v%s", kAppName, qPrintable(kVersion));
|
||||
|
||||
@ -83,12 +83,6 @@ MainWindow::MainWindow()
|
||||
m_actionRestartCore{new QAction(tr("Rest&art"), this)},
|
||||
m_actionStopCore{new QAction(tr("S&top"), this)}
|
||||
{
|
||||
const auto themeName = QStringLiteral("deskflow-%1").arg(iconMode());
|
||||
if (QIcon::themeName().isEmpty())
|
||||
QIcon::setThemeName(themeName);
|
||||
else
|
||||
QIcon::setFallbackThemeName(themeName);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
// Setup Actions
|
||||
|
||||
@ -35,31 +35,4 @@ inline QString iconMode()
|
||||
return isDarkMode() ? QStringLiteral("dark") : QStringLiteral("light");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checkSubDir checks for subdirs in a dir
|
||||
* @param path The path to check for subdirs
|
||||
* @return list of subdirs
|
||||
*/
|
||||
inline QStringList checkSubDir(const QString &path)
|
||||
{
|
||||
QStringList paths;
|
||||
auto dir = QDir(path);
|
||||
const QFileInfoList items = dir.entryInfoList({"*"}, QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (const QFileInfo &item : items) {
|
||||
if (item.isDir()) {
|
||||
paths.append(item.absoluteFilePath());
|
||||
paths.append(checkSubDir(item.absoluteFilePath()));
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setIconFallbackPaths Set the icon fallback path to our light or dark theme
|
||||
*/
|
||||
inline void setIconFallbackPaths()
|
||||
{
|
||||
QStringList paths = checkSubDir(QStringLiteral(":/icons/deskflow-%1").arg(iconMode()));
|
||||
QIcon::setFallbackSearchPaths(paths);
|
||||
}
|
||||
} // namespace deskflow::gui
|
||||
|
||||
Reference in New Issue
Block a user