summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/coreplugin.cpp
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@theqtcompany.com>2015-08-03 12:44:48 +0200
committerDaniel Teske <daniel.teske@theqtcompany.com>2015-08-31 14:57:09 +0000
commitcac53ea41f98e5cf0b81ca3eea696940b98caeb3 (patch)
treee28c920bd7d553af02d5d7718897acfed06e4d0b /src/plugins/coreplugin/coreplugin.cpp
parent06483d3720e385adb16d6b84592e890239ef2020 (diff)
downloadqt-creator-cac53ea41f98e5cf0b81ca3eea696940b98caeb3.tar.gz
Utils::PathChooser: Allow the core plugin to extend the context menu
And then use this to add the "Open in Graphical Shell" and "Open in Terminal" actions. Those actions cannot be implemented in Utils directly since the Core::FileUtils depends on the Options dialog. This affects all PathChoosers, and there's currently no way for a PathChooser to opt out or have a different context menu. That can be added at a later point. Change-Id: I22121c19d66f08785381c7e0bca5317628eb6342 Task-number: QTCREATORBUG-14736 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/coreplugin/coreplugin.cpp')
-rw-r--r--src/plugins/coreplugin/coreplugin.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp
index 7d75bb79eb..f52fd82849 100644
--- a/src/plugins/coreplugin/coreplugin.cpp
+++ b/src/plugins/coreplugin/coreplugin.cpp
@@ -44,9 +44,11 @@
#include <coreplugin/find/findplugin.h>
#include <coreplugin/locator/locator.h>
#include <coreplugin/coreconstants.h>
+#include <coreplugin/fileutils.h>
#include <extensionsystem/pluginerroroverview.h>
#include <extensionsystem/pluginmanager.h>
+#include <utils/pathchooser.h>
#include <utils/macroexpander.h>
#include <utils/savefile.h>
#include <utils/stringutils.h>
@@ -57,6 +59,7 @@
#include <QDebug>
#include <QDateTime>
#include <QDir>
+#include <QMenu>
using namespace Core;
using namespace Core::Internal;
@@ -229,6 +232,8 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
// Make sure all wizards are there when the user might access the keyboard shortcuts:
connect(ICore::instance(), &ICore::optionsDialogRequested, []() { IWizardFactory::allWizardFactories(); });
+ Utils::PathChooser::setAboutToShowContextMenuHandler(&CorePlugin::addToPathChooserContextMenu);
+
return success;
}
@@ -271,6 +276,27 @@ void CorePlugin::fileOpenRequest(const QString &f)
remoteCommand(QStringList(), QString(), QStringList(f));
}
+void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QMenu *menu)
+{
+ QList<QAction*> actions = menu->actions();
+ QAction *firstAction = actions.isEmpty() ? nullptr : actions.first();
+
+ auto *showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), menu);
+ connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser]() {
+ Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->path());
+ });
+ menu->insertAction(firstAction, showInGraphicalShell);
+
+ auto *showInTerminal = new QAction(Core::FileUtils::msgTerminalAction(), menu);
+ connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser]() {
+ Core::FileUtils::openTerminal(pathChooser->path());
+ });
+ menu->insertAction(firstAction, showInTerminal);
+
+ if (firstAction)
+ menu->insertSeparator(firstAction);
+}
+
ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
{
m_findPlugin->aboutToShutdown();