2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
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);
|
2024-04-02 14:32:52 +08:00
|
|
|
PToolItem getTool(int row);
|
|
|
|
void updateTool(int row, PToolItem item);
|
|
|
|
void removeTool(int row);
|
2021-10-08 00:06:41 +08:00
|
|
|
|
|
|
|
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
|
|
|
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:
|
2023-01-24 09:17:27 +08:00
|
|
|
void finishEditing(bool askSave, const QModelIndex& itemIndex=QModelIndex());
|
|
|
|
void prepareEdit(const PToolItem& PToolItem);
|
|
|
|
void showEditPanel(bool isShow);
|
2021-10-08 00:06:41 +08:00
|
|
|
private slots:
|
2023-01-24 09:17:27 +08:00
|
|
|
void onEdited();
|
|
|
|
void onToolsCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
2021-10-08 00:06:41 +08:00
|
|
|
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;
|
2023-01-24 09:17:27 +08:00
|
|
|
bool mEdited;
|
2024-04-02 14:32:52 +08:00
|
|
|
int mCurrentEditingRow;
|
2021-10-08 00:06:41 +08:00
|
|
|
|
|
|
|
// 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
|