improved icon theme lookup
This commit is contained in:
parent
ce39061808
commit
5c89dbbb87
|
@ -78,10 +78,12 @@ void QtConfigArguments::applySettings() const
|
||||||
cout << "Warning: Can not set a style for the Qt Quick GUI." << endl;
|
cout << "Warning: Can not set a style for the Qt Quick GUI." << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
bool searchPathsPresent = false;
|
||||||
|
#endif
|
||||||
if(m_iconThemeArg.isPresent()) {
|
if(m_iconThemeArg.isPresent()) {
|
||||||
auto i = m_iconThemeArg.values().cbegin(), end = m_iconThemeArg.values().end();
|
auto i = m_iconThemeArg.values().cbegin(), end = m_iconThemeArg.values().end();
|
||||||
if(i != end) {
|
if(i != end) {
|
||||||
QIcon::setThemeName(QString::fromLocal8Bit(i->data()));
|
|
||||||
if(++i != end) {
|
if(++i != end) {
|
||||||
QStringList searchPaths;
|
QStringList searchPaths;
|
||||||
searchPaths.reserve(m_iconThemeArg.values().size() - 1);
|
searchPaths.reserve(m_iconThemeArg.values().size() - 1);
|
||||||
|
@ -89,24 +91,36 @@ void QtConfigArguments::applySettings() const
|
||||||
searchPaths << QString::fromLocal8Bit(i->data());
|
searchPaths << QString::fromLocal8Bit(i->data());
|
||||||
}
|
}
|
||||||
QIcon::setThemeSearchPaths(searchPaths);
|
QIcon::setThemeSearchPaths(searchPaths);
|
||||||
} else {
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QStringLiteral("../share/icons"));
|
searchPathsPresent = !searchPaths.isEmpty();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
QIcon::setThemeName(QString::fromLocal8Bit(i->data()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(qEnvironmentVariableIsSet("ICON_THEME_SEARCH_PATH")) {
|
||||||
|
QString path;
|
||||||
|
path.append(qgetenv("ICON_THEME_SEARCH_PATH"));
|
||||||
|
QIcon::setThemeSearchPaths(QStringList() << path);
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
searchPathsPresent = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if(qEnvironmentVariableIsSet("ICON_THEME")) {
|
if(qEnvironmentVariableIsSet("ICON_THEME")) {
|
||||||
QString themeName;
|
QString themeName;
|
||||||
themeName.append(qgetenv("ICON_THEME"));
|
themeName.append(qgetenv("ICON_THEME"));
|
||||||
QIcon::setThemeName(themeName);
|
QIcon::setThemeName(themeName);
|
||||||
}
|
}
|
||||||
if(qEnvironmentVariableIsSet("ICON_THEME_SEARCH_PATH")) {
|
|
||||||
QString path;
|
|
||||||
path.append(qgetenv("ICON_THEME_SEARCH_PATH"));
|
|
||||||
QIcon::setThemeSearchPaths(QStringList() << path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
// default configuration under Windows
|
||||||
|
if(!searchPathsPresent) {
|
||||||
|
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QStringLiteral("../share/icons"));
|
||||||
|
}
|
||||||
|
if(QIcon::themeName().isEmpty()) {
|
||||||
|
QIcon::setThemeName(QStringLiteral("default"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(m_fontArg.isPresent()) {
|
if(m_fontArg.isPresent()) {
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily(QString::fromLocal8Bit(m_fontArg.values().front().data()));
|
font.setFamily(QString::fromLocal8Bit(m_fontArg.values().front().data()));
|
||||||
|
|
Loading…
Reference in New Issue