forked from qt-creator/qt-creator
Update "paste snippet" action state depending on editor.
This commit is contained in:
@@ -142,6 +142,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -160,6 +163,13 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown()
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
void CodepasterPlugin::updateActions()
|
||||
{
|
||||
const IEditor* editor = EditorManager::instance()->currentEditor();
|
||||
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
|
||||
m_postEditorAction->setEnabled(textEditor != 0);
|
||||
}
|
||||
|
||||
void CodepasterPlugin::postEditor()
|
||||
{
|
||||
const IEditor* editor = EditorManager::instance()->currentEditor();
|
||||
|
||||
@@ -70,6 +70,9 @@ public slots:
|
||||
const QString &content,
|
||||
bool error);
|
||||
|
||||
private slots:
|
||||
void updateActions();
|
||||
|
||||
private:
|
||||
void post(QString data, const QString &mimeType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user