2024-04-24 03:57:56 +00:00
|
|
|
|
#ifndef FORM_DEVICECONFIG_H
|
|
|
|
|
#define FORM_DEVICECONFIG_H
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
2024-04-25 03:06:28 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2024-04-24 10:08:14 +00:00
|
|
|
|
#include "sane/sane_ex.h"
|
2024-04-24 03:57:56 +00:00
|
|
|
|
|
2024-04-25 03:06:28 +00:00
|
|
|
|
struct DeviceConfig
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig()
|
2024-04-25 09:04:11 +00:00
|
|
|
|
{
|
|
|
|
|
valueType = 0;
|
|
|
|
|
intValue = 0;
|
|
|
|
|
doubleValue = 0;
|
|
|
|
|
boolValue = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 配置名
|
|
|
|
|
std::string name;
|
|
|
|
|
// 配置值
|
|
|
|
|
int valueType; // 0-无,1-字符串,2-整型,3-浮点,4-布尔
|
|
|
|
|
std::string stringValue;
|
|
|
|
|
int intValue;
|
|
|
|
|
double doubleValue;
|
|
|
|
|
bool boolValue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct DeviceConfigEx
|
|
|
|
|
{
|
|
|
|
|
DeviceConfigEx()
|
2024-04-25 03:06:28 +00:00
|
|
|
|
{
|
2024-04-29 09:29:39 +00:00
|
|
|
|
label = nullptr;
|
|
|
|
|
ctrl = nullptr;
|
|
|
|
|
ctrlWidget = nullptr;
|
|
|
|
|
id = -1;
|
|
|
|
|
name.clear();
|
|
|
|
|
title.clear();
|
2024-04-30 02:39:08 +00:00
|
|
|
|
hide = false;
|
2024-04-30 03:53:18 +00:00
|
|
|
|
readOnly = false;
|
2024-04-29 09:29:39 +00:00
|
|
|
|
|
2024-04-25 03:06:28 +00:00
|
|
|
|
valueType = 0;
|
2024-04-29 09:29:39 +00:00
|
|
|
|
stringValue.clear();
|
2024-04-25 03:06:28 +00:00
|
|
|
|
intValue = 0;
|
|
|
|
|
doubleValue = 0;
|
|
|
|
|
boolValue = false;
|
|
|
|
|
|
|
|
|
|
rangeType = 0;
|
2024-04-29 09:29:39 +00:00
|
|
|
|
stringValueList.clear();
|
|
|
|
|
intValueList.clear();
|
|
|
|
|
doubleValueList.clear();
|
2024-04-25 03:06:28 +00:00
|
|
|
|
intValueMin = 0;
|
|
|
|
|
intValueMax = 0;
|
|
|
|
|
doubleValueMin = 0;
|
|
|
|
|
doubleValueMax = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-29 09:29:39 +00:00
|
|
|
|
// 控件
|
|
|
|
|
QWidget *label;
|
|
|
|
|
QWidget *ctrl;
|
|
|
|
|
QWidget *ctrlWidget;
|
2024-04-25 03:06:28 +00:00
|
|
|
|
// 配置名
|
2024-04-28 10:15:51 +00:00
|
|
|
|
int id;
|
2024-04-25 03:06:28 +00:00
|
|
|
|
std::string name;
|
|
|
|
|
std::string title;
|
2024-04-30 02:39:08 +00:00
|
|
|
|
bool hide;
|
2024-04-30 03:53:18 +00:00
|
|
|
|
bool readOnly;
|
2024-04-25 03:06:28 +00:00
|
|
|
|
|
2024-04-25 08:06:21 +00:00
|
|
|
|
// 配置值
|
2024-04-25 03:06:28 +00:00
|
|
|
|
int valueType; // 0-无,1-字符串,2-整型,3-浮点,4-布尔
|
|
|
|
|
std::string stringValue;
|
|
|
|
|
int intValue;
|
|
|
|
|
double doubleValue;
|
|
|
|
|
bool boolValue;
|
|
|
|
|
|
2024-04-25 08:06:21 +00:00
|
|
|
|
// 配置取值范围
|
2024-04-25 03:06:28 +00:00
|
|
|
|
int rangeType; // 0-无,1-字符串列表,2-整型列表,3-浮点数列表,4-整型范围,5-浮点数范围
|
|
|
|
|
std::vector<std::string> stringValueList;
|
|
|
|
|
std::vector<int> intValueList;
|
|
|
|
|
std::vector<double> doubleValueList;
|
|
|
|
|
int intValueMin;
|
|
|
|
|
int intValueMax;
|
|
|
|
|
double doubleValueMin;
|
|
|
|
|
double doubleValueMax;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct DeviceConfigsGroup
|
|
|
|
|
{
|
|
|
|
|
std::string groupTitle;
|
2024-04-25 09:04:11 +00:00
|
|
|
|
std::vector<DeviceConfigEx> deviceConfigs;
|
2024-04-25 03:06:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-04-24 03:57:56 +00:00
|
|
|
|
class Form_DeviceConfig : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2024-04-25 03:06:28 +00:00
|
|
|
|
explicit Form_DeviceConfig(SANE_Handle devHandle, const std::vector<DeviceConfig>& deviceConfigs, QWidget *parent = nullptr);
|
2024-04-24 03:57:56 +00:00
|
|
|
|
~Form_DeviceConfig();
|
|
|
|
|
|
2024-04-25 03:06:28 +00:00
|
|
|
|
std::vector<DeviceConfig> GetDeviceConfigs();
|
2024-04-24 03:57:56 +00:00
|
|
|
|
|
2024-04-24 10:08:14 +00:00
|
|
|
|
private:
|
2024-04-29 09:29:39 +00:00
|
|
|
|
void Init(const std::vector<DeviceConfig>& deviceConfigs);
|
|
|
|
|
void Update(int ignoreId);
|
2024-04-26 06:11:33 +00:00
|
|
|
|
|
2024-04-29 09:29:39 +00:00
|
|
|
|
protected:
|
|
|
|
|
virtual bool eventFilter(QObject *target, QEvent *event) override;
|
2024-04-25 08:06:21 +00:00
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void on_defaultBtn_clicked();
|
2024-04-29 09:29:39 +00:00
|
|
|
|
void on_string_list_comboBoxClicked();
|
|
|
|
|
void on_int_list_comboBoxClicked();
|
|
|
|
|
void on_double_list_comboBoxClicked();
|
|
|
|
|
void on_int_sliderClicked(int value);
|
|
|
|
|
void on_double_sliderClicked(int value);
|
|
|
|
|
void on_relate_spinBoxClicked(int value);
|
|
|
|
|
void on_relate_doubleSpinboxClicked(double value);
|
|
|
|
|
void on_string_comboBoxClicked();
|
2024-04-26 06:11:33 +00:00
|
|
|
|
void on_spinBoxClicked(int value);
|
2024-04-28 10:15:51 +00:00
|
|
|
|
void on_checkedClicked();
|
2024-04-26 06:11:33 +00:00
|
|
|
|
|
2024-04-24 03:57:56 +00:00
|
|
|
|
private:
|
2024-04-28 10:15:51 +00:00
|
|
|
|
SANE_Handle m_devHandle;
|
2024-04-29 09:29:39 +00:00
|
|
|
|
std::vector<DeviceConfig> m_defDeviceConfigs; // 默认配置值
|
|
|
|
|
std::vector<DeviceConfigsGroup> m_deviceConfigsGroups; // 当前配置信息
|
2024-04-24 03:57:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // FORM_DEVICECONFIG_H
|