aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/haskell/haskellplugin.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-03-02 16:30:18 +0100
committerEike Ziller <eike.ziller@qt.io>2020-03-04 07:28:35 +0000
commitedf6d1f89d2c78832253a60d48d7f0cf05bec89c (patch)
treebe36b44396e9a60f251d0d65d8d39bca4ee64a3f /plugins/haskell/haskellplugin.cpp
parent8326e16c4ef1ae6bfa60b6495b6a1f5a8ec290f0 (diff)
Add button for running GHCi to editor tool bar
Loading the file automatically in GHCi, so it is directly available for investigation. Change-Id: I221d02ef2e17de465244df3a8b6674d84ba52c6e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'plugins/haskell/haskellplugin.cpp')
-rw-r--r--plugins/haskell/haskellplugin.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/haskell/haskellplugin.cpp b/plugins/haskell/haskellplugin.cpp
index 0aa187f..843a524 100644
--- a/plugins/haskell/haskellplugin.cpp
+++ b/plugins/haskell/haskellplugin.cpp
@@ -34,10 +34,14 @@
#include "optionspage.h"
#include "stackbuildstep.h"
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <projectexplorer/projectmanager.h>
#include <texteditor/snippets/snippetprovider.h>
+#include <QAction>
+
namespace Haskell {
namespace Internal {
@@ -56,6 +60,16 @@ HaskellPlugin::~HaskellPlugin()
delete d;
}
+static void registerGhciAction()
+{
+ QAction *action = new QAction(HaskellManager::tr("Run GHCi"), HaskellManager::instance());
+ Core::ActionManager::registerAction(action, Constants::A_RUN_GHCI);
+ QObject::connect(action, &QAction::triggered, HaskellManager::instance(), [] {
+ if (Core::IDocument *doc = Core::EditorManager::currentDocument())
+ HaskellManager::openGhci(doc->filePath());
+ });
+}
+
bool HaskellPlugin::initialize(const QStringList &arguments, QString *errorString)
{
Q_UNUSED(arguments)
@@ -72,6 +86,8 @@ bool HaskellPlugin::initialize(const QStringList &arguments, QString *errorStrin
HaskellManager::writeSettings(Core::ICore::settings());
});
+ registerGhciAction();
+
HaskellManager::readSettings(Core::ICore::settings());
return true;
}