aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2010-11-09 16:01:58 +0100
committerLeandro Melo <leandro.melo@nokia.com>2010-11-09 16:15:36 +0100
commita534c271ecc5c63015b4b8d2fa55716661dfd3fc (patch)
tree0ec5b758084a25775cd4c4201a590eedb8360656 /src/plugins/texteditor/generichighlighter/highlightersettings.cpp
parentb5edda3c32d91754fd7d4ea3592cf2fec3949e86 (diff)
Generic highlighter: Add Creator's share folder in the fallback definitions search.
This leaves the code prepared if we decide to ship some of the Kate XMLs (still a pending decision). In this case the installer needs to be "notified" and the Kate files put in the repo. An addition check for actual XML files in the searched directories is also added. Reviewed-by: con Reviewed-by: Thorbjorn Lindeijer
Diffstat (limited to 'src/plugins/texteditor/generichighlighter/highlightersettings.cpp')
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettings.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
index 2298df67aa..22c76d789d 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
@@ -36,6 +36,7 @@
#include <QtCore/QLatin1Char>
#include <QtCore/QDir>
#include <QtCore/QFile>
+#include <QtCore/QStringList>
#ifdef Q_OS_UNIX
#include <QtCore/QProcess>
#endif
@@ -43,8 +44,11 @@
namespace TextEditor {
namespace Internal {
-QString findDefinitionsLocation()
+QString findFallbackDefinitionsLocation()
{
+ QDir dir;
+ dir.setNameFilters(QStringList(QLatin1String("*.xml")));
+
#ifdef Q_OS_UNIX
static const QLatin1String kateSyntax[] = {
QLatin1String("/share/apps/katepart/syntax"),
@@ -54,7 +58,6 @@ QString findDefinitionsLocation()
sizeof(kateSyntax) / sizeof(kateSyntax[0]);
// Some wild guesses.
- QDir dir;
for (int i = 0; i < kateSyntaxCount; ++i) {
QStringList paths;
paths << QLatin1String("/usr") + kateSyntax[i]
@@ -62,7 +65,7 @@ QString findDefinitionsLocation()
<< QLatin1String("/opt") + kateSyntax[i];
foreach (const QString &path, paths) {
dir.setPath(path);
- if (dir.exists())
+ if (dir.exists() && !dir.entryInfoList().isEmpty())
return dir.path();
}
}
@@ -79,13 +82,17 @@ QString findDefinitionsLocation()
output.remove(QLatin1Char('\n'));
for (int i = 0; i < kateSyntaxCount; ++i) {
dir.setPath(output + kateSyntax[i]);
- if (dir.exists())
+ if (dir.exists() && !dir.entryInfoList().isEmpty())
return dir.path();
}
}
}
#endif
+ dir.setPath(Core::ICore::instance()->resourcePath() + QLatin1String("/generic-highlighter"));
+ if (dir.exists() && !dir.entryInfoList().isEmpty())
+ return dir.path();
+
return QString();
}
@@ -139,7 +146,7 @@ void HighlighterSettings::fromSettings(const QString &category, QSettings *s)
else
m_definitionFilesPath = s->value(kDefinitionFilesPath).toString();
if (!s->contains(kFallbackDefinitionFilesPath)) {
- m_fallbackDefinitionFilesPath = findDefinitionsLocation();
+ m_fallbackDefinitionFilesPath = findFallbackDefinitionsLocation();
if (m_fallbackDefinitionFilesPath.isEmpty())
m_useFallbackLocation = false;
else