aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2010-09-23 15:38:32 +0200
committerhjk <qtc-committer@nokia.com>2010-09-23 15:41:20 +0200
commit75d1c4f43d057e80ec360731d5e3fef3050644cb (patch)
treebde36bfee752cff096a024b63ce4af2e5f5327f2 /src/plugins/texteditor/generichighlighter/highlightersettings.cpp
parent75048873778e61dbd32e2883f9f97d1dc05c4e4b (diff)
generichighlighter: search more alternative locations
Diffstat (limited to 'src/plugins/texteditor/generichighlighter/highlightersettings.cpp')
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettings.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
index cf7f99d47c..c62b1339cd 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
@@ -45,47 +45,48 @@ namespace Internal {
QString findDefinitionsLocation()
{
- QString definitionsLocation;
-
#ifdef Q_OS_UNIX
- static const QLatin1String kateSyntax("/share/apps/katepart/syntax");
+ 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.
QDir dir;
- QStringList paths;
- paths << QLatin1String("/usr") + kateSyntax
- << QLatin1String("/usr/local") + kateSyntax
- << QLatin1String("/opt") + kateSyntax;
- foreach (const QString &path, paths) {
- dir.setPath(path);
- if (dir.exists()) {
- definitionsLocation = path;
- break;
+ for (unsigned 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())
+ return dir.path();
}
}
- if (definitionsLocation.isEmpty()) {
- // 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'));
- dir.setPath(output + kateSyntax);
- if (dir.exists()) {
- definitionsLocation = dir.path();
- break;
- }
+ // 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 (unsigned i = 0; i < kateSyntaxCount; ++i) {
+ dir.setPath(output + kateSyntax[i]);
+ if (dir.exists())
+ return dir.path();
}
}
}
#endif
- return definitionsLocation;
+ return QString();
}
} // namespace Internal