2023-05-25 10:00:00 +08:00
# include "devicepanel.h"
2023-05-15 16:06:10 +08:00
# include "globaldefine.h"
2023-04-18 14:14:46 +08:00
# include "gutil/qgui.h"
2023-05-15 16:06:10 +08:00
# include "gutil/qnetwork.h"
# include "base/waitingdlg.h"
# include "deviceitem.h"
2022-08-25 18:37:24 +08:00
# include <QAction>
# include <QBoxLayout>
# include <QEvent>
# include <QHeaderView>
# include <QLineEdit>
# include <QNetworkDatagram>
2022-09-28 18:21:57 +08:00
# include <QNetworkInterface>
# include <QMessageBox>
2023-05-15 16:06:10 +08:00
# include <QJsonArray>
# include <QJsonObject>
# include <QStyledItemDelegate>
2022-08-25 18:37:24 +08:00
DevicePanel * gDevicePanel ;
2023-05-15 16:06:10 +08:00
void setCard ( LedCard & card , const QString & addr , const QJsonDocument & json ) {
if ( ! addr . isEmpty ( ) ) card . ip = addr ;
else {
card . ip = json [ " newIp " ] . toString ( ) ;
if ( card . ip . isEmpty ( ) ) card . ip = json [ " ip " ] . toString ( ) ;
}
2023-05-16 18:03:53 +08:00
if ( card . mWidth = = 0 ) card . mWidth = json [ " width " ] . toInt ( ) ;
if ( card . mHeight = = 0 ) card . mHeight = json [ " height " ] . toInt ( ) ;
2023-05-15 16:06:10 +08:00
card . androidVersion = json [ " androidVersion " ] . toString ( ) ;
}
2022-09-30 18:08:39 +08:00
DevicePanel : : DevicePanel ( QSettings & settings , QWidget * parent ) : QWidget ( parent ) {
2022-08-25 18:37:24 +08:00
gDevicePanel = this ;
setAutoFillBackground ( true ) ;
QPalette pal ;
pal . setBrush ( QPalette : : Window , QColor ( 0xeeeeee ) ) ;
setPalette ( pal ) ;
2022-10-12 18:17:10 +08:00
auto vBox = new VBox ( this ) ;
2022-08-25 18:37:24 +08:00
vBox - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
vBox - > setSpacing ( 0 ) ;
2022-10-12 18:17:10 +08:00
auto hBox = new HBox ( vBox ) ;
2022-08-25 18:37:24 +08:00
hBox - > setContentsMargins ( 6 , 2 , 6 , 2 ) ;
hBox - > setSpacing ( 2 ) ;
auto label = new QLabel ( ) ;
2023-04-18 14:14:46 +08:00
label - > setPixmap ( { " :/res/device/DeviceNum_All.png " } ) ;
2022-08-25 18:37:24 +08:00
label - > setScaledContents ( true ) ;
label - > setFixedSize ( 33 , 24 ) ;
hBox - > addWidget ( label ) ;
label_3 = new QLabel ( tr ( " All " ) ) ;
hBox - > addWidget ( label_3 ) ;
nDeviceNum = new QLabel ( ) ;
nDeviceNum - > setFixedSize ( 40 , 20 ) ;
hBox - > addWidget ( nDeviceNum ) ;
auto fdSearch = new QLineEdit ( ) ;
fdSearch - > setClearButtonEnabled ( true ) ;
fdSearch - > setFixedSize ( 220 , 30 ) ;
2023-04-18 14:14:46 +08:00
fdSearch - > addAction ( new QAction ( QIcon ( " :/res/program/bnSearch.png " ) , QString ( ) ) , QLineEdit : : LeadingPosition ) ;
2022-08-25 18:37:24 +08:00
fdSearch - > setStyleSheet ( " border: 1px solid #aaaaaa; " ) ;
2023-04-18 14:14:46 +08:00
connect ( fdSearch , & QLineEdit : : textChanged , this , [ this ] ( const QString & search ) {
auto cnt = mDeviceTable - > topLevelItemCount ( ) ;
if ( search . isEmpty ( ) ) for ( int i = 0 ; i < cnt ; i + + ) mDeviceTable - > topLevelItem ( i ) - > setHidden ( false ) ;
else for ( int i = 0 ; i < cnt ; i + + ) {
auto item = mDeviceTable - > topLevelItem ( i ) ;
item - > setHidden ( ! ( item - > text ( DeviceTable_ID ) . contains ( search ) | | item - > text ( DeviceTable_Remark ) . contains ( search ) | | item - > text ( DeviceTable_IP ) . contains ( search ) ) ) ;
}
} ) ;
2022-08-25 18:37:24 +08:00
hBox - > addWidget ( fdSearch ) ;
hBox - > addSpacing ( 10 ) ;
fdCardNumInfo = new QLabel ( tr ( " Current Screen " ) + " : " + tr ( " none " ) ) ;
fdCardNumInfo - > setStyleSheet ( " QLabel{color: #15f;} " ) ;
fdCardNumInfo - > hide ( ) ;
hBox - > addWidget ( fdCardNumInfo ) ;
hBox - > addStretch ( ) ;
auto areaFlash = new QWidget ( ) ;
areaFlash - > setFixedSize ( 100 , 34 ) ;
bnSpecifyIP = new QComboBox ( areaFlash ) ;
bnSpecifyIP - > addItem ( tr ( " Specify IP " ) ) ;
bnSpecifyIP - > setGeometry ( 0 , 0 , areaFlash - > width ( ) , areaFlash - > height ( ) ) ;
bnSpecifyIP - > setItemDelegate ( new QStyledItemDelegate ) ;
connect ( bnSpecifyIP , & QComboBox : : textActivated , this , [ this ] {
2022-09-28 18:21:57 +08:00
mUdpTimer . stop ( ) ;
specifyIPDlg - > exec ( ) ;
mUdpTimer . start ( 30000 ) ;
2022-08-25 18:37:24 +08:00
} ) ;
bnSpecifyIP - > setStyleSheet ( R " rrr(
QComboBox {
border : none ;
border - radius : 5 px ;
background - color : # 19 c ;
}
QComboBox : hover { background - color : # 08 b ; }
QComboBox : : drop - down { width : 25 px ; }
2023-04-18 14:14:46 +08:00
QComboBox : : down - arrow { image : url ( : / res / device / FlashArrow . png ) ; }
2022-08-25 18:37:24 +08:00
QComboBox QAbstractItemView : : item {
height : 28 px ;
color : # fff ;
}
QComboBox QAbstractItemView : : item : selected { background - color : # 09 c ; }
) rrr " );
2022-09-28 18:21:57 +08:00
btnRefresh = new QPushButton ( tr ( " Refresh " ) , areaFlash ) ;
btnRefresh - > setGeometry ( 0 , 0 , 75 , areaFlash - > height ( ) ) ;
connect ( btnRefresh , & QPushButton : : clicked , this , [ this ] {
2022-08-25 18:37:24 +08:00
mDeviceTable - > onCheckAll ( false ) ;
mDeviceTable - > clear ( ) ;
nDeviceNum - > setText ( " 0 " ) ;
sendGetInfo ( ) ;
} ) ;
2022-09-28 18:21:57 +08:00
btnRefresh - > setStyleSheet ( R " rrr(
2022-08-25 18:37:24 +08:00
QPushButton {
border - radius : 5 px ;
background - color : # 19 c ;
color : # fff ;
}
QPushButton : hover { background - color : # 08 b ; }
) rrr " );
hBox - > addWidget ( areaFlash ) ;
mHBox = new QHBoxLayout ( ) ;
mDeviceTable = new LoQTreeWidget ( this ) ;
2023-05-15 16:06:10 +08:00
mDeviceTable - > setSelectionMode ( QAbstractItemView : : NoSelection ) ;
2022-08-25 18:37:24 +08:00
mDeviceTable - > setIndentation ( 0 ) ;
mDeviceTable - > setSortingEnabled ( true ) ;
mHBox - > addWidget ( mDeviceTable ) ;
vBox - > addLayout ( mHBox ) ;
2022-09-28 18:21:57 +08:00
connect ( & mUdpTimer , & QTimer : : timeout , this , & DevicePanel : : sendGetInfo ) ;
connect ( & mUdpSocket , & QUdpSocket : : readyRead , this , [ this ] {
while ( mUdpSocket . hasPendingDatagrams ( ) ) {
auto gram = mUdpSocket . receiveDatagram ( ) ;
2022-08-25 18:37:24 +08:00
auto data = gram . data ( ) ;
if ( data . isEmpty ( ) ) continue ;
auto senderAddress = gram . senderAddress ( ) ;
bool ok = true ;
if ( senderAddress . protocol ( ) = = QUdpSocket : : IPv6Protocol ) senderAddress . setAddress ( senderAddress . toIPv4Address ( & ok ) ) ;
2022-09-26 18:10:47 +08:00
auto addr = ok ? senderAddress . toString ( ) : " " ;
2023-05-15 16:06:10 +08:00
DeviceItem * item ;
2022-08-25 18:37:24 +08:00
if ( data . startsWith ( " { \" " ) ) {
QJsonParseError error ;
2023-05-15 16:06:10 +08:00
QJsonDocument json = QJsonDocument : : fromJson ( gram . data ( ) , & error ) ;
2022-08-25 18:37:24 +08:00
if ( error . error ! = QJsonParseError : : NoError ) {
qDebug ( ) < < " DeviceItem OnProHttpResponse 解析json文件错误! " ;
continue ;
}
2023-05-15 16:06:10 +08:00
auto cardId = json [ " cardId " ] . toString ( ) ;
int cnt = mDeviceTable - > topLevelItemCount ( ) ;
for ( int i = 0 ; i < cnt ; i + + ) if ( ( item = ( DeviceItem * ) mDeviceTable - > topLevelItem ( i ) ) - > mCard . id = = cardId ) {
item - > mCard . id = cardId ;
item - > mCard . isOnline = true ;
setCard ( item - > mCard , addr , json ) ;
item - > init ( ) ;
goto end ;
}
item = new DeviceItem ( mDeviceTable ) ;
item - > mCard . id = cardId ;
setCard ( item - > mCard , addr , json ) ;
2022-08-25 18:37:24 +08:00
} else {
2022-09-30 18:08:39 +08:00
auto bytes = gram . data ( ) ;
2023-05-15 16:06:10 +08:00
auto packet = ( UDPPacket * ) bytes . data ( ) ;
int cnt = mDeviceTable - > topLevelItemCount ( ) ;
for ( int i = 0 ; i < cnt ; i + + ) if ( ( item = ( DeviceItem * ) mDeviceTable - > topLevelItem ( i ) ) - > mCard . id = = packet - > serialCode ) {
item - > mCard . id = packet - > serialCode ;
item - > mCard . isOnline = true ;
item - > mCard . ip = addr ;
item - > init ( ) ;
goto end ;
2022-09-28 18:21:57 +08:00
}
2023-05-15 16:06:10 +08:00
item = new DeviceItem ( mDeviceTable ) ;
item - > mCard . id = packet - > serialCode ;
item - > mCard . ip = addr ;
2022-08-25 18:37:24 +08:00
}
2023-05-15 16:06:10 +08:00
connect ( item - > m_bnCardDetailInfo , & QPushButton : : clicked , item , [ = ] {
2023-05-25 10:00:00 +08:00
QString msgpre ;
msgpre . append ( tr ( " Current Brightness " ) ) . append ( " : " ) . append ( QString : : number ( item - > mCard . bright ) ) . append ( " % " ) . append ( " \n " ) ;
msgpre . append ( tr ( " Brightness Level " ) ) . append ( " : " ) . append ( QString : : number ( item - > mCard . BrightnessLevel ) ) . append ( " \n " ) ;
msgpre . append ( tr ( " Android OS Resolution " ) ) . append ( " : " ) . append ( item - > mCard . ScreenResolution ) . append ( " \n " ) ;
msgpre . append ( tr ( " Android Version " ) ) . append ( " : " ) . append ( item - > mCard . androidVersion ) . append ( " \n " ) ;
msgpre . append ( tr ( " FPGA Version " ) ) . append ( " : " ) . append ( item - > mCard . HardVersion ) . append ( " \n " ) ;
msgpre . append ( tr ( " Firmware Version " ) ) . append ( " : " ) . append ( item - > mCard . FirmwareVersion ) . append ( " \n " ) ;
msgpre . append ( tr ( " IMEI " ) ) . append ( " : " ) . append ( item - > mCard . IMEI ) . append ( " \n " ) ;
QMessageBox msgBox ( QMessageBox : : Information , item - > mCard . id + " " + tr ( " Detail Info " ) , msgpre + tr ( " Player Version " ) + " : " + tr ( " Getting " ) + " ... " ) ;
2023-05-15 16:06:10 +08:00
QJsonObject json ;
json . insert ( " _id " , " CheckSoftVersions " ) ;
json . insert ( " _type " , " CheckSoftVersions " ) ;
auto card = item - > mCard ;
auto reply = NetReq ( " http:// " + card . ip + " :2016/settings " ) . timeout ( 120000 ) . post ( json ) ;
2023-05-25 10:00:00 +08:00
connect ( & msgBox , & QMessageBox : : finished , reply , [ reply ] {
abortSilence ( reply ) ;
} ) ;
connect ( reply , & QNetworkReply : : finished , & msgBox , [ = , & msgBox ] {
QJsonDocument json ;
QString err = checkReplyForJson ( reply , & json ) ;
if ( ! err . isEmpty ( ) ) {
msgBox . setText ( msgpre + tr ( " Player Version " ) + " : " + err ) ;
return ;
}
auto apps = json [ " apps " ] . toArray ( ) ;
foreach ( QJsonValue value , apps ) {
2023-05-15 16:06:10 +08:00
QJsonObject app = value . toObject ( ) ;
2023-05-25 10:00:00 +08:00
if ( app [ " packageName " ] . toString ( ) . contains ( " xixunplayer " ) ) {
msgBox . setText ( msgpre + tr ( " Player Version " ) + " : " + app [ " versionName " ] . toString ( ) ) ;
return ;
}
2023-05-15 16:06:10 +08:00
}
2023-05-25 10:00:00 +08:00
msgBox . setText ( msgpre + tr ( " Player Version " ) + " : " ) ;
2023-05-15 16:06:10 +08:00
} ) ;
2023-05-25 10:00:00 +08:00
msgBox . exec ( ) ;
2023-05-15 16:06:10 +08:00
} ) ;
item - > init ( ) ;
item - > DeviceItemHttpPost ( ) ;
nDeviceNum - > setText ( QString : : number ( mDeviceTable - > topLevelItemCount ( ) ) ) ;
{
QJsonObject json ;
json . insert ( " _id " , " SyncTime " ) ;
json . insert ( " _type " , " SyncTime " ) ;
json . insert ( " time " , QDateTime : : currentDateTime ( ) . toMSecsSinceEpoch ( ) ) ;
auto reply = NetReq ( " http:// " + item - > mCard . ip + " :2016/settings " ) . timeout ( 60000 ) . post ( json ) ;
connect ( reply , & QNetworkReply : : finished , reply , & QNetworkReply : : deleteLater ) ;
}
end : ;
2022-08-25 18:37:24 +08:00
}
} ) ;
m_headerItem = new QTreeWidgetItem ( ) ;
for ( int i = 1 ; i < DeviceTable_End ; i + + ) m_headerItem - > setTextAlignment ( i , Qt : : AlignCenter ) ;
mDeviceTable - > setHeaderItem ( m_headerItem ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Check , QHeaderView : : Fixed ) ;
2023-04-18 14:14:46 +08:00
mDeviceTable - > setColumnWidth ( DeviceTable_Check , 36 ) ;
2022-08-25 18:37:24 +08:00
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Online , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Online , 48 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_ID , QHeaderView : : Stretch ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_IP , QHeaderView : : Stretch ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_ScreenSize , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_ScreenSize , 108 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Remark , QHeaderView : : Stretch ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Brightness , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Brightness , 108 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Power , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Power , 84 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Password , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Password , 72 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Info , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Info , 72 ) ;
mDeviceTable - > header ( ) - > setSectionResizeMode ( DeviceTable_Screenshot , QHeaderView : : Fixed ) ;
mDeviceTable - > setColumnWidth ( DeviceTable_Screenshot , 72 ) ;
2023-05-15 16:06:10 +08:00
connect ( mDeviceTable , & LoQTreeWidget : : sigCheckStateChanged , this , [ = ] {
gSelCards . clear ( ) ;
int cnt = mDeviceTable - > topLevelItemCount ( ) ;
for ( int i = 0 ; i < cnt ; i + + ) if ( mDeviceTable - > topLevelItem ( i ) - > checkState ( 0 ) = = Qt : : Checked ) gSelCards . append ( static_cast < DeviceItem * > ( mDeviceTable - > topLevelItem ( i ) ) - > mCard ) ;
emit sigSelectedDeviceList ( ) ;
} ) ;
2022-08-25 18:37:24 +08:00
mDeviceTable - > hideColumn ( 0 ) ;
mDeviceTable - > fdIsSelAll - > hide ( ) ;
2022-10-12 18:17:10 +08:00
specifyIPDlg = new QDialog ( this ) ;
specifyIPDlg - > setWindowTitle ( tr ( " Specify IP " ) ) ;
vBox = new VBox ( specifyIPDlg ) ;
vBox - > addStretch ( ) ;
label = new QLabel ( tr ( " Specify IP list " ) ) ;
label - > setAlignment ( Qt : : AlignCenter ) ;
vBox - > addWidget ( label ) ;
fdIP = new QTextEdit ;
auto ipstr = settings . value ( " SpecifyIP " ) . toString ( ) ;
if ( ! ipstr . isEmpty ( ) ) fdIP - > setText ( ipstr ) ;
fdIP - > setPlaceholderText ( " 192.168.1.1 \n 192.168.1.2 \n ... " ) ;
fdIP - > setMinimumWidth ( 160 ) ;
vBox - > addWidget ( fdIP ) ;
hBox = new HBox ( vBox ) ;
hBox - > addStretch ( ) ;
auto bnSearch = new QPushButton ( tr ( " Search " ) ) ;
connect ( bnSearch , & QPushButton : : clicked , this , [ this ] {
QString ipsStr = fdIP - > toPlainText ( ) ;
if ( ipsStr . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : warning ( this , tr ( " Attention " ) , tr ( " Please input IP address! " ) ) ;
2022-10-12 18:17:10 +08:00
return ;
}
auto ips = ipsStr . split ( " \n " , Qt : : SkipEmptyParts ) ;
if ( ips . isEmpty ( ) ) {
2023-05-11 11:47:00 +08:00
QMessageBox : : warning ( this , tr ( " Attention " ) , tr ( " Please input IP address! " ) ) ;
2022-10-12 18:17:10 +08:00
return ;
}
2023-05-15 16:06:10 +08:00
QByteArray data = QJsonDocument ( QJsonObject { { " action " , " getInfo " } } ) . toJson ( QJsonDocument : : Compact ) ;
2023-05-11 11:47:00 +08:00
foreach ( auto ip , ips ) if ( mUdpSocket . writeDatagram ( data , QHostAddress ( ip ) , 22222 ) ! = data . length ( ) ) qDebug ( ) < < " Specify IP write Failed. " < < ip ;
2022-10-12 18:17:10 +08:00
specifyIPDlg - > accept ( ) ;
} ) ;
hBox - > addWidget ( bnSearch ) ;
auto btnCancel = new QPushButton ( tr ( " Cancel " ) ) ;
connect ( btnCancel , & QPushButton : : clicked , specifyIPDlg , & QDialog : : reject ) ;
hBox - > addWidget ( btnCancel ) ;
hBox - > addStretch ( ) ;
2022-08-25 18:37:24 +08:00
transUi ( ) ;
2022-10-12 18:17:10 +08:00
sendGetInfo ( ) ;
mUdpTimer . start ( 30000 ) ;
2022-08-25 18:37:24 +08:00
}
DevicePanel : : ~ DevicePanel ( ) {
2022-09-28 18:21:57 +08:00
mUdpSocket . close ( ) ;
mUdpTimer . stop ( ) ;
2022-08-25 18:37:24 +08:00
}
void DevicePanel : : sendGetInfo ( ) {
2023-05-15 16:06:10 +08:00
const QByteArray data = QJsonDocument ( QJsonObject { { " action " , " getInfo " } } ) . toJson ( QJsonDocument : : Compact ) ;
2023-04-18 14:14:46 +08:00
uchar ccc [ ] { 0x7E , 0x7E , 0x7E , 0x90 , 0x42 , 0x72 , 0x6F , 0x61 , 0x64 , 0x63 , 0x61 , 0x73 , 0x74 , 0x21 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x1C , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x9F } ;
if ( mUdpSocket . writeDatagram ( data , QHostAddress ( " 255.255.255.255 " ) , 22222 ) ! = data . length ( ) ) qDebug ( ) < < " getInfo write to 255.255.255.255 failed " ;
if ( mUdpSocket . writeDatagram ( ( char * ) ccc , sizeof ( ccc ) , QHostAddress ( " 255.255.255.255 " ) , 31296 ) ! = sizeof ( ccc ) ) qDebug ( ) < < " getInfo write to 255.255.255.255 failed " ;
2022-08-25 18:37:24 +08:00
QList < QNetworkInterface > networkinterfaces = QNetworkInterface : : allInterfaces ( ) ;
foreach ( QNetworkInterface face , networkinterfaces ) {
auto flags = face . flags ( ) ;
bool can = ( flags & QNetworkInterface : : IsRunning ) & & ( flags & QNetworkInterface : : CanBroadcast ) & & ! ( flags & QNetworkInterface : : IsLoopBack ) ;
if ( ! can ) continue ;
auto addrEntries = face . addressEntries ( ) ;
foreach ( QNetworkAddressEntry addrEntry , addrEntries ) {
auto ip = addrEntry . ip ( ) ;
if ( ip . protocol ( ) ! = QAbstractSocket : : IPv4Protocol ) continue ;
auto broadcast = addrEntry . broadcast ( ) ;
2023-04-18 14:14:46 +08:00
if ( mUdpSocket . writeDatagram ( data , broadcast , 22222 ) ! = data . length ( ) ) qDebug ( ) < < " getInfo write failed. " < < ip . toString ( ) < < " -> " < < broadcast . toString ( ) ;
2022-08-25 18:37:24 +08:00
}
}
2022-10-12 18:17:10 +08:00
auto ipstr = fdIP - > toPlainText ( ) ;
if ( ! ipstr . isEmpty ( ) ) {
auto ips = ipstr . split ( " \n " , Qt : : SkipEmptyParts ) ;
2023-04-18 14:14:46 +08:00
foreach ( auto ip , ips ) if ( mUdpSocket . writeDatagram ( data , QHostAddress ( ip ) , 22222 ) ! = data . length ( ) ) qDebug ( ) < < " getInfo specify IP write failed. " < < ip ;
2022-10-12 18:17:10 +08:00
}
2022-08-25 18:37:24 +08:00
}
void DevicePanel : : changeEvent ( QEvent * event ) {
QWidget : : changeEvent ( event ) ;
if ( event - > type ( ) = = QEvent : : LanguageChange ) transUi ( ) ;
}
void DevicePanel : : transUi ( ) {
2022-09-28 18:21:57 +08:00
btnRefresh - > setText ( tr ( " Refresh " ) ) ;
2022-08-25 18:37:24 +08:00
bnSpecifyIP - > setItemText ( 0 , tr ( " Specify IP " ) ) ;
label_3 - > setText ( tr ( " All " ) ) ;
2023-04-18 14:14:46 +08:00
m_headerItem - > setText ( DeviceTable_Online , tr ( " Online " ) ) ;
m_headerItem - > setText ( DeviceTable_ID , tr ( " Screen ID " ) ) ;
m_headerItem - > setText ( DeviceTable_IP , tr ( " Screen IP " ) ) ;
m_headerItem - > setText ( DeviceTable_ScreenSize , tr ( " Screen Size " ) ) ;
m_headerItem - > setText ( DeviceTable_Remark , tr ( " Remark Name " ) ) ;
m_headerItem - > setText ( DeviceTable_Screenshot , tr ( " readback pic " ) ) ;
2023-05-16 18:03:53 +08:00
m_headerItem - > setText ( DeviceTable_Brightness , tr ( " Screen Brightness " ) ) ;
2023-04-18 14:14:46 +08:00
m_headerItem - > setText ( DeviceTable_Power , tr ( " Power Status " ) ) ;
m_headerItem - > setText ( DeviceTable_Password , tr ( " Security " ) ) ;
m_headerItem - > setText ( DeviceTable_Info , tr ( " More Info " ) ) ;
2022-08-25 18:37:24 +08:00
auto cnt = mDeviceTable - > topLevelItemCount ( ) ;
2022-09-28 18:21:57 +08:00
for ( int i = 0 ; i < cnt ; i + + ) {
2023-05-15 16:06:10 +08:00
auto item = ( DeviceItem * ) mDeviceTable - > topLevelItem ( i ) ;
item - > setData ( DeviceTable_Power , 0 , item - > mCard . isScreenOn ? tr ( " On " ) : tr ( " Off " ) ) ;
2022-09-28 18:21:57 +08:00
}
}