File indexing completed on 2024-04-28 15:30:41
0001 /* 0002 SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATE_SCRIPT_ACTION_H 0008 #define KATE_SCRIPT_ACTION_H 0009 0010 #include "katecommandlinescript.h" 0011 0012 #include <KActionMenu> 0013 0014 #include <QAction> 0015 0016 namespace KTextEditor 0017 { 0018 class ViewPrivate; 0019 } 0020 0021 /** 0022 * KateScriptAction is an action that executes a commandline-script 0023 * if triggered. It is shown in Tools > Scripts. 0024 */ 0025 class KateScriptAction : public QAction 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 KateScriptAction(const QString &cmd, const QJsonObject &action, KTextEditor::ViewPrivate *view); 0031 0032 public Q_SLOTS: 0033 void exec(); 0034 0035 private: 0036 KTextEditor::ViewPrivate *m_view; 0037 QString m_command; 0038 bool m_interactive; 0039 }; 0040 0041 /** 0042 * Tools > Scripts menu 0043 * This menu is filled with the command line scripts exported 0044 * via the scripting support. 0045 */ 0046 class KateScriptActionMenu : public KActionMenu 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 KateScriptActionMenu(KTextEditor::ViewPrivate *view, const QString &text); 0052 ~KateScriptActionMenu() override; 0053 0054 void cleanup(); 0055 0056 public Q_SLOTS: 0057 void repopulate(); 0058 0059 private: 0060 KTextEditor::ViewPrivate *m_view; 0061 QList<QMenu *> m_menus; 0062 QList<QAction *> m_actions; 0063 }; 0064 0065 #endif