|
|
@ -4,10 +4,16 @@ |
|
|
|
#include "mainconfig.h" |
|
|
|
|
|
|
|
#define NAMELIST_LENGTH 4 |
|
|
|
QString namelist[] = {"传立春","传立夏","传立秋","传立冬"}; |
|
|
|
QString namelist[] = {"传十一","传十三","传十五","传十七"}; |
|
|
|
qint8 gindex = 0; |
|
|
|
|
|
|
|
MainWidget::MainWidget(QWidget *parent) : |
|
|
|
MainWidget::MainWidget(HttpService *httpService, |
|
|
|
WebsocketService *websocketService, |
|
|
|
DeviceService *deviceService, |
|
|
|
QWidget *parent) : |
|
|
|
m_httpService(httpService), |
|
|
|
m_websocketService(websocketService), |
|
|
|
m_deviceService(deviceService), |
|
|
|
QWidget(parent), |
|
|
|
ui(new Ui::MainWidget) |
|
|
|
{ |
|
|
@ -16,6 +22,7 @@ MainWidget::MainWidget(QWidget *parent) : |
|
|
|
m_wsConnectedStatus = 0; |
|
|
|
m_maxPatientNum = MainConfig::maxPatientNum.toInt(); |
|
|
|
m_switchPatientInterval = MainConfig::switchPatientInterval.toInt(); |
|
|
|
keyDownPInfo = Q_NULLPTR;//zhixiang kongzhizhen
|
|
|
|
|
|
|
|
//1s倒计时
|
|
|
|
m_countDownTimer.setInterval(1000); |
|
|
@ -37,14 +44,22 @@ MainWidget::MainWidget(QWidget *parent) : |
|
|
|
m_patientIndex = 0; |
|
|
|
} |
|
|
|
updateUi(); |
|
|
|
m_curX = 0; |
|
|
|
}); |
|
|
|
|
|
|
|
//LED闪烁
|
|
|
|
m_ledTurnTimer.setInterval(1000); |
|
|
|
connect(&m_ledTurnTimer, &QTimer::timeout,[=](){ |
|
|
|
m_deviceService->m_ledStatus ^= 1; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
}); |
|
|
|
|
|
|
|
//显示连接状态
|
|
|
|
ui->statusLabel->setText("Not Connected"); |
|
|
|
|
|
|
|
//显示设置
|
|
|
|
font1.setPointSize(240); |
|
|
|
font2.setPointSize(240); |
|
|
|
font1.setPointSize(180); |
|
|
|
font2.setPointSize(180); |
|
|
|
font3.setPointSize(20); |
|
|
|
ui->textLabel->setFont(font1); |
|
|
|
ui->countdownLabel->setFont(font2); |
|
|
@ -56,9 +71,12 @@ MainWidget::MainWidget(QWidget *parent) : |
|
|
|
// ui->countdownLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
// ui->statusLabel->setAlignment(Qt::AlignRight);
|
|
|
|
|
|
|
|
isFenzhen = false; |
|
|
|
m_curX = 0; |
|
|
|
connect(&m_lableScrollTimer,SIGNAL(timeout()),this,SLOT(lableScrollDisplay())); |
|
|
|
m_lableScrollTimer.start(10); |
|
|
|
|
|
|
|
this->setCursor(Qt::BlankCursor); |
|
|
|
} |
|
|
|
|
|
|
|
MainWidget::~MainWidget() |
|
|
@ -68,19 +86,23 @@ MainWidget::~MainWidget() |
|
|
|
|
|
|
|
void MainWidget::updateUi() |
|
|
|
{ |
|
|
|
m_curX = 0;//内容超出显示区域时,更新患者信息显示从头开始滚动
|
|
|
|
// m_curX = 0;//内容超出显示区域时,更新患者信息显示从头开始滚动
|
|
|
|
|
|
|
|
//更新statusLabel
|
|
|
|
// ui->statusLabel->setText(QString("%1 | %2")
|
|
|
|
// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
|
|
|
|
// .arg(m_patientEmergencyInfos.length())
|
|
|
|
// );
|
|
|
|
// ui->statusLabel->setText(QString("%1 | %2")
|
|
|
|
// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
|
|
|
|
// .arg(m_patientEmergencyInfos.length())
|
|
|
|
// );
|
|
|
|
if(m_wsConnectedStatus){ |
|
|
|
ui->LEDLabel->setStyleSheet("border-image: url(:/image/1LED_green.png);"); |
|
|
|
}else{ |
|
|
|
ui->LEDLabel->setStyleSheet("border-image: url(::/image/1LED_gray.png);"); |
|
|
|
} |
|
|
|
ui->statusLabel->setText(QString::number(m_patientEmergencyInfos.length())); |
|
|
|
if(m_patientEmergencyInfos.length() == 0){ |
|
|
|
ui->statusLabel->setText(QString::number(m_patientEmergencyInfos.length())); |
|
|
|
}else{ |
|
|
|
ui->statusLabel->setText(QString::number(m_patientIndex+1) + "/" + QString::number(m_patientEmergencyInfos.length())); |
|
|
|
} |
|
|
|
|
|
|
|
if(m_patientEmergencyInfos.length() == 0){ |
|
|
|
//不显示
|
|
|
@ -102,6 +124,7 @@ void MainWidget::updateUi() |
|
|
|
QString str = ""; |
|
|
|
if(pInfo->realCountDownInSeconds < 0){ |
|
|
|
str = ""; |
|
|
|
isFenzhen = true; |
|
|
|
}else{ |
|
|
|
int hour,min,sec,nTotalSecs; |
|
|
|
nTotalSecs = pInfo->realCountDownInSeconds; |
|
|
@ -130,28 +153,38 @@ void MainWidget::resizeEvent(QResizeEvent *event) |
|
|
|
QWidget::resizeEvent(event); |
|
|
|
|
|
|
|
//标题
|
|
|
|
// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2);
|
|
|
|
// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2);
|
|
|
|
ui->countdownLabel->setGeometry(0,(this->height()-30)/2,this->width(),(this->height()-30)/2); |
|
|
|
ui->LEDLabel->setGeometry(this->width()-120,this->height()-30,20,30); |
|
|
|
ui->statusLabel->setGeometry(this->width()-80,this->height()-30,20,30); |
|
|
|
ui->LEDLabel->setGeometry(this->width()-110,this->height()-30,30,30); |
|
|
|
ui->statusLabel->setGeometry(this->width()-80,this->height()-30,55,30); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::lableScrollDisplay() |
|
|
|
{ |
|
|
|
// qDebug()<<"m_curX = "<<m_curX;
|
|
|
|
|
|
|
|
if(m_patientEmergencyInfos.length() == 0){ |
|
|
|
return; |
|
|
|
} |
|
|
|
QFontMetrics fm(font1); |
|
|
|
m_width = fm.width(ui->textLabel->text()); |
|
|
|
m_height = ui->textLabel->height(); |
|
|
|
if(isFenzhen){ |
|
|
|
m_y = (this->height()-m_height)/2; |
|
|
|
} |
|
|
|
else{ |
|
|
|
int m_y = 0; |
|
|
|
} |
|
|
|
if(this->width() > m_width){ |
|
|
|
ui->textLabel->setGeometry((this->width()-m_width)/2, 0,m_width,(this->height()-30)/2); |
|
|
|
ui->textLabel->setGeometry((this->width()-m_width)/2, m_y,m_width,(this->height()-30)/2); |
|
|
|
} |
|
|
|
else{ |
|
|
|
m_curX ++; |
|
|
|
ui->textLabel->setGeometry(20-m_curX,0,m_width,(this->height()-30)/2); |
|
|
|
// qDebug()<<"move" <<m_curX;
|
|
|
|
ui->textLabel->setGeometry(150-m_curX*5,m_y,m_width,(this->height()-30)/2); |
|
|
|
} |
|
|
|
if(m_curX > (m_width - this->width())){ |
|
|
|
if(m_curX > m_width){ |
|
|
|
m_curX = 0; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onWsConnectedStatusChanged(int status) |
|
|
@ -167,6 +200,7 @@ void MainWidget::onNewPatientMergencyInfo(QString firstAidId, QString name, QStr |
|
|
|
PatientEmergencyInfo *pInfo = new PatientEmergencyInfo(firstAidId,name,content,realCountDownInSeconds); |
|
|
|
addPatientToList(pInfo); |
|
|
|
qDebug() << "MainWidget::onNewPatientMergencyInfo " << firstAidId << name << content << realCountDownInSeconds; |
|
|
|
m_ledTurnTimer.start(); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onPatientMergencyStatusChanged(QString firstAidId,QString time, QString status) |
|
|
@ -200,6 +234,41 @@ void MainWidget::onKeyClicked() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onKeyDown() |
|
|
|
{ |
|
|
|
qDebug() << "emit keyDown()"; |
|
|
|
if(m_patientEmergencyInfos.length() > 0){ |
|
|
|
keyDownPInfo = m_patientEmergencyInfos[m_patientIndex]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onKeyWorked(KeyFlag flag) |
|
|
|
{ |
|
|
|
qDebug() << "emit keyWork()" << flag; |
|
|
|
if(flag == Click){ |
|
|
|
m_ledTurnTimer.stop(); |
|
|
|
m_deviceService->m_ledStatus = 0; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
onKeyClicked(); |
|
|
|
}else if(flag == Dbl_Click){ |
|
|
|
qDebug()<<"Key Dbl_Clicked"; |
|
|
|
//切换病人
|
|
|
|
if(++m_patientIndex >= m_patientEmergencyInfos.length()){ |
|
|
|
m_patientIndex = 0; |
|
|
|
} |
|
|
|
updateUi(); |
|
|
|
m_curX = 0; |
|
|
|
}else if(flag == Press){ |
|
|
|
qDebug()<<"Key Press"; |
|
|
|
if(keyDownPInfo != Q_NULLPTR){ |
|
|
|
deletePatientFromList(keyDownPInfo->id); |
|
|
|
keyDownPInfo = Q_NULLPTR; |
|
|
|
} |
|
|
|
m_deviceService->m_ledStatus = 1; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::addPatientToList(PatientEmergencyInfo *info) |
|
|
|
{ |
|
|
|
//1.如果有就删除,以保证同一个病人按两次应该重新开始计时
|
|
|
@ -213,6 +282,8 @@ void MainWidget::addPatientToList(PatientEmergencyInfo *info) |
|
|
|
|
|
|
|
//3.加入链表
|
|
|
|
m_patientEmergencyInfos.push_back(info); |
|
|
|
|
|
|
|
onKeyDown();//模拟按键按下
|
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::deletePatientFromList(QString firstAidId) |
|
|
@ -226,12 +297,37 @@ void MainWidget::deletePatientFromList(QString firstAidId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
{ |
|
|
|
|
|
|
|
if(event->button()==Qt::LeftButton){ |
|
|
|
//TODO
|
|
|
|
} |
|
|
|
else if(event->button()==Qt::RightButton){ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//鼠标左键双击,代替按键一下
|
|
|
|
//鼠标右键双击,代替按键两下
|
|
|
|
void MainWidget::mouseDoubleClickEvent(QMouseEvent *event) |
|
|
|
{ |
|
|
|
if(event->button()==Qt::LeftButton){ |
|
|
|
//TODO
|
|
|
|
m_deviceService->key.flag = Click; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
else if(event->button()==Qt::RightButton){ |
|
|
|
onKeyClicked(); |
|
|
|
m_deviceService->key.flag = Dbl_Click; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
} |
|
|
|
//鼠标滚动,代替长按
|
|
|
|
void MainWidget::wheelEvent(QWheelEvent *event) |
|
|
|
{ // 当滚轮远离使用者时
|
|
|
|
if(event->delta() > 0){ |
|
|
|
//TODO
|
|
|
|
}else{//当滚轮向使用者方向旋转时
|
|
|
|
m_deviceService->key.flag = Press; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
} |
|
|
|