diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 2c9c11f10ba..b699afe37b7 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -327,11 +327,9 @@ bool FormatDescription::showControl(FormatDescription::ShowControls showControl) } // ------------ FontSettingsPage -FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd, - Core::Id id, - QObject *parent) : - Core::IOptionsPage(parent), - d_ptr(new FontSettingsPagePrivate(fd, id, tr("Font && Colors"), TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY)) +FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd) : + d_ptr(new FontSettingsPagePrivate(fd, Constants::TEXT_EDITOR_FONT_SETTINGS, + tr("Font && Colors"), TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY)) { setId(d_ptr->m_id); setDisplayName(d_ptr->m_displayName); diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index 4ff91f22b6c..4d963533294 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -123,8 +123,7 @@ class TEXTEDITOR_EXPORT FontSettingsPage : public Core::IOptionsPage Q_OBJECT public: - FontSettingsPage(const FormatDescriptions &fd, Core::Id id, QObject *parent = nullptr); - + explicit FontSettingsPage(const FormatDescriptions &fd); ~FontSettingsPage() override; QWidget *widget() override; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 9b70393cce8..06c3c637f4f 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -53,7 +53,6 @@ #include -using namespace TextEditor; using namespace TextEditor::Constants; using namespace TextEditor::Internal; @@ -62,8 +61,10 @@ namespace Internal { class TextEditorSettingsPrivate { + Q_DECLARE_TR_FUNCTIONS(TextEditor::TextEditorSettings) + public: - FontSettingsPage *m_fontSettingsPage; + FontSettingsPage m_fontSettingsPage{initialFormats()}; BehaviorSettingsPage m_behaviorSettingsPage; DisplaySettingsPage m_displaySettingsPage; HighlighterSettingsPage m_highlighterSettingsPage; @@ -75,23 +76,13 @@ public: QMap m_languageToCodeStyle; QMap m_languageToCodeStylePool; QMap m_mimeTypeToLanguage; + +private: + static std::vector initialFormats(); }; -} // namespace Internal -} // namespace TextEditor - - -static TextEditorSettingsPrivate *d = nullptr; -static TextEditorSettings *m_instance = nullptr; - -TextEditorSettings::TextEditorSettings() +FormatDescriptions TextEditorSettingsPrivate::initialFormats() { - QTC_ASSERT(!m_instance, return); - m_instance = this; - d = new Internal::TextEditorSettingsPrivate; - - // Note: default background colors are coming from FormatDescription::background() - // Add font preference page FormatDescriptions formatDescr; formatDescr.reserve(C_LAST_STYLE_SENTINEL); @@ -346,16 +337,29 @@ TextEditorSettings::TextEditorSettings() outputArgumentFormat, FormatDescription::ShowAllControls); - d->m_fontSettingsPage = new FontSettingsPage(formatDescr, - Constants::TEXT_EDITOR_FONT_SETTINGS, - this); + return formatDescr; +} + +} // namespace Internal + + +static TextEditorSettingsPrivate *d = nullptr; +static TextEditorSettings *m_instance = nullptr; + +TextEditorSettings::TextEditorSettings() +{ + QTC_ASSERT(!m_instance, return); + m_instance = this; + d = new Internal::TextEditorSettingsPrivate; + + // Note: default background colors are coming from FormatDescription::background() auto updateGeneralMessagesFontSettings = []() { - Core::MessageManager::setFont(d->m_fontSettingsPage->fontSettings().font()); + Core::MessageManager::setFont(d->m_fontSettingsPage.fontSettings().font()); }; - connect(d->m_fontSettingsPage, &FontSettingsPage::changed, + connect(&d->m_fontSettingsPage, &FontSettingsPage::changed, this, &TextEditorSettings::fontSettingsChanged); - connect(d->m_fontSettingsPage, &FontSettingsPage::changed, + connect(&d->m_fontSettingsPage, &FontSettingsPage::changed, this, updateGeneralMessagesFontSettings); updateGeneralMessagesFontSettings(); connect(&d->m_behaviorSettingsPage, &BehaviorSettingsPage::typingSettingsChanged, @@ -400,7 +404,7 @@ TextEditorSettings *TextEditorSettings::instance() const FontSettings &TextEditorSettings::fontSettings() { - return d->m_fontSettingsPage->fontSettings(); + return d->m_fontSettingsPage.fontSettings(); } const TypingSettings &TextEditorSettings::typingSettings() @@ -525,19 +529,21 @@ Core::Id TextEditorSettings::languageId(const QString &mimeType) int TextEditorSettings::increaseFontZoom(int step) { - auto &fs = const_cast(d->m_fontSettingsPage->fontSettings()); + auto &fs = const_cast(d->m_fontSettingsPage.fontSettings()); const int previousZoom = fs.fontZoom(); const int newZoom = qMax(10, previousZoom + step); if (newZoom != previousZoom) { fs.setFontZoom(newZoom); - d->m_fontSettingsPage->saveSettings(); + d->m_fontSettingsPage.saveSettings(); } return newZoom; } void TextEditorSettings::resetFontZoom() { - auto &fs = const_cast(d->m_fontSettingsPage->fontSettings()); + auto &fs = const_cast(d->m_fontSettingsPage.fontSettings()); fs.setFontZoom(100); - d->m_fontSettingsPage->saveSettings(); + d->m_fontSettingsPage.saveSettings(); } + +} // TextEditor diff --git a/src/plugins/vcsbase/diffandloghighlighter.h b/src/plugins/vcsbase/diffandloghighlighter.h index 40c2d62b561..3847f287ba2 100644 --- a/src/plugins/vcsbase/diffandloghighlighter.h +++ b/src/plugins/vcsbase/diffandloghighlighter.h @@ -35,7 +35,6 @@ class QTextCharFormat; QT_END_NAMESPACE namespace Core { class ICore; } -namespace TextEditor { class FontSettingsPage; } namespace VcsBase {