aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
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
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')
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettings.cpp17
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettings.h2
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp2
3 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp
index 2298df67aa5..22c76d789d0 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
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.h b/src/plugins/texteditor/generichighlighter/highlightersettings.h
index 0fbbe7e3eda..323cf833ac3 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettings.h
+++ b/src/plugins/texteditor/generichighlighter/highlightersettings.h
@@ -88,7 +88,7 @@ inline bool operator!=(const HighlighterSettings &a, const HighlighterSettings &
{ return !a.equals(b); }
namespace Internal {
-QString findDefinitionsLocation();
+QString findFallbackDefinitionsLocation();
}
} // namespace TextEditor
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
index 44eddbfc795..ffa80862253 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
@@ -171,7 +171,7 @@ void HighlighterSettingsPage::settingsToUI()
void HighlighterSettingsPage::resetDefinitionsLocation()
{
- const QString &location = findDefinitionsLocation();
+ const QString &location = findFallbackDefinitionsLocation();
if (location.isEmpty())
QMessageBox::information(0, tr("Autodetect Definitions"),
tr("No pre-installed definitions could be found."));