diff options
33 files changed, 93 insertions, 218 deletions
diff --git a/src/plugins/android/androidmanifesteditorfactory.cpp b/src/plugins/android/androidmanifesteditorfactory.cpp index ba80296bd7..58cdbaaa96 100644 --- a/src/plugins/android/androidmanifesteditorfactory.cpp +++ b/src/plugins/android/androidmanifesteditorfactory.cpp @@ -51,7 +51,7 @@ AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent) Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent) { - AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget(parent, m_actionHandler); + AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget(parent); TextEditor::TextEditorSettings::initializeEditor(editor); return editor->editor(); } diff --git a/src/plugins/android/androidmanifesteditorwidget.cpp b/src/plugins/android/androidmanifesteditorwidget.cpp index 8053f28a77..5cdcb141f4 100644 --- a/src/plugins/android/androidmanifesteditorwidget.cpp +++ b/src/plugins/android/androidmanifesteditorwidget.cpp @@ -95,7 +95,7 @@ Project *androidProject(const QString &file) } // anonymous namespace -AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah) +AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent) : TextEditor::PlainTextEditorWidget(parent), m_dirty(false), m_stayClean(false), @@ -106,7 +106,6 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent, TextEd doc->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE)); setBaseTextDocument(doc); - ah->setupActions(this); configure(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE)); initializePage(); diff --git a/src/plugins/android/androidmanifesteditorwidget.h b/src/plugins/android/androidmanifesteditorwidget.h index cdd77ef926..3318c39782 100644 --- a/src/plugins/android/androidmanifesteditorwidget.h +++ b/src/plugins/android/androidmanifesteditorwidget.h @@ -51,8 +51,6 @@ QT_END_NAMESPACE namespace Core { class IEditor; } -namespace TextEditor { class TextEditorActionHandler; } - namespace Android { namespace Internal { class AndroidManifestEditor; @@ -86,7 +84,7 @@ public: Source }; - explicit AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah); + explicit AndroidManifestEditorWidget(QWidget *parent); bool open(QString *errorString, const QString &fileName, const QString &realFileName); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 3ae4a1e730..05c71707d6 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -68,7 +68,7 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor) Core::IEditor *CMakeEditor::duplicate(QWidget *parent) { CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(widget()); - CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler()); + CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory()); ret->duplicateFrom(w); TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); @@ -116,8 +116,8 @@ void CMakeEditor::build() // CMakeEditor // -CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah) - : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah) +CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory) + : BaseTextEditorWidget(parent), m_factory(factory) { QSharedPointer<CMakeDocument> doc(new CMakeDocument); doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)); @@ -127,8 +127,6 @@ CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factor m_commentDefinition.clearCommentStyles(); m_commentDefinition.singleLine = QLatin1Char('#'); - - ah->setupActions(this); } TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor() diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index 55e7639a24..8f6f6a1f1d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -71,12 +71,11 @@ class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget Q_OBJECT public: - CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah); + CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory); bool save(const QString &fileName = QString()); CMakeEditorFactory *factory() { return m_factory; } - TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; } Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true, bool inNextSplit = false); @@ -89,7 +88,6 @@ public slots: private: CMakeEditorFactory *m_factory; - TextEditor::TextEditorActionHandler *m_ah; Utils::CommentDefinition m_commentDefinition; }; diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 7b7b32ae5a..629518f08a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -72,7 +72,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) { - CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler); + CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this); TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 132cfed46b..6ed4ed215a 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -125,8 +125,6 @@ CppEditorPlugin *CppEditorPlugin::instance() void CppEditorPlugin::initializeEditor(CPPEditorWidget *editor) { - m_actionHandler->setupActions(editor); - editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID); TextEditor::TextEditorSettings::initializeEditor(editor); @@ -298,8 +296,6 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err | TextEditor::TextEditorActionHandler::UnCollapseAll | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - m_actionHandler->initializeActions(); - contextMenu->addSeparator(context); cmd = ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION); diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index 287ce30563..61470effc4 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -50,9 +50,8 @@ namespace Internal { // //////////////////////////////////////////////////////////////////////////////////////// -ProjectFilesFactory::ProjectFilesFactory(Manager *manager, TextEditorActionHandler *handler) - : Core::IEditorFactory(manager), - m_actionHandler(handler) +ProjectFilesFactory::ProjectFilesFactory(Manager *manager) + : Core::IEditorFactory(manager) { setId(Constants::FILES_EDITOR_ID); setDisplayName(QCoreApplication::translate("OpenWith::Editors", ".files Editor")); @@ -63,7 +62,7 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager, TextEditorActionHandl Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent) { - ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget(parent, this, m_actionHandler); + ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget(parent, this); TextEditorSettings::initializeEditor(ed); return ed->editor(); } @@ -94,8 +93,7 @@ Core::IEditor *ProjectFilesEditor::duplicate(QWidget *parent) { ProjectFilesEditorWidget *parentEditor = qobject_cast<ProjectFilesEditorWidget *>(editorWidget()); ProjectFilesEditorWidget *editor = new ProjectFilesEditorWidget(parent, - parentEditor->factory(), - parentEditor->actionHandler()); + parentEditor->factory()); TextEditorSettings::initializeEditor(editor); return editor->editor(); } @@ -106,16 +104,12 @@ Core::IEditor *ProjectFilesEditor::duplicate(QWidget *parent) // //////////////////////////////////////////////////////////////////////////////////////// -ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory, - TextEditorActionHandler *handler) +ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory) : BaseTextEditorWidget(parent), - m_factory(factory), - m_actionHandler(handler) + m_factory(factory) { QSharedPointer<BaseTextDocument> doc(new BaseTextDocument()); setBaseTextDocument(doc); - - handler->setupActions(this); } ProjectFilesFactory *ProjectFilesEditorWidget::factory() const @@ -123,11 +117,6 @@ ProjectFilesFactory *ProjectFilesEditorWidget::factory() const return m_factory; } -TextEditorActionHandler *ProjectFilesEditorWidget::actionHandler() const -{ - return m_actionHandler; -} - BaseTextEditor *ProjectFilesEditorWidget::createEditor() { return new ProjectFilesEditor(this); diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h index 75014f8060..61cd858cde 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h @@ -35,10 +35,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -namespace TextEditor { -class TextEditorActionHandler; -} - namespace GenericProjectManager { namespace Internal { @@ -52,12 +48,9 @@ class ProjectFilesFactory: public Core::IEditorFactory Q_OBJECT public: - ProjectFilesFactory(Manager *manager, TextEditor::TextEditorActionHandler *handler); + ProjectFilesFactory(Manager *manager); Core::IEditor *createEditor(QWidget *parent); - -private: - TextEditor::TextEditorActionHandler *m_actionHandler; }; class ProjectFilesEditor : public TextEditor::BaseTextEditor @@ -77,16 +70,13 @@ class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget Q_OBJECT public: - ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory, - TextEditor::TextEditorActionHandler *handler); + ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory); ProjectFilesFactory *factory() const; - TextEditor::TextEditorActionHandler *actionHandler() const; TextEditor::BaseTextEditor *createEditor(); private: ProjectFilesFactory *m_factory; - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/genericprojectmanager/genericprojectplugin.cpp b/src/plugins/genericprojectmanager/genericprojectplugin.cpp index 9f2093f94b..d43c175d53 100644 --- a/src/plugins/genericprojectmanager/genericprojectplugin.cpp +++ b/src/plugins/genericprojectmanager/genericprojectplugin.cpp @@ -75,10 +75,9 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage Manager *manager = new Manager; - TextEditor::TextEditorActionHandler *actionHandler = - new TextEditor::TextEditorActionHandler(Constants::C_FILESEDITOR); + new TextEditor::TextEditorActionHandler(Constants::C_FILESEDITOR); // owned by ICore - m_projectFilesEditorFactory = new ProjectFilesFactory(manager, actionHandler); + m_projectFilesEditorFactory = new ProjectFilesFactory(manager); addObject(m_projectFilesEditorFactory); addAutoReleasedObject(manager); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index f7cdc00336..a38a753f3f 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -191,7 +191,7 @@ Core::IEditor *GLSLEditorEditable::duplicate(QWidget *parent) { GLSLTextEditorWidget *newEditor = new GLSLTextEditorWidget(parent); newEditor->duplicateFrom(editorWidget()); - GLSLEditorPlugin::initializeEditor(newEditor); + TextEditor::TextEditorSettings::initializeEditor(newEditor); return newEditor->editor(); } diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index 5afdfe65cb..4ccceddae1 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -37,6 +37,7 @@ #include <extensionsystem/pluginspec.h> #include <coreplugin/icore.h> +#include <texteditor/texteditorsettings.h> #include <QCoreApplication> #include <QSettings> @@ -59,7 +60,7 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent) Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) { GLSLTextEditorWidget *rc = new GLSLTextEditorWidget(parent); - GLSLEditorPlugin::initializeEditor(rc); + TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index 43b30df305..de927d26ec 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -48,7 +48,6 @@ #include <projectexplorer/taskhub.h> #include <extensionsystem/pluginmanager.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <texteditor/textfilewizard.h> #include <texteditor/texteditoractionhandler.h> #include <utils/qtcassert.h> @@ -149,7 +148,6 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er TextEditorActionHandler::Format | TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::UnCollapseAll); - dd->m_actionHandler->initializeActions(); ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT); ActionContainer *glslToolsMenu = ActionManager::createMenu(Id(Constants::M_TOOLS_GLSL)); @@ -245,13 +243,6 @@ ExtensionSystem::IPlugin::ShutdownFlag GLSLEditorPlugin::aboutToShutdown() return IPlugin::aboutToShutdown(); } -void GLSLEditorPlugin::initializeEditor(GLSLTextEditorWidget *editor) -{ - QTC_CHECK(m_instance); - dd->m_actionHandler->setupActions(editor); - TextEditorSettings::initializeEditor(editor); -} - static QByteArray glslFile(const QString &fileName) { QFile file(ICore::resourcePath() + QLatin1String("/glsl/") + fileName); diff --git a/src/plugins/glsleditor/glsleditorplugin.h b/src/plugins/glsleditor/glsleditorplugin.h index 882f01800a..f9974bc17b 100644 --- a/src/plugins/glsleditor/glsleditorplugin.h +++ b/src/plugins/glsleditor/glsleditorplugin.h @@ -52,8 +52,6 @@ public: void extensionsInitialized(); ShutdownFlag aboutToShutdown(); - static void initializeEditor(GLSLTextEditorWidget *editor); - struct InitFile { InitFile(GLSL::Engine *engine = 0, GLSL::TranslationUnitAST *ast = 0) diff --git a/src/plugins/pythoneditor/pythoneditor.cpp b/src/plugins/pythoneditor/pythoneditor.cpp index 6afb318e7b..9719b66513 100644 --- a/src/plugins/pythoneditor/pythoneditor.cpp +++ b/src/plugins/pythoneditor/pythoneditor.cpp @@ -62,7 +62,7 @@ Core::IEditor *PythonEditor::duplicate(QWidget *parent) { EditorWidget *widget = new EditorWidget(parent); widget->duplicateFrom(editorWidget()); - PythonEditorPlugin::initializeEditor(widget); + TextEditor::TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp index 2851d611af..e8b0d67274 100644 --- a/src/plugins/pythoneditor/pythoneditorfactory.cpp +++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp @@ -52,7 +52,7 @@ EditorFactory::EditorFactory(QObject *parent) Core::IEditor *EditorFactory::createEditor(QWidget *parent) { EditorWidget *widget = new EditorWidget(parent); - PythonEditorPlugin::initializeEditor(widget); + TextEditor::TextEditorSettings::initializeEditor(widget); return widget->editor(); } diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 856c0677a7..873661e185 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -43,7 +43,6 @@ #include <coreplugin/editormanager/editormanager.h> #include <extensionsystem/pluginmanager.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/texteditorsettings.h> #include <QtPlugin> #include <QCoreApplication> @@ -223,12 +222,11 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error addObject(m_factory); // Initialize editor actions handler - m_actionHandler.reset(new TextEditor::TextEditorActionHandler( + m_actionHandler = new TextEditor::TextEditorActionHandler( C_PYTHONEDITOR_ID, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::UnCollapseAll)); - m_actionHandler->initializeActions(); + | TextEditor::TextEditorActionHandler::UnCollapseAll); // Add MIME overlay icons (these icons displayed at Project dock panel) const QIcon icon = QIcon::fromTheme(QLatin1String(C_PY_MIME_ICON)); @@ -247,12 +245,6 @@ void PythonEditorPlugin::extensionsInitialized() { } -void PythonEditorPlugin::initializeEditor(EditorWidget *widget) -{ - instance()->m_actionHandler->setupActions(widget); - TextEditor::TextEditorSettings::initializeEditor(widget); -} - QSet<QString> PythonEditorPlugin::keywords() { return instance()->m_keywords; diff --git a/src/plugins/pythoneditor/pythoneditorplugin.h b/src/plugins/pythoneditor/pythoneditorplugin.h index f6c730cb69..529d30202c 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.h +++ b/src/plugins/pythoneditor/pythoneditorplugin.h @@ -57,7 +57,6 @@ public: virtual bool initialize(const QStringList &arguments, QString *errorMessage); virtual void extensionsInitialized(); static PythonEditorPlugin *instance() { return m_instance; } - static void initializeEditor(EditorWidget *widget); static QSet<QString> keywords(); static QSet<QString> magics(); @@ -66,7 +65,7 @@ public: private: static PythonEditorPlugin *m_instance; EditorFactory *m_factory; - QScopedPointer<TextEditor::TextEditorActionHandler> m_actionHandler; + TextEditor::TextEditorActionHandler *m_actionHandler; QSet<QString> m_keywords; QSet<QString> m_magics; QSet<QString> m_builtins; diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp index 230cff4440..e547f7bfa5 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp @@ -61,8 +61,7 @@ ProFileEditor::ProFileEditor(ProFileEditorWidget *editor) Core::IEditor *ProFileEditor::duplicate(QWidget *parent) { - ProFileEditorWidget *ret = new ProFileEditorWidget(parent, qobject_cast<ProFileEditorWidget*>(editorWidget())->factory(), - qobject_cast<ProFileEditorWidget*>(editorWidget())->actionHandler()); + ProFileEditorWidget *ret = new ProFileEditorWidget(parent, qobject_cast<ProFileEditorWidget*>(editorWidget())->factory()); ret->duplicateFrom(editorWidget()); TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); @@ -82,15 +81,13 @@ TextEditor::CompletionAssistProvider *ProFileEditor::completionAssistProvider() // ProFileEditorWidget // -ProFileEditorWidget::ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory, TextEditor::TextEditorActionHandler *ah) - : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah) +ProFileEditorWidget::ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory) + : BaseTextEditorWidget(parent), m_factory(factory) { QSharedPointer<ProFileDocument> doc(new ProFileDocument()); doc->setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE)); setBaseTextDocument(doc); - ah->setupActions(this); - baseTextDocument()->setSyntaxHighlighter(new ProFileHighlighter); m_commentDefinition.clearCommentStyles(); m_commentDefinition.singleLine = QLatin1Char('#'); diff --git a/src/plugins/qmakeprojectmanager/profileeditor.h b/src/plugins/qmakeprojectmanager/profileeditor.h index 4976ebd081..1f5425e3f0 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.h +++ b/src/plugins/qmakeprojectmanager/profileeditor.h @@ -34,11 +34,6 @@ #include <texteditor/basetexteditor.h> #include <utils/uncommentselection.h> -namespace TextEditor { -class FontSettings; -class TextEditorActionHandler; -} - namespace QmakeProjectManager { namespace Internal { @@ -63,11 +58,9 @@ class ProFileEditorWidget : public TextEditor::BaseTextEditorWidget Q_OBJECT public: - ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory, - TextEditor::TextEditorActionHandler *ah); + ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory); ProFileEditorFactory *factory() { return m_factory; } - TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; } void unCommentSelection(); @@ -79,7 +72,6 @@ protected: private: ProFileEditorFactory *m_factory; - TextEditor::TextEditorActionHandler *m_ah; Utils::CommentDefinition m_commentDefinition; }; diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp index 3f75d5809d..b3ea76a576 100644 --- a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp @@ -59,7 +59,7 @@ ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager, TextEditor::Te Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent) { - ProFileEditorWidget *editor = new ProFileEditorWidget(parent, this, m_actionHandler); + ProFileEditorWidget *editor = new ProFileEditorWidget(parent, this); TextEditor::TextEditorSettings::initializeEditor(editor); return editor->editor(); } diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 0bc0ffdba0..672a9dd813 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -170,7 +170,6 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - m_actionHandler->initializeActions(); Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT); Core::ActionContainer *qmlToolsMenu = Core::ActionManager::actionContainer(Core::Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); @@ -266,8 +265,6 @@ void QmlJSEditorPlugin::initializeEditor(QmlJSTextEditorWidget *editor) { QTC_CHECK(m_instance); - m_actionHandler->setupActions(editor); - editor->setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID); TextEditor::TextEditorSettings::initializeEditor(editor); } diff --git a/src/plugins/qnx/bardescriptoreditorfactory.cpp b/src/plugins/qnx/bardescriptoreditorfactory.cpp index 5d9a6cdbef..c89e09fcc5 100644 --- a/src/plugins/qnx/bardescriptoreditorfactory.cpp +++ b/src/plugins/qnx/bardescriptoreditorfactory.cpp @@ -72,6 +72,6 @@ BarDescriptorEditorFactory::~BarDescriptorEditorFactory() Core::IEditor *BarDescriptorEditorFactory::createEditor(QWidget *parent) { - BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(parent, m_actionHandler); + BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(parent); return editorWidget->editor(); } diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp index 5d069112a8..5611d5600a 100644 --- a/src/plugins/qnx/bardescriptoreditorwidget.cpp +++ b/src/plugins/qnx/bardescriptoreditorwidget.cpp @@ -45,18 +45,15 @@ #include <projectexplorer/iprojectproperties.h> #include <projectexplorer/projectwindow.h> #include <texteditor/plaintexteditor.h> -#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorsettings.h> #include <texteditor/texteditorconstants.h> using namespace Qnx; using namespace Qnx::Internal; -BarDescriptorEditorWidget::BarDescriptorEditorWidget( - QWidget *parent, TextEditor::TextEditorActionHandler *handler) +BarDescriptorEditorWidget::BarDescriptorEditorWidget(QWidget *parent) : QStackedWidget(parent) , m_editor(0) - , m_handler(handler) , m_dirty(false) { Core::IContext *myContext = new Core::IContext(this); @@ -161,7 +158,6 @@ void BarDescriptorEditorWidget::initSourcePage() addWidget(m_xmlSourceWidget); TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget); - m_handler->setupActions(m_xmlSourceWidget); m_xmlSourceWidget->configure(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE)); connect(m_xmlSourceWidget, SIGNAL(textChanged()), this, SLOT(setDirty())); } diff --git a/src/plugins/qnx/bardescriptoreditorwidget.h b/src/plugins/qnx/bardescriptoreditorwidget.h index 8e5edc69e6..4f1314d5e9 100644 --- a/src/plugins/qnx/bardescriptoreditorwidget.h +++ b/src/plugins/qnx/bardescriptoreditorwidget.h @@ -46,7 +46,6 @@ class PanelsWidget; namespace TextEditor { class PlainTextEditorWidget; -class TextEditorActionHandler; class BaseTextEditorWidget; } @@ -67,7 +66,7 @@ class BarDescriptorEditorWidget : public QStackedWidget Q_OBJECT public: - explicit BarDescriptorEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *handler); + explicit BarDescriptorEditorWidget(QWidget *parent); Core::IEditor *editor() const; @@ -107,7 +106,6 @@ private: mutable Core::IEditor *m_editor; - TextEditor::TextEditorActionHandler *m_handler; bool m_dirty; // New UI diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index c970d6bc19..0ea3d5fdf6 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -102,7 +102,6 @@ public: BaseTextEditorWidgetPrivate(); ~BaseTextEditorWidgetPrivate(); - void setupBasicEditActions(TextEditorActionHandler *actionHandler); void setupDocumentSignals(const QSharedPointer<BaseTextDocument> &document); void updateLineSelectionColor(); diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index c664cdbafa..297441922e 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -79,7 +79,7 @@ IEditor *PlainTextEditor::duplicate(QWidget *parent) { PlainTextEditorWidget *newWidget = new PlainTextEditorWidget(parent); newWidget->duplicateFrom(editorWidget()); - TextEditorPlugin::instance()->initializeEditor(newWidget); + TextEditorSettings::initializeEditor(newWidget); return newWidget->editor(); } diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index c31d411e58..af85d21ac5 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -30,9 +30,10 @@ #include "plaintexteditorfactory.h" #include "plaintexteditor.h" #include "basetextdocument.h" +#include "texteditoractionhandler.h" #include "texteditorconstants.h" #include "texteditorplugin.h" -#include "texteditoractionhandler.h" +#include "texteditorsettings.h" #include <coreplugin/coreconstants.h> #include <coreplugin/infobar.h> @@ -65,7 +66,7 @@ PlainTextEditorFactory::~PlainTextEditorFactory() Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) { PlainTextEditorWidget *rc = new PlainTextEditorWidget(parent); - TextEditorPlugin::instance()->initializeEditor(rc); + TextEditorSettings::initializeEditor(rc); connect(rc, SIGNAL(configured(Core::IEditor*)), this, SLOT(updateEditorInfoBar(Core::IEditor*))); updateEditorInfoBar(rc->editor()); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 7ba3466710..eeaf6affd9 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -102,10 +102,10 @@ TextEditorActionHandler::TextEditorActionHandler(Core::Id contextId, uint option m_jumpToFileAction(0), m_jumpToFileInNextSplitAction(0), m_optionalActions(optionalActions), - m_currentEditor(0), - m_contextId(contextId), - m_initialized(false) + m_currentEditorWidget(0), + m_contextId(contextId) { + createActions(); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateCurrentEditor(Core::IEditor*))); } @@ -114,24 +114,6 @@ TextEditorActionHandler::~TextEditorActionHandler() { } -void TextEditorActionHandler::setupActions(BaseTextEditorWidget *editor) -{ - initializeActions(); - QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction())); - QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction())); - QObject::connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction())); - QObject::connect(editor, SIGNAL(readOnlyChanged()), this, SLOT(updateActions())); -} - - -void TextEditorActionHandler::initializeActions() -{ - if (!m_initialized) { - createActions(); - m_initialized = true; - } -} - void TextEditorActionHandler::createActions() { using namespace Core::Constants; @@ -369,6 +351,13 @@ void TextEditorActionHandler::createActions() m_modifyingActions << m_switchUtf8bomAction; m_modifyingActions << m_indentAction; m_modifyingActions << m_unindentAction; + + // set enabled state of optional actions + m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor); + m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor); + m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor); + m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor); + m_unfoldAllAction->setEnabled(m_optionalActions & UnCollapseAll); } QAction *TextEditorActionHandler::registerAction(const Core::Id &id, @@ -391,34 +380,16 @@ QAction *TextEditorActionHandler::registerAction(const Core::Id &id, return result; } -TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const -{ - Q_ASSERT(m_currentEditor != 0); - return m_currentEditor->isReadOnly() ? ReadOnlyMode : WriteMode; -} - void TextEditorActionHandler::updateActions() { - if (!m_currentEditor || !m_initialized) - return; - updateActions(updateMode()); -} - -void TextEditorActionHandler::updateActions(UpdateMode um) -{ + QTC_ASSERT(m_currentEditorWidget, return); + bool isWritable = !m_currentEditorWidget->isReadOnly(); foreach (QAction *a, m_modifyingActions) - a->setEnabled(um != ReadOnlyMode); - m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode); - m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode); - m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor); - m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor); - m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor); - m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor); - - m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll)); - m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace); - if (m_textWrappingAction) - m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping); + a->setEnabled(isWritable); + m_formatAction->setEnabled((m_optionalActions & Format) && isWritable); + m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && isWritable); + m_visualizeWhitespaceAction->setChecked(m_currentEditorWidget->displaySettings().m_visualizeWhitespace); + m_textWrappingAction->setChecked(m_currentEditorWidget->displaySettings().m_textWrapping); updateRedoAction(); updateUndoAction(); @@ -427,21 +398,22 @@ void TextEditorActionHandler::updateActions(UpdateMode um) void TextEditorActionHandler::updateRedoAction() { - if (m_redoAction) - m_redoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isRedoAvailable()); + QTC_ASSERT(m_currentEditorWidget, return); + m_redoAction->setEnabled(m_currentEditorWidget->document()->isRedoAvailable()); } void TextEditorActionHandler::updateUndoAction() { - if (m_undoAction) - m_undoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isUndoAvailable()); + QTC_ASSERT(m_currentEditorWidget, return); + m_undoAction->setEnabled(m_currentEditorWidget->document()->isUndoAvailable()); } void TextEditorActionHandler::updateCopyAction() { - const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection(); + QTC_ASSERT(m_currentEditorWidget, return); + const bool hasCopyableText = m_currentEditorWidget->textCursor().hasSelection(); if (m_cutAction) - m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode); + m_cutAction->setEnabled(hasCopyableText && !m_currentEditorWidget->isReadOnly()); if (m_copyAction) m_copyAction->setEnabled(hasCopyableText); } @@ -457,37 +429,37 @@ void TextEditorActionHandler::gotoAction() void TextEditorActionHandler::printAction() { - if (m_currentEditor) - m_currentEditor->print(Core::ICore::printer()); + if (m_currentEditorWidget) + m_currentEditorWidget->print(Core::ICore::printer()); } void TextEditorActionHandler::setVisualizeWhitespace(bool checked) { - if (m_currentEditor) { - DisplaySettings ds = m_currentEditor->displaySettings(); + if (m_currentEditorWidget) { + DisplaySettings ds = m_currentEditorWidget->displaySettings(); ds.m_visualizeWhitespace = checked; - m_currentEditor->setDisplaySettings(ds); + m_currentEditorWidget->setDisplaySettings(ds); } } void TextEditorActionHandler::setTextWrapping(bool checked) { - if (m_currentEditor) { - DisplaySettings ds = m_currentEditor->displaySettings(); + if (m_currentEditorWidget) { + DisplaySettings ds = m_currentEditorWidget->displaySettings(); ds.m_textWrapping = checked; - m_currentEditor->setDisplaySettings(ds); + m_currentEditorWidget->setDisplaySettings(ds); } } #define FUNCTION(funcname) void TextEditorActionHandler::funcname ()\ {\ - if (m_currentEditor)\ - m_currentEditor->funcname ();\ + if (m_currentEditorWidget)\ + m_currentEditorWidget->funcname ();\ } #define FUNCTION2(funcname, funcname2) void TextEditorActionHandler::funcname ()\ {\ - if (m_currentEditor)\ - m_currentEditor->funcname2 ();\ + if (m_currentEditorWidget)\ + m_currentEditorWidget->funcname2 ();\ } @@ -566,20 +538,21 @@ BaseTextEditorWidget *TextEditorActionHandler::resolveTextEditorWidget(Core::IEd void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) { - m_currentEditor = 0; + if (m_currentEditorWidget) + m_currentEditorWidget->disconnect(this); + m_currentEditorWidget = 0; + // don't need to do anything if the editor's context doesn't match + // (our actions will be disabled because our context will not be active) if (!editor || !editor->context().contains(m_contextId)) return; - BaseTextEditorWidget *baseEditor = resolveTextEditorWidget(editor); - - if (!baseEditor) - return; - m_currentEditor = baseEditor; + BaseTextEditorWidget *editorWidget = resolveTextEditorWidget(editor); + QTC_ASSERT(editorWidget, return); // editor has our context id, so shouldn't happen + m_currentEditorWidget = editorWidget; + connect(m_currentEditorWidget, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction())); + connect(m_currentEditorWidget, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction())); + connect(m_currentEditorWidget, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction())); + connect(m_currentEditorWidget, SIGNAL(readOnlyChanged()), this, SLOT(updateActions())); updateActions(); } - -const QPointer<BaseTextEditorWidget> &TextEditorActionHandler::currentEditor() const -{ - return m_currentEditor; -} diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 48f79408e0..eaea4735cf 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -68,20 +68,10 @@ public: explicit TextEditorActionHandler(Core::Id contextId, uint optionalActions = None); ~TextEditorActionHandler(); - void setupActions(BaseTextEditorWidget *editor); - - void initializeActions(); - -public slots: - void updateActions(); - void updateRedoAction(); - void updateUndoAction(); - void updateCopyAction(); - protected: virtual BaseTextEditorWidget *resolveTextEditorWidget(Core::IEditor *editor) const; - const QPointer<BaseTextEditorWidget> ¤tEditor() const; +private: QAction *registerAction(const Core::Id &id, const char *slot, bool scriptable = false, @@ -90,13 +80,14 @@ protected: const char *menueGroup = 0, Core::ActionContainer *container = 0); - enum UpdateMode { ReadOnlyMode, WriteMode }; - UpdateMode updateMode() const; - void createActions(); - void updateActions(UpdateMode um); private slots: + void updateActions(); + void updateRedoAction(); + void updateUndoAction(); + void updateCopyAction(); + void undoAction(); void redoAction(); void copyAction(); @@ -225,9 +216,8 @@ private: QList<QAction *> m_modifyingActions; uint m_optionalActions; - QPointer<BaseTextEditorWidget> m_currentEditor; + QPointer<BaseTextEditorWidget> m_currentEditorWidget; Core::Id m_contextId; - bool m_initialized; }; } // namespace TextEditor diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index a61e82f02a..2721eac7c3 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -203,11 +203,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe m_outlineFactory = new OutlineFactory; addAutoReleasedObject(m_outlineFactory); - // We have to initialize the actions because other plugins that - // depend upon the texteditorplugin expect that actions will be - // registered in the action manager at plugin initialization time. - m_editorFactory->actionHandler()->initializeActions(); - m_baseTextMarkRegistry = new BaseTextMarkRegistry(this); return true; @@ -246,14 +241,6 @@ void TextEditorPlugin::extensionsInitialized() this, SLOT(updateCurrentSelection(QString))); } -void TextEditorPlugin::initializeEditor(PlainTextEditorWidget *editor) -{ - // common actions - m_editorFactory->actionHandler()->setupActions(editor); - - TextEditorSettings::initializeEditor(editor); -} - void TextEditorPlugin::invokeCompletion() { Core::IEditor *iface = Core::EditorManager::currentEditor(); diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h index 3d19745a64..892c176816 100644 --- a/src/plugins/texteditor/texteditorplugin.h +++ b/src/plugins/texteditor/texteditorplugin.h @@ -64,8 +64,6 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); - void initializeEditor(PlainTextEditorWidget *editor); - PlainTextEditorFactory *editorFactory() { return m_editorFactory; } LineNumberFilter *lineNumberFilter() { return m_lineNumberFilter; } BaseTextMarkRegistry *baseTextMarkRegistry() { return m_baseTextMarkRegistry; } diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index 9d085ab639..85512b08fb 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -83,7 +83,6 @@ Core::IEditor *BaseVcsEditorFactory::createEditor(QWidget *parent) VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type, parent); vcsEditor->setMimeType(mimeTypes().front()); - d->m_editorHandler->setupActions(vcsEditor); // Wire font settings and set initial values connect(TextEditor::TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), |