1/*
2 SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_SCRIPT_ACTION_H
8#define KATE_SCRIPT_ACTION_H
9
10#include "katecommandlinescript.h"
11
12#include <KActionMenu>
13
14#include <QAction>
15
16namespace KTextEditor
17{
18class ViewPrivate;
19}
20
21/**
22 * KateScriptAction is an action that executes a commandline-script
23 * if triggered. It is shown in Tools > Scripts.
24 */
25class KateScriptAction : public QAction
26{
27public:
28 KateScriptAction(const QString &cmd, const QJsonObject &action, KTextEditor::ViewPrivate *view);
29
30public:
31 void exec();
32
33private:
34 KTextEditor::ViewPrivate *m_view;
35 QString m_command;
36 bool m_interactive;
37};
38
39/**
40 * Tools > Scripts menu
41 * This menu is filled with the command line scripts exported
42 * via the scripting support.
43 */
44class KateScriptActionMenu : public KActionMenu
45{
46public:
47 KateScriptActionMenu(KTextEditor::ViewPrivate *view, const QString &text);
48 ~KateScriptActionMenu() override;
49
50 void cleanup();
51
52public:
53 void repopulate();
54
55private:
56 KTextEditor::ViewPrivate *m_view;
57 QList<QMenu *> m_menus;
58 QList<QAction *> m_actions;
59};
60
61#endif
62

source code of ktexteditor/src/script/katescriptaction.h