Commit 87a7ed94 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Fixed an issue with keeping a shipped color scheme selected

When the path to the shipped color schemes changes, Qt Creator was
unable to load the chosen color scheme. Now, when it can't find the
color scheme, it will look for it in the default color scheme path.

Reviewed-by: con
parent 232db420
......@@ -145,8 +145,6 @@ bool ColorScheme::save(const QString &fileName) const
if (!m_name.isEmpty())
w.writeAttribute(QLatin1String("name"), m_name);
Format textFormat = formatFor(QLatin1String(Constants::C_TEXT));
QMapIterator<QString, Format> i(m_formats);
while (i.hasNext()) {
const Format &format =;
......@@ -33,6 +33,8 @@
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtCore/QCoreApplication>
#include <QtGui/QTextCharFormat>
......@@ -114,8 +116,10 @@ bool FontSettings::fromSettings(const QString &category,
if (s->contains(group + QLatin1String(schemeFileNameKey))) {
// Load the selected color scheme
loadColorScheme(s->value(group + QLatin1String(schemeFileNameKey), defaultSchemeFileName()).toString(),
QString scheme = s->value(group + QLatin1String(schemeFileNameKey)).toString();
if (scheme.isEmpty() || !QFile::exists(scheme))
scheme = defaultSchemeFileName(QFileInfo(scheme).fileName());
loadColorScheme(scheme, descriptions);
} else {
// Load color scheme from ini file
foreach (const FormatDescription &desc, descriptions) {
......@@ -316,11 +320,21 @@ int FontSettings::defaultFontSize()
QString FontSettings::defaultSchemeFileName()
* Returns the default scheme file name, or the path to a shipped scheme when
* one exists with the given \a fileName.
QString FontSettings::defaultSchemeFileName(const QString &fileName)
QString fileName = Core::ICore::instance()->resourcePath();
fileName += QLatin1String("/styles/default.xml");
return fileName;
QString defaultScheme = Core::ICore::instance()->resourcePath();
defaultScheme += QLatin1String("/styles/");
if (!fileName.isEmpty() && QFile::exists(defaultScheme + fileName))
defaultScheme += fileName;
defaultScheme += QLatin1String("default.xml");
return defaultScheme;
} // namespace TextEditor
......@@ -100,7 +100,7 @@ public:
static int defaultFontSize();
static QString defaultSchemeFileName();
static QString defaultSchemeFileName(const QString &fileName = QString());
QString m_family;
QString m_schemeFileName;
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