File indexing completed on 2024-04-21 03:57:38
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 public: 0028 KateScriptAction(const QString &cmd, const QJsonObject &action, KTextEditor::ViewPrivate *view); 0029 0030 public: 0031 void exec(); 0032 0033 private: 0034 KTextEditor::ViewPrivate *m_view; 0035 QString m_command; 0036 bool m_interactive; 0037 }; 0038 0039 /** 0040 * Tools > Scripts menu 0041 * This menu is filled with the command line scripts exported 0042 * via the scripting support. 0043 */ 0044 class KateScriptActionMenu : public KActionMenu 0045 { 0046 public: 0047 KateScriptActionMenu(KTextEditor::ViewPrivate *view, const QString &text); 0048 ~KateScriptActionMenu() override; 0049 0050 void cleanup(); 0051 0052 public: 0053 void repopulate(); 0054 0055 private: 0056 KTextEditor::ViewPrivate *m_view; 0057 QList<QMenu *> m_menus; 0058 QList<QAction *> m_actions; 0059 }; 0060 0061 #endif