#ifndef FORM_DEVICECONFIG_H #define FORM_DEVICECONFIG_H #include #include #include #include "sane/sane_ex.h" struct DeviceConfig { DeviceConfig() { 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() { label = nullptr; ctrl = nullptr; ctrlWidget = nullptr; id = -1; name.clear(); title.clear(); hide = false; valueType = 0; stringValue.clear(); intValue = 0; doubleValue = 0; boolValue = false; 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; // 配置值 int valueType; // 0-无,1-字符串,2-整型,3-浮点,4-布尔 std::string stringValue; int intValue; double doubleValue; bool boolValue; // 配置取值范围 int rangeType; // 0-无,1-字符串列表,2-整型列表,3-浮点数列表,4-整型范围,5-浮点数范围 std::vector stringValueList; std::vector intValueList; std::vector doubleValueList; int intValueMin; int intValueMax; double doubleValueMin; double doubleValueMax; }; struct DeviceConfigsGroup { std::string groupTitle; std::vector deviceConfigs; }; class Form_DeviceConfig : public QWidget { Q_OBJECT public: explicit Form_DeviceConfig(SANE_Handle devHandle, const std::vector& deviceConfigs, QWidget *parent = nullptr); ~Form_DeviceConfig(); std::vector GetDeviceConfigs(); private: void Init(const std::vector& deviceConfigs); void Update(int ignoreId); protected: virtual bool eventFilter(QObject *target, QEvent *event) override; private slots: 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_checkedClicked(); private: SANE_Handle m_devHandle; std::vector m_defDeviceConfigs; // 默认配置值 std::vector m_deviceConfigsGroups; // 当前配置信息 }; #endif // FORM_DEVICECONFIG_H