// -- FontSettings FontSettings::FontSettings() : m_family(defaultFixedFontFamily()), m_fontSize(defaultFontSize()), m_fontZoom(100), m_antialias(DEFAULT_ANTIALIAS) { }
bool FontSettings::fromSettings(const QString &category, const FormatDescriptions &descriptions, const QSettings *s) { clear(); if (!s->childGroups().contains(category)) return false; QString group = category; group += QLatin1Char('/'); m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString(); m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt(); m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt(); m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool(); if (s->contains(group + QLatin1String(schemeFileNamesKey))) { // Load the selected color scheme for the current theme auto schemeFileNames = s->value(group + QLatin1String(schemeFileNamesKey)).toMap(); if (schemeFileNames.contains(Utils::creatorTheme()->id())) { const QString scheme = schemeFileNames.value(Utils::creatorTheme()->id()).toString(); loadColorScheme(scheme, descriptions); } } return true; }
void FontSettings::clear() { m_family = defaultFixedFontFamily(); m_fontSize = DEFAULT_FONT_SIZE; m_fontZoom = 100; m_antialias = DEFAULT_ANTIALIAS; m_scheme.clear(); }
void FontSettings::clear() { m_family = defaultFixedFontFamily(); m_fontSize = defaultFontSize(); m_fontZoom = 100; m_antialias = DEFAULT_ANTIALIAS; m_scheme.clear(); m_formatCache.clear(); m_textCharFormatCache.clear(); }
bool FontSettings::fromSettings(const QString &category, const FormatDescriptions &descriptions, const QSettings *s) { clear(); if (!s->childGroups().contains(category)) return false; QString group = category; group += QLatin1Char('/'); m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString(); m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt(); m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt(); m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool(); if (s->contains(group + QLatin1String(schemeFileNameKey))) { // Load the selected color scheme 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) { const TextStyle id = desc.id(); const QString fmt = s->value(group + Constants::nameForStyle(id), QString()).toString(); Format format; if (fmt.isEmpty()) { format.setForeground(desc.foreground()); format.setBackground(desc.background()); format.setBold(desc.format().bold()); format.setItalic(desc.format().italic()); } else { format.fromString(fmt); } m_scheme.setFormatFor(id, format); } m_scheme.setDisplayName(QCoreApplication::translate("TextEditor::Internal::FontSettings", "Customized")); } return true; }
void FontSettings::toSettings(const QString &category, QSettings *s) const { s->beginGroup(category); if (m_family != defaultFixedFontFamily() || s->contains(QLatin1String(fontFamilyKey))) s->setValue(QLatin1String(fontFamilyKey), m_family); if (m_fontSize != DEFAULT_FONT_SIZE || s->contains(QLatin1String(fontSizeKey))) s->setValue(QLatin1String(fontSizeKey), m_fontSize); if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey))) s->setValue(QLatin1String(fontZoomKey), m_fontZoom); if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey))) s->setValue(QLatin1String(antialiasKey), m_antialias); if (m_schemeFileName != defaultSchemeFileName() || s->contains(QLatin1String(schemeFileNameKey))) s->setValue(QLatin1String(schemeFileNameKey), m_schemeFileName); s->endGroup(); }
void FontSettings::toSettings(const QString &category, QSettings *s) const { s->beginGroup(category); if (m_family != defaultFixedFontFamily() || s->contains(QLatin1String(fontFamilyKey))) s->setValue(QLatin1String(fontFamilyKey), m_family); if (m_fontSize != defaultFontSize() || s->contains(QLatin1String(fontSizeKey))) s->setValue(QLatin1String(fontSizeKey), m_fontSize); if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey))) s->setValue(QLatin1String(fontZoomKey), m_fontZoom); if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey))) s->setValue(QLatin1String(antialiasKey), m_antialias); auto schemeFileNames = s->value(QLatin1String(schemeFileNamesKey)).toMap(); if (m_schemeFileName != defaultSchemeFileName() || schemeFileNames.contains(Utils::creatorTheme()->id())) { schemeFileNames.insert(Utils::creatorTheme()->id(), m_schemeFileName); s->setValue(QLatin1String(schemeFileNamesKey), schemeFileNames); } s->endGroup(); }