Commit 81d40def authored by Leandro Melo's avatar Leandro Melo
Browse files

Generic highlighter: Create default dir for definitions on user's area (at runtime).

parent acbb8cd5
This is Creator's default directory for syntax highlight definitions.
You can download them through the Generic Highlighter options dialog.
......@@ -35,7 +35,7 @@ DATA_DIRS = \
qmlicons \
qml \
qml-type-descriptions \
generic-highlighter
qmljsdebugger
!isEmpty(copydata) {
......
......@@ -34,9 +34,9 @@
#include <QtCore/QSettings>
#include <QtCore/QLatin1String>
#include <QtCore/QLatin1Char>
#include <QtCore/QDebug>
#ifdef Q_OS_UNIX
#include <QtCore/QDir>
#include <QtCore/QFile>
#ifdef Q_OS_UNIX
#include <QtCore/QProcess>
#endif
......@@ -135,8 +135,7 @@ void HighlighterSettings::fromSettings(const QString &category, QSettings *s)
s->beginGroup(group);
m_definitionFilesPath = s->value(kDefinitionFilesPath, QString()).toString();
if (!s->contains(kDefinitionFilesPath))
m_definitionFilesPath = Core::ICore::instance()->resourcePath() +
QLatin1String("/generic-highlighter");
assignDefaultDefinitionsPath();
else
m_definitionFilesPath = s->value(kDefinitionFilesPath).toString();
if (!s->contains(kFallbackDefinitionFilesPath)) {
......@@ -151,7 +150,7 @@ void HighlighterSettings::fromSettings(const QString &category, QSettings *s)
}
m_alertWhenNoDefinition = s->value(kAlertWhenDefinitionIsNotFound, true).toBool();
if (!s->contains(kIgnoredFilesPatterns))
assignInitialIgnoredPatterns();
assignDefaultIgnoredPatterns();
else
setIgnoredFilesPatterns(s->value(kIgnoredFilesPatterns, QString()).toString());
s->endGroup();
......@@ -167,7 +166,7 @@ QString HighlighterSettings::ignoredFilesPatterns() const
return listFromExpressions().join(QLatin1String(","));
}
void HighlighterSettings::assignInitialIgnoredPatterns()
void HighlighterSettings::assignDefaultIgnoredPatterns()
{
QStringList patterns;
patterns << QLatin1String("*.txt")
......@@ -180,6 +179,14 @@ void HighlighterSettings::assignInitialIgnoredPatterns()
setExpressionsFromList(patterns);
}
void HighlighterSettings::assignDefaultDefinitionsPath()
{
const QString &path =
Core::ICore::instance()->userResourcePath() + QLatin1String("/generic-highlighter");
if (QFile::exists(path) || QDir().mkpath(path))
m_definitionFilesPath = path;
}
bool HighlighterSettings::isIgnoredFilePattern(const QString &fileName) const
{
foreach (const QRegExp &regExp, m_ignoredFiles)
......
......@@ -68,7 +68,8 @@ public:
bool equals(const HighlighterSettings &highlighterSettings) const;
private:
void assignInitialIgnoredPatterns();
void assignDefaultIgnoredPatterns();
void assignDefaultDefinitionsPath();
void setExpressionsFromList(const QStringList &patterns);
QStringList listFromExpressions() const;
......
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