Commit 75d1c4f4 authored by hjk's avatar hjk
Browse files

generichighlighter: search more alternative locations

parent 75048873
...@@ -45,26 +45,28 @@ namespace Internal { ...@@ -45,26 +45,28 @@ namespace Internal {
QString findDefinitionsLocation() QString findDefinitionsLocation()
{ {
QString definitionsLocation;
#ifdef Q_OS_UNIX #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. // Some wild guesses.
QDir dir; QDir dir;
for (unsigned i = 0; i < kateSyntaxCount; ++i) {
QStringList paths; QStringList paths;
paths << QLatin1String("/usr") + kateSyntax paths << QLatin1String("/usr") + kateSyntax[i]
<< QLatin1String("/usr/local") + kateSyntax << QLatin1String("/usr/local") + kateSyntax[i]
<< QLatin1String("/opt") + kateSyntax; << QLatin1String("/opt") + kateSyntax[i];
foreach (const QString &path, paths) { foreach (const QString &path, paths) {
dir.setPath(path); dir.setPath(path);
if (dir.exists()) { if (dir.exists())
definitionsLocation = path; return dir.path();
break;
} }
} }
if (definitionsLocation.isEmpty()) {
// Try kde-config. // Try kde-config.
QStringList programs; QStringList programs;
programs << QLatin1String("kde-config") << QLatin1String("kde4-config"); programs << QLatin1String("kde-config") << QLatin1String("kde4-config");
...@@ -75,17 +77,16 @@ QString findDefinitionsLocation() ...@@ -75,17 +77,16 @@ QString findDefinitionsLocation()
process.waitForFinished(5000); process.waitForFinished(5000);
QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); QString output = QString::fromLocal8Bit(process.readAllStandardOutput());
output.remove(QLatin1Char('\n')); output.remove(QLatin1Char('\n'));
dir.setPath(output + kateSyntax); for (unsigned i = 0; i < kateSyntaxCount; ++i) {
if (dir.exists()) { dir.setPath(output + kateSyntax[i]);
definitionsLocation = dir.path(); if (dir.exists())
break; return dir.path();
}
} }
} }
} }
#endif #endif
return definitionsLocation; return QString();
} }
} // namespace Internal } // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment