Commit b9d5f62e authored by David Schulz's avatar David Schulz

Revert "Editor: Simplify Format handling."

Introduces errors with the default colorscheme.

This reverts commit a0d27fc1dccb9623b4c1bcafc915c84f5988af80.

Change-Id: I3268a9a14f10959fb71423650fd10cfe840e019e
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 497e6d30
......@@ -125,10 +125,16 @@ bool FontSettings::fromSettings(const QString &category,
const TextStyle id = desc.id();
const QString fmt = s->value(group + QLatin1String(Constants::nameForStyle(id)), QString()).toString();
Format format;
if (!fmt.isEmpty())
if (fmt.isEmpty()) {
format.setForeground(desc.foreground());
format.setBackground(desc.background());
format.setBold(desc.format().bold());
format.setItalic(desc.format().italic());
format.setUnderlineColor(desc.format().underlineColor());
format.setUnderlineStyle(desc.format().underlineStyle());
} else {
format.fromString(fmt);
else
format = desc.format();
}
m_scheme.setFormatFor(id, format);
}
......@@ -268,14 +274,15 @@ void FontSettings::setAntialias(bool antialias)
/**
* Returns the format for the given font category.
*/
Format FontSettings::formatFor(TextStyle category) const
Format &FontSettings::formatFor(TextStyle category)
{
return m_scheme.formatFor(category);
}
void FontSettings::setFormatFor(TextStyle category, const Format &format)
Format FontSettings::formatFor(TextStyle category) const
{
m_scheme.setFormatFor(category, format);
return m_scheme.formatFor(category);
}
/**
......@@ -312,12 +319,17 @@ bool FontSettings::loadColorScheme(const QString &fileName,
foreach (const FormatDescription &desc, descriptions) {
const TextStyle id = desc.id();
if (!m_scheme.contains(id)) {
Format format = desc.format();
if (format == Format() && m_scheme.contains(C_TEXT)) {
const Format &textFormat = m_scheme.formatFor(C_TEXT);
format.setForeground(textFormat.foreground());
format.setBackground(textFormat.background());
Format format;
if (desc.format() == format && m_scheme.contains(C_TEXT)) {
format = m_scheme.formatFor(C_TEXT); // Default format -> Text
} else {
format.setForeground(desc.foreground());
format.setBackground(desc.background());
}
format.setBold(desc.format().bold());
format.setItalic(desc.format().italic());
format.setUnderlineColor(desc.format().underlineColor());
format.setUnderlineStyle(desc.format().underlineStyle());
m_scheme.setFormatFor(id, format);
}
}
......
......@@ -86,8 +86,8 @@ public:
bool antialias() const;
void setAntialias(bool antialias);
Format &formatFor(TextStyle category);
Format formatFor(TextStyle category) const;
void setFormatFor(TextStyle category, const Format &format);
QString colorSchemeFileName() const;
void setColorSchemeFileName(const QString &fileName);
......
......@@ -186,13 +186,27 @@ FontSettingsPagePrivate::FontSettingsPagePrivate(const FormatDescriptions &fd,
settingsFound = m_value.fromSettings(m_settingsGroup, m_descriptions, settings);
if (!settingsFound) { // Apply defaults
foreach (const FormatDescription &f, m_descriptions)
m_value.setFormatFor(f.id(), f.format());
foreach (const FormatDescription &f, m_descriptions) {
Format &format = m_value.formatFor(f.id());
format.setForeground(f.foreground());
format.setBackground(f.background());
format.setBold(f.format().bold());
format.setItalic(f.format().italic());
format.setUnderlineColor(f.format().underlineColor());
format.setUnderlineStyle(f.format().underlineStyle());
}
} else if (m_value.colorSchemeFileName().isEmpty()) {
// No color scheme was loaded, but one might be imported from the ini file
ColorScheme defaultScheme;
foreach (const FormatDescription &f, m_descriptions)
defaultScheme.setFormatFor(f.id(), f.format());
foreach (const FormatDescription &f, m_descriptions) {
Format &format = defaultScheme.formatFor(f.id());
format.setForeground(f.foreground());
format.setBackground(f.background());
format.setBold(f.format().bold());
format.setItalic(f.format().italic());
format.setUnderlineColor(f.format().underlineColor());
format.setUnderlineStyle(f.format().underlineStyle());
}
if (m_value.colorScheme() != defaultScheme) {
// Save it as a color scheme file
QString schemeFileName = createColorSchemeFileName(QLatin1String("customized%1.xml"));
......
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