code_app/app/scantool/form_deviceconfig.h

156 lines
3.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef FORM_DEVICECONFIG_H
#define FORM_DEVICECONFIG_H
#include <QWidget>
#include <string>
#include <vector>
#include <QMessageBox>
#include "base/HGDef.h"
#include "sane/sane_ex.h"
#include "sane/sane_option_definitions.h"
#include "setpicclrtool.h"
struct DeviceConfig
{
DeviceConfig()
{
valueType = 0;
intValue = 0;
doubleValue = 0;
boolValue = false;
gammaValue = {0};
}
// 配置名
std::string name;
// 配置值
int valueType; // 0-无1-字符串2-整型3-浮点4-布尔5-gamma
std::string stringValue;
int intValue;
double doubleValue;
bool boolValue;
SANE_Gamma gammaValue;
};
struct DeviceConfigEx
{
DeviceConfigEx()
{
label = nullptr;
ctrl = nullptr;
ctrlWidget = nullptr;
id = 0;
name.clear();
title.clear();
hide = false;
readOnly = false;
valueType = 0;
stringValue.clear();
defStringValue.clear();
intValue = 0;
defIntValue = 0;
doubleValue = 0;
defDoubleValue = 0;
boolValue = false;
defBoolValue = false;
gammaValue = {0};
defGammaValue = {0};
rangeType = 0;
stringValueList.clear();
intValueList.clear();
doubleValueList.clear();
intValueMin = 0;
intValueMax = 0;
doubleValueMin = 0;
doubleValueMax = 0;
}
// 控件
QWidget *label;
QWidget *ctrl;
QWidget *ctrlWidget;
// 配置名
int id;
std::string name;
std::string title;
bool hide;
bool readOnly;
// 配置值
int valueType; // 0-无1-字符串2-整型3-浮点4-布尔5-gamma
std::string stringValue;
std::string defStringValue;
int intValue;
int defIntValue;
double doubleValue;
double defDoubleValue;
bool boolValue;
bool defBoolValue;
SANE_Gamma gammaValue;
SANE_Gamma defGammaValue;
// 配置取值范围
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;
};
Q_DECLARE_METATYPE(DeviceConfigEx*)
struct DeviceConfigsGroup
{
std::string groupTitle;
std::vector<DeviceConfigEx> deviceConfigs;
};
class Form_DeviceConfig : public QWidget
{
Q_OBJECT
public:
explicit Form_DeviceConfig(SANE_Handle devHandle, const std::vector<DeviceConfig>& deviceConfigs, QWidget *parent = nullptr);
~Form_DeviceConfig();
std::vector<DeviceConfig> GetDeviceConfigs();
private:
void Init(const std::vector<DeviceConfig>& deviceConfigs);
void Update(int ignoreId);
void PopupMsgBox(const QString& content);
protected:
virtual bool eventFilter(QObject *target, QEvent *event) override;
private slots:
void on_closeDevice();
void on_defaultBtn_clicked();
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();
void on_spinBoxClicked(int value);
void on_customGamma_checkedClicked();
void on_customGammaBtn_clicked();
void on_checkedClicked();
private:
setPicClrTool *m_clrToolDlg;
QMessageBox *m_qMessageBoxDlg;
SANE_Handle m_devHandle;
int m_defButtonId;
std::vector<DeviceConfigsGroup> m_deviceConfigsGroups; // 当前配置信息
};
#endif // FORM_DEVICECONFIG_H