diff --git a/src/app/syncbox16ch/syncbox16ch.cpp b/src/app/syncbox16ch/syncbox16ch.cpp index e7fe794..11604cb 100644 --- a/src/app/syncbox16ch/syncbox16ch.cpp +++ b/src/app/syncbox16ch/syncbox16ch.cpp @@ -1,14 +1,105 @@ #include "syncbox16ch.h" + #include "ui_syncbox16ch.h" -SyncBox16CH::SyncBox16CH(QWidget *parent) : - QWidget(parent), - ui(new Ui::SyncBox16CH) -{ - ui->setupUi(this); +typedef enum { + koutput_mode_continue_mode, + koutput_mode_pluse_mode, +} OutputMode_t; + +typedef enum { + // 自定义 + koutput_pluse_type_custom, + // 方波 + koutput_pluse_type_square_wave, +} OutputPluseType_t; + +static QString outputMode2Str(OutputMode_t mode) { + if (mode == koutput_mode_continue_mode) { + return "连续模式"; + } else if (mode == koutput_mode_pluse_mode) { + return "脉冲模式"; + } else { + return "未知模式"; + } +} + +static OutputMode_t outputModeStr2Enum(QString str) { + if (str == "连续模式") { + return koutput_mode_continue_mode; + } else if (str == "脉冲模式") { + return koutput_mode_pluse_mode; + } else { + return koutput_mode_continue_mode; + } +} + +static QString outputPluseType2Str(OutputPluseType_t type) { + if (type == koutput_pluse_type_custom) { + return "自定义"; + } else if (type == koutput_pluse_type_square_wave) { + return "方波"; + } else { + return "未知"; + } +} + +static OutputPluseType_t outputPluseTypeStr2Enum(QString str) { + if (str == "自定义") { + return koutput_pluse_type_custom; + } else if (str == "方波") { + return koutput_pluse_type_square_wave; + } else { + return koutput_pluse_type_custom; + } +} + +SyncBox16CH::SyncBox16CH(QWidget *parent) : QWidget(parent), ui(new Ui::SyncBox16CH) { + ui->setupUi(this); + + { + // + // ui->StateGB->hide(); + ui->OutputModeVal->addItem(outputMode2Str(koutput_mode_continue_mode)); + ui->OutputModeVal->addItem(outputMode2Str(koutput_mode_pluse_mode)); + + ui->OutputPluseTypeVal->addItem(outputPluseType2Str(koutput_pluse_type_custom)); + ui->OutputPluseTypeVal->addItem(outputPluseType2Str(koutput_pluse_type_square_wave)); + + ui->OutputPluseWidthVal->setText("1"); + ui->OutputPluseNumVal->setText("1"); + ui->OutputPluseFreqVal->setText("1000"); + } } -SyncBox16CH::~SyncBox16CH() -{ - delete ui; +SyncBox16CH::~SyncBox16CH() { delete ui; } + +void SyncBox16CH::on_OutputModeVal_currentIndexChanged(const QString &arg1) { onModeChange(); } +void SyncBox16CH::on_OutputPluseTypeVal_currentIndexChanged(const QString &arg1) { onModeChange(); } +void SyncBox16CH::onModeChange() { + OutputMode_t outputMode = outputModeStr2Enum(ui->OutputModeVal->currentText()); + OutputPluseType_t outputPluseType = outputPluseTypeStr2Enum(ui->OutputPluseTypeVal->currentText()); + + if (outputMode == koutput_mode_continue_mode) { + ui->OutputPluseNumVal->hide(); + ui->OutputPluseNumTag->hide(); + } else if (outputMode == koutput_mode_pluse_mode) { + ui->OutputPluseNumVal->show(); + ui->OutputPluseNumTag->show(); + } + + if (outputPluseType == koutput_pluse_type_custom) { + ui->OutputPluseWidthVal->show(); + ui->OutputPluseWidthTag->show(); + } else if (outputPluseType == koutput_pluse_type_square_wave) { + ui->OutputPluseWidthVal->hide(); + ui->OutputPluseWidthTag->hide(); + } +} + +void SyncBox16CH::on_SendButton_clicked() { + + + + } diff --git a/src/app/syncbox16ch/syncbox16ch.h b/src/app/syncbox16ch/syncbox16ch.h index 23cf3a8..0000c7b 100644 --- a/src/app/syncbox16ch/syncbox16ch.h +++ b/src/app/syncbox16ch/syncbox16ch.h @@ -14,8 +14,14 @@ class SyncBox16CH : public QWidget { explicit SyncBox16CH(QWidget *parent = nullptr); ~SyncBox16CH(); + private slots: + void on_OutputModeVal_currentIndexChanged(const QString &arg1); + void on_OutputPluseTypeVal_currentIndexChanged(const QString &arg1); + void on_SendButton_clicked(); + private: Ui::SyncBox16CH *ui; + void onModeChange(); }; #endif // SYNCBOX16CH_H diff --git a/src/app/syncbox16ch/syncbox16ch.ui b/src/app/syncbox16ch/syncbox16ch.ui index f4bce80..4f58f89 100644 --- a/src/app/syncbox16ch/syncbox16ch.ui +++ b/src/app/syncbox16ch/syncbox16ch.ui @@ -6,10 +6,16 @@ 0 0 - 439 - 323 + 454 + 338 + + + 16777215 + 16777215 + + Form @@ -203,7 +209,7 @@ 20 - 91 + 106