diff --git a/src/plugins/android/androidmanifesteditorwidget.cpp b/src/plugins/android/androidmanifesteditorwidget.cpp index e1da129b47a8fbd1dc527891762bccb18f91ac95..b023a8c978c0c033200e4dbd7287b201cfddee8b 100644 --- a/src/plugins/android/androidmanifesteditorwidget.cpp +++ b/src/plugins/android/androidmanifesteditorwidget.cpp @@ -47,7 +47,6 @@ #include <projectexplorer/kitinformation.h> #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/basetexteditor.h> #include <utils/algorithm.h> @@ -112,7 +111,6 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget() { m_textEditorWidget = new AndroidManifestTextEditorWidget(this); m_textEditorWidget->setupAsPlainEditor(); - TextEditor::TextEditorSettings::initializeEditor(m_textEditorWidget); initializePage(); diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp index 532127749d97c6cf58446a381b119af679ed4484..1520c9dd3435516882c17db4f261009099fb4010 100644 --- a/src/plugins/android/javaeditor.cpp +++ b/src/plugins/android/javaeditor.cpp @@ -33,7 +33,6 @@ #include "androidconstants.h" #include "javacompletionassistprovider.h" -#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorconstants.h> #include <texteditor/normalindenter.h> #include <texteditor/highlighterutils.h> @@ -56,14 +55,12 @@ JavaEditor::JavaEditor() setDuplicateSupported(true); setCommentStyle(Utils::CommentDefinition::CppStyle); setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>()); - setAutoCompleter(new JavaAutoCompleter); } Core::IEditor *JavaEditor::duplicate() { JavaEditorWidget *ret = new JavaEditorWidget; ret->setTextDocument(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } @@ -73,6 +70,7 @@ Core::IEditor *JavaEditor::duplicate() JavaEditorWidget::JavaEditorWidget() { + setAutoCompleter(new JavaAutoCompleter); } TextEditor::BaseTextEditor *JavaEditorWidget::createEditor() diff --git a/src/plugins/android/javaeditorfactory.cpp b/src/plugins/android/javaeditorfactory.cpp index 3a634467f23213cbab14989a01483c861b150466..14cb04c82e6fbac1b127560b4298e783c66dd2a1 100644 --- a/src/plugins/android/javaeditorfactory.cpp +++ b/src/plugins/android/javaeditorfactory.cpp @@ -32,7 +32,6 @@ #include "androidconstants.h" #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> using namespace Android; using namespace Android::Internal; @@ -50,6 +49,5 @@ Core::IEditor *JavaEditorFactory::createEditor() { JavaEditorWidget *editor = new JavaEditorWidget; editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new JavaDocument)); - TextEditor::TextEditorSettings::initializeEditor(editor); return editor->editor(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 739808d94330df4d56b29c3b128faf4ed7c7bab1..ad5cb4350de0b664249ba8fdcf63b5a0c382f6a7 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -43,7 +43,6 @@ #include <projectexplorer/session.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/highlighterutils.h> #include <QFileInfo> @@ -70,7 +69,6 @@ Core::IEditor *CMakeEditor::duplicate() { CMakeEditorWidget *ret = new CMakeEditorWidget; ret->setTextDocument(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index d6a6f96570f2bc0cc70a6cb5c2e44e807903d4a8..3174dc1fd1771aa0071982f46a984e6c5bb413cd 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -37,7 +37,6 @@ #include <coreplugin/editormanager/editormanager.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; @@ -74,6 +73,5 @@ Core::IEditor *CMakeEditorFactory::createEditor() { CMakeEditorWidget *widget = new CMakeEditorWidget; widget->setTextDocument(TextEditor::BaseTextDocumentPtr(new CMakeDocument)); - TextEditor::TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index 2dadacfe63b6835e12f534a4e8ea1c5805f28fad..82b14fa25c39751d2b47910a819ed7c5b0ccb310 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -253,7 +253,7 @@ bool CppDocumentationCommentHelper::handleKeyPressEvent(QKeyEvent *e) const if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { QTextCursor cursor = m_editorWidget->textCursor(); - if (!m_editorWidget->editor()->autoCompleter()->isInComment(cursor)) + if (!m_editorWidget->autoCompleter()->isInComment(cursor)) return false; // We are interested on two particular cases: diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 37a8ab5e674b72e596c6e0d9ff9957f39ea9dc80..05cb2beaa1b237d84636636109d7feaa4d492c0d 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -50,6 +50,7 @@ #include <cpptools/cpphighlightingsupport.h> #include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppsemanticinfo.h> +#include <cpptools/cpptoolsconstants.h> #include <cpptools/cpptoolseditorsupport.h> #include <cpptools/cpptoolsplugin.h> #include <cpptools/cpptoolsreuse.h> @@ -116,7 +117,6 @@ CPPEditor::CPPEditor() setCompletionAssistProvider([this] () -> TextEditor::CompletionAssistProvider * { return CppModelManagerInterface::instance()->cppEditorSupport(this)->completionAssistProvider(); }); - setAutoCompleter(new CppAutoCompleter); } Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder) @@ -180,6 +180,7 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc) { setTextDocument(doc); d.reset(new CppEditorWidgetPrivate(this)); + setAutoCompleter(new CppAutoCompleter); qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo"); @@ -243,6 +244,7 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc) connect(d->m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget())); insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_preprocessorButton); insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_cppEditorOutline->widget()); + setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID); } CppEditorWidget::~CppEditorWidget() diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index e060fe402d73e1d28435e54a6ce0286de744eae6..a12f54279315cb1a4295b1d9e69327e0cc85c9f4 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -54,7 +54,6 @@ #include <cpptools/cpptoolsconstants.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/highlighterfactory.h> #include <utils/hostosinfo.h> @@ -130,9 +129,6 @@ CppEditorPlugin *CppEditorPlugin::instance() void CppEditorPlugin::initializeEditor(CppEditorWidget *editor) { - editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID); - TextEditor::TextEditorSettings::initializeEditor(editor); - // function combo box sorting connect(this, SIGNAL(outlineSortingChanged(bool)), editor->outline(), SLOT(setSorted(bool))); diff --git a/src/plugins/cppeditor/cppsnippetprovider.cpp b/src/plugins/cppeditor/cppsnippetprovider.cpp index 0b28166002338dc06b42920aee410a4da20c7399..2d560363ab2f9a1407ed064c3b4b5083f0035173 100644 --- a/src/plugins/cppeditor/cppsnippetprovider.cpp +++ b/src/plugins/cppeditor/cppsnippetprovider.cpp @@ -64,5 +64,5 @@ void CppSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *editor) { editor->setSyntaxHighlighter(new CppHighlighter); editor->textDocument()->setIndenter(new CppTools::CppQtStyleIndenter); - editor->editor()->setAutoCompleter(new CppAutoCompleter); + editor->setAutoCompleter(new CppAutoCompleter); } diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index d4b680d5e072089e71f0113c4b5a0102119c896b..4a39c8f33b30164d6a412991fb7e483b23e6a14f 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -49,7 +49,6 @@ #include <coreplugin/minisplitter.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/outputpane.h> -#include <texteditor/texteditorsettings.h> #include <utils/qtcassert.h> #include <QDesignerFormEditorPluginInterface> @@ -684,7 +683,6 @@ EditorData FormEditorW::createEditor() #endif data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form); DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form); - TextEditor::TextEditorSettings::initializeEditor(xmlEditor); data.formWindowEditor = xmlEditor->designerEditor(); connect(data.formWindowEditor->document(), SIGNAL(filePathChanged(QString,QString)), resourceHandler, SLOT(updateResources())); diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index e286fcac184c4fa02758078c04805a4094400006..8244e47ec948a3bdd588649bcf7e68ae3874175b 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -32,9 +32,7 @@ #include "genericprojectconstants.h" #include <coreplugin/editormanager/editormanager.h> -#include <texteditor/fontsettings.h> #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> #include <QCoreApplication> #include <QSharedPointer> @@ -66,7 +64,6 @@ Core::IEditor *ProjectFilesFactory::createEditor() { auto widget = new ProjectFilesEditorWidget; widget->setSimpleTextDocument(Constants::FILES_EDITOR_ID); - TextEditorSettings::initializeEditor(widget); return widget->editor(); } @@ -86,7 +83,6 @@ Core::IEditor *ProjectFilesEditor::duplicate() { auto widget = new ProjectFilesEditorWidget; widget->setTextDocument(editorWidget()->textDocumentPtr()); - TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index c32b95832a0d327ea7cd058179995838cc715b7d..c9fcbe1ebd4fba0ec22b05b4f7c7d223d0b2ef3e 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -52,25 +52,18 @@ #include <extensionsystem/pluginmanager.h> #include <texteditor/basetextdocument.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/syntaxhighlighter.h> #include <texteditor/refactoroverlay.h> #include <qmldesigner/qmldesignerconstants.h> #include <utils/changeset.h> #include <utils/uncommentselection.h> -#include <QFileInfo> -#include <QSignalMapper> -#include <QTimer> -#include <QTextBlock> - -#include <QMenu> #include <QComboBox> +#include <QFileInfo> #include <QHeaderView> -#include <QInputDialog> -#include <QToolBar> +#include <QTextBlock> +#include <QTimer> #include <QTreeView> -#include <QSharedPointer> using namespace GLSL; using namespace GLSLEditor; @@ -143,6 +136,7 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope) GlslEditorWidget::GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc) { setTextDocument(doc); + setAutoCompleter(new GLSLCompleter); m_outlineCombo = 0; setParenthesesMatchingEnabled(true); @@ -206,7 +200,6 @@ bool GlslEditorWidget::isOutdated() const Core::IEditor *GlslEditor::duplicate() { GlslEditorWidget *newEditor = new GlslEditorWidget(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(newEditor); return newEditor->editor(); } diff --git a/src/plugins/glsleditor/glsleditoreditable.cpp b/src/plugins/glsleditor/glsleditoreditable.cpp index 3a86a54817ab266d69cfc66826643350fb6c0d31..e1ec3172e496d76a58243a47d559f6a6c1eaee11 100644 --- a/src/plugins/glsleditor/glsleditoreditable.cpp +++ b/src/plugins/glsleditor/glsleditoreditable.cpp @@ -48,7 +48,6 @@ GlslEditor::GlslEditor() setDuplicateSupported(true); setCommentStyle(Utils::CommentDefinition::CppStyle); setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>()); - setAutoCompleter(new GLSLCompleter); } } // namespace Internal diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index a492c6758b82bae5935bd08c28bae3dd8105ede5..edadb40181d3590d218b02a59687026a0cf23022 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -66,10 +66,8 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent) Core::IEditor *GLSLEditorFactory::createEditor() { - TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument); - doc->setId(C_GLSLEDITOR_ID); + TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument(C_GLSLEDITOR_ID)); doc->setIndenter(new GLSLIndenter); GlslEditorWidget *rc = new GlslEditorWidget(doc); - TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } diff --git a/src/plugins/pythoneditor/pythoneditor.cpp b/src/plugins/pythoneditor/pythoneditor.cpp index 0522fcbc3bdf62fd077405d9a36410beb93b0b9f..367ccb6f7763178c287d7902b0e47db3133e8e4e 100644 --- a/src/plugins/pythoneditor/pythoneditor.cpp +++ b/src/plugins/pythoneditor/pythoneditor.cpp @@ -40,7 +40,6 @@ #include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <QFileInfo> @@ -58,7 +57,6 @@ PythonEditor::PythonEditor() Core::IEditor *PythonEditor::duplicate() { PythonEditorWidget *widget = new PythonEditorWidget(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp index 25089e6fb0d09fc8bc5b98cf2c9baf838bcf34b4..af4d0bd9fe1454f707e39d7fcf8d7b6357606d68 100644 --- a/src/plugins/pythoneditor/pythoneditorfactory.cpp +++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp @@ -36,9 +36,6 @@ #include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> - -#include <QDebug> using namespace TextEditor; @@ -64,7 +61,6 @@ Core::IEditor *EditorFactory::createEditor() doc->setId(Constants::C_PYTHONEDITOR_ID); doc->setIndenter(new PythonIndenter); PythonEditorWidget *widget = new PythonEditorWidget(doc); - TextEditor::TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp index 37c06aac16aae9c143b3a8fd6851124de72268ee..14ccf433fb3d850b270803babc2c87864053792f 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp @@ -36,13 +36,8 @@ #include <extensionsystem/pluginmanager.h> -#include <texteditor/fontsettings.h> -#include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> - #include <QFileInfo> #include <QDir> -#include <QSharedPointer> #include <QTextBlock> namespace QmakeProjectManager { @@ -65,7 +60,6 @@ Core::IEditor *ProFileEditor::duplicate() { ProFileEditorWidget *ret = new ProFileEditorWidget; ret->setTextDocument(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp index 8dee30c4999102ef3fc67de81ac36f42f74c88ae..eec75c7857d94622af93478669b1ebcf2347e5b6 100644 --- a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp @@ -36,7 +36,6 @@ #include <qtsupport/qtsupportconstants.h> #include <coreplugin/fileiconprovider.h> #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> #include <QCoreApplication> @@ -67,6 +66,5 @@ Core::IEditor *ProFileEditorFactory::createEditor() { ProFileEditorWidget *editor = new ProFileEditorWidget; editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new ProFileDocument)); - TextEditor::TextEditorSettings::initializeEditor(editor); return editor->editor(); } diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 24ec29c96ed9e81b459abe3efc4432d5adb1e3dc..411dcb22203fe26231c9e1d8072ba70df9b6faf8 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -29,6 +29,7 @@ #include "qmljseditor.h" +#include "qmljsautocompleter.h" #include "qmljseditoreditable.h" #include "qmljseditorconstants.h" #include "qmljseditordocument.h" @@ -58,7 +59,6 @@ #include <texteditor/fontsettings.h> #include <texteditor/tabsettings.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/syntaxhighlighter.h> #include <texteditor/refactoroverlay.h> #include <texteditor/codeassist/genericproposal.h> @@ -100,6 +100,7 @@ namespace Internal { QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc) { setTextDocument(doc); + setAutoCompleter(new AutoCompleter); m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(doc.data()); m_outlineCombo = 0; @@ -169,7 +170,6 @@ QModelIndex QmlJSTextEditorWidget::outlineModelIndex() IEditor *QmlJSEditor::duplicate() { QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(editorWidget()->textDocumentPtr()); - TextEditor::TextEditorSettings::initializeEditor(newEditor); return newEditor->editor(); } diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp index 81f7f23caa8fb53409ecde0bd3e0304a47267b64..dfec522d2628a108e8a63b2eafd6206758af9bd9 100644 --- a/src/plugins/qmljseditor/qmljseditoreditable.cpp +++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp @@ -56,7 +56,6 @@ QmlJSEditor::QmlJSEditor() setDuplicateSupported(true); setCommentStyle(Utils::CommentDefinition::CppStyle); setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>()); - setAutoCompleter(new AutoCompleter); } bool QmlJSEditor::isDesignModePreferred() const diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index 6b76c10c7f2a02f6ed47faac50fbcd2a9fac74ed..d781686ae133fdcaed346263ecc14abc27c508e0 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -36,7 +36,6 @@ #include <qmljstools/qmljstoolsconstants.h> #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> #include <QCoreApplication> @@ -66,7 +65,6 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent) Core::IEditor *QmlJSEditorFactory::createEditor() { QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr(new QmlJSEditorDocument)); - TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } diff --git a/src/plugins/qmljseditor/qmljssnippetprovider.cpp b/src/plugins/qmljseditor/qmljssnippetprovider.cpp index 83ec7eb6ec736a8431b93e640e2b6f52a5e4fde6..0766ff13e95c1aa5bc82359f54c6a517559621e6 100644 --- a/src/plugins/qmljseditor/qmljssnippetprovider.cpp +++ b/src/plugins/qmljseditor/qmljssnippetprovider.cpp @@ -66,5 +66,5 @@ void QmlJSSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *edito { editor->setSyntaxHighlighter(new Highlighter); editor->textDocument()->setIndenter(new Indenter); - editor->editor()->setAutoCompleter(new AutoCompleter); + editor->setAutoCompleter(new AutoCompleter); } diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp index efda173dc400223bb3c5a8389edcf3833cc0d488..fb9f5474726dcd00871e075c4ff2497ebb67dd06 100644 --- a/src/plugins/qnx/bardescriptoreditorwidget.cpp +++ b/src/plugins/qnx/bardescriptoreditorwidget.cpp @@ -49,7 +49,6 @@ #include <projectexplorer/taskhub.h> #include <texteditor/basetextdocument.h> #include <texteditor/basetexteditor.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorconstants.h> #include <texteditor/normalindenter.h> #include <utils/qtcassert.h> @@ -178,7 +177,6 @@ void BarDescriptorEditorWidget::initSourcePage() m_xmlSourceWidget->setupAsPlainEditor(); addWidget(m_xmlSourceWidget); - TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget); m_xmlSourceWidget->configureMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE)); } diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 74abd72c60e3f94d6371eeba47fa7b01f59fa046..80258f3d2e71eb72ba1dbfc0b8b265eecb978a89 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -189,7 +189,6 @@ class BaseTextEditorPrivate { public: BaseTextEditorPrivate() - : m_autoCompleter(new AutoCompleter) {} // Note: This is always a copy of IContext::m_widget. @@ -197,7 +196,6 @@ public: CommentDefinition m_commentDefinition; std::function<CompletionAssistProvider *()> m_completionAssistProvider; - QScopedPointer<AutoCompleter> m_autoCompleter; }; class BaseTextEditorWidgetPrivate : public QObject @@ -206,9 +204,6 @@ public: BaseTextEditorWidgetPrivate(BaseTextEditorWidget *parent); ~BaseTextEditorWidgetPrivate() { delete m_toolBar; } - // FIXME: Remove after relevant members have been moved to BaseTextEditorPrivate - BaseTextEditorPrivate *dd() { return q->editor()->d; } - void setupDocumentSignals(); void updateLineSelectionColor(); @@ -399,6 +394,8 @@ public: QScopedPointer<Internal::ClipboardAssistProvider> m_clipboardAssistProvider; bool m_isMissingSyntaxDefinition; + + QScopedPointer<AutoCompleter> m_autoCompleter; }; BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *parent) @@ -451,7 +448,8 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *p m_blockCount(0), m_markDragging(false), m_clipboardAssistProvider(new Internal::ClipboardAssistProvider), - m_isMissingSyntaxDefinition(false) + m_isMissingSyntaxDefinition(false), + m_autoCompleter(new AutoCompleter) { Aggregation::Aggregate *aggregate = new Aggregation::Aggregate; BaseTextFind *baseTextFind = new BaseTextFind(q); @@ -2026,7 +2024,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e) cursor.beginEditBlock(); int extraBlocks = - dd()->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor, + d->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor, d->m_document->tabSettings()); QString previousIndentationString; @@ -2226,7 +2224,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e) case Qt::Key_Insert: if (ro) break; if (e->modifiers() == Qt::NoModifier) { - AutoCompleter *ac = dd()->m_autoCompleter.data(); + AutoCompleter *ac = d->m_autoCompleter.data(); if (inOverwriteMode) { ac->setAutoParenthesesEnabled(d->autoParenthesisOverwriteBackup); ac->setSurroundWithEnabled(d->surroundWithEnabledOverwriteBackup); @@ -2285,7 +2283,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e) // only go here if control is not pressed, except if also alt is pressed // because AltGr maps to Alt + Ctrl QTextCursor cursor = textCursor(); - const QString &autoText = dd()->m_autoCompleter->autoComplete(cursor, eventText); + const QString &autoText = d->m_autoCompleter->autoComplete(cursor, eventText); QChar electricChar; if (d->m_document->typingSettings().m_autoIndent) { @@ -2325,7 +2323,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e) //Select the inserted text, to be able to re-indent the inserted text cursor.setPosition(pos, QTextCursor::KeepAnchor); } - if (!electricChar.isNull() && dd()->m_autoCompleter->contextAllowsElectricCharacters(cursor)) + if (!electricChar.isNull() && d->m_autoCompleter->contextAllowsElectricCharacters(cursor)) d->m_document->autoIndent(cursor, electricChar); if (!autoText.isEmpty()) cursor.setPosition(autoText.length() == 1 ? cursor.position() : cursor.anchor()); @@ -2800,12 +2798,12 @@ int BaseTextEditorWidget::visibleWrapColumn() const return d->m_visibleWrapColumn; } -void BaseTextEditor::setAutoCompleter(AutoCompleter *autoCompleter) +void BaseTextEditorWidget::setAutoCompleter(AutoCompleter *autoCompleter) { d->m_autoCompleter.reset(autoCompleter); } -AutoCompleter *BaseTextEditor::autoCompleter() const +AutoCompleter *BaseTextEditorWidget::autoCompleter() const { return d->m_autoCompleter.data(); } @@ -2847,8 +2845,44 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals() this, &BaseTextEditorWidgetPrivate::applyFontSettingsDelayed); slotUpdateExtraAreaWidth(); -} + TextEditorSettings *settings = TextEditorSettings::instance(); + + // Connect to settings change signals + connect(settings, &TextEditorSettings::fontSettingsChanged, + m_document.data(), &BaseTextDocument::setFontSettings); + connect(settings, &TextEditorSettings::typingSettingsChanged, + q, &BaseTextEditorWidget::setTypingSettings); + connect(settings, &TextEditorSettings::storageSettingsChanged, + q, &BaseTextEditorWidget::setStorageSettings); + connect(settings, &TextEditorSettings::behaviorSettingsChanged, + q, &BaseTextEditorWidget::setBehaviorSettings); + connect(settings, &TextEditorSettings::marginSettingsChanged, + q, &BaseTextEditorWidget::setMarginSettings); + connect(settings, &TextEditorSettings::displaySettingsChanged, + q, &BaseTextEditorWidget::setDisplaySettings); + connect(settings, &TextEditorSettings::completionSettingsChanged, + q, &BaseTextEditorWidget::setCompletionSettings); + connect(settings, &TextEditorSettings::extraEncodingSettingsChanged, + q, &BaseTextEditorWidget::setExtraEncodingSettings); + + connect(q, &BaseTextEditorWidget::requestFontZoom, + settings, &TextEditorSettings::fontZoomRequested); + connect(q, &BaseTextEditorWidget::requestZoomReset, + settings, &TextEditorSettings::zoomResetRequested); + + // Apply current settings + m_document->setFontSettings(settings->fontSettings()); + m_document->setTabSettings(settings->codeStyle()->tabSettings()); // also set through code style ??? + q->setTypingSettings(settings->typingSettings()); + q->setStorageSettings(settings->storageSettings()); + q->setBehaviorSettings(settings->behaviorSettings()); + q->setMarginSettings(settings->marginSettings()); + q->setDisplaySettings(settings->displaySettings()); + q->setCompletionSettings(settings->completionSettings()); + q->setExtraEncodingSettings(settings->extraEncodingSettings()); + q->setCodeStyle(settings->codeStyle(q->languageSettingsId())); +} bool BaseTextEditorWidgetPrivate::snippetCheckCursor(const QTextCursor &cursor) { @@ -5159,7 +5193,7 @@ void BaseTextEditorWidgetPrivate::handleBackspaceKey() const TextEditor::TabSettings &tabSettings = m_document->tabSettings(); const TextEditor::TypingSettings &typingSettings = m_document->typingSettings(); - if (typingSettings.m_autoIndent && dd()->m_autoCompleter->autoBackspace(cursor)) + if (typingSettings.m_autoIndent && m_autoCompleter->autoBackspace(cursor)) return; bool handled = false; @@ -6102,8 +6136,8 @@ void BaseTextEditorWidget::setStorageSettings(const StorageSettings &storageSett void BaseTextEditorWidget::setCompletionSettings(const TextEditor::CompletionSettings &completionSettings) { - dd()->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets); - dd()->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets + d->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets); + d->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets && completionSettings.m_surroundingAutoBrackets); } @@ -6729,11 +6763,6 @@ void BaseTextEditorWidget::doFoo() #endif } -BaseTextEditorPrivate *BaseTextEditorWidget::dd() const -{ - return editor()->d; -} - BaseTextBlockSelection::BaseTextBlockSelection(const BaseTextBlockSelection &other) { positionBlock = other.positionBlock; @@ -7110,10 +7139,9 @@ void BaseTextEditorWidget::setupAsPlainEditor() IEditor *BaseTextEditor::duplicate() { - auto newWidget = new BaseTextEditorWidget(0); + auto newWidget = new BaseTextEditorWidget; newWidget->setTextDocument(editorWidget()->textDocumentPtr()); newWidget->setupAsPlainEditor(); - TextEditorSettings::initializeEditor(newWidget); auto editor = newWidget->editor(); editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, TextEditor::Constants::C_TEXTEDITOR)); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index e9e42f53da93bfc1c0a408ca188ac843ba77c344..2e0ee1367a1559666a4327f27ad2a065075211f5 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -189,9 +189,6 @@ public: // There should be something simpler. void setCompletionAssistProvider(const std::function<CompletionAssistProvider *()> &provider); - void setAutoCompleter(AutoCompleter *autoCompleter); - AutoCompleter *autoCompleter() const; - signals: void markRequested(TextEditor::BaseTextEditor *editor, int line, TextEditor::BaseTextEditor::MarkRequestKind kind); void markContextMenuRequested(TextEditor::BaseTextEditor *editor, int line, QMenu *menu); @@ -238,6 +235,9 @@ public: void appendStandardContextMenuActions(QMenu *menu); + void setAutoCompleter(AutoCompleter *autoCompleter); + AutoCompleter *autoCompleter() const; + // Works only in conjunction with a syntax highlighter that puts // parentheses into text block user data void setParenthesesMatchingEnabled(bool b); @@ -591,7 +591,6 @@ protected slots: private: Internal::BaseTextEditorWidgetPrivate *d; - Internal::BaseTextEditorPrivate *dd() const; friend class BaseTextEditor; friend class Internal::BaseTextEditorWidgetPrivate; friend class Internal::TextEditorOverlay; diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index f14dce268529858a13c3dcbb6abacd24755378bc..40d6e5daa5f0072c30a16643b52826a021dbfc6c 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -61,15 +61,13 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) Core::IEditor *PlainTextEditorFactory::createEditor() { - BaseTextDocumentPtr doc(new BaseTextDocument); - doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); + BaseTextDocumentPtr doc(new BaseTextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID)); doc->setIndenter(new NormalIndenter); - auto widget = new BaseTextEditorWidget(0); + auto widget = new BaseTextEditorWidget; widget->setTextDocument(doc); widget->setupAsPlainEditor(); - TextEditorSettings::initializeEditor(widget); - connect(widget, SIGNAL(configured(Core::IEditor*)), - this, SLOT(updateEditorInfoBar(Core::IEditor*))); + connect(widget, &BaseTextEditorWidget::configured, + this, &PlainTextEditorFactory::updateEditorInfoBar); updateEditorInfoBar(widget->editor()); return widget->editor(); } diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 274a63a11a9f69eabccef768b2dd82e007ed5e54..2a5e98eeb1090da3ed3b538e3ec1def5231b0b3f 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -329,48 +329,6 @@ TextEditorSettings *TextEditorSettings::instance() return m_instance; } -/** - * Initializes editor settings. Also connects signals to keep them up to date - * when they are changed. - */ -void TextEditorSettings::initializeEditor(BaseTextEditorWidget *editor) -{ - // Connect to settings change signals - connect(m_instance, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), - editor->textDocument(), SLOT(setFontSettings(TextEditor::FontSettings))); - connect(m_instance, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)), - editor, SLOT(setTypingSettings(TextEditor::TypingSettings))); - connect(m_instance, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), - editor, SLOT(setStorageSettings(TextEditor::StorageSettings))); - connect(m_instance, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)), - editor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings))); - connect(m_instance, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)), - editor, SLOT(setMarginSettings(TextEditor::MarginSettings))); - connect(m_instance, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), - editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings))); - connect(m_instance, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), - editor, SLOT(setCompletionSettings(TextEditor::CompletionSettings))); - connect(m_instance, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)), - editor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings))); - - connect(editor, SIGNAL(requestFontZoom(int)), - m_instance, SLOT(fontZoomRequested(int))); - connect(editor, SIGNAL(requestZoomReset()), - m_instance, SLOT(zoomResetRequested())); - - // Apply current settings - editor->textDocument()->setFontSettings(fontSettings()); - editor->textDocument()->setTabSettings(codeStyle()->tabSettings()); // also set through code style ??? - editor->setTypingSettings(typingSettings()); - editor->setStorageSettings(storageSettings()); - editor->setBehaviorSettings(behaviorSettings()); - editor->setMarginSettings(marginSettings()); - editor->setDisplaySettings(displaySettings()); - editor->setCompletionSettings(completionSettings()); - editor->setExtraEncodingSettings(extraEncodingSettings()); - editor->setCodeStyle(codeStyle(editor->languageSettingsId())); -} - const FontSettings &TextEditorSettings::fontSettings() { return d->m_fontSettingsPage->fontSettings(); diff --git a/src/plugins/texteditor/texteditorsettings.h b/src/plugins/texteditor/texteditorsettings.h index 7a7a779a16b9c75abc3ac4247b6f9774de7d9d31..119eefce5e6f8a6d36390583554b4344ddea052d 100644 --- a/src/plugins/texteditor/texteditorsettings.h +++ b/src/plugins/texteditor/texteditorsettings.h @@ -43,7 +43,6 @@ QT_END_NAMESPACE namespace TextEditor { -class BaseTextEditorWidget; class FontSettings; class TabSettings; class TypingSettings; @@ -73,8 +72,6 @@ public: static TextEditorSettings *instance(); - static void initializeEditor(BaseTextEditorWidget *editor); - static const FontSettings &fontSettings(); static const TypingSettings &typingSettings(); static const StorageSettings &storageSettings(); @@ -116,7 +113,7 @@ signals: void completionSettingsChanged(const TextEditor::CompletionSettings &); void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &); -private slots: +public slots: void fontZoomRequested(int zoom); void zoomResetRequested(); }; diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index 39c1d0a43c86d81d8caae78deef1a2aa4f8978a5..73289913295aafd2489a6e6f501b5d403179f0b5 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -31,7 +31,6 @@ #include "vcsbaseeditor.h" #include <texteditor/texteditoractionhandler.h> -#include <texteditor/texteditorsettings.h> #include <diffeditor/diffeditorconstants.h> @@ -90,7 +89,6 @@ Core::IEditor *BaseVcsEditorFactory::createEditor() if (!mimeTypes().isEmpty()) vcsEditor->textDocument()->setMimeType(mimeTypes().front()); - TextEditor::TextEditorSettings::initializeEditor(vcsEditor); return vcsEditor->editor(); } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 9205ccfbe67d57e3968950904e3489dc6eda67c8..ba9f689f00875c7bfe16d3c946c1b23549560a1b 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -44,7 +44,6 @@ #include <projectexplorer/session.h> #include <texteditor/basetextdocument.h> #include <texteditor/basetextdocumentlayout.h> -#include <texteditor/texteditorsettings.h> #include <utils/qtcassert.h> #include <QDebug> @@ -715,7 +714,6 @@ void VcsBaseEditorWidget::init() setCodeFoldingSupported(true); textDocument()->setSyntaxHighlighter(dh); } - TextEditor::TextEditorSettings::initializeEditor(this); // override revisions display (green or red bar on the left, marking changes): setRevisionsVisible(false); }