From edf6d1f89d2c78832253a60d48d7f0cf05bec89c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 2 Mar 2020 16:30:18 +0100 Subject: 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 --- plugins/haskell/haskellplugin.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'plugins/haskell/haskellplugin.cpp') 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 +#include #include #include #include +#include + 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; } -- cgit v1.2.3