diff --git a/plugins/scratchpad/CMakeLists.txt b/plugins/scratchpad/CMakeLists.txt
--- a/plugins/scratchpad/CMakeLists.txt
+++ b/plugins/scratchpad/CMakeLists.txt
@@ -7,6 +7,8 @@
ki18n_wrap_ui(scratchpad_SRCS scratchpadview.ui)
+qt5_add_resources(scratchpad_SRCS kdevscratchpad.qrc)
+
declare_qt_logging_category(scratchpad_SRCS
TYPE PLUGIN
IDENTIFIER PLUGIN_SCRATCHPAD
diff --git a/plugins/scratchpad/kdevscratchpad.qrc b/plugins/scratchpad/kdevscratchpad.qrc
new file mode 100644
--- /dev/null
+++ b/plugins/scratchpad/kdevscratchpad.qrc
@@ -0,0 +1,6 @@
+
+
+
+ kdevscratchpad.rc
+
+
diff --git a/plugins/scratchpad/kdevscratchpad.rc b/plugins/scratchpad/kdevscratchpad.rc
new file mode 100644
--- /dev/null
+++ b/plugins/scratchpad/kdevscratchpad.rc
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/plugins/scratchpad/scratchpad.h b/plugins/scratchpad/scratchpad.h
--- a/plugins/scratchpad/scratchpad.h
+++ b/plugins/scratchpad/scratchpad.h
@@ -31,6 +31,7 @@
class QModelIndex;
class QFileInfo;
class QString;
+class QAction;
class Scratchpad
: public KDevelop::IPlugin
@@ -42,8 +43,12 @@
QStandardItemModel* model() const;
+ QAction* runAction() const;
+
static QString dataDirectory();
+ void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override;
+
enum ExtraRoles {
FullPathRole = Qt::UserRole + 1,
RunCommandRole,
@@ -66,6 +71,8 @@
ScratchpadToolViewFactory* m_factory;
QStandardItemModel* m_model;
QFileIconProvider m_iconProvider;
+
+ QAction* const m_runAction;
};
#endif // SCRATCHPAD_H
diff --git a/plugins/scratchpad/scratchpad.cpp b/plugins/scratchpad/scratchpad.cpp
--- a/plugins/scratchpad/scratchpad.cpp
+++ b/plugins/scratchpad/scratchpad.cpp
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
#include
#include
@@ -108,6 +109,7 @@
: KDevelop::IPlugin(QStringLiteral("scratchpad"), parent)
, m_factory(new ScratchpadToolViewFactory(this))
, m_model(new QStandardItemModel(this))
+ , m_runAction(new QAction(this))
{
Q_UNUSED(args);
@@ -258,4 +260,21 @@
mimeCommands().writeEntry(QFileInfo(index.data().toString()).suffix(), command);
}
+QAction* Scratchpad::runAction() const
+{
+ return m_runAction;
+}
+
+void Scratchpad::createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions)
+{
+ Q_UNUSED(window);
+
+ xmlFile = QStringLiteral("kdevscratchpad.rc");
+
+ // add to gui action collection, so that the shorcut is easily configurable
+ // action setup done in ScratchpadView
+ actions.addAction(QStringLiteral("run_scratch"), m_runAction);
+}
+
+
#include "scratchpad.moc"
diff --git a/plugins/scratchpad/scratchpadview.cpp b/plugins/scratchpad/scratchpadview.cpp
--- a/plugins/scratchpad/scratchpadview.cpp
+++ b/plugins/scratchpad/scratchpadview.cpp
@@ -159,7 +159,9 @@
addAction(action);
m_itemActions.push_back(action);
- action = new QAction(QIcon::fromTheme(QStringLiteral("media-playback-start")), i18n("Run Scratch"), this);
+ action = m_scratchpad->runAction();
+ action->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
+ action->setText(i18n("Run Scratch"));
connect(action, &QAction::triggered, this, &ScratchpadView::runSelectedScratch);
addAction(action);
m_itemActions.push_back(action);