aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vcsbase
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-06-29 14:22:17 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2015-07-08 07:41:43 +0000
commitce96a8b80ade646b77594deaee893eab6ab92897 (patch)
treed5c2c1085f42d5eab1c765c3c7644f3f4712c5f7 /src/plugins/vcsbase
parent81272a9fdb9a1779352cafba1da401448446d9a1 (diff)
CodePaster: Register type safe service object
Use Q_DECLARE_INTERFACE et al. This provides a way to have the dependency on code pasting optional in the using plugins (VCS, diff editor), while still being able to use a nice API to perform the pasting itself. Change-Id: Ia61e0066d552e45031f4aa7fd1f6693b68f92384 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r--src/plugins/vcsbase/vcsbase.qbs4
-rw-r--r--src/plugins/vcsbase/vcsbase_dependencies.pri2
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp21
3 files changed, 16 insertions, 11 deletions
diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs
index d278208224..857577a46a 100644
--- a/src/plugins/vcsbase/vcsbase.qbs
+++ b/src/plugins/vcsbase/vcsbase.qbs
@@ -13,6 +13,10 @@ QtcPlugin {
Depends { name: "ProjectExplorer" }
Depends { name: "CppTools" }
+ pluginRecommends: [
+ "CodePaster"
+ ]
+
files: [
"baseannotationhighlighter.cpp",
"baseannotationhighlighter.h",
diff --git a/src/plugins/vcsbase/vcsbase_dependencies.pri b/src/plugins/vcsbase/vcsbase_dependencies.pri
index 95a11af074..bff0f1dcf4 100644
--- a/src/plugins/vcsbase/vcsbase_dependencies.pri
+++ b/src/plugins/vcsbase/vcsbase_dependencies.pri
@@ -9,3 +9,5 @@ QTC_PLUGIN_DEPENDS += \
texteditor \
projectexplorer \
cpptools
+QTC_PLUGIN_RECOMMENDS += \
+ cpaster
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 8fe872caed..b5f3a848f4 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -40,6 +40,7 @@
#include <coreplugin/vcsmanager.h>
#include <coreplugin/patchtool.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <cpaster/codepasterservice.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/editorconfiguration.h>
#include <projectexplorer/projectexplorer.h>
@@ -953,9 +954,12 @@ void VcsBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e)
switch (d->m_parameters->type) {
case LogOutput: // log might have diff
case DiffOutput: {
- menu->addSeparator();
- connect(menu->addAction(tr("Send to CodePaster...")), &QAction::triggered,
- this, &VcsBaseEditorWidget::slotPaste);
+ if (ExtensionSystem::PluginManager::getObject<CodePaster::Service>()) {
+ // optional code pasting service
+ menu->addSeparator();
+ connect(menu->addAction(tr("Send to CodePaster...")), &QAction::triggered,
+ this, &VcsBaseEditorWidget::slotPaste);
+ }
menu->addSeparator();
// Apply/revert diff chunk.
const DiffChunk chunk = diffChunk(cursorForPosition(e->pos()));
@@ -1472,14 +1476,9 @@ QStringList VcsBaseEditorWidget::annotationPreviousVersions(const QString &) con
void VcsBaseEditorWidget::slotPaste()
{
// Retrieve service by soft dependency.
- QObject *pasteService =
- ExtensionSystem::PluginManager::getObjectByClassName(QLatin1String("CodePaster::CodePasterService"));
- if (pasteService) {
- QMetaObject::invokeMethod(pasteService, "postCurrentEditor");
- } else {
- QMessageBox::information(this, tr("Unable to Paste"),
- tr("Code pasting services are not available."));
- }
+ auto pasteService = ExtensionSystem::PluginManager::getObject<CodePaster::Service>();
+ QTC_ASSERT(pasteService, return);
+ pasteService->postCurrentEditor();
}
void VcsBaseEditorWidget::showProgressIndicator()