2021-10-07 08:34:10 +08:00
|
|
|
#ifndef TOOLSGENERALWIDGET_H
|
|
|
|
#define TOOLSGENERALWIDGET_H
|
|
|
|
|
2021-10-08 00:06:41 +08:00
|
|
|
#include <QAbstractListModel>
|
2021-10-07 08:34:10 +08:00
|
|
|
#include <QWidget>
|
2021-10-08 00:06:41 +08:00
|
|
|
#include "settingswidget.h"
|
|
|
|
#include "../widgets/macroinfomodel.h"
|
|
|
|
#include "../toolsmanager.h"
|
2021-10-07 08:34:10 +08:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ToolsGeneralWidget;
|
|
|
|
}
|
|
|
|
|
2021-10-08 00:06:41 +08:00
|
|
|
class ToolsModel: public QAbstractListModel {
|
|
|
|
public:
|
|
|
|
explicit ToolsModel(QObject* parent = nullptr);
|
|
|
|
|
|
|
|
const QList<PToolItem> &tools() const;
|
|
|
|
void setTools(const QList<PToolItem> &newTools);
|
|
|
|
void addTool(PToolItem item);
|
|
|
|
PToolItem getTool(int index);
|
|
|
|
void removeTool(int index);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<PToolItem> mTools;
|
|
|
|
|
|
|
|
// QAbstractItemModel interface
|
|
|
|
public:
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ToolsGeneralWidget : public SettingsWidget
|
2021-10-07 08:34:10 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-10-08 00:06:41 +08:00
|
|
|
enum class EditType {
|
|
|
|
Add,
|
|
|
|
Edit,
|
|
|
|
None
|
|
|
|
};
|
|
|
|
explicit ToolsGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
2021-10-07 08:34:10 +08:00
|
|
|
~ToolsGeneralWidget();
|
2021-10-08 00:06:41 +08:00
|
|
|
private:
|
|
|
|
void onToolsCurrentChanged();
|
|
|
|
private:
|
|
|
|
void finishEditing(bool askSave);
|
|
|
|
void prepareEdit();
|
|
|
|
private slots:
|
|
|
|
void updateDemo();
|
|
|
|
void on_btnAdd_clicked();
|
|
|
|
|
|
|
|
void on_btnEditOk_clicked();
|
|
|
|
|
|
|
|
void on_btnEditCancel_clicked();
|
|
|
|
|
|
|
|
void on_btnRemove_clicked();
|
|
|
|
|
|
|
|
void on_btnInsertMacro_clicked();
|
|
|
|
|
|
|
|
void on_btnBrowseWorkingDirectory_clicked();
|
|
|
|
|
|
|
|
void on_btnBrowseProgram_clicked();
|
2021-10-07 08:34:10 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ToolsGeneralWidget *ui;
|
2021-10-08 00:06:41 +08:00
|
|
|
MacroInfoModel mMacroInfoModel;
|
|
|
|
ToolsModel mToolsModel;
|
|
|
|
EditType mEditType;
|
|
|
|
|
|
|
|
// SettingsWidget interface
|
|
|
|
protected:
|
|
|
|
void doLoad() override;
|
|
|
|
void doSave() override;
|
2021-12-23 09:11:58 +08:00
|
|
|
|
|
|
|
// SettingsWidget interface
|
|
|
|
protected:
|
|
|
|
void updateIcons(const QSize &size) override;
|
2021-10-07 08:34:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TOOLSGENERALWIDGET_H
|