344 lines
12 KiB
C++
344 lines
12 KiB
C++
#include "settingUiFastCfg.h"
|
|
#include "UiConfig.h"
|
|
#include <QDebug>
|
|
|
|
const int NEXT_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {28, 42, 42, 16, 16};
|
|
|
|
int settingUiFastCfgWireNet::m_pageIndex = 0;
|
|
settingUiFastCfgWireNet::settingUiFastCfgWireNet(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
|
|
{
|
|
m_pageIndex = pageIndex;
|
|
|
|
QFont ft;
|
|
ft.setPointSize(NEXT_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
|
|
//QLabel* title = new QLabel(tr("有线网络配置"), this);
|
|
//title->setFont(ft);
|
|
|
|
m_wireNet = new settingUiDevMngNetWire(0, this);
|
|
m_wireNet->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.7));
|
|
|
|
m_btnNext = new QPushButton(tr("下一步"), this);
|
|
m_btnNext->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 3,
|
|
UiConfig::GetInstance()->getUiWidth() / 6);
|
|
m_btnNext->setFont(ft);
|
|
m_btnNext->setStyleSheet("QPushButton {"
|
|
"border: 0px;"
|
|
"border-radius:10px;"
|
|
"background-color:rgb(24, 144, 255);"
|
|
"focus{outline: none;}"
|
|
"}"
|
|
"QPushButton:hover { "
|
|
"background-color:rgb(24, 144, 255);"
|
|
"}"
|
|
"QPushButton:pressed {"
|
|
"background-color:rgb(222, 222, 222);"
|
|
"}");
|
|
connect(m_btnNext, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
|
|
|
|
QVBoxLayout* bLay = new QVBoxLayout();
|
|
//bLay->addWidget(title, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addWidget(m_wireNet, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addStretch(1);
|
|
bLay->addWidget(m_btnNext, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addStretch(1);
|
|
bLay->setMargin(0);
|
|
bLay->setSpacing(0);
|
|
setLayout(bLay);
|
|
}
|
|
|
|
void settingUiFastCfgWireNet::setBackstageUiinterface(BackstageInterfaceForUi* interface)
|
|
{
|
|
m_backstageIf = interface;
|
|
m_wireNet->setBackstageUiinterface(interface);
|
|
}
|
|
|
|
void settingUiFastCfgWireNet::reset()
|
|
{
|
|
m_wireNet->reset();
|
|
}
|
|
|
|
void settingUiFastCfgWireNet::slotBtnClicked()
|
|
{
|
|
emit signalJumpPage(0); //need page enum
|
|
}
|
|
|
|
|
|
|
|
int settingUiPark::m_pageIndex = 0;
|
|
settingUiPark::settingUiPark(QWidget *parent)
|
|
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
|
|
SetOpn(tr("设备位置"), "(设备具体安装位置)", myListWidget::enPropertyMoreArrow)
|
|
}, parent)
|
|
{
|
|
}
|
|
|
|
void settingUiPark::reset()
|
|
{
|
|
qDebug() << "reset";
|
|
for(int i = 0; i < config.size(); i ++)
|
|
{
|
|
QListWidgetItem* pItem = m_listWidget->item(i);
|
|
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
|
|
if(wdt == nullptr){
|
|
return;
|
|
}
|
|
|
|
QString str;
|
|
const int iBufSize = 128;
|
|
char buf[iBufSize] = {'\0'};
|
|
switch(i)
|
|
{
|
|
case FAST_CFG_DEV_POSI:
|
|
{
|
|
std::string posiStr;
|
|
m_backstageIf->getDevPosi(posiStr);
|
|
str = (posiStr.empty() ? tr("(未设置)") : posiStr.c_str());
|
|
}
|
|
break;
|
|
#if 0
|
|
case FAST_CFG_PARK_INFO:
|
|
{
|
|
std::string infoStr;
|
|
m_backstageIf->getParkInfo(infoStr);
|
|
str = (infoStr.empty() ? tr("(未设置)") : infoStr.c_str());
|
|
}
|
|
break;
|
|
|
|
case FAST_CFG_SERVER:
|
|
if(0 == m_backstageIf->getServerAddr(buf, iBufSize)){
|
|
str = buf;
|
|
}
|
|
break;
|
|
#endif
|
|
default:
|
|
break;
|
|
}
|
|
wdt->updateLabel(str);
|
|
}
|
|
}
|
|
|
|
void settingUiPark::slotItemClicked(QListWidgetItem* item)
|
|
{
|
|
const int row = m_listWidget->currentRow();
|
|
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
|
|
if(wdt == nullptr){
|
|
return;
|
|
}
|
|
switch(row){
|
|
//case FAST_CFG_PARK_INFO:
|
|
case FAST_CFG_DEV_POSI:
|
|
{
|
|
bool settingFailed = true;
|
|
do{
|
|
LineEditInputDialog dlg(config.at(row).m_sOpn, parent()->parent());
|
|
if(dlg.exec() == QDialog::Accepted){
|
|
const QString strInput = dlg.getRow(0);
|
|
do{
|
|
#if 0
|
|
if(row == FAST_CFG_PARK_INFO){
|
|
if(0 == strInput.length()){
|
|
InfoDialog(tr("园区信息不能为空"), parent()->parent()).exec();
|
|
break;
|
|
}
|
|
else if(strInput.length() > 32){
|
|
InfoDialog(tr("园区信息不能超过32个字符"), parent()->parent()).exec();
|
|
break;
|
|
}
|
|
if(0 == m_backstageIf->setParkInfo(strInput.toStdString())){
|
|
wdt->updateLabel(strInput);
|
|
settingFailed = false;
|
|
}
|
|
}
|
|
else
|
|
#endif
|
|
if(row == FAST_CFG_DEV_POSI){
|
|
if(strInput.length() > 32){
|
|
InfoDialog(tr("设备位置不能超过32个字符"), parent()->parent()).exec();
|
|
break;
|
|
}
|
|
if(0 == m_backstageIf->setDevPosi(strInput.toStdString())){
|
|
wdt->updateLabel(strInput.isEmpty() ? tr("(未设置)") : strInput);
|
|
settingFailed = false;
|
|
}
|
|
}
|
|
}while(0);
|
|
}
|
|
else {
|
|
settingFailed = false;
|
|
}
|
|
}while(settingFailed);
|
|
}
|
|
break;
|
|
#if 0
|
|
case FAST_CFG_SERVER:
|
|
{
|
|
bool settingFailed = true;
|
|
do{
|
|
QList<QString> strs;
|
|
if(FAST_CFG_SERVER == row){
|
|
strs << tr("服务器地址:") << tr("端口:");
|
|
}
|
|
LineEditInputDialog dlg(strs, parent()->parent());
|
|
if(dlg.exec() == QDialog::Accepted)
|
|
{
|
|
QString str;
|
|
do{
|
|
if(FAST_CFG_SERVER == row){
|
|
if("" != dlg.getRow(0) && "" != dlg.getRow(1)){
|
|
bool isDigi = false;
|
|
int valueSet = dlg.getRow(1).toInt(&isDigi);
|
|
if( (!isDigi) || (valueSet < 0 || valueSet > 65535)){
|
|
break;
|
|
}
|
|
if(m_backstageIf){
|
|
str = dlg.getRow(0) + ":" + dlg.getRow(1);
|
|
m_backstageIf->setServerAddr(const_cast<char*>(str.toStdString().c_str()));
|
|
wdt->updateLabel(str);
|
|
settingFailed = false;
|
|
}
|
|
}
|
|
}
|
|
}while(0);
|
|
}
|
|
else {
|
|
settingFailed = false;
|
|
}
|
|
if(settingFailed)
|
|
{
|
|
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
|
|
}
|
|
}while(settingFailed);
|
|
}
|
|
break;
|
|
#endif
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
int settingUiFastCfgPark::m_pageIndex = 0;
|
|
settingUiFastCfgPark::settingUiFastCfgPark(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
|
|
{
|
|
m_pageIndex = pageIndex;
|
|
|
|
QFont ft;
|
|
ft.setPointSize(NEXT_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
|
|
|
|
m_park = new settingUiPark(this);
|
|
m_park->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.7));
|
|
|
|
m_btnNext = new QPushButton(tr("下一步"), this);
|
|
m_btnNext->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 3,
|
|
UiConfig::GetInstance()->getUiWidth() / 6);
|
|
m_btnNext->setFont(ft);
|
|
m_btnNext->setStyleSheet("QPushButton {"
|
|
"border: 0px;"
|
|
"border-radius:10px;"
|
|
"background-color:rgb(24, 144, 255);"
|
|
"focus{outline: none;}"
|
|
"}"
|
|
"QPushButton:hover { "
|
|
"background-color:rgb(24, 144, 255);"
|
|
"}"
|
|
"QPushButton:pressed {"
|
|
"background-color:rgb(222, 222, 222);"
|
|
"}");
|
|
connect(m_btnNext, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
|
|
|
|
QVBoxLayout* bLay = new QVBoxLayout();
|
|
//bLay->addWidget(title, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addWidget(m_park, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addStretch(1);
|
|
bLay->addWidget(m_btnNext, 1, Qt::AlignCenter | Qt::AlignTop);
|
|
bLay->addStretch(1);
|
|
bLay->setMargin(0);
|
|
bLay->setSpacing(0);
|
|
setLayout(bLay);
|
|
}
|
|
|
|
void settingUiFastCfgPark::setBackstageUiinterface(BackstageInterfaceForUi* interface)
|
|
{
|
|
m_backstageIf = interface;
|
|
m_park->setBackstageUiinterface(interface);
|
|
}
|
|
|
|
void settingUiFastCfgPark::reset()
|
|
{
|
|
m_park->reset();
|
|
}
|
|
|
|
void settingUiFastCfgPark::slotBtnClicked()
|
|
{
|
|
emit signalJumpPage(0); //need page enum
|
|
}
|
|
|
|
const int SettingUiQrcode::TIP_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {24, 38, 38, 14, 14};
|
|
const QString SettingUiQrcode::BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
|
|
":/res/image/qrcode_middle.png",
|
|
":/res/image/qrcode_large.png",
|
|
":/res/image/qrcode_middle.png",
|
|
":/res/image/qrcode_large.png",
|
|
":/res/image/qrcode_middle.png"
|
|
};
|
|
|
|
int SettingUiQrcode::m_pageIndex = 0;
|
|
SettingUiQrcode::SettingUiQrcode(int pageIndex, QWidget *parent) : WidgetWithBackstageInterface(parent)
|
|
{
|
|
m_pageIndex = pageIndex;
|
|
|
|
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
|
|
setAutoFillBackground(true);
|
|
QPalette palette(this->palette());
|
|
palette.setColor(QPalette::WindowText,Qt::white);
|
|
palette.setBrush(QPalette::Window,QBrush(QPixmap(BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
|
|
setPalette(palette);
|
|
|
|
QLabel* tip = new QLabel(tr("请将配置二维码对准扫码框"), this);
|
|
QFont ft;
|
|
ft.setPointSize(TIP_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
|
|
tip->setFont(ft);
|
|
QVBoxLayout* bLay = new QVBoxLayout();
|
|
bLay->addWidget(tip, 1, Qt::AlignHCenter);
|
|
bLay->addStretch(9);
|
|
setLayout(bLay);
|
|
|
|
m_widget_cMsg = new CenterMsgWidget(this);
|
|
m_widget_cMsg->move((UiConfig::GetInstance()->getUiWidth() - CenterMsgWidget::WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2,
|
|
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
|
|
m_widget_cMsg->hide();
|
|
}
|
|
|
|
void SettingUiQrcode::reset()
|
|
{
|
|
qDebug() << __PRETTY_FUNCTION__;
|
|
//vo显示设置
|
|
if(nullptr == m_backstageIf){
|
|
return;
|
|
}
|
|
|
|
m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
|
|
}
|
|
|
|
void SettingUiQrcode::slotCenterMsg(const int nPage, const QString& msg)
|
|
{
|
|
m_widget_cMsg->showMsg(msg, nPage);
|
|
if(UiConfig::GetInstance()->isRkDevice()){
|
|
update();
|
|
}
|
|
//qDebug() << "slotCenterMsg:" << msg;
|
|
//if(!msg.isEmpty()){
|
|
//QTimer::singleShot(10000, this, [this]{qDebug() << "SettingUiQrcode slotQrcodeCfgSuccessed";emit signalExitSettingUi();});
|
|
//}
|
|
}
|
|
|
|
void SettingUiQrcode::slotQrcodeFastCfgResult(bool isSuccessed)
|
|
{
|
|
qDebug() << "slotQrcodeFastCfgResult:" << isSuccessed;
|
|
if(isSuccessed){
|
|
QTimer::singleShot(10000, this, [this]{qDebug() << "SettingUiQrcode slotQrcodeCfgSuccessed";emit signalExitSettingUi();});
|
|
}
|
|
}
|
|
|
|
|