File indexing completed on 2024-04-28 16:54:23

0001 /*
0002     SPDX-FileCopyrightText: 2009 Dmitry Suzdalev <dimsuz@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDialog>
0010 
0011 class QLineEdit;
0012 class QCheckBox;
0013 class QTableView;
0014 
0015 class ClipAction;
0016 class ActionDetailModel;
0017 
0018 class EditActionDialog : public QDialog
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit EditActionDialog(QWidget *parent);
0024     ~EditActionDialog() override = default;
0025 
0026     /**
0027      * Sets the action this dialog will work with
0028      */
0029     void setAction(ClipAction *act, int commandIdxToSelect = -1);
0030 
0031 private Q_SLOTS:
0032     void onAddCommand();
0033     void onEditCommand();
0034     void onRemoveCommand();
0035     void onSelectionChanged();
0036     void slotAccepted();
0037 
0038 private:
0039     /**
0040      * Updates dialog's widgets according to values
0041      * in m_action.
0042      * If commandIdxToSelect != -1 this command will be preselected
0043      */
0044     void updateWidgets(int commandIdxToSelect);
0045 
0046     /**
0047      * Saves a values from widgets to action
0048      */
0049     void saveAction();
0050 
0051 private:
0052     QLineEdit *m_regExpEdit;
0053     QLineEdit *m_descriptionEdit;
0054     QCheckBox *m_automaticCheck;
0055 
0056     QTableView *m_commandList;
0057     QPushButton *m_addCommandPb;
0058     QPushButton *m_editCommandPb;
0059     QPushButton *m_removeCommandPb;
0060 
0061     ClipAction *m_action;
0062     ActionDetailModel *m_model;
0063 };