File indexing completed on 2024-05-19 05:54:12

0001 // This file was part of the KDE libraries
0002 // SPDX-FileCopyrightText: 2022 Tao Guo <guotao945@gmail.com>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #ifndef QUICKCOMMANDSWIDGET_H
0006 #define QUICKCOMMANDSWIDGET_H
0007 
0008 #include <QKeySequence>
0009 #include <QWidget>
0010 
0011 #include <memory>
0012 
0013 #include "quickcommanddata.h"
0014 #include "quickcommandsmodel.h"
0015 
0016 #include "session/SessionController.h"
0017 
0018 namespace Ui
0019 {
0020 class QuickCommandsWidget;
0021 }
0022 
0023 class QuickCommandsWidget : public QWidget
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit QuickCommandsWidget(QWidget *parent = nullptr);
0028     ~QuickCommandsWidget() override;
0029 
0030     Q_SLOT void viewMode();
0031 
0032     Q_SLOT void addMode();
0033 
0034     Q_SLOT void editMode();
0035 
0036     Q_SLOT void saveCommand();
0037 
0038     Q_SLOT void updateCommand();
0039 
0040     Q_SLOT void invokeCommand(const QModelIndex &idx);
0041     // Run a command from the currently selected Tree element
0042 
0043     Q_SLOT void runCommand();
0044     // Run the command from the Text Area
0045 
0046     Q_SLOT void indexSelected(const QModelIndex &idx);
0047 
0048     Q_SLOT void triggerRename();
0049 
0050     Q_SLOT void triggerDelete();
0051 
0052     Q_SLOT void createMenu(const QPoint &pos);
0053 
0054     Q_SLOT void runShellCheck();
0055 
0056     void setModel(QuickCommandsModel *model);
0057     void setCurrentController(Konsole::SessionController *controller);
0058 
0059     Q_SIGNAL void quickAccessShortcutChanged(QKeySequence shortcut);
0060 
0061 protected:
0062     void showEvent(QShowEvent *) override;
0063 
0064 private:
0065     QuickCommandData data() const;
0066     void prepareEdit();
0067     bool valid();
0068     struct Private;
0069 
0070     std::unique_ptr<Ui::QuickCommandsWidget> ui;
0071     std::unique_ptr<Private> priv;
0072 };
0073 
0074 #endif // QUICKCOMMANDSWIDGET_H