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:
parent
cb508f5c3a
commit
cf9e2ecf49
3 changed files with 7 additions and 35 deletions
|
|
@ -111,8 +111,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sets the fallback icon path
|
// Sets the fallback icon path and fallback theme
|
||||||
setIconFallbackPaths();
|
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);
|
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
||||||
qInfo("%s v%s", kAppName, qPrintable(kVersion));
|
qInfo("%s v%s", kAppName, qPrintable(kVersion));
|
||||||
|
|
|
||||||
|
|
@ -83,12 +83,6 @@ MainWindow::MainWindow()
|
||||||
m_actionRestartCore{new QAction(tr("Rest&art"), this)},
|
m_actionRestartCore{new QAction(tr("Rest&art"), this)},
|
||||||
m_actionStopCore{new QAction(tr("S&top"), 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);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Setup Actions
|
// Setup Actions
|
||||||
|
|
|
||||||
|
|
@ -35,31 +35,4 @@ inline QString iconMode()
|
||||||
return isDarkMode() ? QStringLiteral("dark") : QStringLiteral("light");
|
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
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue