2023-04-18 14:14:46 +08:00
# include "ctrladvancedpanel.h"
2024-05-23 17:13:51 +08:00
# include "device/progressesdlg.h"
2024-08-07 18:18:37 +08:00
# include "main.h"
2023-10-23 15:08:45 +08:00
# include "gutil/qwaitingdlg.h"
2023-05-16 18:03:53 +08:00
# include "base/changepasswordform.h"
2023-04-18 14:14:46 +08:00
# include "tools.h"
# include "gutil/qgui.h"
# include "gutil/qnetwork.h"
2023-08-01 11:42:41 +08:00
# include "gutil/qjson.h"
2023-04-18 14:14:46 +08:00
# include "program/ephoto.h"
# include "upgradeapkdialog.h"
2023-08-01 11:42:41 +08:00
# include "deviceitem.h"
2023-04-18 14:14:46 +08:00
# include <QComboBox>
# include <QFileDialog>
# include <QJsonArray>
# include <QJsonObject>
# include <QKeyEvent>
# include <QMap>
# include <QMessageBox>
# include <QMetaEnum>
# include <QProcess>
# include <QSettings>
# include <QUuid>
# include <QHeaderView>
# include <QColorDialog>
# include <QSpinBox>
# include <QButtonGroup>
2023-05-15 16:06:10 +08:00
# include "devicepanel.h"
2023-05-16 18:03:53 +08:00
# include <QDialogButtonBox>
2024-06-06 21:55:36 +08:00
# include <QInputDialog>
# include <QStandardPaths>
2023-04-18 14:14:46 +08:00
2023-08-01 11:42:41 +08:00
CtrlAdvancedPanel : : CtrlAdvancedPanel ( ) {
2023-04-18 14:14:46 +08:00
setFocusPolicy ( Qt : : StrongFocus ) ;
2023-10-23 15:08:45 +08:00
auto vBox = new VBox ( this ) ;
vBox - > setContentsMargins ( 6 , 6 , 6 , 0 ) ;
2023-04-18 14:14:46 +08:00
lbTitle = new QLabel ;
2023-10-23 15:08:45 +08:00
auto ft = lbTitle - > font ( ) ;
ft . setPixelSize ( 16 ) ;
ft . setBold ( true ) ;
lbTitle - > setFont ( ft ) ;
2023-04-18 14:14:46 +08:00
lbTitle - > setAlignment ( Qt : : AlignCenter ) ;
vBox - > addWidget ( lbTitle ) ;
auto hBox = new HBox ( vBox ) ;
lbScreenWidth = new QLabel ;
hBox - > addWidget ( lbScreenWidth ) ;
fdScreenWidth = new QLineEdit ;
fdScreenWidth - > setMaximumWidth ( 60 ) ;
hBox - > addWidget ( fdScreenWidth ) ;
lbScreenHeight = new QLabel ;
hBox - > addWidget ( lbScreenHeight ) ;
fdScreenHeight = new QLineEdit ;
fdScreenHeight - > setMaximumWidth ( 60 ) ;
hBox - > addWidget ( fdScreenHeight ) ;
2024-07-03 18:32:38 +08:00
auto btn = new QPushButton ;
btnSets . push_back ( btn ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto width = fdScreenWidth - > text ( ) ;
if ( width . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " InputWidthTip " ) ) ;
2023-04-18 14:14:46 +08:00
fdScreenWidth - > setFocus ( ) ;
return ;
}
auto height = fdScreenHeight - > text ( ) ;
if ( height . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " InputHeightTip " ) ) ;
2023-04-18 14:14:46 +08:00
fdScreenHeight - > setFocus ( ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetScreenSize " ) ;
json . insert ( " _type " , " SetScreenSize " ) ;
json . insert ( " width " , width . toInt ( ) ) ;
json . insert ( " height " , height . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetScreenSize " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , gFdResInfo , [ = ] {
auto err = checkReplyForJson ( reply ) ;
gFdResInfo - > append ( card . id + " " + tr ( " SetScreenSize " ) + " " + ( err . isEmpty ( ) ? QCoreApplication : : translate ( " Def " , " Success " ) : err ) ) ;
// if(! err.isEmpty()) return;
// auto item = findItem(card.id);
// if(item) {
// item->mCard.ScreenResolution = aaa;
// item->setText("ScreenResolution", aaa);
// }
} ) ;
2023-04-18 14:14:46 +08:00
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addSpacing ( 20 ) ;
lbAlias = new QLabel ;
hBox - > addWidget ( lbAlias ) ;
fdAlias = new QLineEdit ;
fdAlias - > setMaximumWidth ( 200 ) ;
hBox - > addWidget ( fdAlias ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto alias = fdAlias - > text ( ) ;
QJsonObject json ;
json . insert ( " _id " , " SetCardAlias " ) ;
json . insert ( " _type " , " SetCardAlias " ) ;
json . insert ( " alias " , QString : : fromLatin1 ( alias . toUtf8 ( ) . toBase64 ( ) ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetCardAlias " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
2023-08-01 11:42:41 +08:00
auto item = findItem ( card . id ) ;
if ( item ) {
item - > mCard . alias = alias ;
2023-10-23 15:08:45 +08:00
item - > setText ( " alias " , alias ) ;
2023-08-01 11:42:41 +08:00
}
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , gFdResInfo , [ = ] {
2024-06-06 21:55:36 +08:00
auto err = checkReplyForJson ( reply ) ;
2023-08-01 11:42:41 +08:00
gFdResInfo - > append ( card . id + " " + tr ( " SetCardAlias " ) + " " + ( err . isEmpty ( ) ? QCoreApplication : : translate ( " Def " , " Success " ) : err ) ) ;
if ( ! err . isEmpty ( ) ) return ;
auto item = findItem ( card . id ) ;
if ( item ) {
item - > mCard . alias = alias ;
2023-10-23 15:08:45 +08:00
item - > setText ( " alias " , alias ) ;
2023-08-01 11:42:41 +08:00
}
} ) ;
2023-04-18 14:14:46 +08:00
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
2024-08-08 11:53:16 +08:00
lbWebAddr = new QLabel ;
hBox - > addWidget ( lbWebAddr ) ;
fdWebAddr = new QComboBox ;
fdWebAddr - > addItem ( " www.m2mled.net " ) ;
fdWebAddr - > addItem ( " www.ledaips.com " ) ;
fdWebAddr - > addItem ( " https://www.taxihub.cn:2340 " ) ;
fdWebAddr - > addItem ( " https://www.ledaips.com:2340 " ) ;
fdWebAddr - > addItem ( " https://www.36taxi.com:2340 " ) ;
fdWebAddr - > addItem ( " www.tlzxled.com " ) ;
fdWebAddr - > setMinimumWidth ( 260 ) ;
fdWebAddr - > setEditable ( true ) ;
hBox - > addWidget ( fdWebAddr ) ;
2023-04-18 14:14:46 +08:00
lbCompanyId = new QLabel ;
hBox - > addWidget ( lbCompanyId ) ;
fdCompanyId = new QLineEdit ;
fdCompanyId - > setFixedWidth ( 100 ) ;
hBox - > addWidget ( fdCompanyId ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2024-08-08 11:53:16 +08:00
auto serverAddr = fdWebAddr - > currentText ( ) ;
2023-04-18 14:14:46 +08:00
auto companyId = fdCompanyId - > text ( ) ;
2024-02-21 18:08:50 +08:00
// auto res = QMessageBox::question(this, tr("Tip Info"), tr("This operation will clear current program.")+"\n"+tr("Do you want to continue?"));
// if(res != QMessageBox::Yes) return;
2023-04-18 14:14:46 +08:00
QJsonObject json ;
json . insert ( " _id " , " SetOnlineAddr " ) ;
json . insert ( " _type " , " SetOnlineAddr " ) ;
json . insert ( " server " , serverAddr ) ;
json . insert ( " companyID " , companyId ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetOnlineAddr " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetOnlineAddr " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
2024-02-21 18:08:50 +08:00
hBox - > addWidget ( lbRealtime = new QLabel ) ;
2023-04-18 14:14:46 +08:00
fdRealtimeServer = new QComboBox ;
2024-02-21 18:08:50 +08:00
fdRealtimeServer - > addItem ( " www.ledokcloud.com/realtime " ) ;
2024-08-07 18:18:37 +08:00
fdRealtimeServer - > addItem ( " 192.168.8.:10010 " ) ;
2023-04-18 14:14:46 +08:00
fdRealtimeServer - > setMinimumWidth ( 260 ) ;
fdRealtimeServer - > setEditable ( true ) ;
hBox - > addWidget ( fdRealtimeServer ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetRealtimeServer " ) ;
json . insert ( " _type " , " SetRealtimeServer " ) ;
json . insert ( " server " , fdRealtimeServer - > currentText ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetRealtimeServer " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetRealtimeServer " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
btnRealtimeClear = new QPushButton ;
btnRealtimeClear - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnRealtimeClear , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
fdRealtimeServer - > clearEditText ( ) ;
QJsonObject json ;
json . insert ( " _id " , " SetRealtimeServer " ) ;
json . insert ( " _type " , " SetRealtimeServer " ) ;
json . insert ( " server " , " " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " ClearRealtimeServer " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " ClearRealtimeServer " ) )
}
}
} ) ;
hBox - > addWidget ( btnRealtimeClear ) ;
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
btnWareUpdate = new QPushButton ;
btnWareUpdate - > setMinimumSize ( 100 , 30 ) ;
btnWareUpdate - > setProperty ( " ssType " , " progManageTool " ) ;
2023-05-11 11:47:00 +08:00
connect ( btnWareUpdate , & QPushButton : : clicked , this , [ = ] {
2023-10-23 15:08:45 +08:00
new UpgradeApkDialog ( this ) ;
2023-04-18 14:14:46 +08:00
} ) ;
hBox - > addWidget ( btnWareUpdate ) ;
lbWareTip = new QLabel ;
hBox - > addWidget ( lbWareTip ) ;
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
btnApkCheck = new QPushButton ;
btnApkCheck - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnApkCheck , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " CheckSoftVersions " ) ;
json . insert ( " _type " , " CheckSoftVersions " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) ! = 1 ) return ;
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Check Apk Version " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ this , reply , waitingDlg ] {
Def_CtrlSingleGetReply
waitingDlg - > close ( ) ;
fdPkg - > clear ( ) ;
auto apps = json [ " apps " ] . toArray ( ) ;
auto infoDlg = new QDialog ( this ) ;
2023-05-16 11:13:55 +08:00
infoDlg - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
# ifdef Q_OS_WIN
2023-04-18 14:14:46 +08:00
infoDlg - > setWindowFlag ( Qt : : WindowContextHelpButtonHint , false ) ;
2023-05-16 11:13:55 +08:00
# endif
2023-04-18 14:14:46 +08:00
infoDlg - > resize ( 500 , 500 ) ;
infoDlg - > setWindowTitle ( tr ( " Software Version Info " ) ) ;
auto vBox = new QVBoxLayout ( infoDlg ) ;
vBox - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
2023-10-23 15:08:45 +08:00
auto table = new TableWidget {
2023-04-18 14:14:46 +08:00
{ " apk " , " Apk " } ,
{ " ver " , tr ( " Version " ) } ,
{ " pkg " , tr ( " Package " ) }
} ;
table - > setDefs ( ) ;
table - > horizontalHeader ( ) - > setSectionResizeMode ( QHeaderView : : ResizeToContents ) ;
table - > setRowCount ( apps . size ( ) ) ;
vBox - > addWidget ( table ) ;
for ( int i = 0 ; i < apps . size ( ) ; i + + ) {
auto app = apps . at ( i ) ;
QString packageName = app [ " packageName " ] . toString ( ) ;
table - > setItem ( i , " apk " , new QTableWidgetItem { app [ " appName " ] . toString ( ) } ) ;
table - > setItem ( i , " ver " , new QTableWidgetItem { app [ " versionName " ] . toString ( ) } ) ;
table - > setItem ( i , " pkg " , new QTableWidgetItem { packageName } ) ;
if ( ! ( packageName . endsWith ( " .cardsystem " ) | | packageName . endsWith ( " .systemcore " ) | | packageName . endsWith ( " .update " ) ) ) fdPkg - > addItem ( packageName ) ;
}
infoDlg - > show ( ) ;
2023-05-16 11:13:55 +08:00
infoDlg - > raise ( ) ;
infoDlg - > activateWindow ( ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} ) ;
hBox - > addWidget ( btnApkCheck ) ;
fdPkg = new QComboBox ;
fdPkg - > setEditable ( true ) ;
fdPkg - > setMinimumWidth ( 200 ) ;
hBox - > addWidget ( fdPkg ) ;
fdUninstall = new QPushButton ;
fdUninstall - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( fdUninstall , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto pkg = fdPkg - > currentText ( ) ;
if ( pkg . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Package name is null " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " UninstallSoftware " ) ;
json . insert ( " _type " , " UninstallSoftware " ) ;
json . insert ( " packageName " , pkg ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " UninstallSoftware " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " UninstallSoftware " ) )
}
}
} ) ;
hBox - > addWidget ( fdUninstall ) ;
btnIsRunning = new QPushButton ;
btnIsRunning - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnIsRunning , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto pkg = fdPkg - > currentText ( ) ;
if ( pkg . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Package name is null " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " IsSoftwareRunning " ) ;
json . insert ( " _type " , " IsSoftwareRunning " ) ;
json . insert ( " packageName " , pkg ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Check apk running status " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , json [ " running " ] . toBool ( ) ? tr ( " running " ) : tr ( " no running " ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Check apk running status " ) + " " + ( err . isEmpty ( ) ? ( json [ " running " ] . toBool ( ) ? tr ( " running " ) : tr ( " no running " ) ) : err ) ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnIsRunning ) ;
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
btnRestart = new QPushButton ;
btnRestart - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnRestart , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " RestartAndroid " ) ;
json . insert ( " _type " , " RestartAndroid " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " RestartAndroid " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " RestartAndroid " ) )
}
}
} ) ;
hBox - > addWidget ( btnRestart ) ;
btnClearProg = new QPushButton ;
btnClearProg - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnClearProg , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-08-07 09:04:53 +08:00
JObj json { { " _type " , " DelPrograms " } , { " _id " , " DelPrograms " } , { " zVer " , " xixun1 " } } ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Clearing Program " ) + " ... " ) ;
waitingDlg - > show ( ) ;
2023-05-15 16:06:10 +08:00
auto card = gSelCards [ 0 ] ;
2023-08-07 09:04:53 +08:00
auto tcp = new TcpSocket ;
2023-04-18 14:14:46 +08:00
connect ( waitingDlg , & WaitingDlg : : rejected , tcp , [ = ] {
tcp - > abort ( ) ;
tcp - > deleteLater ( ) ;
} ) ;
2023-05-11 11:47:00 +08:00
connect ( tcp , & QTcpSocket : : connected , tcp , [ = ] {
2023-08-07 09:04:53 +08:00
tcp - > stopTimer ( ) ;
tcp - > write ( JToBytes ( json ) ) ;
tcp - > startTimer ( 10000 ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-05-11 11:47:00 +08:00
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
2023-08-07 09:04:53 +08:00
tcp - > stopTimer ( ) ;
auto resp = tcp - > readAll ( ) ;
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
QString error ;
auto json = JFrom ( resp , & error ) ;
if ( ! error . isEmpty ( ) ) {
2023-04-18 14:14:46 +08:00
waitingDlg - > close ( ) ;
2023-08-07 09:04:53 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , error ) ;
2023-04-18 14:14:46 +08:00
} else if ( ! json [ " success " ] . toBool ( ) ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , tr ( " Clear Program " ) + " " + tr ( " Failed " ) ) ;
2023-04-18 14:14:46 +08:00
} else waitingDlg - > success ( ) ;
} ) ;
2023-05-11 11:47:00 +08:00
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , QString ( socketErrKey ( err ) ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-05-15 16:06:10 +08:00
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-04-18 14:14:46 +08:00
} else {
2023-10-23 15:08:45 +08:00
for ( auto & card : gSelCards ) {
2023-08-07 09:04:53 +08:00
auto tcp = new TcpSocket ;
2023-05-15 16:06:10 +08:00
auto cardId = card . id ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : connected , tcp , [ = ] {
tcp - > stopTimer ( ) ;
tcp - > write ( JToBytes ( json ) ) ;
tcp - > startTimer ( 10000 ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
tcp - > stopTimer ( ) ;
auto resp = tcp - > readAll ( ) ;
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
QString error ;
auto json = JFrom ( resp , & error ) ;
if ( ! error . isEmpty ( ) ) gFdResInfo - > append ( cardId + " " + tr ( " Clear Program " ) + " " + error ) ;
2023-04-18 14:14:46 +08:00
else if ( ! json [ " success " ] . toBool ( ) ) gFdResInfo - > append ( cardId + " " + tr ( " Clear Program " ) + " " + tr ( " Failed " ) ) ;
else gFdResInfo - > append ( cardId + " " + tr ( " Clear Program " ) + " " + tr ( " Success " ) ) ;
} ) ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
gFdResInfo - > append ( cardId + " " + tr ( " Clear Program " ) + " " + socketErrKey ( err ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-05-15 16:06:10 +08:00
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-04-18 14:14:46 +08:00
}
}
} ) ;
hBox - > addWidget ( btnClearProg ) ;
2023-08-01 11:42:41 +08:00
btnGetPlayerState = new QPushButton ;
btnGetPlayerState - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnGetPlayerState , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
JObj json { { " _type " , " getPlayerState " } , { " _id " , " getPlayerState " } , { " zVer " , " xixun1 " } } ;
if ( gSelCards . count ( ) = = 1 ) {
2023-08-07 09:04:53 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting Player State " ) + " ... " ) ;
waitingDlg - > showLater ( ) ;
2023-08-01 11:42:41 +08:00
auto card = gSelCards [ 0 ] ;
2023-08-07 09:04:53 +08:00
auto tcp = new TcpSocket ;
2023-08-01 11:42:41 +08:00
connect ( waitingDlg , & WaitingDlg : : rejected , tcp , [ = ] {
tcp - > abort ( ) ;
tcp - > deleteLater ( ) ;
} ) ;
connect ( tcp , & QTcpSocket : : connected , tcp , [ = ] {
2023-08-07 09:04:53 +08:00
tcp - > stopTimer ( ) ;
2023-08-01 11:42:41 +08:00
tcp - > write ( JToBytes ( json ) ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-08-01 11:42:41 +08:00
} ) ;
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
2023-08-07 09:04:53 +08:00
tcp - > stopTimer ( ) ;
auto resp = tcp - > readAll ( ) ;
2023-08-01 11:42:41 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
waitingDlg - > close ( ) ;
QString error ;
auto json = JFrom ( resp , & error ) ;
if ( ! error . isEmpty ( ) ) {
QMessageBox : : critical ( this , tr ( " Error " ) , error ) ;
return ;
}
QMessageBox : : information ( this , tr ( " Player State " ) , json [ " code " ] . toStr ( ) + " . " + json [ " des_en " ] . toStr ( ) + " \n " + json [ " des " ] . toStr ( ) ) ;
2023-08-01 11:42:41 +08:00
} ) ;
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
waitingDlg - > close ( ) ;
2023-08-07 09:04:53 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , QString ( socketErrKey ( err ) ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
2023-08-01 11:42:41 +08:00
} ) ;
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-08-01 11:42:41 +08:00
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-07 09:04:53 +08:00
auto tcp = new TcpSocket ;
2023-08-01 11:42:41 +08:00
auto cardId = card . id ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : connected , tcp , [ = ] {
tcp - > stopTimer ( ) ;
2023-08-01 11:42:41 +08:00
tcp - > write ( JToBytes ( json ) ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-08-01 11:42:41 +08:00
} ) ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
tcp - > stopTimer ( ) ;
auto resp = tcp - > readAll ( ) ;
2023-08-01 11:42:41 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
QString error ;
auto json = JFrom ( resp , & error ) ;
if ( ! error . isEmpty ( ) ) {
gFdResInfo - > append ( cardId + " " + tr ( " Get Player State " ) + " " + error ) ;
return ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Player State " ) + " " + json [ " code " ] . toStr ( ) + " . " + json [ " des_en " ] . toStr ( ) + " \n " + json [ " des " ] . toStr ( ) ) ;
2023-08-01 11:42:41 +08:00
} ) ;
2023-08-07 09:04:53 +08:00
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
2023-08-01 11:42:41 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
2023-08-07 09:04:53 +08:00
gFdResInfo - > append ( cardId + " " + tr ( " Get Player State " ) + " " + socketErrKey ( err ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
2023-08-01 11:42:41 +08:00
} ) ;
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-08-07 09:04:53 +08:00
tcp - > startTimer ( 10000 ) ;
2023-08-01 11:42:41 +08:00
}
}
} ) ;
hBox - > addWidget ( btnGetPlayerState ) ;
2023-04-18 14:14:46 +08:00
btnGetLog = new QPushButton ;
btnGetLog - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnGetLog , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting Log " ) + " ... " ) ;
waitingDlg - > show ( ) ;
2023-05-15 16:06:10 +08:00
auto card = gSelCards [ 0 ] ;
auto reply = NetReq ( " http:// " + card . ip + " :2016/download?file=logs " ) . timeout ( 120000 ) . get ( ) ;
2023-10-23 15:08:45 +08:00
ConnReply ( reply , waitingDlg ) [ = ] {
2023-04-18 14:14:46 +08:00
waitingDlg - > close ( ) ;
QString err = checkReply ( reply ) ;
if ( ! err . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , err ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-10-23 15:08:45 +08:00
auto wgt = new QWidget ( this , Qt : : Window ) ;
wgt - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
wgt - > resize ( 800 , 800 ) ;
auto vv = new VBox ( wgt ) ;
vv - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
auto fdLog = new QTextEdit ;
fdLog - > setPlainText ( reply - > readAll ( ) ) ;
vv - > addWidget ( fdLog ) ;
wgt - > show ( ) ;
wgt - > raise ( ) ;
wgt - > activateWindow ( ) ;
2023-04-18 14:14:46 +08:00
} ) ;
}
} ) ;
hBox - > addWidget ( btnGetLog ) ;
2024-08-07 18:18:37 +08:00
auto btnLogOn = new QPushButton ( " Log On " ) ;
btnLogOn - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnLogOn , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
JObj json ;
json . insert ( " _id " , " SetLogSwitch " ) ;
json . insert ( " _type " , " SetLogSwitch " ) ;
json . insert ( " isOn " , true ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " SetRealtimeServer " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
for ( auto & card : gSelCards ) {
Def_CtrlSetMulti ( tr ( " SetRealtimeServer " ) )
}
}
} ) ;
hBox - > addWidget ( btnLogOn ) ;
auto btnLogOff = new QPushButton ( " Log Off " ) ;
btnLogOff - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnLogOff , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
JObj json ;
json . insert ( " _id " , " SetLogSwitch " ) ;
json . insert ( " _type " , " SetLogSwitch " ) ;
json . insert ( " isOn " , false ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " SetRealtimeServer " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
for ( auto & card : gSelCards ) {
Def_CtrlSetMulti ( tr ( " SetRealtimeServer " ) )
}
}
} ) ;
hBox - > addWidget ( btnLogOff ) ;
2024-02-21 18:08:50 +08:00
hBox - > addStretch ( ) ;
2024-08-07 18:18:37 +08:00
grpPlayer = new QGroupBox ;
vBox - > addWidget ( grpPlayer ) ;
hBox = new HBox ( grpPlayer ) ;
hBox - > setContentsMargins ( 6 , 0 , 6 , 6 ) ;
auto btnViewProg = new QPushButton ( " View JSON " ) ;
2024-02-21 18:08:50 +08:00
btnViewProg - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnViewProg , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
2024-08-07 18:18:37 +08:00
JObj json { { " _type " , " GetJsonWithFileInfo " } } ;
auto edit = new QTextEdit ;
2024-05-23 17:13:51 +08:00
LocalObj lll ;
2024-08-07 18:18:37 +08:00
connect ( edit , & QTextEdit : : destroyed , & lll , & LocalObj : : reset ) ;
edit - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
edit - > setTabStopDistance ( 26 ) ;
auto ft = edit - > font ( ) ;
2024-02-21 18:08:50 +08:00
ft . setFamily ( " Consolas " ) ;
2024-08-07 18:18:37 +08:00
edit - > setFont ( ft ) ;
edit - > setWindowTitle ( " program " ) ;
edit - > resize ( 600 , 900 ) ;
edit - > show ( ) ;
2024-02-21 18:08:50 +08:00
for ( auto & card : gSelCards ) {
2024-08-07 18:18:37 +08:00
edit - > append ( card . id + " Prog JSON " ) ;
2024-05-23 17:13:51 +08:00
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
2024-06-19 18:54:32 +08:00
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
2024-08-07 18:18:37 +08:00
edit - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected \n " ) ;
2024-05-23 17:13:51 +08:00
continue ;
}
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
2024-08-07 18:18:37 +08:00
edit - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write \n " ) ;
2024-05-23 17:13:51 +08:00
continue ;
}
if ( ! tcp . waitForReadyRead ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
2024-08-07 18:18:37 +08:00
edit - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead \n " ) ;
2024-05-23 17:13:51 +08:00
continue ;
}
2024-08-07 18:18:37 +08:00
edit - > append ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
while ( tcp . waitForReadyRead ( 1000 ) ) {
if ( lll . cnt = = 0 ) return ;
2024-08-07 18:18:37 +08:00
edit - > insertPlainText ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
}
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
2024-08-07 18:18:37 +08:00
if ( tcp . error ( ) ! = QAbstractSocket : : SocketTimeoutError ) edit - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead2 \n " ) ;
edit - > append ( " END " ) ;
2024-02-21 18:08:50 +08:00
}
} ) ;
hBox - > addWidget ( btnViewProg ) ;
2024-08-07 18:18:37 +08:00
auto btnGetPlayerInfo = new QPushButton ( " Get Info " ) ;
btnGetPlayerInfo - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnGetPlayerInfo , & QPushButton : : clicked , this , [ this ] {
2024-02-21 18:08:50 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
2024-08-07 18:18:37 +08:00
JObj json { { " _type " , " GetInfo " } } ;
2024-02-21 18:08:50 +08:00
auto fd = new QTextEdit ;
2024-05-23 17:13:51 +08:00
LocalObj lll ;
connect ( fd , & QTextEdit : : destroyed , & lll , & LocalObj : : reset ) ;
2024-02-21 18:08:50 +08:00
fd - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
auto ft = fd - > font ( ) ;
ft . setFamily ( " Consolas " ) ;
fd - > setFont ( ft ) ;
2024-08-07 18:18:37 +08:00
fd - > setWindowTitle ( " Get Player Info " ) ;
2024-02-21 18:08:50 +08:00
fd - > resize ( 600 , 900 ) ;
fd - > show ( ) ;
for ( auto & card : gSelCards ) {
2024-08-07 18:18:37 +08:00
fd - > append ( card . id + " Player Info " ) ;
2024-05-23 17:13:51 +08:00
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
2024-06-19 18:54:32 +08:00
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected \n " ) ;
continue ;
}
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write \n " ) ;
continue ;
}
if ( ! tcp . waitForReadyRead ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead \n " ) ;
continue ;
}
2024-08-07 18:18:37 +08:00
fd - > append ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
while ( tcp . waitForReadyRead ( 1000 ) ) {
if ( lll . cnt = = 0 ) return ;
2024-06-06 21:55:36 +08:00
fd - > insertPlainText ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
}
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
if ( tcp . error ( ) ! = QAbstractSocket : : SocketTimeoutError ) fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead2 \n " ) ;
2024-08-07 18:18:37 +08:00
fd - > append ( " END " ) ;
2024-02-21 18:08:50 +08:00
}
} ) ;
2024-08-07 18:18:37 +08:00
hBox - > addWidget ( btnGetPlayerInfo ) ;
2024-02-21 18:08:50 +08:00
2024-08-07 18:18:37 +08:00
auto GetBuf = new QPushButton ( " Get Log " ) ;
GetBuf - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( GetBuf , & QPushButton : : clicked , this , [ this ] {
2024-02-21 18:08:50 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
2024-08-07 18:18:37 +08:00
JObj json { { " _type " , " GetLog " } } ;
2024-02-21 18:08:50 +08:00
auto fd = new QTextEdit ;
2024-05-23 17:13:51 +08:00
LocalObj lll ;
connect ( fd , & QTextEdit : : destroyed , & lll , & LocalObj : : reset ) ;
2024-02-21 18:08:50 +08:00
fd - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
auto ft = fd - > font ( ) ;
ft . setFamily ( " Consolas " ) ;
fd - > setFont ( ft ) ;
2024-08-07 18:18:37 +08:00
fd - > setWindowTitle ( " Get Player Log " ) ;
2024-02-21 18:08:50 +08:00
fd - > resize ( 600 , 900 ) ;
fd - > show ( ) ;
for ( auto & card : gSelCards ) {
2024-08-07 18:18:37 +08:00
fd - > append ( card . id + " Player Log " ) ;
2024-05-23 17:13:51 +08:00
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
2024-06-19 18:54:32 +08:00
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected \n " ) ;
continue ;
}
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write \n " ) ;
continue ;
}
if ( ! tcp . waitForReadyRead ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead \n " ) ;
continue ;
}
2024-08-07 18:18:37 +08:00
fd - > append ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
while ( tcp . waitForReadyRead ( 1000 ) ) {
if ( lll . cnt = = 0 ) return ;
2024-06-06 21:55:36 +08:00
fd - > insertPlainText ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
}
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
if ( tcp . error ( ) ! = QAbstractSocket : : SocketTimeoutError ) fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead2 \n " ) ;
2024-08-07 18:18:37 +08:00
fd - > append ( " END " ) ;
2024-02-21 18:08:50 +08:00
}
} ) ;
2024-08-07 18:18:37 +08:00
hBox - > addWidget ( GetBuf ) ;
2024-02-21 18:08:50 +08:00
2024-08-07 18:18:37 +08:00
auto btnListFiles = new QPushButton ( " List Files " ) ;
btnListFiles - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnListFiles , & QPushButton : : clicked , this , [ this ] {
2024-02-21 18:08:50 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
2024-08-07 18:18:37 +08:00
JObj json { { " _type " , " ListProgFiles " } } ;
2024-02-21 18:08:50 +08:00
auto fd = new QTextEdit ;
2024-05-23 17:13:51 +08:00
LocalObj lll ;
connect ( fd , & QTextEdit : : destroyed , & lll , & LocalObj : : reset ) ;
2024-02-21 18:08:50 +08:00
fd - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
auto ft = fd - > font ( ) ;
ft . setFamily ( " Consolas " ) ;
fd - > setFont ( ft ) ;
2024-08-07 18:18:37 +08:00
fd - > setWindowTitle ( " List Prog Files " ) ;
2024-02-21 18:08:50 +08:00
fd - > resize ( 600 , 900 ) ;
fd - > show ( ) ;
for ( auto & card : gSelCards ) {
2024-08-07 18:18:37 +08:00
fd - > append ( card . id + " Prog Files " ) ;
2024-05-23 17:13:51 +08:00
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
2024-06-19 18:54:32 +08:00
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected \n " ) ;
continue ;
}
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write \n " ) ;
continue ;
}
if ( ! tcp . waitForReadyRead ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead \n " ) ;
continue ;
}
2024-08-07 18:18:37 +08:00
fd - > append ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
while ( tcp . waitForReadyRead ( 1000 ) ) {
if ( lll . cnt = = 0 ) return ;
2024-06-06 21:55:36 +08:00
fd - > insertPlainText ( tcp . readAll ( ) ) ;
2024-05-23 17:13:51 +08:00
}
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-05-23 17:13:51 +08:00
if ( lll . cnt = = 0 ) return ;
if ( tcp . error ( ) ! = QAbstractSocket : : SocketTimeoutError ) fd - > append ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead2 \n " ) ;
2024-08-07 18:18:37 +08:00
fd - > append ( " END " ) ;
2024-02-21 18:08:50 +08:00
}
} ) ;
2024-08-07 18:18:37 +08:00
hBox - > addWidget ( btnListFiles ) ;
2024-02-21 18:08:50 +08:00
2024-06-06 21:55:36 +08:00
auto btnDownFile = new QPushButton ( " Down File " ) ;
btnDownFile - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnDownFile , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QInputDialog dlg ( this ) ;
dlg . setWindowTitle ( " Input File Name " ) ;
dlg . setLabelText ( " File Name " ) ;
if ( dlg . exec ( ) ! = QDialog : : Accepted ) return ;
auto name = dlg . textValue ( ) ;
if ( name . isEmpty ( ) ) return ;
auto tar = QFileDialog : : getSaveFileName ( this , " Save File " , QStandardPaths : : writableLocation ( QStandardPaths : : DownloadLocation ) + " / " + name ) ;
if ( tar . isEmpty ( ) ) return ;
JObj json { { " _type " , " GetFile " } , { " name " , name } } ;
QProgressBar fdProgress ;
fdProgress . show ( ) ;
for ( auto & card : gSelCards ) {
fdProgress . setWindowTitle ( " Progress " + card . id ) ;
fdProgress . setValue ( 0 ) ;
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
2024-06-19 18:54:32 +08:00
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
2024-06-06 21:55:36 +08:00
if ( ! fdProgress . isVisible ( ) ) return ;
QMessageBox : : information ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected " ) ;
continue ;
}
QFile file ( tar + " " + card . id ) ;
if ( ! file . open ( QFile : : WriteOnly ) ) continue ;
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2024-06-19 18:54:32 +08:00
tcp . close ( ) ;
2024-06-06 21:55:36 +08:00
if ( ! fdProgress . isVisible ( ) ) return ;
QMessageBox : : information ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write " ) ;
continue ;
}
resNum = 0 ;
qint64 tarSize = 0 ;
while ( tcp . waitForReadyRead ( 10000 ) ) {
if ( ! fdProgress . isVisible ( ) ) return ;
if ( tarSize = = 0 ) {
QString err ;
auto json = JFrom ( & tcp , & err ) ;
if ( ! err . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Error " ) , err ) ;
goto end ;
}
auto msg = json [ " msg " ] . toStr ( ) ;
if ( ! msg . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Error " ) , msg ) ;
goto end ;
}
tarSize = json [ " len " ] . toLong ( ) ;
if ( tarSize = = 0 ) {
QMessageBox : : information ( this , tr ( " Error " ) , " tarSize==0 " ) ;
goto end ;
}
fdProgress . setMaximum ( tarSize ) ;
}
auto res = tcp . readAll ( ) ;
if ( res . size ( ) = = 0 ) continue ;
if ( file . write ( res ) ! = res . size ( ) ) {
QMessageBox : : information ( this , tr ( " Error " ) , " write error " ) ;
goto end ;
}
resNum + = res . size ( ) ;
fdProgress . setValue ( resNum ) ;
if ( resNum > = tarSize ) goto end ;
}
QMessageBox : : information ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitRead2 \n " ) ;
end :
tcp . close ( ) ;
}
fdProgress . close ( ) ;
QMessageBox : : information ( this , tr ( " Error " ) , " OK " ) ;
} ) ;
hBox - > addWidget ( btnDownFile ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
hBox - > addWidget ( lbTimingReboot = new QLabel ) ;
auto fdRebootTime = new QLineEdit ;
fdRebootTime - > setMaximumWidth ( 60 ) ;
hBox - > addWidget ( fdRebootTime ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetTimingReboot " ) ;
json . insert ( " _type " , " SetTimingReboot " ) ;
json . insert ( " time " , fdRebootTime - > text ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting Timing Reboot " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set Timing Reboot " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetTimingReboot " ) ;
json . insert ( " _type " , " GetTimingReboot " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting Timing Reboot " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
fdRebootTime - > setText ( json [ " time " ] . toString ( ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) err = json [ " time " ] . toString ( ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Get Timing Reboot " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
2023-08-01 11:42:41 +08:00
grpY50 = new QGroupBox ;
{
auto hBox = new HBox ( grpY50 ) ;
2023-04-18 14:14:46 +08:00
2023-08-01 11:42:41 +08:00
auto fdY50Resolu = new QComboBox ;
2024-02-21 18:08:50 +08:00
auto params = QDir ( QApplication : : applicationDirPath ( ) + " /rk_lcd_parameters " ) . entryList ( QDir : : Files ) ;
for ( auto & param : params ) fdY50Resolu - > addItem ( param ) ;
2023-08-01 11:42:41 +08:00
fdY50Resolu - > setMinimumWidth ( 160 ) ;
hBox - > addWidget ( fdY50Resolu ) ;
2023-04-18 14:14:46 +08:00
2023-08-01 11:42:41 +08:00
btnY50Set = new QPushButton ;
btnY50Set - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnY50Set , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
2023-04-18 14:14:46 +08:00
}
2024-02-21 18:08:50 +08:00
auto file = QApplication : : applicationDirPath ( ) + " /rk_lcd_parameters/ " + fdY50Resolu - > currentText ( ) ;
QFile qFile ( file ) ;
2023-08-01 11:42:41 +08:00
if ( ! qFile . exists ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " File not exist " ) ) ;
return ;
2023-04-18 14:14:46 +08:00
}
2023-08-01 11:42:41 +08:00
if ( ! qFile . open ( QIODevice : : ReadOnly ) ) {
2024-02-21 18:08:50 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Cannot Open File " ) + " : " + qFile . errorString ( ) + " \n " + file ) ;
2023-08-01 11:42:41 +08:00
return ;
2023-04-18 14:14:46 +08:00
}
2023-08-01 11:42:41 +08:00
auto fileData = qFile . readAll ( ) ;
qFile . close ( ) ;
2023-04-18 14:14:46 +08:00
2023-08-01 11:42:41 +08:00
auto Boundary = " ----QtLedOK_.oOo._ " + QUuid : : createUuid ( ) . toByteArray ( QUuid : : WithoutBraces ) ;
QByteArray data ;
data . append ( " -- " ) . append ( Boundary ) . append ( " \r \n Content-Disposition: form-data; name= \" rk_lcd_parameters \" ; filename= \" rk_lcd_parameters \" \r \n \r \n " ) . append ( fileData ) . append ( " \r \n " ) ;
data . append ( " -- " ) . append ( Boundary ) . append ( " -- \r \n " ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " Uploading " ) + " ... " ) ;
waitingDlg - > show ( ) ;
NetReq req ( " http:// " + gSelCards [ 0 ] . ip + " :2016/upload?type=update_display " ) ;
auto reply = req . timeout ( 120000 ) . type ( " multipart/form-data; boundary= " + Boundary ) . post ( data ) ;
2023-10-23 15:08:45 +08:00
ConnReply ( reply , waitingDlg ) [ = ] {
2023-08-01 11:42:41 +08:00
QString err = checkReply ( reply ) ;
if ( ! err . isEmpty ( ) ) {
waitingDlg - > close ( ) ;
QMessageBox : : critical ( this , tr ( " Error " ) , err ) ;
return ;
}
waitingDlg - > success ( ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
NetReq req ( " http:// " + card . ip + " :2016/upload?type=update_display " ) ;
auto reply = req . timeout ( 120000 ) . type ( " multipart/form-data; boundary= " + Boundary ) . post ( data ) ;
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QString err = checkReply ( reply ) ;
gFdResInfo - > append ( card . id + " " + tr ( " Update " ) + " " + ( err . isEmpty ( ) ? tr ( " Success " ) : err ) ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnY50Set ) ;
hBox - > addStretch ( ) ;
}
vBox - > addWidget ( grpY50 ) ;
2023-04-18 14:14:46 +08:00
hBox = new HBox ( vBox ) ;
lbDisMode = new QLabel ;
hBox - > addWidget ( lbDisMode ) ;
fdDisMode = new QComboBox ;
fdDisMode - > setSizeAdjustPolicy ( QComboBox : : AdjustToContents ) ;
fdDisMode - > addItem ( " Full screen " , 1 ) ;
fdDisMode - > addItem ( " Part " , 2 ) ;
hBox - > addWidget ( fdDisMode ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) + " ... " ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetDisplayModel " ) ;
json . insert ( " _type " , " SetDisplayModel " ) ;
json . insert ( " model " , fdDisMode - > currentData ( ) . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Set Display Mode " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set Display Mode " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetDisplayModel " ) ;
json . insert ( " _type " , " GetDisplayModel " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Get Display Mode " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
2023-10-23 15:08:45 +08:00
SetCurData ( fdDisMode , json [ " result " ] . toInt ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) {
auto result = json [ " result " ] . toInt ( ) ;
int idx = fdDisMode - > findData ( result ) ;
if ( idx ! = - 1 ) err = fdDisMode - > itemText ( idx ) ;
else err = QString : : number ( result ) ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Get Display Mode " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addSpacing ( 40 ) ;
lbScreenPos = new QLabel ;
hBox - > addWidget ( lbScreenPos ) ;
auto fdScreenPos = new QSpinBox ;
fdScreenPos - > setRange ( 0 , 99999 ) ;
hBox - > addWidget ( fdScreenPos ) ;
lbScreenOff = new QLabel ;
hBox - > addWidget ( lbScreenOff ) ;
auto fdScreenOff = new QSpinBox ;
fdScreenOff - > setRange ( - 9999 , 99999 ) ;
hBox - > addWidget ( fdScreenOff ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " ConfigScreen " ) ;
json . insert ( " _type " , " ConfigScreen " ) ;
json . insert ( " index " , fdScreenPos - > value ( ) ) ;
json . insert ( " x " , fdScreenOff - > value ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Set Screen Offset " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set Screen Offset " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetConfigScreen " ) ;
json . insert ( " _type " , " GetConfigScreen " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Get Screen Offset " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
fdScreenPos - > setValue ( json [ " offsetNum " ] . toInt ( ) ) ;
fdScreenOff - > setValue ( json [ " offsetValue " ] . toInt ( ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) {
err = lbScreenPos - > text ( ) + " " + QString : : number ( json [ " offsetNum " ] . toInt ( ) ) + " . " + lbScreenOff - > text ( ) + " " + QString : : number ( json [ " offsetValue " ] . toInt ( ) ) ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Get Screen Offset " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
2024-07-03 18:32:38 +08:00
{
hBox = new HBox ( vBox ) ;
lbCameraDis = new QLabel ;
hBox - > addWidget ( lbCameraDis ) ;
auto edCameraDisMin = new QSpinBox ;
edCameraDisMin - > setRange ( 0 , 99999 ) ;
hBox - > addWidget ( edCameraDisMin ) ;
hBox - > addLabel ( " ~ " ) ;
auto edCameraDisMax = new QSpinBox ;
edCameraDisMax - > setRange ( 0 , 99999 ) ;
hBox - > addWidget ( edCameraDisMax ) ;
hBox - > addLabel ( " mm " ) ;
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
JObj json ;
json . insert ( " _id " , " SetCameraRange " ) ;
json . insert ( " _type " , " SetCameraRange " ) ;
json . insert ( " min " , edCameraDisMin - > value ( ) ) ;
json . insert ( " max " , edCameraDisMax - > value ( ) ) ;
json . insert ( " zVer " , " xixun1 " ) ;
if ( gSelCards . count ( ) = = 1 ) {
WaitingDlg waitingDlg ( this , tr ( " Setting Camera Range " ) + " ... " ) ;
waitingDlg . showLater ( ) ;
auto card = gSelCards [ 0 ] ;
TcpSocket tcp ;
tcp . connectToHost ( card . ip , 3333 ) ;
if ( ! tcp . waitForConnected ( 10000 ) ) {
tcp . close ( ) ;
if ( ! waitingDlg . isVisible ( ) ) return ;
waitingDlg . close ( ) ;
QMessageBox : : critical ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitConnected " ) ;
return ;
}
auto resNum = tcp . write ( JToBytes ( json ) ) ;
tcp . flush ( ) ;
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( 10000 ) ) {
tcp . close ( ) ;
if ( ! waitingDlg . isVisible ( ) ) return ;
waitingDlg . close ( ) ;
QMessageBox : : critical ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at write " ) ;
return ;
}
if ( ! tcp . waitForReadyRead ( 10000 ) ) {
tcp . close ( ) ;
if ( ! waitingDlg . isVisible ( ) ) return ;
waitingDlg . close ( ) ;
QMessageBox : : critical ( this , tr ( " Error " ) , QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " at WaitForReadyRead " ) ;
return ;
}
tcp . readAll ( ) ;
tcp . close ( ) ;
waitingDlg . success ( ) ;
} else {
for ( auto & card : gSelCards ) {
auto tcp = new TcpSocket ;
auto cardId = card . id ;
connect ( tcp , & QTcpSocket : : connected , tcp , [ = ] {
tcp - > stopTimer ( ) ;
tcp - > write ( JToBytes ( json ) ) ;
tcp - > startTimer ( 10000 ) ;
} ) ;
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
tcp - > stopTimer ( ) ;
auto resp = tcp - > readAll ( ) ;
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
QString error ;
auto json = JFrom ( resp , & error ) ;
if ( ! error . isEmpty ( ) ) {
gFdResInfo - > append ( cardId + " " + tr ( " Set Camera Range " ) + " " + error ) ;
return ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Set Camera Range " ) + " " + tr ( " Success " ) ) ;
} ) ;
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Set Camera Range " ) + " " + socketErrKey ( err ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
} ) ;
tcp - > connectToHost ( card . ip , 3333 ) ;
tcp - > startTimer ( 10000 ) ;
}
}
} ) ;
hBox - > addWidget ( btn ) ;
hBox - > addStretch ( ) ;
}
2023-04-18 14:14:46 +08:00
hBox = new HBox ( vBox ) ;
2023-08-01 11:42:41 +08:00
btnLedSet = new QPushButton ;
btnLedSet - > setMinimumHeight ( 30 ) ;
btnLedSet - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnLedSet , & QPushButton : : clicked , btnLedSet , [ ] {
2023-04-18 14:14:46 +08:00
QFileInfo file ( " LedSet4.0/LedSet4.0.exe " ) ;
2024-02-21 18:08:50 +08:00
if ( file . exists ( ) ) QProcess : : startDetached ( file . absoluteFilePath ( ) , QStringList ( ) , file . absolutePath ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-08-01 11:42:41 +08:00
hBox - > addWidget ( btnLedSet ) ;
hBox - > addStretch ( ) ;
2023-04-18 14:14:46 +08:00
2024-02-21 18:08:50 +08:00
hBox = new HBox ( vBox ) ;
btnReceCardsGet = new QPushButton ;
btnReceCardsGet - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnReceCardsGet , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetReceCards " ) ;
json . insert ( " _type " , " GetReceCards " ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , btnReceCardsGet - > text ( ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > close ( ) ;
QMessageBox : : information ( this , btnReceCardsGet - > text ( ) , QString : : number ( json [ " receCardNum " ] . toInt ( ) ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2024-02-21 18:08:50 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) err = QString : : number ( json [ " receCardNum " ] . toInt ( ) ) ;
gFdResInfo - > append ( cardId + " " + btnReceCardsGet - > text ( ) + " " + err ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnReceCardsGet ) ;
hBox - > addStretch ( ) ;
2024-05-23 17:13:51 +08:00
// hBox = new HBox(vBox);
// auto btnTool = new QPushButton("EasyTool");
// btnTool->setMinimumHeight(30);
// btnTool->setProperty("ssType", "progManageTool");
// connect(btnTool, &QPushButton::clicked, btnTool, [] {
// QFileInfo file("EasyTool/EasyTool.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnTool);
// auto btnVMS = new QPushButton("EasyVMS");
// btnVMS->setMinimumHeight(30);
// btnVMS->setProperty("ssType", "progManageTool");
// connect(btnVMS, &QPushButton::clicked, btnVMS, [] {
// QFileInfo file("EasyVMS/EasyVMS.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnVMS);
// hBox->addStretch();
2023-05-25 10:00:00 +08:00
# ifndef Q_OS_WIN
2023-08-01 11:42:41 +08:00
btnLedSet - > setVisible ( false ) ;
2023-05-08 09:59:15 +08:00
# endif
2023-04-18 14:14:46 +08:00
auto line = new QFrame ;
line - > setFrameShape ( QFrame : : HLine ) ;
line - > setFrameShadow ( QFrame : : Sunken ) ;
vBox - > addWidget ( line ) ;
hBox = new HBox ( vBox ) ;
btnBindTaxiIc = new QPushButton ;
btnBindTaxiIc - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnBindTaxiIc , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QString icFile = QFileDialog : : getOpenFileName ( this , " open file dialog " , " " , tr ( " indentity voucher (*.ic) " ) ) ;
if ( icFile . isEmpty ( ) ) return ;
QFile file ( icFile ) ;
if ( ! file . open ( QIODevice : : ReadOnly ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Open file Failed " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto data = file . readAll ( ) ;
file . close ( ) ;
QJsonParseError jsonErr ;
QJsonDocument icJson = QJsonDocument : : fromJson ( data , & jsonErr ) ;
if ( jsonErr . error ! = QJsonParseError : : NoError ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , " JsonError " + jsonErr . errorString ( ) + " \n " + data ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject jsonCommand ;
jsonCommand . insert ( " action " , " BindAccount " ) ;
jsonCommand . insert ( " accountIdToken " , icJson [ " account_id_token " ] ) ;
jsonCommand . insert ( " server " , icJson [ " taxiServerURL " ] ) ;
jsonCommand . insert ( " tlsServer " , icJson [ " taxiServerTLSURL " ] ) ;
QJsonObject json ;
json . insert ( " action " , " InvokeTaxiAppFunction " ) ;
json . insert ( " jsonCommand " , jsonCommand ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " InvokeTaxiAppFunction " ) ) ;
waitingDlg - > show ( ) ;
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + gSelCards [ 0 ] . ip + " :3000 " ) . timeout ( 120000 ) . post ( json ) ;
2023-10-23 15:08:45 +08:00
ConnReply ( reply , waitingDlg ) [ = ] {
2023-04-18 14:14:46 +08:00
QString err = checkReply ( reply ) ;
if ( ! err . isEmpty ( ) ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , err ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto data = reply - > readAll ( ) ;
QJsonParseError jsonErr ;
QJsonDocument json = QJsonDocument : : fromJson ( data , & jsonErr ) ;
if ( jsonErr . error ! = QJsonParseError : : NoError ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , " JsonError " + jsonErr . errorString ( ) + " \n " + data ) ;
2023-04-18 14:14:46 +08:00
return ;
}
if ( json [ " result " ] . toString ( ) ! = " true " ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , data ) ;
2023-04-18 14:14:46 +08:00
return ;
}
waitingDlg - > success ( ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :3000 " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QString err = checkReply ( reply ) ;
if ( ! err . isEmpty ( ) ) {
gFdResInfo - > append ( cardId + " " + tr ( " InvokeTaxiAppFunction " ) + " " + tr ( " Error " ) + " " + err ) ;
return ;
}
auto data = reply - > readAll ( ) ;
QJsonParseError jsonErr ;
QJsonDocument json = QJsonDocument : : fromJson ( data , & jsonErr ) ;
if ( jsonErr . error ! = QJsonParseError : : NoError ) {
gFdResInfo - > append ( cardId + " " + tr ( " InvokeTaxiAppFunction " ) + " " + tr ( " Error " ) + " JsonError " + jsonErr . errorString ( ) + " \n " + data ) ;
return ;
}
if ( json [ " result " ] . toString ( ) ! = " true " ) {
gFdResInfo - > append ( cardId + " " + tr ( " InvokeTaxiAppFunction " ) + " " + tr ( " Error " ) + " " + data ) ;
return ;
}
gFdResInfo - > append ( cardId + " " + tr ( " InvokeTaxiAppFunction " ) + " " + QCoreApplication : : translate ( " Def " , " Success " ) ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnBindTaxiIc ) ;
hBox - > addStretch ( ) ;
grpHighForBusy = new QGroupBox ;
grpHighForBusy - > setVisible ( false ) ;
hBox = new HBox ( grpHighForBusy ) ;
fdHighForBusy = new QRadioButton ;
fdHighForBusy - > setChecked ( true ) ;
hBox - > addWidget ( fdHighForBusy ) ;
fdTopLevelLH = new QRadioButton ;
hBox - > addWidget ( fdTopLevelLH ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetHighForBusy " ) ;
json . insert ( " _type " , " SetHighForBusy " ) ;
json . insert ( " busyState " , fdTopLevelLH - > isChecked ( ) ? 0 : 1 ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetHighForBusy " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetHighForBusy " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
btnGetTopLevel = new QPushButton ;
btnGetTopLevel - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnGetTopLevel , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetStateForBusy " ) ;
json . insert ( " _type " , " GetStateForBusy " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " GetStateForBusy " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ this , reply , waitingDlg ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
if ( json [ " result " ] . toInt ( ) = = 0 ) fdTopLevelLH - > setChecked ( true ) ;
else fdHighForBusy - > setChecked ( true ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) err = json [ " result " ] . toInt ( ) ? tr ( " Service:High Out of service:Low " ) : tr ( " Service:Low Out of service:High " ) ;
gFdResInfo - > append ( cardId + " " + tr ( " GetStateForBusy " ) + " " + err ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnGetTopLevel ) ;
hBox - > addStretch ( ) ;
vBox - > addWidget ( grpHighForBusy ) ;
grpMinMaxBrightness = new QGroupBox ( ) ;
grpMinMaxBrightness - > setVisible ( false ) ;
hBox = new HBox ( grpMinMaxBrightness ) ;
lbMinBright = new QLabel ( ) ;
hBox - > addWidget ( lbMinBright ) ;
fdMinBright = new QLineEdit ( " 1 " ) ;
fdMinBright - > setPlaceholderText ( " 1 " ) ;
fdMinBright - > setMaximumWidth ( 50 ) ;
hBox - > addWidget ( fdMinBright ) ;
hBox - > addWidget ( new QLabel ( " % " ) ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetMinBrightness " ) ;
json . insert ( " _type " , " SetMinBrightness " ) ;
json . insert ( " minBrightnessPercentage " , fdMinBright - > text ( ) . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetMinBrightness " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetMinBrightness " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetMinBrightness " ) ;
json . insert ( " _type " , " GetMinBrightness " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-25 16:30:58 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " GetMinBrightness " ) + " ... " ) ;
2023-04-18 14:14:46 +08:00
Def_CtrlReqPre
2023-05-15 16:06:10 +08:00
auto brightLevel = card . BrightnessLevel ;
2023-04-25 16:30:58 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
2023-04-25 16:30:58 +08:00
auto value = json [ " minBrightnessPercentage " ] . toInt ( - 1 ) ;
if ( value = = - 1 ) value = qRound ( json [ " brightness " ] . toInt ( ) * 100.0 / brightLevel ) ;
fdMinBright - > setText ( QString : : number ( value ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
auto brightLevel = card . BrightnessLevel ;
2023-04-25 16:30:58 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
2023-04-25 16:30:58 +08:00
if ( err . isEmpty ( ) ) {
auto value = json [ " minBrightnessPercentage " ] . toInt ( - 1 ) ;
if ( value = = - 1 ) value = qRound ( json [ " brightness " ] . toInt ( ) * 100.0 / brightLevel ) ;
err = QString : : number ( value ) + " % " ;
}
2023-04-18 14:14:46 +08:00
gFdResInfo - > append ( cardId + " " + tr ( " GetMinBrightness " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addSpacing ( 10 ) ;
label_3 = new QLabel ( ) ;
hBox - > addWidget ( label_3 ) ;
fdMaxBright = new QLineEdit ( " 100 " ) ;
fdMaxBright - > setPlaceholderText ( " 100 " ) ;
fdMaxBright - > setMaximumWidth ( 50 ) ;
hBox - > addWidget ( fdMaxBright ) ;
hBox - > addWidget ( new QLabel ( " % " ) ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetMaxBrightness " ) ;
json . insert ( " _type " , " SetMaxBrightness " ) ;
json . insert ( " maxBrightnessPercentage " , fdMaxBright - > text ( ) . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetMaxBrightness " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetMaxBrightness " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetMaxBrightness " ) ;
json . insert ( " _type " , " GetMaxBrightness " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-25 16:30:58 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " GetMaxBrightness " ) + " ... " ) ;
2023-04-18 14:14:46 +08:00
Def_CtrlReqPre
2023-05-15 16:06:10 +08:00
auto brightLevel = card . BrightnessLevel ;
2023-04-25 16:30:58 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
2023-04-25 16:30:58 +08:00
auto value = json [ " maxBrightnessPercentage " ] . toInt ( - 1 ) ;
if ( value = = - 1 ) value = qRound ( json [ " brightness " ] . toInt ( ) * 100.0 / brightLevel ) ;
fdMaxBright - > setText ( QString : : number ( value ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
auto brightLevel = card . BrightnessLevel ;
2023-04-25 16:30:58 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
2023-04-25 16:30:58 +08:00
if ( err . isEmpty ( ) ) {
auto value = json [ " maxBrightnessPercentage " ] . toInt ( - 1 ) ;
if ( value = = - 1 ) value = qRound ( json [ " brightness " ] . toInt ( ) * 100.0 / brightLevel ) ;
err = QString : : number ( value ) + " % " ;
}
2023-04-18 14:14:46 +08:00
gFdResInfo - > append ( cardId + " " + tr ( " GetMaxBrightness " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
vBox - > addWidget ( grpMinMaxBrightness ) ;
vBox - > addSpacing ( 20 ) ;
grpBoxHiddenSettings = new QGroupBox ;
grpBoxHiddenSettings - > setVisible ( false ) ;
{
auto vBox = new QVBoxLayout ( grpBoxHiddenSettings ) ;
vBox - > setContentsMargins ( 6 , 6 , 6 , 6 ) ;
hBox = new HBox ( vBox ) ;
btnSetBack = new QPushButton ;
btnSetBack - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnSetBack , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QColorDialog colorDlg ( this ) ;
colorDlg . setOption ( QColorDialog : : DontUseNativeDialog ) ;
if ( colorDlg . exec ( ) ! = QColorDialog : : Accepted ) return ;
QColor color = colorDlg . selectedColor ( ) ;
if ( ! color . isValid ( ) ) return ;
QJsonObject json ;
json . insert ( " _id " , " SetWallpaper " ) ;
json . insert ( " _type " , " SetWallpaper " ) ;
json . insert ( " rgb " , color . name ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting Wallpaper " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set Wallpaper " ) )
}
}
} ) ;
hBox - > addWidget ( btnSetBack ) ;
btnSysUpd = new QPushButton ;
btnSysUpd - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnSysUpd , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SystemUpdate " ) ;
json . insert ( " _type " , " SystemUpdate " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " System Updating " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " System Update " ) )
}
}
} ) ;
hBox - > addWidget ( btnSysUpd ) ;
hBox - > addSpacing ( 20 ) ;
2024-05-23 17:13:51 +08:00
btnMcuUpd = new QPushButton ( " Update MCU " ) ;
2023-04-18 14:14:46 +08:00
btnMcuUpd - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnMcuUpd , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto filePath = QFileDialog : : getOpenFileName ( this , " Open File " , QString ( ) , " .bin file (*.bin) " ) ;
if ( filePath . isEmpty ( ) ) return ;
QFile qFile ( filePath ) ;
2023-05-16 18:03:53 +08:00
if ( ! qFile . exists ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " File not exist " ) ) ;
return ;
}
if ( ! qFile . open ( QIODevice : : ReadOnly ) ) {
2023-05-18 18:24:40 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Cannot Open File " ) + " : " + qFile . errorString ( ) + " \n " + filePath ) ;
2023-05-16 18:03:53 +08:00
return ;
}
2023-04-18 14:14:46 +08:00
auto fileData = qFile . readAll ( ) ;
qFile . close ( ) ;
auto nameBytes = QFileInfo ( filePath ) . fileName ( ) . toUtf8 ( ) ;
auto Boundary = " ----QtLedOK_.oOo._ " + QUuid : : createUuid ( ) . toByteArray ( QUuid : : WithoutBraces ) ;
QByteArray data ;
data . append ( " -- " ) . append ( Boundary ) . append ( " \r \n Content-Disposition: form-data; name= \" " ) . append ( nameBytes ) . append ( " \" ; filename= \" " ) . append ( nameBytes ) . append ( " \" \r \n \r \n " ) . append ( fileData ) . append ( " \r \n " ) ;
data . append ( " -- " ) . append ( Boundary ) . append ( " -- \r \n " ) ;
2024-05-23 17:13:51 +08:00
ProgressesDlg dlg ;
dlg . resize ( 1024 , 600 ) ;
for ( auto & card : gSelCards ) {
ProgressesItem * item ;
item = new ProgressesItem ( dlg . table ) ;
item - > setText ( " id " , card . id ) ;
item - > fdProgress = new QProgressBar ;
item - > fdProgress - > setAlignment ( Qt : : AlignCenter ) ;
item - > fdProgress - > setMaximumHeight ( 24 ) ;
item - > setCellWidget ( " progress " , WrapVCenter ( item - > fdProgress ) ) ;
item - > setText ( " ip " , card . ip ) ;
item - > setText ( " alias " , card . alias ) ;
NetReq req ( " http:// " + card . ip + " :2016/upload?type=mcu_update " ) ;
2023-04-18 14:14:46 +08:00
auto reply = req . timeout ( 120000 ) . type ( " multipart/form-data; boundary= " + Boundary ) . post ( data ) ;
2024-05-23 17:13:51 +08:00
connect ( reply , & QNetworkReply : : uploadProgress , item , [ = ] ( qint64 bytesSent , qint64 bytesTotal ) {
if ( bytesTotal = = 0 ) return ;
item - > fdProgress - > setValue ( bytesSent * 100 / bytesTotal ) ;
} ) ;
ConnReply ( reply , item ) [ = ] {
auto err = errStrWithData ( reply ) ;
2023-04-18 14:14:46 +08:00
if ( ! err . isEmpty ( ) ) {
2024-05-23 17:13:51 +08:00
item - > setRes ( tr ( " Upload error " ) + " : " + err , Qt : : red ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2024-05-23 17:13:51 +08:00
auto info = tr ( " Upgrading " ) + " ... " ;
item - > setRes ( info ) ;
item - > sendProgress ( " GetMcuUpgradeProgress " ) ;
item - > fdProgress - > setValue ( 0 ) ;
2023-04-18 14:14:46 +08:00
} ) ;
}
2024-05-23 17:13:51 +08:00
dlg . exec ( ) ;
2023-04-18 14:14:46 +08:00
} ) ;
hBox - > addWidget ( btnMcuUpd ) ;
btnMcuGet = new QPushButton ;
btnMcuGet - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnMcuGet , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SelectMCUVersion " ) ;
json . insert ( " _type " , " SelectMCUVersion " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting MCU Version " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " MCU Version " ) + " : " + json [ " mcuVersion " ] . toString ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) err = json [ " mcuVersion " ] . toString ( ) ;
gFdResInfo - > append ( cardId + " " + tr ( " MCU Version " ) + " " + err ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnMcuGet ) ;
hBox - > addSpacing ( 20 ) ;
btnPlayerBackSet = new QPushButton ;
btnPlayerBackSet - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnPlayerBackSet , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-10-23 15:08:45 +08:00
auto file = QFileDialog : : getOpenFileName ( this , tr ( " Select File " ) , gFileHome , EPhoto : : filters ( ) ) ;
2023-04-18 14:14:46 +08:00
if ( file . isEmpty ( ) ) return ;
QFileInfo info ( file ) ;
if ( ! info . isFile ( ) ) return ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting player background " ) + " ... " ) ;
2023-08-01 11:42:41 +08:00
waitingDlg - > setWindowFlag ( Qt : : WindowCloseButtonHint , 0 ) ;
2023-04-18 14:14:46 +08:00
waitingDlg - > show ( ) ;
2023-05-15 16:06:10 +08:00
auto thread = new PlayerBackSendThread ( file , gSelCards [ 0 ] . ip ) ;
2023-05-11 11:47:00 +08:00
connect ( thread , & PlayerBackSendThread : : emErr , this , [ = ] ( QString err ) {
2023-04-18 14:14:46 +08:00
if ( err . isEmpty ( ) ) waitingDlg - > success ( ) ;
else {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Error " ) , err ) ;
2023-04-18 14:14:46 +08:00
}
} ) ;
thread - > start ( ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto thread = new PlayerBackSendThread ( file , card . ip ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( thread , & PlayerBackSendThread : : emErr , this , [ cardId ] ( QString err ) {
gFdResInfo - > append ( cardId + " " + tr ( " Set player background " ) + " " + ( err . isEmpty ( ) ? tr ( " Success " ) : err ) ) ;
} ) ;
thread - > start ( ) ;
}
}
} ) ;
hBox - > addWidget ( btnPlayerBackSet ) ;
btnPlayerBackClear = new QPushButton ;
btnPlayerBackClear - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnPlayerBackClear , & QPushButton : : clicked , this , [ this ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Clearing player background " ) + " ... " ) ;
waitingDlg - > show ( ) ;
2023-05-15 16:06:10 +08:00
auto card = gSelCards [ 0 ] ;
2023-04-18 14:14:46 +08:00
auto tcp = new QTcpSocket ( ) ;
auto timer = new QTimer ( tcp ) ;
timer - > setSingleShot ( true ) ;
2023-05-11 11:47:00 +08:00
connect ( timer , & QTimer : : timeout , tcp , [ = ] {
2023-04-18 14:14:46 +08:00
waitingDlg - > close ( ) ;
tcp - > abort ( ) ;
tcp - > deleteLater ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , tr ( " Clear player background " ) + " " + tr ( " Timeout " ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
connect ( waitingDlg , & WaitingDlg : : rejected , tcp , [ = ] {
timer - > stop ( ) ;
tcp - > abort ( ) ;
tcp - > deleteLater ( ) ;
} ) ;
connect ( tcp , & QTcpSocket : : connected , tcp , [ tcp , timer ] {
timer - > stop ( ) ;
tcp - > write ( " { \" _type \" : \" DelBackImg \" , \" _id \" : \" DelBackImg \" , \" zVer \" : \" xixun1 \" } " ) ;
timer - > start ( 10000 ) ;
} ) ;
2023-05-11 11:47:00 +08:00
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ = ] {
2023-04-18 14:14:46 +08:00
timer - > stop ( ) ;
2023-08-07 09:04:53 +08:00
auto resp = tcp - > readAll ( ) ;
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
QJsonParseError parseErr ;
QJsonDocument json = QJsonDocument : : fromJson ( resp , & parseErr ) ;
if ( parseErr . error ! = QJsonParseError : : NoError ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , parseErr . errorString ( ) ) ;
2023-04-18 14:14:46 +08:00
} else if ( ! json [ " success " ] . toBool ( ) ) {
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , tr ( " Clear player background " ) + " " + tr ( " Failed " ) ) ;
2023-04-18 14:14:46 +08:00
} else waitingDlg - > success ( ) ;
} ) ;
2023-05-11 11:47:00 +08:00
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ = ] ( QAbstractSocket : : SocketError err ) {
2023-04-18 14:14:46 +08:00
timer - > stop ( ) ;
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
waitingDlg - > close ( ) ;
2023-05-11 11:47:00 +08:00
QMessageBox : : critical ( this , tr ( " Tip " ) , QString ( socketErrKey ( err ) ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
2023-05-15 16:06:10 +08:00
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-04-18 14:14:46 +08:00
timer - > start ( 10000 ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
auto tcp = new QTcpSocket ( ) ;
auto timer = new QTimer ( tcp ) ;
timer - > setSingleShot ( true ) ;
2023-05-15 16:06:10 +08:00
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( timer , & QTimer : : timeout , tcp , [ tcp , cardId ] {
tcp - > abort ( ) ;
tcp - > deleteLater ( ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Clear player background " ) + " " + tr ( " Timeout " ) ) ;
} ) ;
connect ( tcp , & QTcpSocket : : connected , tcp , [ tcp , timer ] {
timer - > stop ( ) ;
tcp - > write ( " { \" _type \" : \" DelBackImg \" , \" _id \" : \" DelBackImg \" , \" zVer \" : \" xixun1 \" } " ) ;
timer - > start ( 10000 ) ;
} ) ;
connect ( tcp , & QTcpSocket : : readyRead , tcp , [ tcp , timer , cardId ] {
timer - > stop ( ) ;
2023-08-07 09:04:53 +08:00
auto resp = tcp - > readAll ( ) ;
2023-04-18 14:14:46 +08:00
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
QJsonParseError parseErr ;
QJsonDocument json = QJsonDocument : : fromJson ( resp , & parseErr ) ;
if ( parseErr . error ! = QJsonParseError : : NoError ) gFdResInfo - > append ( cardId + " " + tr ( " Clear player background " ) + " " + parseErr . errorString ( ) ) ;
else if ( ! json [ " success " ] . toBool ( ) ) gFdResInfo - > append ( cardId + " " + tr ( " Clear player background " ) + " " + tr ( " Failed " ) ) ;
else gFdResInfo - > append ( cardId + " " + tr ( " Clear player background " ) + " " + tr ( " Success " ) ) ;
} ) ;
connect ( tcp , & QTcpSocket : : errorOccurred , tcp , [ tcp , timer , cardId ] ( QAbstractSocket : : SocketError err ) {
timer - > stop ( ) ;
tcp - > close ( ) ;
tcp - > deleteLater ( ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Clear player background " ) + " " + QMetaEnum : : fromType < QAbstractSocket : : SocketError > ( ) . valueToKey ( err ) + " ( " + QString : : number ( err ) + " ) " + tcp - > errorString ( ) ) ;
} ) ;
2023-05-15 16:06:10 +08:00
tcp - > connectToHost ( card . ip , 3333 ) ;
2023-04-18 14:14:46 +08:00
timer - > start ( 10000 ) ;
}
}
} ) ;
hBox - > addWidget ( btnPlayerBackClear ) ;
hBox - > addStretch ( ) ;
auto line = new QFrame ;
line - > setFrameStyle ( QFrame : : HLine | QFrame : : Sunken ) ;
vBox - > addWidget ( line ) ;
2023-08-01 11:42:41 +08:00
grpM80 = new QGroupBox ;
2023-05-25 10:00:00 +08:00
{
2023-08-01 11:42:41 +08:00
auto hBox = new HBox ( grpM80 ) ;
2023-05-25 10:00:00 +08:00
2023-08-01 11:42:41 +08:00
fdM80Resolu = new QComboBox ;
fdM80Resolu - > setMinimumWidth ( 160 ) ;
2024-02-21 18:08:50 +08:00
fdM80Resolu - > addItem ( " 480x4096 " , " 550x4500 " ) ;
fdM80Resolu - > addItem ( " 576x3840 " , " 625x3960 " ) ;
fdM80Resolu - > addItem ( " 720x3200 " , " 750x3300 " ) ;
fdM80Resolu - > addItem ( " 864x2672 " , " 900x2750 " ) ;
fdM80Resolu - > addItem ( " 1080x1920 " , " 1125x2200 " ) ;
fdM80Resolu - > addItem ( " 1280x1760 " , " 1320x1850 " ) ;
fdM80Resolu - > addItem ( " 1472x1536 " , " 1500x1650 " ) ;
fdM80Resolu - > addItem ( " 1536x1472 " , " 1650x1500 " ) ;
fdM80Resolu - > addItem ( " 1920x1080 " , " 2200x1125 " ) ;
fdM80Resolu - > addItem ( " 2672x864 " , " 2750x900 " ) ;
fdM80Resolu - > addItem ( " 3200x720 " , " 3300x750 " ) ;
fdM80Resolu - > addItem ( " 3840x576 " , " 3960x625 " ) ;
fdM80Resolu - > addItem ( " 4096x480 " , " 4500x550 " ) ;
2023-08-01 11:42:41 +08:00
hBox - > addWidget ( fdM80Resolu ) ;
2023-05-25 10:00:00 +08:00
2023-08-01 11:42:41 +08:00
btnM80Set = new QPushButton ( ) ;
btnM80Set - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnM80Set , & QPushButton : : clicked , this , [ this ] {
2023-05-25 10:00:00 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
2023-08-01 11:42:41 +08:00
QJsonObject json ;
json . insert ( " _id " , " SetSpecialResolution " ) ;
json . insert ( " _type " , " SetSpecialResolution " ) ;
json . insert ( " displayResolution " , fdM80Resolu - > currentText ( ) ) ; //显示分辨率
json . insert ( " totalResolution " , fdM80Resolu - > currentData ( ) . toString ( ) ) ; //显示分辨率
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " SetSpecialResolution " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
Def_CtrlSetMulti ( tr ( " SetSpecialResolution " ) )
}
2023-05-25 10:00:00 +08:00
}
2023-08-01 11:42:41 +08:00
} ) ;
hBox - > addWidget ( btnM80Set ) ;
2024-08-07 18:18:37 +08:00
btnM80Refresh = new QPushButton ;
2023-08-01 11:42:41 +08:00
btnM80Refresh - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnM80Refresh , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-05-25 10:00:00 +08:00
return ;
}
2023-08-01 11:42:41 +08:00
QJsonObject json ;
json . insert ( " _id " , " GetSpecialResolution " ) ;
json . insert ( " _type " , " GetSpecialResolution " ) ;
2023-05-25 10:00:00 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-08-01 11:42:41 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " GetSpecialResolution " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ this , reply , waitingDlg ] {
Def_CtrlSingleGetReply
2023-05-25 10:00:00 +08:00
waitingDlg - > success ( ) ;
2023-08-01 11:42:41 +08:00
fdM80Resolu - > setCurrentText ( json [ " displayResolution " ] . toString ( ) ) ;
2023-05-25 10:00:00 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
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 = tr ( " totalResolution " ) + " [ " + json [ " totalResolution " ] . toString ( ) + " ], " + tr ( " strCurDisplayResolution " ) + " [ " + json [ " displayResolution " ] . toString ( ) + " ] " ;
gFdResInfo - > append ( cardId + " " + tr ( " GetSpecialResolution " ) + " " + err ) ;
2023-05-25 10:00:00 +08:00
} ) ;
}
}
} ) ;
2023-08-01 11:42:41 +08:00
hBox - > addWidget ( btnM80Refresh ) ;
btnM80Restore = new QPushButton ( ) ;
btnM80Restore - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnM80Restore , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " CleanDisplayScreenSize " ) ;
json . insert ( " _type " , " CleanDisplayScreenSize " ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " CleanDisplayScreenSize " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
Def_CtrlSetMulti ( tr ( " CleanDisplayScreenSize " ) )
}
}
} ) ;
hBox - > addWidget ( btnM80Restore ) ;
2023-05-25 10:00:00 +08:00
hBox - > addStretch ( ) ;
}
2023-08-01 11:42:41 +08:00
vBox - > addWidget ( grpM80 ) ;
2023-05-25 10:00:00 +08:00
2023-04-18 14:14:46 +08:00
hBox = new HBox ( vBox ) ;
lbRotate = new QLabel ;
hBox - > addWidget ( lbRotate ) ;
2024-08-19 16:10:49 +08:00
hBox - > addSpacing ( 6 ) ;
2023-04-18 14:14:46 +08:00
auto fdDeg0 = new QRadioButton ( " 0° " ) ;
hBox - > addWidget ( fdDeg0 ) ;
auto fdDeg90 = new QRadioButton ( " 90° " ) ;
hBox - > addWidget ( fdDeg90 ) ;
auto fdDeg180 = new QRadioButton ( " 180° " ) ;
hBox - > addWidget ( fdDeg180 ) ;
auto fdDeg270 = new QRadioButton ( " 270° " ) ;
hBox - > addWidget ( fdDeg270 ) ;
2023-08-01 11:42:41 +08:00
auto btnGrp = new QButtonGroup ( hBox ) ;
2023-04-18 14:14:46 +08:00
btnGrp - > addButton ( fdDeg0 , 0 ) ;
btnGrp - > addButton ( fdDeg90 , 1 ) ;
btnGrp - > addButton ( fdDeg180 , 2 ) ;
btnGrp - > addButton ( fdDeg270 , 3 ) ;
2023-08-01 11:42:41 +08:00
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-08-01 11:42:41 +08:00
auto id = btnGrp - > checkedId ( ) ;
2023-04-18 14:14:46 +08:00
QJsonObject json ;
json . insert ( " _id " , " SetScreenRotation " ) ;
json . insert ( " _type " , " SetScreenRotation " ) ;
2023-08-01 11:42:41 +08:00
json . insert ( " rotation " , id ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " SetScreenRotation " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " SetScreenRotation " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-08-01 11:42:41 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-08-01 11:42:41 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetScreenRotation " ) ;
json . insert ( " _type " , " GetScreenRotation " ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " GetScreenRotation " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
auto btn = btnGrp - > button ( json [ " rotation " ] . toInt ( ) ) ;
if ( btn ) btn - > setChecked ( true ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-08-01 11:42:41 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) {
auto rotation = json [ " rotation " ] . toInt ( ) ;
auto btn = btnGrp - > button ( rotation ) ;
err = btn ? btn - > text ( ) : QString : : number ( rotation ) ;
}
gFdResInfo - > append ( card . id + " " + tr ( " GetScreenRotation " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2024-08-19 16:10:49 +08:00
hBox - > addSpacing ( 12 ) ;
lbOffset = new QLabel ;
hBox - > addWidget ( lbOffset ) ;
hBox - > addLabel ( " X " ) ;
auto edOffX = new QSpinBox ;
edOffX - > setRange ( - 9999 , 99999 ) ;
hBox - > addWidget ( edOffX ) ;
hBox - > addLabel ( " Y " ) ;
auto edOffY = new QSpinBox ;
edOffY - > setRange ( - 9999 , 99999 ) ;
hBox - > addWidget ( edOffY ) ;
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
JObj json ;
json . insert ( " _id " , " SetScreenOffset " ) ;
json . insert ( " _type " , " SetScreenOffset " ) ;
json . insert ( " x " , edOffX - > value ( ) ) ;
json . insert ( " y " , edOffY - > value ( ) ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " SetScreenOffset " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
for ( auto & card : gSelCards ) {
Def_CtrlSetMulti ( tr ( " SetScreenOffset " ) )
}
}
} ) ;
hBox - > addWidget ( btn ) ;
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetScreenOffset " ) ;
json . insert ( " _type " , " GetScreenOffset " ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " GetScreenOffset " ) + " ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
edOffX - > setValue ( json [ " x " ] . toInt ( ) ) ;
edOffY - > setValue ( json [ " y " ] . toInt ( ) ) ;
} ) ;
} else {
for ( auto & card : gSelCards ) {
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
auto err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) err = " x: " + QString : : number ( json [ " x " ] . toInt ( ) ) + " y: " + QString : : number ( json [ " y " ] . toInt ( ) ) ;
gFdResInfo - > append ( card . id + " " + tr ( " GetScreenOffset " ) + " " + err ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btn ) ;
2023-08-01 11:42:41 +08:00
hBox - > addStretch ( ) ;
2023-04-18 14:14:46 +08:00
2023-10-23 15:08:45 +08:00
hBox = new HBox ( vBox ) ;
lbChargingStation = new QLabel ( tr ( " Charging Station " ) + " ID: " ) ;
hBox - > addWidget ( lbChargingStation ) ;
auto fdChargingStation = new QLineEdit ;
fdChargingStation - > setMaximumWidth ( 120 ) ;
hBox - > addWidget ( fdChargingStation ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-10-23 15:08:45 +08:00
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetChargingStationID " ) ;
json . insert ( " _type " , " SetChargingStationID " ) ;
json . insert ( " number " , fdChargingStation - > text ( ) ) ;
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting " ) + tr ( " Charging Station " ) + " ID ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-10-23 15:08:45 +08:00
Def_CtrlSetMulti ( tr ( " Set " ) + " " + tr ( " Charging Station " ) + " ID " )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-10-23 15:08:45 +08:00
hBox - > addStretch ( ) ;
2023-04-18 14:14:46 +08:00
hBox = new HBox ( vBox ) ;
lbBaudCfg = new QLabel ;
hBox - > addWidget ( lbBaudCfg ) ;
line = new QFrame ;
line - > setFrameStyle ( QFrame : : HLine | QFrame : : Sunken ) ;
hBox - > addWidget ( line , 1 ) ;
hBox = new HBox ( vBox ) ;
lbBaudModel = new QLabel ;
hBox - > addWidget ( lbBaudModel ) ;
auto fdBaudDevMod = new QComboBox ;
fdBaudDevMod - > addItems ( {
" M5x/M6x " ,
" M7x/Y7x " ,
" E2x/Y6x " ,
" L20 "
} ) ;
hBox - > addWidget ( fdBaudDevMod ) ;
lbUart = new QLabel ;
hBox - > addWidget ( lbUart ) ;
auto fdUart = new QComboBox ;
fdUart - > setEditable ( true ) ;
fdUart - > setMinimumWidth ( 140 ) ;
fdUart - > setSizeAdjustPolicy ( QComboBox : : AdjustToContents ) ;
fdUart - > addItems ( {
" /dev/ttyS3 " ,
" /dev/ttyS4 " ,
" /dev/ttyS5 "
} ) ;
hBox - > addWidget ( fdUart ) ;
connect ( fdBaudDevMod , & QComboBox : : currentTextChanged , fdUart , [ fdUart ] ( const QString & text ) {
fdUart - > clear ( ) ;
if ( text . startsWith ( " M5x " ) ) fdUart - > addItems ( {
" /dev/ttyS3 " ,
" /dev/ttyS4 " ,
" /dev/ttyS5 "
} ) ;
else if ( text . startsWith ( " M7x " ) ) fdUart - > addItem ( " /dev/ttyS4 " ) ;
else if ( text . startsWith ( " E2x " ) ) fdUart - > addItems ( {
" /dev/ttysWK0 " ,
" /dev/ttysWK1 " ,
" /dev/ttysWK2 " ,
" /dev/ttysWK3 " ,
" /dev/tty232 " ,
" /dev/tty485 " ,
" /dev/ttyTTL "
} ) ;
else if ( text . startsWith ( " L20 " ) ) fdUart - > addItems ( {
" /dev/ttyS0 " ,
" /dev/ttyS1 " ,
" /dev/ttyS4 "
} ) ;
} ) ;
lbBaud = new QLabel ;
hBox - > addWidget ( lbBaud ) ;
auto fdBaud = new QLineEdit ;
fdBaud - > setMaximumWidth ( 70 ) ;
hBox - > addWidget ( fdBaud ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this , fdUart , fdBaud ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetBaudRateByCardType " ) ;
json . insert ( " _type " , " SetBaudRateByCardType " ) ;
json . insert ( " uartName " , fdUart - > currentText ( ) ) ;
json . insert ( " baud " , fdBaud - > text ( ) . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting Baud Rate " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set Baud Rate " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this , fdUart , fdBaud ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetBaudRateByCardType " ) ;
json . insert ( " _type " , " GetBaudRateByCardType " ) ;
json . insert ( " uartName " , fdUart - > currentText ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting Baud Rate " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
fdBaud - > setText ( QString : : number ( json [ " baud " ] . toInt ( ) ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
gFdResInfo - > append ( cardId + " " + tr ( " Get Baud Rate " ) + " " + ( err . isEmpty ( ) ? QString : : number ( json [ " baud " ] . toInt ( ) ) : err ) ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
fdIsOpenADB = new QCheckBox ;
connect ( fdIsOpenADB , & QCheckBox : : toggled , this , [ this ] ( bool checked ) {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " OpenAdb " ) ;
json . insert ( " _type " , " OpenAdb " ) ;
json . insert ( " open " , checked ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " OpenAdb " ) + " ... " ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " OpenAdb " ) )
}
}
} ) ;
vBox - > addWidget ( fdIsOpenADB ) ;
hBox = new HBox ( vBox ) ;
lbCustomJson = new QLabel ;
hBox - > addWidget ( lbCustomJson ) ;
hBox - > addSpacing ( 40 ) ;
btnSendCustomJson = new QPushButton ;
btnSendCustomJson - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnSendCustomJson , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
auto text = fdCustomJson - > toPlainText ( ) . toUtf8 ( ) ;
if ( text . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Text is empty " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonParseError jsonErr ;
QJsonDocument json = QJsonDocument : : fromJson ( text , & jsonErr ) ;
if ( jsonErr . error ! = QJsonParseError : : NoError ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Json Parse Error " ) + jsonErr . errorString ( ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
if ( ! json . isObject ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Json isn't an Object " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " AliIotSetting " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " AliIotSetting " ) )
}
}
} ) ;
hBox - > addWidget ( btnSendCustomJson ) ;
2023-10-23 15:08:45 +08:00
btnCustomJsonGet = new QPushButton ;
btnCustomJsonGet - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btnCustomJsonGet , & QPushButton : : clicked , this , [ = ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
auto text = fdCustomJson - > toPlainText ( ) . toUtf8 ( ) ;
if ( text . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Text is empty " ) ) ;
return ;
}
QString jsonErr ;
auto json = JFrom ( text , & jsonErr ) ;
if ( ! jsonErr . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Json Parse Error " ) + " " + jsonErr ) ;
return ;
}
if ( ! json . isObj ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " Json isn't an Object " ) ) ;
return ;
}
if ( gSelCards . count ( ) = = 1 ) {
auto waitingDlg = new WaitingDlg ( this , " Custom Json Getting ... " ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
waitingDlg - > close ( ) ;
auto err = errStrWithData ( reply ) ;
if ( ! err . isEmpty ( ) ) QMessageBox : : critical ( this , tr ( " Error " ) , err ) ;
else QMessageBox : : information ( this , tr ( " Info " ) , reply - > readAll ( ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-10-23 15:08:45 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , gFdResInfo , [ = ] {
auto err = errStrWithData ( reply ) ;
gFdResInfo - > append ( card . id + " Custom Json Get " + ( err . isEmpty ( ) ? reply - > readAll ( ) : err ) ) ;
} ) ;
}
}
} ) ;
hBox - > addWidget ( btnCustomJsonGet ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
fdCustomJson = new QTextEdit ;
fdCustomJson - > setMinimumHeight ( 120 ) ;
2023-10-23 15:08:45 +08:00
fdCustomJson - > setPlainText ( " { \" _id \" : \" 0 \" , \" _type \" : \" \" } " ) ;
2023-04-18 14:14:46 +08:00
vBox - > addWidget ( fdCustomJson ) ;
vBox - > addWidget ( new QLabel ( tr ( " Traffic screen settings " ) ) ) ;
hBox = new HBox ( vBox ) ;
lbTraficProtocol = new QLabel ;
lbTraficProtocol - > setMinimumWidth ( 100 ) ;
hBox - > addWidget ( lbTraficProtocol ) ;
auto fdTraficProtocol = new QComboBox ;
fdTraficProtocol - > addItem ( " 三思协议 " , 1 ) ;
hBox - > addWidget ( fdTraficProtocol ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this , fdTraficProtocol ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetProtocolType " ) ;
json . insert ( " _type " , " SetProtocolType " ) ;
json . insert ( " protocolType " , fdTraficProtocol - > currentData ( ) . toInt ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting protocol ... " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set protocol " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ this , fdTraficProtocol ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetProtocolType " ) ;
json . insert ( " _type " , " GetProtocolType " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting protocol ... " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
2023-10-23 15:08:45 +08:00
SetCurData ( fdTraficProtocol , json [ " protocolType " ] . toInt ( ) ) ;
2023-04-18 14:14:46 +08:00
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ reply , cardId , fdTraficProtocol ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) {
auto protocolType = json [ " protocolType " ] . toInt ( ) ;
int idx = fdTraficProtocol - > findData ( protocolType ) ;
if ( idx ! = - 1 ) err = fdTraficProtocol - > itemText ( idx ) ;
else err = QString : : number ( protocolType ) ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Get protocol " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
hBox = new HBox ( vBox ) ;
lbCardMode = new QLabel ;
lbCardMode - > setMinimumWidth ( 100 ) ;
hBox - > addWidget ( lbCardMode ) ;
fdServerType = new QComboBox ;
fdServerType - > setSizeAdjustPolicy ( QComboBox : : AdjustToContents ) ;
fdServerType - > addItem ( " 服务端 " , 1 ) ;
fdServerType - > addItem ( " 客户端 " , 2 ) ;
hBox - > addWidget ( fdServerType ) ;
hBox - > addSpacing ( 10 ) ;
lbTraficPort = new QLabel ;
hBox - > addWidget ( lbTraficPort ) ;
auto fdPort = new QSpinBox ;
fdPort - > setRange ( 0 , 99999 ) ;
fdPort - > setValue ( 5000 ) ;
hBox - > addWidget ( fdPort ) ;
2024-07-03 18:32:38 +08:00
btnSets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " SetCardMode " ) ;
json . insert ( " _type " , " SetCardMode " ) ;
json . insert ( " serverType " , fdServerType - > currentData ( ) . toInt ( ) ) ;
json . insert ( " port " , fdPort - > value ( ) ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Setting card work mode ... " ) ) ;
Def_CtrlReqPre
2023-05-11 11:47:00 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
2023-04-18 14:14:46 +08:00
Def_CtrlSetReqAfter
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-04-18 14:14:46 +08:00
Def_CtrlSetMulti ( tr ( " Set card work mode " ) )
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
btnGets . push_back ( btn = new QPushButton ) ;
connect ( btn , & QPushButton : : clicked , this , [ = ] {
2023-05-15 16:06:10 +08:00
if ( gSelCards . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
2023-04-18 14:14:46 +08:00
return ;
}
QJsonObject json ;
json . insert ( " _id " , " GetCardMode " ) ;
json . insert ( " _type " , " GetCardMode " ) ;
2023-05-15 16:06:10 +08:00
if ( gSelCards . count ( ) = = 1 ) {
2023-04-18 14:14:46 +08:00
auto waitingDlg = new WaitingDlg ( this , tr ( " Getting card work mode ... " ) ) ;
Def_CtrlReqPre
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
Def_CtrlSingleGetReply
waitingDlg - > success ( ) ;
2023-10-23 15:08:45 +08:00
SetCurData ( fdServerType , json [ " serverType " ] . toInt ( ) ) ;
2023-04-18 14:14:46 +08:00
fdPort - > setValue ( json [ " port " ] . toInt ( ) ) ;
} ) ;
} else {
2024-06-06 21:55:36 +08:00
for ( auto & card : gSelCards ) {
2023-05-15 16:06:10 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
auto cardId = card . id ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ = ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( err . isEmpty ( ) ) {
err = tr ( " Card work mode " ) + " : " ;
auto serverType = json [ " serverType " ] . toInt ( ) ;
int idx = fdServerType - > findData ( serverType ) ;
if ( idx ! = - 1 ) err + = fdServerType - > itemText ( idx ) ;
else err + = QString : : number ( serverType ) ;
err + = " . " + tr ( " Port " ) + " : " + QString : : number ( json [ " port " ] . toInt ( ) ) ;
}
gFdResInfo - > append ( cardId + " " + tr ( " Get card work mode " ) + " " + err ) ;
} ) ;
}
}
} ) ;
2024-07-03 18:32:38 +08:00
hBox - > addWidget ( btn ) ;
2023-04-18 14:14:46 +08:00
hBox - > addStretch ( ) ;
}
vBox - > addWidget ( grpBoxHiddenSettings ) ;
2024-02-21 18:08:50 +08:00
hBox = new HBox ( vBox ) ;
2024-07-03 18:32:38 +08:00
btn = new QPushButton ( " List Card Infos " ) ;
2024-02-21 18:08:50 +08:00
btn - > setProperty ( " ssType " , " progManageTool " ) ;
connect ( btn , & QPushButton : : clicked , this , [ this ] {
if ( gSelCards . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Tip " ) , tr ( " NoSelectedController " ) ) ;
return ;
}
auto fd = new QTextEdit ;
fd - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
auto ft = fd - > font ( ) ;
ft . setFamily ( " Consolas " ) ;
fd - > setFont ( ft ) ;
fd - > setWindowTitle ( " List Card Infos " ) ;
fd - > resize ( 600 , 900 ) ;
fd - > show ( ) ;
for ( auto & card : gSelCards ) fd - > append ( card . id + " , " + card . ip + " , " + QString : : number ( card . mWidth ) + " x " + QString : : number ( card . mHeight ) + " , " + card . alias + " , " + QString : : number ( card . bright ) + " %, " + ( card . isScreenOn ? " On " : " Off " ) ) ;
} ) ;
hBox - > addWidget ( btn ) ;
hBox - > addStretch ( ) ;
2023-04-18 14:14:46 +08:00
vBox - > addStretch ( ) ;
2024-07-03 18:32:38 +08:00
for ( auto btn : btnSets ) btn - > setProperty ( " ssType " , " progManageTool " ) ;
for ( auto btn : btnGets ) btn - > setProperty ( " ssType " , " progManageTool " ) ;
2023-10-23 15:08:45 +08:00
if ( QSettings ( ) . value ( " advUiPs " , " 888 " ) . toString ( ) . isEmpty ( ) ) isPassed = true ;
2023-04-18 14:14:46 +08:00
connect ( gDevicePanel , & DevicePanel : : sigSelectedDeviceList , this , [ this ] {
if ( isVisible ( ) ) init ( ) ;
} ) ;
transUi ( ) ;
}
void CtrlAdvancedPanel : : showEvent ( QShowEvent * event ) {
QWidget : : showEvent ( event ) ;
init ( ) ;
}
void CtrlAdvancedPanel : : init ( ) {
if ( ! isPassed ) {
hide ( ) ;
2023-05-16 18:03:53 +08:00
QDialog dlg ( this ) ;
# ifdef Q_OS_WIN
dlg . setWindowFlag ( Qt : : WindowContextHelpButtonHint , false ) ;
# endif
dlg . resize ( 240 , 150 ) ;
auto vBox = new VBox ( & dlg ) ;
vBox - > addStretch ( ) ;
auto hBox = new HBox ( vBox ) ;
hBox - > addWidget ( new QLabel ( tr ( " Input password " ) ) ) ;
auto fdPassword = new QLineEdit ;
fdPassword - > setEchoMode ( QLineEdit : : Password ) ;
fdPassword - > setFocus ( ) ;
hBox - > addWidget ( fdPassword ) ;
auto btnChangePassword = new QPushButton ( tr ( " Change Password " ) ) ;
vBox - > addWidget ( btnChangePassword , 0 , Qt : : AlignRight ) ;
connect ( btnChangePassword , & QPushButton : : clicked , & dlg , [ & dlg ] {
ChangePasswordForm cdlg ( & dlg ) ;
cdlg . exec ( ) ;
} ) ;
vBox - > addStretch ( ) ;
auto btnBox = new QDialogButtonBox ( QDialogButtonBox : : Ok | QDialogButtonBox : : Cancel ) ;
connect ( btnBox , & QDialogButtonBox : : rejected , & dlg , & QDialog : : reject ) ;
vBox - > addWidget ( btnBox ) ;
connect ( btnBox , & QDialogButtonBox : : accepted , & dlg , [ = , & dlg ] {
2023-10-23 15:08:45 +08:00
auto pwdVar = QSettings ( ) . value ( " advUiPs " ) ;
auto password = pwdVar . isNull ( ) ? " 888 " : QString : : fromUtf8 ( QByteArray : : fromBase64 ( pwdVar . toString ( ) . toLatin1 ( ) ) ) ;
2023-05-16 18:03:53 +08:00
if ( fdPassword - > text ( ) = = password ) dlg . accept ( ) ;
2023-04-18 14:14:46 +08:00
else QMessageBox : : critical ( & dlg , tr ( " Tip " ) , tr ( " Password is error " ) ) ;
} ) ;
if ( dlg . exec ( ) = = QDialog : : Accepted ) {
isPassed = true ;
show ( ) ;
} else return ;
}
2023-05-15 16:06:10 +08:00
bool isSingle = gSelCards . count ( ) = = 1 ;
2023-04-18 14:14:46 +08:00
btnApkCheck - > setEnabled ( isSingle ) ;
btnGetLog - > setEnabled ( isSingle ) ;
if ( ! isSingle ) {
grpM80 - > setVisible ( true ) ;
grpY50 - > setVisible ( true ) ;
return ;
}
2023-05-15 16:06:10 +08:00
auto card = gSelCards [ 0 ] ;
fdScreenWidth - > setText ( QString : : number ( card . mWidth ) ) ;
fdScreenHeight - > setText ( QString : : number ( card . mHeight ) ) ;
fdAlias - > setText ( card . alias ) ;
auto isM80 = card . id . startsWith ( " M8 " , Qt : : CaseInsensitive ) ;
2023-04-18 14:14:46 +08:00
grpM80 - > setVisible ( isM80 ) ;
2024-02-21 18:08:50 +08:00
// if(isM80) {
// QJsonObject json;
// json.insert("_id", "GetAllScreenSizeM80");
// json.insert("_type", "GetAllScreenSizeM80");
// auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
// connect(reply, &QNetworkReply::finished, this, [this, reply] {
// QJsonDocument json;
// QString err = checkReplyForJson(reply, &json);
// if(! err.isEmpty()) return;
// auto sizes = json["result"].toObject();
// fdM80Resolu->clear();
// auto send = sizes.constEnd();
// for(auto size=sizes.constBegin(); size<send; size++) fdM80Resolu->addItem(size.key(), size.value().toString());
// });
// }
2023-04-18 14:14:46 +08:00
2023-05-15 16:06:10 +08:00
auto isY50 = card . id . startsWith ( " st5 " , Qt : : CaseInsensitive )
2023-10-23 15:08:45 +08:00
| | card . id . startsWith ( " m5h " , Qt : : CaseInsensitive )
| | card . id . startsWith ( " m5s " , Qt : : CaseInsensitive )
| | card . id . startsWith ( " m6s " , Qt : : CaseInsensitive )
2024-05-23 17:13:51 +08:00
| | card . id . startsWith ( " m7 " , Qt : : CaseInsensitive )
2024-08-07 18:18:37 +08:00
| | card . id . startsWith ( " y0 " , Qt : : CaseInsensitive )
2023-10-23 15:08:45 +08:00
| | card . id . startsWith ( " y1 " , Qt : : CaseInsensitive )
2024-08-07 18:18:37 +08:00
| | card . id . startsWith ( " y3 " , Qt : : CaseInsensitive )
2023-10-23 15:08:45 +08:00
| | card . id . startsWith ( " y4 " , Qt : : CaseInsensitive )
| | card . id . startsWith ( " y5 " , Qt : : CaseInsensitive ) ;
2023-04-18 14:14:46 +08:00
grpY50 - > setVisible ( isY50 ) ;
QJsonObject json ;
json . insert ( " _id " , " GetOnlineAddr " ) ;
json . insert ( " _type " , " GetOnlineAddr " ) ;
2024-02-21 18:08:50 +08:00
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 30000 ) . post ( json ) ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ this , reply ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( ! err . isEmpty ( ) ) return ;
2024-08-08 11:53:16 +08:00
fdWebAddr - > setCurrentText ( json [ " server " ] . toString ( ) ) ;
2023-04-18 14:14:46 +08:00
fdCompanyId - > setText ( json [ " companuID " ] . toString ( ) ) ;
} ) ;
json = QJsonObject ( ) ;
json . insert ( " _id " , " GetRealtimeServer " ) ;
json . insert ( " _type " , " GetRealtimeServer " ) ;
2024-02-21 18:08:50 +08:00
reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 30000 ) . post ( json ) ;
2023-04-18 14:14:46 +08:00
connect ( reply , & QNetworkReply : : finished , this , [ this , reply ] {
QJsonDocument json ;
2024-02-21 18:08:50 +08:00
auto err = checkReplyForJson ( reply , & json ) ;
2023-04-18 14:14:46 +08:00
if ( ! err . isEmpty ( ) ) return ;
fdRealtimeServer - > setCurrentText ( json [ " server " ] . toString ( ) ) ;
} ) ;
}
void CtrlAdvancedPanel : : changeEvent ( QEvent * event ) {
QWidget : : changeEvent ( event ) ;
if ( event - > type ( ) = = QEvent : : LanguageChange ) transUi ( ) ;
}
void CtrlAdvancedPanel : : transUi ( ) {
2024-07-03 18:32:38 +08:00
for ( auto btn : btnSets ) btn - > setText ( tr ( " Set " ) ) ;
for ( auto btn : btnGets ) btn - > setText ( tr ( " Get " ) ) ;
2023-04-18 14:14:46 +08:00
btnBindTaxiIc - > setText ( tr ( " Binding *.ic account indentity voucher " ) ) ;
btnGetTopLevel - > setText ( tr ( " Readback " ) ) ;
2023-08-01 11:42:41 +08:00
btnLedSet - > setText ( tr ( " Start LedSet4 " ) ) ;
2024-02-21 18:08:50 +08:00
btnReceCardsGet - > setText ( tr ( " Get Receive Card Num " ) ) ;
2023-04-18 14:14:46 +08:00
2024-08-07 18:18:37 +08:00
grpPlayer - > setTitle ( tr ( " Player Debug " ) ) ;
2023-04-18 14:14:46 +08:00
grpM80 - > setTitle ( " M80 " + tr ( " Config " ) ) ;
btnM80Refresh - > setText ( tr ( " Refresh " ) ) ;
btnM80Restore - > setText ( tr ( " Restore to default " ) ) ;
btnM80Set - > setText ( tr ( " Set " ) ) ;
2024-08-07 18:18:37 +08:00
grpY50 - > setTitle ( " M50S / M60S / M70S / M5H / M7L / ST50 / Y1G / Y1C / Y4A / Y5A / Y08 / Y35 / Y37 " + tr ( " Resolution Config " ) ) ;
2023-04-18 14:14:46 +08:00
fdDisMode - > setItemText ( 0 , tr ( " Full screen " ) ) ;
fdDisMode - > setItemText ( 1 , tr ( " Part " ) ) ;
btnY50Set - > setText ( tr ( " Set " ) ) ;
2024-07-03 18:32:38 +08:00
lbDisMode - > setText ( tr ( " Display Mode " ) + " : " ) ;
lbScreenPos - > setText ( tr ( " Screen Position " ) + " : " ) ;
lbScreenOff - > setText ( tr ( " Offset " ) + " : " ) ;
2023-04-18 14:14:46 +08:00
2024-07-03 18:32:38 +08:00
lbCameraDis - > setText ( tr ( " Camera Distance " ) + " : " ) ;
2023-04-18 14:14:46 +08:00
fdScreenHeight - > setPlaceholderText ( tr ( " Height " ) ) ;
fdScreenWidth - > setPlaceholderText ( tr ( " Width " ) ) ;
fdHighForBusy - > setText ( tr ( " Service:High Out of service:Low " ) ) ;
fdTopLevelLH - > setText ( tr ( " Service:Low Out of service:High " ) ) ;
lbRotate - > setText ( tr ( " Rotate " ) ) ;
2024-08-19 16:10:49 +08:00
lbOffset - > setText ( tr ( " Offset " ) ) ;
2023-04-18 14:14:46 +08:00
grpBoxHiddenSettings - > setTitle ( tr ( " Hidden Settings " ) + " ( " + tr ( " Click right button to hide " ) + " ) " ) ;
btnSysUpd - > setText ( tr ( " System Update " ) ) ;
btnMcuGet - > setText ( tr ( " Get MCU Version " ) ) ;
lbBaudCfg - > setText ( tr ( " Baud Config " ) ) ;
lbBaudModel - > setText ( tr ( " Model " ) ) ;
lbUart - > setText ( tr ( " Uart " ) ) ;
lbBaud - > setText ( tr ( " Baud " ) ) ;
fdIsOpenADB - > setText ( tr ( " Open ADB " ) ) ;
lbCustomJson - > setText ( tr ( " Post Custom JSON " ) ) ;
btnSendCustomJson - > setText ( tr ( " Send " ) ) ;
2023-10-23 15:08:45 +08:00
btnCustomJsonGet - > setText ( tr ( " Get " ) ) ;
2023-04-18 14:14:46 +08:00
grpHighForBusy - > setTitle ( tr ( " Taxi top screen configuration " ) ) ;
lbTitle - > setText ( tr ( " Advanced " ) ) ;
lbCompanyId - > setText ( tr ( " Compant ID: " ) ) ;
2024-08-08 11:53:16 +08:00
lbWebAddr - > setText ( tr ( " Web (Plat 2) Address " ) + " : " ) ;
lbRealtime - > setText ( tr ( " Realtime (Plat 4) Address " ) + " : " ) ;
2023-04-18 14:14:46 +08:00
lbMinBright - > setText ( tr ( " Min brightness " ) ) ;
label_3 - > setText ( tr ( " Max brightness " ) ) ;
lbAlias - > setText ( tr ( " Alias " ) ) ;
lbScreenHeight - > setText ( tr ( " Height " ) ) ;
lbScreenWidth - > setText ( tr ( " Screen Width(pixel) " ) ) ;
fdCompanyId - > setPlaceholderText ( tr ( " Compant ID " ) ) ;
btnWareUpdate - > setText ( tr ( " Firmware Management " ) ) ;
lbWareTip - > setText ( " (APK / FPGA " + tr ( " update or uninstall " ) + " ) " ) ;
btnApkCheck - > setText ( tr ( " Check Apk " ) ) ;
btnGetLog - > setText ( tr ( " Check Log " ) ) ;
btnSetBack - > setText ( tr ( " Set Wallpaper " ) ) ;
btnClearProg - > setText ( tr ( " Clear Program " ) ) ;
2023-08-07 09:04:53 +08:00
btnGetPlayerState - > setText ( tr ( " Get Player State " ) ) ;
2023-04-18 14:14:46 +08:00
btnPlayerBackSet - > setText ( tr ( " Set player background " ) ) ;
btnPlayerBackClear - > setText ( tr ( " Clear player background " ) ) ;
btnRealtimeClear - > setText ( tr ( " Clear " ) ) ;
btnRestart - > setText ( tr ( " Restart " ) ) ;
btnIsRunning - > setText ( tr ( " Running check " ) ) ;
fdUninstall - > setText ( tr ( " Uninstall " ) ) ;
lbTimingReboot - > setText ( tr ( " Timing Reboot " ) ) ;
lbTraficProtocol - > setText ( tr ( " Protocol " ) ) ;
lbCardMode - > setText ( tr ( " Card work mode " ) ) ;
fdServerType - > setItemText ( 0 , tr ( " Server " ) ) ;
fdServerType - > setItemText ( 1 , tr ( " Client " ) ) ;
lbTraficPort - > setText ( tr ( " Port " ) ) ;
}
void messageHandler ( QtMsgType type , const QMessageLogContext & , const QString & msg ) {
auto cur = QDateTime : : currentDateTime ( ) ;
QFile file ( " D:/LedOK-advanced- " + cur . toString ( " yy-MM-dd " ) + " .log " ) ;
file . open ( QIODevice : : WriteOnly | QIODevice : : Append ) ;
file . write ( cur . toString ( " yy-MM-dd hh:mm:ss " ) . toUtf8 ( ) ) ;
if ( type = = QtDebugMsg ) file . write ( " Debug: " ) ;
else if ( type = = QtWarningMsg ) file . write ( " Warning: " ) ;
else if ( type = = QtCriticalMsg ) file . write ( " Critical: " ) ;
else if ( type = = QtFatalMsg ) file . write ( " Fatal: " ) ;
else if ( type = = QtInfoMsg ) file . write ( " Info: " ) ;
else if ( type = = QtSystemMsg ) file . write ( " System: " ) ;
file . write ( msg . toUtf8 ( ) ) ;
file . close ( ) ;
}
void CtrlAdvancedPanel : : keyReleaseEvent ( QKeyEvent * event ) {
auto key = event - > key ( ) ;
if ( key = = Qt : : Key_F5 ) grpBoxHiddenSettings - > setVisible ( ! grpBoxHiddenSettings - > isVisible ( ) ) ;
else if ( key = = Qt : : Key_F6 ) grpMinMaxBrightness - > setVisible ( ! grpMinMaxBrightness - > isVisible ( ) ) ;
else if ( key = = Qt : : Key_F8 ) grpHighForBusy - > setVisible ( ! grpHighForBusy - > isVisible ( ) ) ;
else if ( key = = Qt : : Key_F12 ) qInstallMessageHandler ( messageHandler ) ;
QWidget : : keyPressEvent ( event ) ;
}
void CtrlAdvancedPanel : : mouseReleaseEvent ( QMouseEvent * event ) {
if ( event - > button ( ) = = Qt : : RightButton ) grpBoxHiddenSettings - > setVisible ( ! grpBoxHiddenSettings - > isVisible ( ) ) ;
}
PlayerBackSendThread : : PlayerBackSendThread ( const QString & file , const QString & ip ) : file ( file ) , ip ( ip ) {
connect ( this , & QThread : : finished , this , & QThread : : deleteLater ) ;
}
void PlayerBackSendThread : : run ( ) {
TcpSocket tcp ;
tcp . connectToHost ( ip , 3333 ) ;
if ( ! tcp . waitForConnected ( ) ) {
emit emErr ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) when waitForConnected " ) ;
tcp . close ( ) ;
return ;
}
QFileInfo info ( file ) ;
auto remain = info . size ( ) ;
2024-08-07 18:18:37 +08:00
JObj req ;
2023-04-18 14:14:46 +08:00
req . insert ( " _type " , " imgFileStart " ) ;
req . insert ( " size " , remain ) ;
2024-08-07 18:18:37 +08:00
auto resNum = tcp . write ( JToBytes ( req ) ) ;
2023-04-18 14:14:46 +08:00
if ( resNum = = - 1 | | ! tcp . waitForBytesWritten ( ) ) {
2023-08-07 09:04:53 +08:00
emit emErr ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " when write 'imgFileStart' " ) ;
2023-04-18 14:14:46 +08:00
tcp . close ( ) ;
return ;
}
auto file = new QFile ( info . filePath ( ) ) ;
if ( ! file - > open ( QFile : : ReadOnly ) ) {
emit emErr ( tr ( " Open file failed " ) + " " + file - > errorString ( ) ) ;
tcp . close ( ) ;
return ;
}
while ( remain > 0 ) {
auto readed = file - > read ( qMin ( 4096LL , remain ) ) ;
if ( readed . isEmpty ( ) ) {
emit emErr ( tr ( " Read file failed " ) + " " + file - > errorString ( ) ) ;
tcp . close ( ) ;
file - > close ( ) ;
return ;
}
resNum = tcp . write ( readed ) ;
if ( resNum = = - 1 ) {
2023-08-07 09:04:53 +08:00
emit emErr ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " when write file: " + file - > fileName ( ) ) ;
2023-04-18 14:14:46 +08:00
tcp . close ( ) ;
file - > close ( ) ;
return ;
}
if ( ! tcp . waitForBytesWritten ( ) ) {
2023-08-07 09:04:53 +08:00
emit emErr ( QString ( socketErrKey ( tcp . error ( ) ) ) + " ( " + QString : : number ( tcp . error ( ) ) + " ) " + tcp . errorString ( ) + " when waitForWritten file: " + file - > fileName ( ) ) ;
2023-04-18 14:14:46 +08:00
tcp . close ( ) ;
file - > close ( ) ;
return ;
}
remain - = resNum ;
}
file - > close ( ) ;
tcp . close ( ) ;
emit emErr ( " " ) ;
}