diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 7b4b063..24ebb24 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -221,6 +221,25 @@ updateDeviceWidget(); } } +QList CounterWindowRT::getClockNumList() +{ + QJsonObject clockListRes = httpReq->initDeviceList("00", "sys_group_clock"); + QList clockNumList; + if (clockListRes.value("code").toInt() == 200) + { + // 将获取到的设备绘制到表格中 + QJsonArray devArray = clockListRes.value("data").toArray(); + for (int i = 0; i < devArray.size(); i++) + { + // 接口返回的device对象 + QJsonObject clockItem = devArray.at(i).toObject(); + QString clockNum = clockItem.value("deviceNo").toString(); // + clockNumList.append(clockNum); + } + } + + return clockNumList; +} void CounterWindowRT::getChannelList(QString deviceId) { // 查询计数器的通道 @@ -531,6 +550,7 @@ settingForm->setWindowModality(Qt::ApplicationModal); settingForm->setWindowTitle("系统设置"); settingForm->initCounterSelect(); + settingForm->initClockNumSelect(getClockNumList()); settingForm->show(); } void CounterWindowRT::on_btnMenuMin_clicked() diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 7b4b063..24ebb24 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -221,6 +221,25 @@ updateDeviceWidget(); } } +QList CounterWindowRT::getClockNumList() +{ + QJsonObject clockListRes = httpReq->initDeviceList("00", "sys_group_clock"); + QList clockNumList; + if (clockListRes.value("code").toInt() == 200) + { + // 将获取到的设备绘制到表格中 + QJsonArray devArray = clockListRes.value("data").toArray(); + for (int i = 0; i < devArray.size(); i++) + { + // 接口返回的device对象 + QJsonObject clockItem = devArray.at(i).toObject(); + QString clockNum = clockItem.value("deviceNo").toString(); // + clockNumList.append(clockNum); + } + } + + return clockNumList; +} void CounterWindowRT::getChannelList(QString deviceId) { // 查询计数器的通道 @@ -531,6 +550,7 @@ settingForm->setWindowModality(Qt::ApplicationModal); settingForm->setWindowTitle("系统设置"); settingForm->initCounterSelect(); + settingForm->initClockNumSelect(getClockNumList()); settingForm->show(); } void CounterWindowRT::on_btnMenuMin_clicked() diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index 256b7ac..d934324 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -61,6 +61,7 @@ int initHttpToken(); void getDeviceList(); + QList getClockNumList(); void getChannelList(QString deviceId); void initDevAndChannelForm(int count); diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 7b4b063..24ebb24 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -221,6 +221,25 @@ updateDeviceWidget(); } } +QList CounterWindowRT::getClockNumList() +{ + QJsonObject clockListRes = httpReq->initDeviceList("00", "sys_group_clock"); + QList clockNumList; + if (clockListRes.value("code").toInt() == 200) + { + // 将获取到的设备绘制到表格中 + QJsonArray devArray = clockListRes.value("data").toArray(); + for (int i = 0; i < devArray.size(); i++) + { + // 接口返回的device对象 + QJsonObject clockItem = devArray.at(i).toObject(); + QString clockNum = clockItem.value("deviceNo").toString(); // + clockNumList.append(clockNum); + } + } + + return clockNumList; +} void CounterWindowRT::getChannelList(QString deviceId) { // 查询计数器的通道 @@ -531,6 +550,7 @@ settingForm->setWindowModality(Qt::ApplicationModal); settingForm->setWindowTitle("系统设置"); settingForm->initCounterSelect(); + settingForm->initClockNumSelect(getClockNumList()); settingForm->show(); } void CounterWindowRT::on_btnMenuMin_clicked() diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index 256b7ac..d934324 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -61,6 +61,7 @@ int initHttpToken(); void getDeviceList(); + QList getClockNumList(); void getChannelList(QString deviceId); void initDevAndChannelForm(int count); diff --git a/CounterRealTime/QLineEditDblClick.cpp b/CounterRealTime/QLineEditDblClick.cpp new file mode 100644 index 0000000..68bfd94 --- /dev/null +++ b/CounterRealTime/QLineEditDblClick.cpp @@ -0,0 +1,17 @@ +#include "QLineEditDblClick.h" + +QLineEditDblClick::QLineEditDblClick(QWidget *parent) : QLineEdit(parent) +{ + +} + +QLineEditDblClick::~QLineEditDblClick() +{ + +} + +void QLineEditDblClick::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit doubleClicked(); +} + diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 7b4b063..24ebb24 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -221,6 +221,25 @@ updateDeviceWidget(); } } +QList CounterWindowRT::getClockNumList() +{ + QJsonObject clockListRes = httpReq->initDeviceList("00", "sys_group_clock"); + QList clockNumList; + if (clockListRes.value("code").toInt() == 200) + { + // 将获取到的设备绘制到表格中 + QJsonArray devArray = clockListRes.value("data").toArray(); + for (int i = 0; i < devArray.size(); i++) + { + // 接口返回的device对象 + QJsonObject clockItem = devArray.at(i).toObject(); + QString clockNum = clockItem.value("deviceNo").toString(); // + clockNumList.append(clockNum); + } + } + + return clockNumList; +} void CounterWindowRT::getChannelList(QString deviceId) { // 查询计数器的通道 @@ -531,6 +550,7 @@ settingForm->setWindowModality(Qt::ApplicationModal); settingForm->setWindowTitle("系统设置"); settingForm->initCounterSelect(); + settingForm->initClockNumSelect(getClockNumList()); settingForm->show(); } void CounterWindowRT::on_btnMenuMin_clicked() diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index 256b7ac..d934324 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -61,6 +61,7 @@ int initHttpToken(); void getDeviceList(); + QList getClockNumList(); void getChannelList(QString deviceId); void initDevAndChannelForm(int count); diff --git a/CounterRealTime/QLineEditDblClick.cpp b/CounterRealTime/QLineEditDblClick.cpp new file mode 100644 index 0000000..68bfd94 --- /dev/null +++ b/CounterRealTime/QLineEditDblClick.cpp @@ -0,0 +1,17 @@ +#include "QLineEditDblClick.h" + +QLineEditDblClick::QLineEditDblClick(QWidget *parent) : QLineEdit(parent) +{ + +} + +QLineEditDblClick::~QLineEditDblClick() +{ + +} + +void QLineEditDblClick::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit doubleClicked(); +} + diff --git a/CounterRealTime/QLineEditDblClick.h b/CounterRealTime/QLineEditDblClick.h new file mode 100644 index 0000000..145e8b2 --- /dev/null +++ b/CounterRealTime/QLineEditDblClick.h @@ -0,0 +1,19 @@ +#ifndef QLINEEDITDBLCLICK_H +#define QLINEEDITDBLCLICK_H + +#include +#include + +class QLineEditDblClick : public QLineEdit +{ + Q_OBJECT +public: + QLineEditDblClick(QWidget * parent = 0); + ~QLineEditDblClick(); + void mouseDoubleClickEvent(QMouseEvent * event); + +signals: + void doubleClicked(); +}; + +#endif // QLINEEDITDBLCLICK_H diff --git a/CounterRealTime/CounterRealTime.pro b/CounterRealTime/CounterRealTime.pro index dd3d1eb..c323f04 100644 --- a/CounterRealTime/CounterRealTime.pro +++ b/CounterRealTime/CounterRealTime.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp SOURCES += QLabelDblClick.cpp +SOURCES += QLineEditDblClick.cpp SOURCES += CounterWindowRT.cpp SOURCES += CounterDevice.cpp SOURCES += CounterChannel.cpp @@ -29,6 +30,7 @@ HEADERS += CounterWindowRT.h HEADERS += QLabelDblClick.h +HEADERS += QLineEditDblClick.h HEADERS += CounterDevice.h HEADERS += CounterChannel.h HEADERS += ChannelChartForm.h diff --git a/CounterRealTime/CounterSettingForm.cpp b/CounterRealTime/CounterSettingForm.cpp index 619dfd0..2dedd0c 100644 --- a/CounterRealTime/CounterSettingForm.cpp +++ b/CounterRealTime/CounterSettingForm.cpp @@ -1,8 +1,6 @@ #include "CounterSettingForm.h" #include "ui_CounterSettingForm.h" -#include - CounterSettingForm::CounterSettingForm(QWidget *parent) : QWidget(parent), ui(new Ui::CounterSettingForm) @@ -40,7 +38,6 @@ void CounterSettingForm::initCounterSelect() { - ui->iptPasswd->setText(""); ui->selectCounter->clear(); ui->selectCounter->addItem("== 请选择 ==", "-1"); QList devIds = SettingConfig::getInstance().MASTER == 1 ? ConstCache::getInstance().deviceIdLoopA : ConstCache::getInstance().deviceIdLoopB; @@ -48,6 +45,20 @@ { ui->selectCounter->addItem(ConstCache::getInstance().deviceMap.value(devIds.at(i))->getDeviceName(), devIds.at(i)); } + + ui->iptPasswd->setText(""); +} + +void CounterSettingForm::initClockNumSelect(QList clockNumList) +{ + ui->selectClockNum->clear(); + ui->selectClockNum->addItem("请选择", "-"); + + for (int i = 0; i < clockNumList.size(); i++) + { + ui->selectClockNum->addItem(clockNumList.at(i), clockNumList.at(i)); + } + ui->selectClockNum->hide(); } int CounterSettingForm::getDisplayGroupFlag() @@ -175,8 +186,8 @@ leftLayout->addWidget(tdLeftNo, i + 1, 1); rightLayout->addWidget(tdRightNo, i + 1 , 1); - QLineEdit * tdLeftClock = new QLineEdit(ui->widgetChannel); - QLineEdit * tdRightClock = new QLineEdit(ui->widgetChannel); + QLineEditDblClick * tdLeftClock = new QLineEditDblClick(ui->widgetChannel); + QLineEditDblClick * tdRightClock = new QLineEditDblClick(ui->widgetChannel); tdLeftClock->setMinimumSize(100, 40); tdLeftClock->setMaximumSize(100, 40); tdRightClock->setMinimumSize(100, 40); @@ -184,6 +195,9 @@ leftLayout->addWidget(tdLeftClock, i + 1, 2); rightLayout->addWidget(tdRightClock, i + 1 , 2); + tdLeftClock->setProperty("position", QString("%1-%2").arg("left").arg(i)); + tdRightClock->setProperty("position", QString("%1-%2").arg("right").arg(i)); + clockListLeft.append(tdLeftClock); clockListRight.append(tdRightClock); @@ -435,12 +449,30 @@ } } +void CounterSettingForm::on_selectClockNum_activated(int index) +{ + QString lineEditPos = sender()->property("LineEditPos").toString(); + QStringList pos = lineEditPos.split("-"); + QString selectedVal = ui->selectClockNum->currentData().toString(); + + if (pos.at(0).toLower() == "left") { + if (clockListLeft.size() > pos.at(1).toInt()) { + clockListLeft.at(pos.at(1).toInt())->setText(selectedVal); + } + } else if (pos.at(0).toLower() == "right") { + if (clockListRight.size() > pos.at(1).toInt()) { + clockListRight.at(pos.at(1).toInt())->setText(selectedVal); + } + } + + ui->selectClockNum->hide(); +} + void CounterSettingForm::onActiveStateChanged() { QCheckBox * obj = (QCheckBox *) sender(); QString channelIndex = obj->property("channelIndex").toString(); - if (obj->isChecked() == true) { obj->setText("启用"); enableChannel(channelIndex.toInt(), true); @@ -450,15 +482,39 @@ } } +void CounterSettingForm::onClockNumDoubleClicked() +{ + QLineEditDblClick * target = (QLineEditDblClick *) sender(); + + ui->selectClockNum->setProperty("LineEditPos", target->property("position")); + ui->selectClockNum->setCurrentIndex(0); + ui->selectClockNum->move(target->pos().x(), target->pos().y() + 80); + ui->selectClockNum->show(); +} + void CounterSettingForm::enableChannel(int index, bool enable) { if (index < 8) { clockListLeft.at(index)->setReadOnly(!enable); delayListLeft.at(index)->setReadOnly(!enable); + if (enable == true) { + connect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListLeft.at(index), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListLeft.at(index)->setText("-"); + delayListLeft.at(index)->setValue(0.0); + } } else if (index >= 8 && index < 16) { clockListRight.at(index - 8)->setReadOnly(!enable); delayListRight.at(index - 8)->setReadOnly(!enable); + if (enable == true) { + connect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + } else { + disconnect(clockListRight.at(index - 8), &QLineEditDblClick::doubleClicked, this, &CounterSettingForm::onClockNumDoubleClicked); + clockListRight.at(index - 8)->setText("-"); + delayListRight.at(index - 8)->setValue(0.0); + } } } diff --git a/CounterRealTime/CounterSettingForm.h b/CounterRealTime/CounterSettingForm.h index c008aa3..b9d31f0 100644 --- a/CounterRealTime/CounterSettingForm.h +++ b/CounterRealTime/CounterSettingForm.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include "QLineEditDblClick.h" #include "common/ConstCache.h" #include "common/utils/SettingConfig.h" @@ -21,22 +24,24 @@ explicit CounterSettingForm(QWidget *parent = nullptr); ~CounterSettingForm(); void initCounterSelect(); + void initClockNumSelect(QList clockNumList); int getDisplayGroupFlag(); private slots: void on_btnSettingClose_clicked(); - void on_btnSetDialog_accepted(); - void on_btnSetDialog_rejected(); - void on_btnSelectDir_clicked(); void on_selectCounter_currentIndexChanged(int index); + void on_selectClockNum_activated(int index); void onActiveStateChanged(); + void onClockNumDoubleClicked(); + + void on_btnSetDialog_accepted(); + void on_btnSetDialog_rejected(); void on_btnChanelSetDialog_accepted(); - void on_btnChanelSetDialog_rejected(); private: @@ -47,11 +52,13 @@ QVector activeListLeft; QVector activeListRight; - QVector clockListLeft; - QVector clockListRight; + QVector clockListLeft; + QVector clockListRight; QVector delayListLeft; QVector delayListRight; + int channelEditedIndex = -1; + void initDefaultSettings(); void initChannelSettingTable(); void clearChannelSettingValue(); diff --git a/CounterRealTime/CounterSettingForm.ui b/CounterRealTime/CounterSettingForm.ui index a0d4438..407ebab 100644 --- a/CounterRealTime/CounterSettingForm.ui +++ b/CounterRealTime/CounterSettingForm.ui @@ -511,6 +511,22 @@ QLineEdit::Password + + + + 510 + 20 + 100 + 40 + + + + + 100 + 40 + + + diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 7b4b063..24ebb24 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -221,6 +221,25 @@ updateDeviceWidget(); } } +QList CounterWindowRT::getClockNumList() +{ + QJsonObject clockListRes = httpReq->initDeviceList("00", "sys_group_clock"); + QList clockNumList; + if (clockListRes.value("code").toInt() == 200) + { + // 将获取到的设备绘制到表格中 + QJsonArray devArray = clockListRes.value("data").toArray(); + for (int i = 0; i < devArray.size(); i++) + { + // 接口返回的device对象 + QJsonObject clockItem = devArray.at(i).toObject(); + QString clockNum = clockItem.value("deviceNo").toString(); // + clockNumList.append(clockNum); + } + } + + return clockNumList; +} void CounterWindowRT::getChannelList(QString deviceId) { // 查询计数器的通道 @@ -531,6 +550,7 @@ settingForm->setWindowModality(Qt::ApplicationModal); settingForm->setWindowTitle("系统设置"); settingForm->initCounterSelect(); + settingForm->initClockNumSelect(getClockNumList()); settingForm->show(); } void CounterWindowRT::on_btnMenuMin_clicked() diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index 256b7ac..d934324 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -61,6 +61,7 @@ int initHttpToken(); void getDeviceList(); + QList getClockNumList(); void getChannelList(QString deviceId); void initDevAndChannelForm(int count); diff --git a/CounterRealTime/QLineEditDblClick.cpp b/CounterRealTime/QLineEditDblClick.cpp new file mode 100644 index 0000000..68bfd94 --- /dev/null +++ b/CounterRealTime/QLineEditDblClick.cpp @@ -0,0 +1,17 @@ +#include "QLineEditDblClick.h" + +QLineEditDblClick::QLineEditDblClick(QWidget *parent) : QLineEdit(parent) +{ + +} + +QLineEditDblClick::~QLineEditDblClick() +{ + +} + +void QLineEditDblClick::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit doubleClicked(); +} + diff --git a/CounterRealTime/QLineEditDblClick.h b/CounterRealTime/QLineEditDblClick.h new file mode 100644 index 0000000..145e8b2 --- /dev/null +++ b/CounterRealTime/QLineEditDblClick.h @@ -0,0 +1,19 @@ +#ifndef QLINEEDITDBLCLICK_H +#define QLINEEDITDBLCLICK_H + +#include +#include + +class QLineEditDblClick : public QLineEdit +{ + Q_OBJECT +public: + QLineEditDblClick(QWidget * parent = 0); + ~QLineEditDblClick(); + void mouseDoubleClickEvent(QMouseEvent * event); + +signals: + void doubleClicked(); +}; + +#endif // QLINEEDITDBLCLICK_H diff --git a/CounterRealTime/qss/mainClock.css b/CounterRealTime/qss/mainClock.css index 3d51134..b850753 100644 --- a/CounterRealTime/qss/mainClock.css +++ b/CounterRealTime/qss/mainClock.css @@ -315,25 +315,28 @@ border-radius: 6px; font-family: "Microsoft YaHei"; font-size: 16px; - padding: 6px; +/* padding: 6px;*/ + color: #FFFFFF; +} +QComboBox#selectClockNum { + font-family: "Microsoft YaHei"; + font-size: 16px; +/* padding: 6px;*/ color: #FFFFFF; } -QComboBox#selectCounter QAbstractItemView { +QComboBox#selectCounter, QComboBox#selectClockNum QAbstractItemView { font-family: "Microsoft YaHei"; color: #0BB2E9; background-color: #123553; selection-background-color: #1E5A7C; } - QComboBox#selectCounter::down-arrow { image: url(":/images/arrowDown2.png"); } - QComboBox#selectCounter::down-arrow::on { image: url(":/images/arrowUp2.png"); } - QComboBox#selectCounter::drop-down { subcontrol-origin: padding; subcontrol-position: top right;