diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-03-14 11:17:37 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-03-18 10:58:26 +0100 |
commit | cb9ac60609979d71f1093e18bb4e94635bdfd1bf (patch) | |
tree | 457783a7b4dee777ae8ba518da09ba69a36873ab /src/plugins/texteditor/generichighlighter/highlightersettings.cpp | |
parent | 99b2eb1ca9f0515681bf949db0ab6650f857e82b (diff) |
TextEditor: Minimize use of ifdefs.
Change-Id: Icc924fda429032d8806caac66230c6fc55b96c53
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/texteditor/generichighlighter/highlightersettings.cpp')
-rw-r--r-- | src/plugins/texteditor/generichighlighter/highlightersettings.cpp | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp index 49761b0a5e..023e960b00 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp @@ -30,16 +30,15 @@ #include "highlightersettings.h" #include <coreplugin/icore.h> +#include <utils/hostosinfo.h> #include <QSettings> #include <QLatin1String> #include <QLatin1Char> #include <QDir> #include <QFile> -#include <QStringList> -#ifdef Q_OS_UNIX #include <QProcess> -#endif +#include <QStringList> namespace TextEditor { namespace Internal { @@ -49,45 +48,45 @@ QString findFallbackDefinitionsLocation() QDir dir; dir.setNameFilters(QStringList(QLatin1String("*.xml"))); -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) - static const QLatin1String kateSyntax[] = { - QLatin1String("/share/apps/katepart/syntax"), - QLatin1String("/share/kde4/apps/katepart/syntax") - }; - static const int kateSyntaxCount = - sizeof(kateSyntax) / sizeof(kateSyntax[0]); - - // Some wild guesses. - for (int i = 0; i < kateSyntaxCount; ++i) { - QStringList paths; - paths << QLatin1String("/usr") + kateSyntax[i] - << QLatin1String("/usr/local") + kateSyntax[i] - << QLatin1String("/opt") + kateSyntax[i]; - foreach (const QString &path, paths) { - dir.setPath(path); - if (dir.exists() && !dir.entryInfoList().isEmpty()) - return dir.path(); - } - } - - // Try kde-config. - QStringList programs; - programs << QLatin1String("kde-config") << QLatin1String("kde4-config"); - foreach (const QString &program, programs) { - QProcess process; - process.start(program, QStringList(QLatin1String("--prefix"))); - if (process.waitForStarted(5000)) { - process.waitForFinished(5000); - QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); - output.remove(QLatin1Char('\n')); - for (int i = 0; i < kateSyntaxCount; ++i) { - dir.setPath(output + kateSyntax[i]); + if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost()) { + static const QLatin1String kateSyntax[] = { + QLatin1String("/share/apps/katepart/syntax"), + QLatin1String("/share/kde4/apps/katepart/syntax") + }; + static const int kateSyntaxCount = + sizeof(kateSyntax) / sizeof(kateSyntax[0]); + + // Some wild guesses. + for (int i = 0; i < kateSyntaxCount; ++i) { + QStringList paths; + paths << QLatin1String("/usr") + kateSyntax[i] + << QLatin1String("/usr/local") + kateSyntax[i] + << QLatin1String("/opt") + kateSyntax[i]; + foreach (const QString &path, paths) { + dir.setPath(path); if (dir.exists() && !dir.entryInfoList().isEmpty()) return dir.path(); } } + + // Try kde-config. + QStringList programs; + programs << QLatin1String("kde-config") << QLatin1String("kde4-config"); + foreach (const QString &program, programs) { + QProcess process; + process.start(program, QStringList(QLatin1String("--prefix"))); + if (process.waitForStarted(5000)) { + process.waitForFinished(5000); + QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); + output.remove(QLatin1Char('\n')); + for (int i = 0; i < kateSyntaxCount; ++i) { + dir.setPath(output + kateSyntax[i]); + if (dir.exists() && !dir.entryInfoList().isEmpty()) + return dir.path(); + } + } + } } -#endif dir.setPath(Core::ICore::resourcePath() + QLatin1String("/generic-highlighter")); if (dir.exists() && !dir.entryInfoList().isEmpty()) |