forked from qt-creator/qt-creator
CodePaster: Provide service for soft-dependent plugins.
Offer 'Paste' in VCSBase-Diff-Editor context menu. Make new protocol the default one if user changes it in view/paste dialogs.
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <extensionsystem/invoker.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -547,6 +549,9 @@ void VCSBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
break;
|
||||
case DiffOutput: {
|
||||
menu->addSeparator();
|
||||
connect(menu->addAction(tr("Send to CodePaster...")), SIGNAL(triggered()),
|
||||
this, SLOT(slotPaste()));
|
||||
menu->addSeparator();
|
||||
QAction *revertAction = menu->addAction(tr("Revert Chunk..."));
|
||||
const DiffChunk chunk = diffChunk(cursorForPosition(e->pos()));
|
||||
revertAction->setEnabled(canRevertDiffChunk(chunk));
|
||||
@@ -1038,6 +1043,20 @@ QStringList VCSBaseEditorWidget::annotationPreviousVersions(const QString &) con
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
void VCSBaseEditorWidget::slotPaste()
|
||||
{
|
||||
// Retrieve service by soft dependency.
|
||||
QObject *pasteService =
|
||||
ExtensionSystem::PluginManager::instance()
|
||||
->getObjectByClassName("CodePaster::CodePasterService");
|
||||
if (pasteService) {
|
||||
QMetaObject::invokeMethod(pasteService, "postCurrentEditor");
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Unable to Paste"),
|
||||
tr("Code pasting services are not available."));
|
||||
}
|
||||
}
|
||||
|
||||
bool VCSBaseEditorWidget::isRevertDiffChunkEnabled() const
|
||||
{
|
||||
return d->m_revertChunkEnabled;
|
||||
|
||||
Reference in New Issue
Block a user