From d78cc7201dfd9687490d6f24dd208bb039c64d47 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 16 Mar 2011 10:24:30 +0100 Subject: [PATCH] Codepaster: Always enable send to codepaster menu action. As the dialog is editable, now. Task-number: QTCREATORBUG-4060 --- src/plugins/cpaster/cpasterplugin.cpp | 31 ++++++++++----------------- src/plugins/cpaster/cpasterplugin.h | 3 --- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 5ceef87b4b6..4ae5d18e8c6 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -142,9 +142,6 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch())); cpContainer->addAction(command); - connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), - this, SLOT(updateActions())); - updateActions(); return true; } @@ -163,25 +160,19 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown() return SynchronousShutdown; } -void CodepasterPlugin::updateActions() -{ - const IEditor* editor = EditorManager::instance()->currentEditor(); - const BaseTextEditor *textEditor = qobject_cast(editor); - m_postEditorAction->setEnabled(textEditor != 0); -} - void CodepasterPlugin::postEditor() { - const IEditor* editor = EditorManager::instance()->currentEditor(); - const BaseTextEditor *textEditor = qobject_cast(editor); - if (!textEditor) - return; - - QString data = textEditor->selectedText(); - if (data.isEmpty()) - data = textEditor->contents(); - if (!data.isEmpty()) - post(data, textEditor->editorWidget()->mimeType()); + QString data; + QString mimeType; + if (const IEditor* editor = EditorManager::instance()->currentEditor()) { + if (const BaseTextEditor *textEditor = qobject_cast(editor)) { + data = textEditor->selectedText(); + if (data.isEmpty()) + data = textEditor->contents(); + mimeType = textEditor->editorWidget()->mimeType(); + } + } + post(data, mimeType); } void CodepasterPlugin::postClipboard() diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h index 190445c57b0..591daa6ef29 100644 --- a/src/plugins/cpaster/cpasterplugin.h +++ b/src/plugins/cpaster/cpasterplugin.h @@ -70,9 +70,6 @@ public slots: const QString &content, bool error); -private slots: - void updateActions(); - private: void post(QString data, const QString &mimeType);