#include "ctrlverifyclockpanel.h" #include "gutil/qwaitingdlg.h" #include "gutil/qnetwork.h" #include "main.h" #include "gutil/qgui.h" #include "tools.h" #include #include #include #include #include "devicepanel.h" CtrlVerifyClockPanel::CtrlVerifyClockPanel() { auto vBox = new VBox(this); auto hBox = new HBox(vBox); label = new QLabel; hBox->addWidget(label); fdTimezone = new QComboBox; auto zoneIds = QTimeZone::availableTimeZoneIds(); for(auto &zoneId : zoneIds) fdTimezone->addItem(zoneId); hBox->addWidget(fdTimezone); fdTimeZoneSet = new QPushButton; connect(fdTimeZoneSet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "SetTimezone"); json.insert("_type", "SetTimezone"); json.insert("timezone", fdTimezone->currentText()); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("SetTimezone")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { Def_CtrlSetMulti(tr("SetTimezone")) } } }); hBox->addWidget(fdTimeZoneSet); hBox->addSpacing(20); lbLang = new QLabel; hBox->addWidget(lbLang); fdIsEn = new QRadioButton("English"); hBox->addWidget(fdIsEn); fdIsCn = new QRadioButton("中文"); hBox->addWidget(fdIsCn); btnLangSet = new QPushButton; connect(btnLangSet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "SetLanguage"); json.insert("_type", "SetLanguage"); json.insert("language", fdIsCn->isChecked() ? 1 : 0); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, "设置语言"); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { Def_CtrlSetMulti("设置语言") } } }); hBox->addWidget(btnLangSet); btnLangGet = new QPushButton; connect(btnLangGet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "GetLanguage"); json.insert("_type", "GetLanguage"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, "获取语言"); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { Def_CtrlSingleGetReply waitingDlg->success(); if(json["language"].toInt()==1) fdIsCn->setChecked(true); else fdIsEn->setChecked(true); }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto cardId = card.id; connect(reply, &QNetworkReply::finished, this, [reply, cardId] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文"; gFdResInfo->append(cardId+" 获取语言 "+err); }); } } }); hBox->addWidget(btnLangGet); hBox->addStretch(); labelVerifyClockConfiguration = new QLabel; labelVerifyClockConfiguration->setAlignment(Qt::AlignCenter); vBox->addWidget(labelVerifyClockConfiguration); auto line = new QFrame; line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); vBox->addWidget(line); hBox = new HBox(vBox); auto vvv = new VBox(hBox); btnSyncTime = new QPushButton(tr("Verify to Computer time")); btnSyncTime->setMinimumSize(QSize(60, 30)); connect(btnSyncTime, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "SyncTime"); json.insert("_type", "SyncTime"); json.insert("time", QDateTime::currentDateTime().toMSecsSinceEpoch()); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("SyncTime")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { Def_CtrlSetMulti(tr("SyncTime")) } } }); vvv->addWidget(btnSyncTime); groupBox_5 = new QGroupBox; vvv->addWidget(groupBox_5); auto vvvv = new QVBoxLayout(groupBox_5); vvvv->addStretch(); btnDateGet = new QPushButton; btnDateGet->setMinimumSize(QSize(0, 30)); connect(btnDateGet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "GetControllerDate"); json.insert("_type", "GetControllerDate"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("GetControllerDate")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { Def_CtrlSingleGetReply waitingDlg->success(); labelCurTime->setText(json["date"].toString()); }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto cardId = card.id; connect(reply, &QNetworkReply::finished, this, [reply, cardId] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(err.isEmpty()) err = json["date"].toString(); gFdResInfo->append(cardId+" "+tr("GetControllerDate")+" "+err); }); } } }); vvvv->addWidget(btnDateGet); labelCurTime = new QLabel; vvvv->addWidget(labelCurTime); vvvv->addStretch(); hBox->addSpacing(20); groupBox = new QGroupBox; groupBox->setCheckable(true); vvv = new VBox(groupBox); vvv->setSpacing(3); auto hhh = new HBox(vvv); fdIsLora = new QRadioButton("Lora"); hhh->addWidget(fdIsLora); fdIsGPS = new QRadioButton("GPS"); hhh->addWidget(fdIsGPS); fdIsNTP = new QRadioButton("NTP"); hhh->addWidget(fdIsNTP); fdIsLan = new QRadioButton; hhh->addWidget(fdIsLan); horizontalLayout_5 = new QHBoxLayout(); horizontalLayout_5->setContentsMargins(0, 0, 0, 0); labelSyncTimeInterval = new QLabel(groupBox); horizontalLayout_5->addWidget(labelSyncTimeInterval); lineEdit_3 = new QLineEdit(groupBox); lineEdit_3->setMinimumSize(QSize(160, 30)); lineEdit_3->setMaximumSize(QSize(160, 16777215)); horizontalLayout_5->addWidget(lineEdit_3); labelmintime = new QLabel(groupBox); horizontalLayout_5->addWidget(labelmintime); vvv->addLayout(horizontalLayout_5); horizontalLayout_9 = new QHBoxLayout(); horizontalLayout_9->setContentsMargins(-1, 0, -1, -1); labelIdCode = new QLabel(groupBox); horizontalLayout_9->addWidget(labelIdCode); lineEditIdCode = new QLineEdit(groupBox); lineEditIdCode->setMinimumSize(QSize(0, 30)); lineEditIdCode->setStyleSheet(QString::fromUtf8("background-color: #FFFFFF;")); horizontalLayout_9->addWidget(lineEditIdCode); vvv->addLayout(horizontalLayout_9); horizontalLayout_10 = new QHBoxLayout(); horizontalLayout_10->setContentsMargins(-1, 0, -1, -1); labelTimeOffset = new QLabel(groupBox); horizontalLayout_10->addWidget(labelTimeOffset); lineEditTimeOffset = new QLineEdit(groupBox); lineEditTimeOffset->setMinimumSize(QSize(0, 30)); lineEditTimeOffset->setStyleSheet(QString::fromUtf8("background-color: #FFFFFF;")); horizontalLayout_10->addWidget(lineEditTimeOffset); vvv->addLayout(horizontalLayout_10); horizontalLayout_13 = new QHBoxLayout(); horizontalLayout_13->setContentsMargins(-1, 0, -1, -1); checkBoxBrightness = new QCheckBox(groupBox); horizontalLayout_13->addWidget(checkBoxBrightness); checkBoxVolume = new QCheckBox(groupBox); horizontalLayout_13->addWidget(checkBoxVolume); checkBoxScreenSwitch = new QCheckBox(groupBox); horizontalLayout_13->addWidget(checkBoxScreenSwitch); vvv->addLayout(horizontalLayout_13); horizontalLayout_7 = new QHBoxLayout(); horizontalLayout_7->setContentsMargins(-1, 0, -1, -1); btnSyncSet = new QPushButton(groupBox); btnSyncSet->setMinimumSize(QSize(60, 30)); connect(btnSyncSet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "SetingSyncMethod"); json.insert("_type", "SetingSyncMethod"); json.insert("ntpServer", labelNtpServerAddress->text()); json.insert("delaySync", lineEditTimeOffset->text().toInt()); json.insert("identificationCode",lineEditIdCode->text()); json.insert("brightness", checkBoxBrightness->isChecked() ? "serial" : "none"); json.insert("volume", checkBoxVolume->isChecked() ? "serial" : "none"); json.insert("screenSwitch", checkBoxScreenSwitch->isChecked() ? "serial" : "none"); if(fdIsLora->isChecked()) json.insert("time", "serial"); else if(fdIsNTP->isChecked()) { json.insert("time", "ntp"); json.insert("checkNtpTime", lineEdit_3->text().toInt()); } else if(fdIsGPS->isChecked()) json.insert("time", "gps"); else if(fdIsLan->isChecked()) json.insert("time", "Lan"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("SetingSyncMethod")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { Def_CtrlSetMulti(tr("SetingSyncMethod")) } } }); horizontalLayout_7->addWidget(btnSyncSet); fdSyncGet = new QPushButton; fdSyncGet->setMinimumSize(QSize(60, 30)); connect(fdSyncGet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "GetingSyncMethod"); json.insert("_type", "GetingSyncMethod"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("GetingSyncMethod")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { Def_CtrlSingleGetReply waitingDlg->success(); dealGetSync(json); }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto cardId = card.id; connect(reply, &QNetworkReply::finished, this, [reply, cardId] { QJsonDocument json; QByteArray data; QString err = checkReplyForJson(reply, &json, &data); if(err.isEmpty()) { QString strOtherSyncItem = tr("screenSwitch") + ":" + (json["screenSwitch"].toBool() ? tr("YES") : tr("NO")) + " " + tr("volume") + ":" + (json["volume"].toBool() ? tr("YES") : tr("NO")) + " " + tr("brightness") + ":" + (json["brightness"].toBool() ? tr("YES") : tr("NO")); QString lastSynchronousTime = QDateTime::fromMSecsSinceEpoch(json["lastSynchronousTime"].toDouble()).toString("yyyy-MM-dd HH:mm:ss"); QString time = json["time"].toString(); QString lower = time.toLower(); if(lower=="serial") { err = "Lora\n "+tr("identificationCode")+": "+json["identificationCode"].toString()+"\n " +tr("delaySync")+": "+QString::number(json["delaySync"].toInt())+tr("msec")+"\n " +tr("OtherSyncItem")+": "+strOtherSyncItem+"\n " +tr("lastSynchronousTime")+": "+lastSynchronousTime; } else if(lower=="ntp") { err = time+"\n "+tr("checkNtpTime")+": "+QString::number(json["checkNtpTime"].toInt())+"\n " +tr("OtherSyncItem")+": "+strOtherSyncItem+"\n " +tr("lastSynchronousTime")+": "+lastSynchronousTime; } else if(lower=="gps") { err = time+"\n "+tr("OtherSyncItem")+": "+strOtherSyncItem+"\n "+tr("lastSynchronousTime")+": "+lastSynchronousTime; } else if(lower=="lan") { err = tr("LAN")+"\n "+tr("identificationCode")+": "+json["identificationCode"].toString()+"\n " +tr("delaySync")+": "+QString::number(json["delaySync"].toInt())+tr("msec")+"\n " +tr("OtherSyncItem")+": "+strOtherSyncItem+"\n " +tr("lastSynchronousTime")+": "+lastSynchronousTime; } else { err = time+"\n "+data; } } gFdResInfo->append(cardId+" "+tr("GetingSyncMethod")+" "+err); }); } } }); horizontalLayout_7->addWidget(fdSyncGet); vvv->addLayout(horizontalLayout_7); vvv->addStretch(); groupBox_4 = new QGroupBox(groupBox); groupBox_4->setMinimumSize(QSize(0, 20)); horizontalLayout_11 = new QHBoxLayout(groupBox_4); horizontalLayout_11->setSpacing(6); horizontalLayout_11->setContentsMargins(0, 0, 0, 0); fdMaster = new QRadioButton(groupBox_4); buttonGroup_2 = new QButtonGroup(this); buttonGroup_2->addButton(fdMaster); fdMaster->setChecked(true); horizontalLayout_11->addWidget(fdMaster, 0, Qt::AlignHCenter); fdSlave = new QRadioButton(groupBox_4); buttonGroup_2->addButton(fdSlave); horizontalLayout_11->addWidget(fdSlave, 0, Qt::AlignHCenter); vvv->addWidget(groupBox_4); horizontalLayout_12 = new QHBoxLayout(); horizontalLayout_12->setContentsMargins(-1, 0, -1, -1); btnLoraMasterSet = new QPushButton(groupBox); btnLoraMasterSet->setMinimumSize(QSize(0, 30)); connect(btnLoraMasterSet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "MasterSlaveSwitch"); json.insert("_type", "MasterSlaveSwitch"); bool isMaster = buttonGroup_2->checkedId()==0; json.insert("master", isMaster); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, isMaster ? tr("MasterSwitch ") : tr("SlaveSwitch ")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); connect(reply, &QNetworkReply::finished, this, [reply, card, isMaster] { QString err = checkReplyForJson(reply); gFdResInfo->append(card.id+" "+(isMaster ? tr("MasterSwitch ") : tr("SlaveSwitch "))+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err)); }); } } }); horizontalLayout_12->addWidget(btnLoraMasterSet); btnLoraMasterGet = new QPushButton(groupBox); btnLoraMasterGet->setMinimumSize(QSize(0, 30)); connect(btnLoraMasterGet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "IsMasterSlave"); json.insert("_type", "IsMasterSlave"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("IsMasterSlave")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { Def_CtrlSingleGetReply waitingDlg->success(); bool isMaster = json["result"].toBool(); fdMaster->setChecked(isMaster); fdSlave->setChecked(! isMaster); }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto cardId = card.id; connect(reply, &QNetworkReply::finished, this, [reply, cardId] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave"); gFdResInfo->append(cardId+" "+tr("Lora identity")+" "+err); }); } } }); horizontalLayout_12->addWidget(btnLoraMasterGet); vvv->addLayout(horizontalLayout_12); hBox->addWidget(groupBox); hBox->addSpacing(20); groupNTP = new QGroupBox; vvv = new VBox(groupNTP); hhh = new HBox(vvv); labelNtpServerAddress = new QLabel(groupNTP); hhh->addWidget(labelNtpServerAddress); fdNtpServer = new QLineEdit(groupNTP); fdNtpServer->setMinimumSize(QSize(160, 30)); fdNtpServer->setMaximumSize(QSize(160, 16777215)); fdNtpServer->setStyleSheet(QString::fromUtf8("background-color: #FFFFFF;")); hhh->addWidget(fdNtpServer); hhh->addStretch(); vvv->addSpacing(20); hhh = new HBox(vvv); btnNtpSet = new QPushButton; btnNtpSet->setMinimumSize(QSize(60, 30)); connect(btnNtpSet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "SetNtpServer"); json.insert("_type", "SetNtpServer"); json.insert("ntpServer", fdNtpServer->text()); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("SetNtpServer")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [=] { Def_CtrlSetReqAfter }); } else { foreach(auto card, gSelCards) { Def_CtrlSetMulti(tr("SetNtpServer")) } } }); hhh->addWidget(btnNtpSet); btnNtpGet = new QPushButton; btnNtpGet->setMinimumSize(QSize(60, 30)); connect(btnNtpGet, &QPushButton::clicked, this, [this] { if(gSelCards.isEmpty()) { QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); return; } QJsonObject json; json.insert("_id", "GetNtpServer"); json.insert("_type", "GetNtpServer"); if(gSelCards.count() == 1) { auto waitingDlg = new WaitingDlg(this, tr("GetNtpServer")); Def_CtrlReqPre connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { Def_CtrlSingleGetReply waitingDlg->success(); fdNtpServer->setText(json["ntpServer"].toString()); }); } else { foreach(auto card, gSelCards) { auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto cardId = card.id; connect(reply, &QNetworkReply::finished, this, [reply, cardId] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(err.isEmpty()) err = json["ntpServer"].toString(); gFdResInfo->append(cardId+" "+tr("GetNtpServer")+" "+err); }); } } }); hhh->addWidget(btnNtpGet); vvv->addStretch(); hBox->addWidget(groupNTP); hBox->addStretch(); vBox->addStretch(); btnNtpSet->setProperty("ssType", "progManageTool"); btnSyncSet->setProperty("ssType", "progManageTool"); btnSyncTime->setProperty("ssType", "progManageTool"); fdSyncGet->setProperty("ssType", "progManageTool"); btnNtpGet->setProperty("ssType", "progManageTool"); btnLoraMasterSet->setProperty("ssType", "progManageTool"); btnLoraMasterGet->setProperty("ssType", "progManageTool"); btnDateGet->setProperty("ssType", "progManageTool"); fdTimeZoneSet->setProperty("ssType", "progManageTool"); buttonGroup_2->setId(fdMaster, 0); buttonGroup_2->setId(fdSlave, 1); fdIsLora->setChecked(true); labelIdCode->setVisible(true); lineEditIdCode->setVisible(true); labelTimeOffset->setVisible(true); lineEditTimeOffset->setVisible(true); lineEdit_3->setVisible(false); labelSyncTimeInterval->setVisible(false); labelmintime->setVisible(false); //按钮事件绑定 connect(fdIsGPS,SIGNAL(clicked()),this,SLOT(OnRadioButton())); connect(fdIsLora,SIGNAL(clicked()),this,SLOT(OnRadioButton2())); connect(fdIsNTP,SIGNAL(clicked()),this,SLOT(OnRadioButton3())); connect(fdIsLan,SIGNAL(clicked()),this,SLOT(OnRadioButton6())); connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] { if(isVisible()) init(); }); transUi(); } void CtrlVerifyClockPanel::showEvent(QShowEvent *event) { QWidget::showEvent(event); init(); } void CtrlVerifyClockPanel::init() { bool isSingle = gSelCards.count()==1; if(! isSingle) return; auto card = gSelCards[0]; QJsonObject json; json.insert("_id", "GetingSyncMethod"); json.insert("_type", "GetingSyncMethod"); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); connect(reply, &QNetworkReply::finished, this, [this, reply] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(! err.isEmpty()) return; dealGetSync(json); }); json = QJsonObject(); json.insert("_id", "GetTimezone"); json.insert("_type", "GetTimezone"); reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); connect(reply, &QNetworkReply::finished, this, [this, reply] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(! err.isEmpty()) return; fdTimezone->setCurrentText(json["timezone"].toString()); }); json = QJsonObject(); json.insert("_id", "GetLanguage"); json.insert("_type", "GetLanguage"); reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); connect(reply, &QNetworkReply::finished, this, [this, reply] { QJsonDocument json; QString err = checkReplyForJson(reply, &json); if(! err.isEmpty()) return; if(json["language"].toInt()==1) fdIsCn->setChecked(true); else fdIsEn->setChecked(true); }); } void CtrlVerifyClockPanel::changeEvent(QEvent *event) { QWidget::changeEvent(event); if(event->type() == QEvent::LanguageChange) transUi(); } void CtrlVerifyClockPanel::transUi() { btnDateGet->setText(tr("Readback")); btnLangGet->setText(tr("Readback")); btnLangSet->setText(tr("Set")); btnLoraMasterGet->setText(tr("Readback")); btnLoraMasterSet->setText(tr("Set")); btnNtpGet->setText(tr("Readback")); btnNtpSet->setText(tr("Set")); btnSyncTime->setText(tr("Verify to Computer time")); checkBoxBrightness->setText(tr("Brightness")); checkBoxScreenSwitch->setText(tr("Screen on/off")); checkBoxVolume->setText(tr("Volume")); fdIsLan->setText(tr("LAN")); fdNtpServer->setPlaceholderText(tr("NTP Server address")); fdSyncGet->setText(tr("Readback")); fdTimeZoneSet->setText(tr("Set")); groupBox->setTitle(tr("Enable Synchronous playing")); groupBox_5->setTitle(tr("Cur time of controller")); groupNTP->setTitle(tr("NTP Server")); label->setText(tr("TimeZone")); labelIdCode->setText(tr("Identification Code")); labelNtpServerAddress->setText(tr("NTP Server address")); labelSyncTimeInterval->setText(tr("Sync time interval")); labelTimeOffset->setText(tr("Time offset(msec)")); labelVerifyClockConfiguration->setText(tr("Verify Clock Configuration")); labelmintime->setText(tr("(min/time)")); lbLang->setText(tr("Language:")); lineEditIdCode->setPlaceholderText(tr("identification code")); lineEdit_3->setPlaceholderText(tr("Sync time interval")); btnSyncSet->setText(tr("Set")); fdMaster->setText(tr("Master")); fdSlave->setText(tr("Slave")); } void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) { QString strType = json["time"].toString().toLower(); if(strType=="serial" || strType=="lan") { if(strType=="serial") fdIsLora->setChecked(true); else fdIsLan->setChecked(true); lineEditIdCode->setText(json["identificationCode"].toString()); lineEditTimeOffset->setText(QString::number(json["delaySync"].toInt())); labelIdCode->setVisible(true); lineEditIdCode->setVisible(true); labelTimeOffset->setVisible(true); lineEditTimeOffset->setVisible(true); lineEdit_3->setVisible(false); labelSyncTimeInterval->setVisible(false); labelmintime->setVisible(false); checkBoxScreenSwitch->setChecked(json["screenSwitch"].toString()!="NONE"); checkBoxVolume->setChecked(json["volume"].toString()!="NONE"); checkBoxBrightness->setChecked(json["brightness"].toString()!="NONE"); checkBoxScreenSwitch->setVisible(true); checkBoxVolume->setVisible(true); checkBoxBrightness->setVisible(true); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } else if(strType=="ntp") { fdIsNTP->setChecked(true); lineEdit_3->setText(QString::number(json["checkNtpTime"].toInt())); labelIdCode->setVisible(false); lineEditIdCode->setVisible(false); labelTimeOffset->setVisible(false); lineEditTimeOffset->setVisible(false); lineEdit_3->setVisible(true); labelSyncTimeInterval->setVisible(true); labelmintime->setVisible(true); groupBox_4->setVisible(false); fdMaster->setVisible(false); fdSlave->setVisible(false); btnLoraMasterSet->setVisible(false); btnLoraMasterGet->setVisible(false); checkBoxScreenSwitch->setVisible(false); checkBoxVolume->setVisible(false); checkBoxBrightness->setVisible(false); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } else if(strType=="gps") { fdIsGPS->setChecked(true); labelIdCode->setVisible(false); lineEditIdCode->setVisible(false); labelTimeOffset->setVisible(false); lineEditTimeOffset->setVisible(false); labelSyncTimeInterval->setVisible(false); lineEdit_3->setVisible(false); labelmintime->setVisible(false); groupBox_4->setVisible(false); fdMaster->setVisible(false); fdSlave->setVisible(false); btnLoraMasterSet->setVisible(false); btnLoraMasterGet->setVisible(false); checkBoxScreenSwitch->setVisible(false); checkBoxVolume->setVisible(false); checkBoxBrightness->setVisible(false); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } } void CtrlVerifyClockPanel::OnRadioButton()//gps { labelIdCode->setVisible(false); lineEditIdCode->setVisible(false); labelTimeOffset->setVisible(false); lineEditTimeOffset->setVisible(false); labelSyncTimeInterval->setVisible(false); lineEdit_3->setVisible(false); labelmintime->setVisible(false); groupBox_4->setVisible(false); fdMaster->setVisible(false); fdSlave->setVisible(false); btnLoraMasterSet->setVisible(false); btnLoraMasterGet->setVisible(false); checkBoxScreenSwitch->setVisible(false); checkBoxVolume->setVisible(false); checkBoxBrightness->setVisible(false); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } void CtrlVerifyClockPanel::OnRadioButton2()//lora { labelIdCode->setVisible(true); lineEditIdCode->setVisible(true); labelTimeOffset->setVisible(true); lineEditTimeOffset->setVisible(true); lineEdit_3->setVisible(false); labelSyncTimeInterval->setVisible(false); labelmintime->setVisible(false); groupBox_4->setVisible(true); fdMaster->setVisible(true); fdSlave->setVisible(true); btnLoraMasterSet->setVisible(true); btnLoraMasterGet->setVisible(true); checkBoxScreenSwitch->setVisible(true); checkBoxVolume->setVisible(true); checkBoxBrightness->setVisible(true); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } void CtrlVerifyClockPanel::OnRadioButton3()//ntp { labelIdCode->setVisible(false); lineEditIdCode->setVisible(false); labelTimeOffset->setVisible(false); lineEditTimeOffset->setVisible(false); lineEdit_3->setVisible(true); labelSyncTimeInterval->setVisible(true); labelmintime->setVisible(true); groupBox_4->setVisible(false); fdMaster->setVisible(false); fdSlave->setVisible(false); btnLoraMasterSet->setVisible(false); btnLoraMasterGet->setVisible(false); checkBoxScreenSwitch->setVisible(false); checkBoxVolume->setVisible(false); checkBoxBrightness->setVisible(false); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); } void CtrlVerifyClockPanel::OnRadioButton6() { labelIdCode->setVisible(true); lineEditIdCode->setVisible(true); labelTimeOffset->setVisible(true); lineEditTimeOffset->setVisible(true); lineEdit_3->setVisible(false); labelSyncTimeInterval->setVisible(false); labelmintime->setVisible(false); groupBox_4->setVisible(true); fdMaster->setVisible(true); fdSlave->setVisible(true); btnLoraMasterSet->setVisible(true); btnLoraMasterGet->setVisible(true); checkBoxScreenSwitch->setVisible(true); checkBoxVolume->setVisible(true); checkBoxBrightness->setVisible(true); btnSyncSet->setVisible(true); fdSyncGet->setVisible(true); }