185 lines
4.3 KiB
C++
185 lines
4.3 KiB
C++
#include "StartUpForm.h"
|
|
#include "ui_StartUpForm.h"
|
|
#include "MonitorCommon.h"
|
|
#include "DataMng.h"
|
|
#include "../include/sys/sys_login_api/CLoginDlg.h"
|
|
|
|
#include <QDebug>
|
|
#include <QMessageBox>
|
|
|
|
using namespace sys_startup;
|
|
|
|
StartUpForm::StartUpForm(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::StartUpForm)
|
|
{
|
|
ui->setupUi(this);
|
|
initVariables();
|
|
initView();
|
|
initConn();
|
|
}
|
|
|
|
StartUpForm::~StartUpForm()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
int StartUpForm::getCurrentIndex()
|
|
{
|
|
return ui->stackedWidget->currentIndex();
|
|
}
|
|
|
|
int StartUpForm::getStartValue()
|
|
{
|
|
return ui->sys_start_bar->value();
|
|
}
|
|
|
|
int StartUpForm::getStopValue()
|
|
{
|
|
return ui->sys_stop_bar->value();
|
|
}
|
|
|
|
void StartUpForm::changeIndex(int index)
|
|
{
|
|
if(index < (int)EN_SYSTEM_UNKNOW)
|
|
{
|
|
ui->stackedWidget->setCurrentIndex(index);
|
|
}
|
|
}
|
|
|
|
void StartUpForm::changeStartValue(int value)
|
|
{
|
|
ui->sys_start_bar->setValue(value);
|
|
}
|
|
|
|
void StartUpForm::changeStopValue(int value)
|
|
{
|
|
ui->sys_stop_bar->setValue(value);
|
|
}
|
|
|
|
void StartUpForm::initStartValue()
|
|
{
|
|
ui->sys_start_bar->setValue(0);
|
|
}
|
|
|
|
void StartUpForm::initStopValue()
|
|
{
|
|
ui->sys_stop_bar->setValue(0);
|
|
}
|
|
|
|
void StartUpForm::initValue()
|
|
{
|
|
initStartValue();
|
|
initStopValue();
|
|
}
|
|
|
|
void StartUpForm::startSystem()
|
|
{
|
|
emit sigStartSystem();
|
|
}
|
|
|
|
void StartUpForm::stopSystem()
|
|
{
|
|
if(!DataMng::instance()->getAllowedStatus())
|
|
{
|
|
return ;
|
|
}
|
|
CLoginDlg dlg;
|
|
QString perm ="FUNC_NOM_SYSTEM_EXIT";
|
|
dlg.setCheckPerm(perm);
|
|
dlg.setOkButtonText(tr("验证"));
|
|
dlg.setTitle(tr("权限验证"));
|
|
int res = dlg.exec();
|
|
if(res == QDialog::Accepted)
|
|
{
|
|
emit sigStopSystem();
|
|
}
|
|
}
|
|
|
|
void StartUpForm::initVariables()
|
|
{
|
|
|
|
}
|
|
|
|
void StartUpForm::initView()
|
|
{
|
|
//设置启动状态和停止状态图片
|
|
QString stStartPng = DataMng::instance()->getStartPng();
|
|
QString stStopPng = DataMng::instance()->getStopPng();
|
|
if(stStartPng.isEmpty())
|
|
{
|
|
ui->startpng->setStyleSheet("QLabel{border-image: url(:/images/start.png);}");
|
|
}else
|
|
{
|
|
ui->startpng->setStyleSheet(QString("QLabel{background-image: url(%1);}").arg(stStartPng));
|
|
}
|
|
if(stStopPng.isEmpty())
|
|
{
|
|
ui->stoppng->setStyleSheet("QLabel{border-image: url(:/images/stop.png);}");
|
|
}else
|
|
{
|
|
ui->stoppng->setStyleSheet(QString("QLabel{background-image: url(%1);}").arg(stStopPng));
|
|
}
|
|
|
|
//初始化进度条
|
|
MyProgressBar::PercentStyle_Type index = MyProgressBar::PercentStyle_Type(1);
|
|
ui->sys_start_bar->setPercentStyle(index);
|
|
ui->sys_stop_bar->setPercentStyle(index);
|
|
//设置进度条边框宽度
|
|
ui->sys_start_bar->setBorderWidth(0);
|
|
ui->sys_stop_bar->setBorderWidth(0);
|
|
//设置外边框颜色
|
|
QString stStartBorderColor = DataMng::instance()->getStartBorderColor();
|
|
QString stStopBorderColor = DataMng::instance()->getStopBorderColor();
|
|
if(stStartBorderColor.isEmpty())
|
|
{
|
|
QColor c1(204,244,211);
|
|
ui->sys_start_bar->setBoderColor(c1);
|
|
ui->sys_start_bar->setBgColor(c1);
|
|
}else
|
|
{
|
|
QColor c1(stStartBorderColor);
|
|
ui->sys_start_bar->setBoderColor(c1);
|
|
ui->sys_start_bar->setBgColor(c1);
|
|
}
|
|
if(stStopBorderColor.isEmpty())
|
|
{
|
|
QColor c2(255,225,217);
|
|
ui->sys_stop_bar->setBoderColor(c2);
|
|
ui->sys_stop_bar->setBgColor(c2);
|
|
}else
|
|
{
|
|
QColor c2(stStopBorderColor);
|
|
ui->sys_stop_bar->setBoderColor(c2);
|
|
ui->sys_stop_bar->setBgColor(c2);
|
|
}
|
|
|
|
QString stStartWaterColor = DataMng::instance()->getStartWaterColor();
|
|
QString stStopWaterColor = DataMng::instance()->getStopWaterColor();
|
|
if(stStartWaterColor.isEmpty())
|
|
{
|
|
QColor c3(0,202,33);
|
|
ui->sys_start_bar->setColor(c3);
|
|
}else
|
|
{
|
|
QColor c3(stStartWaterColor);
|
|
ui->sys_start_bar->setColor(c3);
|
|
}
|
|
if(stStopWaterColor.isEmpty())
|
|
{
|
|
QColor c4(255,104,64);
|
|
ui->sys_stop_bar->setColor(c4);
|
|
}else
|
|
{
|
|
QColor c4(stStopWaterColor);
|
|
ui->sys_stop_bar->setColor(c4);
|
|
}
|
|
ui->sys_stop_btn->setToolTip(tr("退出系统前,请将所有配置工具和人机界面退出!"));
|
|
}
|
|
|
|
void StartUpForm::initConn()
|
|
{
|
|
connect(ui->sys_start_btn,&QPushButton::clicked,this,&StartUpForm::startSystem);
|
|
connect(ui->sys_stop_btn,&QPushButton::clicked,this,&StartUpForm::stopSystem);
|
|
}
|