361 lines
9.5 KiB
C++
361 lines
9.5 KiB
C++
#include "titlewidget.h"
|
||
#include "ui_titlewidget.h"
|
||
#include <QPixmap>
|
||
#include <windows.h>
|
||
#include <wlanapi.h>
|
||
#include "mainwindowpagecontrol.h"
|
||
#include <QDebug>
|
||
#include <QDir>
|
||
#include "icemodule.h"
|
||
#include "ccommunicateapi.h"
|
||
#include "currentuserdata.h"
|
||
#include "loginwidget.h"
|
||
|
||
TitleWidget::TitleWidget(QWidget *parent) :
|
||
QWidget(parent),
|
||
ui(new Ui::TitleWidget),
|
||
checkTimer(nullptr)
|
||
{
|
||
ui->setupUi(this);
|
||
connect(ui->back1_Btn,SIGNAL(clicked()),this,SLOT(slotBackClicked()));
|
||
connect(ui->back2_Btn,SIGNAL(clicked()),this,SLOT(slotBackClicked()));
|
||
|
||
ui->user_Btn->setIcon(QIcon(":/DependFile/Source/User/user1.png"));
|
||
ui->user_Btn->setIconSize(QSize(40,40));
|
||
|
||
setBackBtnVisible(false);
|
||
|
||
checkTimer = new QTimer();
|
||
checkTimer->setInterval(3000);
|
||
connect(checkTimer,SIGNAL(timeout()),this,SLOT(slotCheckTimer()));
|
||
checkTimer->start();
|
||
|
||
connect(CCommunicateAPI::getInstance(),SIGNAL(signalCommunicateChanged(QString)),this,SLOT(slotStateChanged(QString)));
|
||
|
||
ui->signal_Label->setVisible(false);
|
||
ui->wifiSignal2_Label->setVisible(true);
|
||
ui->brainSignal_Labe->move(1550,30);
|
||
ui->sound_Button->move(1480,30);
|
||
|
||
ui->wifiSignal_Label->move(1620,30);
|
||
|
||
|
||
ui->title_Label->setText(tr("功能选择")); //默认汉字
|
||
|
||
ui->quit_Btn->setVisible(false);
|
||
ui->back1_Btn->setVisible(true);
|
||
ui->back2_Btn->setVisible(true);
|
||
|
||
m_soundDialog = new SoundDialog();
|
||
}
|
||
|
||
TitleWidget::~TitleWidget()
|
||
{
|
||
|
||
if(m_soundDialog)
|
||
{
|
||
delete m_soundDialog;
|
||
}
|
||
delete ui;
|
||
}
|
||
|
||
|
||
void TitleWidget::slotBackClicked()
|
||
{
|
||
|
||
int currentPage = MainWindowPageControl::getInstance()->getCurrentPageIndex();
|
||
if(!(currentPage>=MainPage_E && currentPage <=visionTrain))
|
||
currentPage = MainPage_E;//初始化异常值276795792,设置当前页索引为0
|
||
qDebug()<<"当前页"<<currentPage;
|
||
switch(currentPage)
|
||
{
|
||
case MainPage_E:
|
||
{
|
||
LoginWidget login;//
|
||
login.setWindowModality(Qt::WindowModal);//
|
||
login.exec(); //
|
||
// MainWindowPageControl::getInstance()->setCurrentPage(LoginPage_E);
|
||
// qDebug()<<"开始跳转";
|
||
}
|
||
break;
|
||
case BrainTraining:
|
||
case UserPage_E:
|
||
case SettingPage_E:
|
||
case BicycleParamSet_E:
|
||
case FesBicycleParamSet_E:
|
||
MainWindowPageControl::getInstance()->setCurrentPage(MainPage_E);
|
||
break;
|
||
case FesParamSet_E:
|
||
{
|
||
|
||
//分两种情况
|
||
switch(m_trainType)
|
||
{
|
||
case 0://1、直接选择的FES训练跳到主界面
|
||
MainWindowPageControl::getInstance()->setCurrentPage(MainPage_E);
|
||
break;
|
||
case 1://2、从踏车界面跳转到FES界面,跳到踏车界面
|
||
MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E);
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
case BicycleToFes_E:
|
||
MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E);
|
||
break;
|
||
case TrainingParamSetting_E:
|
||
{
|
||
if(m_trainType == 0)
|
||
MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E);
|
||
else if(m_trainType == 1)
|
||
MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E);
|
||
|
||
//qDebug() <<"Hello";
|
||
}
|
||
break;
|
||
case visionTrain:
|
||
MainWindowPageControl::getInstance()->setCurrentPage(BrainTraining);
|
||
break;
|
||
|
||
}
|
||
}
|
||
//设置当前用户
|
||
void TitleWidget::setUser(const ST_PatientMsg& st_patientMsg)
|
||
{
|
||
ui->user_Btn->setText(st_patientMsg.name);
|
||
}
|
||
//设置wifi信号强度
|
||
void TitleWidget::setSignalStrength(int value)
|
||
{
|
||
Q_UNUSED(value)
|
||
}
|
||
|
||
//设置标题
|
||
void TitleWidget::setTitleByPage(E_PAGENAME pageType)
|
||
{
|
||
QString title;
|
||
switch(pageType)
|
||
{
|
||
case MainPage_E:
|
||
title = tr("功能选择");
|
||
setBackBtnVisible(true);
|
||
ui->quit_Btn->setVisible(false);
|
||
//只修改pageIndex,不发送槽函数
|
||
MainWindowPageControl::getInstance()->setPageIndex(MainPage_E);
|
||
break;
|
||
case TrainingPage_E:
|
||
title = tr("");//上肢、下肢、四肢训练
|
||
setBackBtnVisible(false);
|
||
ui->quit_Btn->setVisible(false);
|
||
break;
|
||
case UserPage_E:
|
||
title = tr("用户管理");
|
||
setBackBtnVisible(true);
|
||
break;
|
||
case SettingPage_E:
|
||
title = tr("软件设置");
|
||
setBackBtnVisible(true);
|
||
break;
|
||
case BicycleParamSet_E:
|
||
title = tr("参数设置");
|
||
setBackBtnVisible(true);
|
||
break;
|
||
case FesParamSet_E:
|
||
setBackBtnVisible(true);
|
||
title = tr("FES参数");
|
||
break;
|
||
case FesBicycleParamSet_E:
|
||
setBackBtnVisible(true);
|
||
title = tr("踏车参数");
|
||
break;
|
||
case TrainingParamSetting_E:
|
||
setBackBtnVisible(true);
|
||
title = tr("参数设置");
|
||
break;
|
||
case BrainTraining:
|
||
setBackBtnVisible(true);
|
||
title = tr("脑控康复");
|
||
break;
|
||
case visionTrain:
|
||
setBackBtnVisible(true);
|
||
title = tr("视觉脑机康复训练");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
ui->title_Label->setText(title);
|
||
}
|
||
|
||
void TitleWidget::setTrainType(int8_t type)
|
||
{
|
||
m_trainType = type;
|
||
}
|
||
|
||
void TitleWidget::on_user_Btn_clicked()
|
||
{
|
||
MainWindowPageControl::getInstance()->setCurrentPage(UserPage_E);
|
||
}
|
||
|
||
void TitleWidget::slotCheckTimer()
|
||
{
|
||
showWIFI();
|
||
}
|
||
|
||
void TitleWidget::showWIFI()
|
||
{
|
||
#if 0
|
||
DWORD dwError = ERROR_SUCCESS;
|
||
DWORD dwNegotiatedVersion;
|
||
HANDLE hClientHandle = NULL;
|
||
dwError = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle);
|
||
if (dwError != ERROR_SUCCESS)
|
||
{
|
||
WlanCloseHandle(hClientHandle,NULL);
|
||
return;
|
||
}
|
||
PWLAN_INTERFACE_INFO_LIST pInterfaceList = NULL;
|
||
dwError = WlanEnumInterfaces(hClientHandle, NULL,&pInterfaceList);
|
||
if ( dwError != ERROR_SUCCESS )
|
||
{
|
||
WlanFreeMemory(pInterfaceList);
|
||
WlanCloseHandle(hClientHandle,NULL);
|
||
return;
|
||
}
|
||
|
||
GUID &guid = pInterfaceList->InterfaceInfo[0].InterfaceGuid;
|
||
PWLAN_AVAILABLE_NETWORK_LIST pWLAN_AVAILABLE_NETWORK_LIST = NULL;
|
||
|
||
dwError = WlanGetAvailableNetworkList(hClientHandle, &guid,
|
||
2,NULL, &pWLAN_AVAILABLE_NETWORK_LIST);
|
||
if (dwError != ERROR_SUCCESS)
|
||
{
|
||
WlanFreeMemory(pInterfaceList);
|
||
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
|
||
WlanCloseHandle(hClientHandle,NULL);
|
||
return;
|
||
}
|
||
WLAN_AVAILABLE_NETWORK wlanAN;
|
||
bool isConnected=false;
|
||
int numberOfItems = pWLAN_AVAILABLE_NETWORK_LIST->dwNumberOfItems;
|
||
if (numberOfItems > 0)
|
||
{
|
||
for(int i = 0; i <numberOfItems; i++)
|
||
{
|
||
wlanAN = pWLAN_AVAILABLE_NETWORK_LIST->Network[i];
|
||
if(wlanAN.dwFlags & 1)
|
||
{
|
||
isConnected=true;
|
||
|
||
int wifiQuality=(int)wlanAN.wlanSignalQuality;
|
||
|
||
if(wifiQuality>75)
|
||
{
|
||
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi3.png");
|
||
ui->wifiSignal_Label->setPixmap(pixmapWireless);
|
||
}
|
||
else if(wifiQuality>50&&wifiQuality<=75)
|
||
{
|
||
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi2.png");
|
||
ui->wifiSignal_Label->setPixmap(pixmapWireless);
|
||
}
|
||
else if(wifiQuality>25&&wifiQuality<=50)
|
||
{
|
||
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi1.png");
|
||
ui->wifiSignal_Label->setPixmap(pixmapWireless);
|
||
}
|
||
else if(wifiQuality>0&&wifiQuality<=25)
|
||
{
|
||
QPixmap pixmapWireless(":/icons/WirelessIcon3.png");
|
||
ui->wifiSignal_Label->setPixmap(pixmapWireless);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
if (!isConnected)
|
||
{
|
||
QPixmap pixmapWireless(":/icons/WirelessIcon4.png");
|
||
ui->wifiSignal_Label->setPixmap(pixmapWireless);
|
||
}
|
||
WlanFreeMemory(pInterfaceList);
|
||
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
|
||
WlanCloseHandle(hClientHandle,NULL);
|
||
|
||
#else
|
||
QPixmap pixmap;
|
||
|
||
if(IceModule::getInstance()->getBicycleDeviceState())
|
||
{
|
||
pixmap.load(":/DependFile/Source/signal/deviceConnected.png");
|
||
}
|
||
else
|
||
pixmap.load(":/DependFile/Source/signal/deviceDisconnected.png");
|
||
|
||
ui->wifiSignal_Label->setPixmap(pixmap);
|
||
#endif
|
||
|
||
}
|
||
|
||
void TitleWidget::setBackBtnVisible(bool visible)
|
||
{
|
||
ui->back1_Btn->setVisible(visible);
|
||
ui->back2_Btn->setVisible(visible);
|
||
|
||
ui->quit_Btn->setVisible(!visible);
|
||
}
|
||
|
||
void TitleWidget::on_quit_Btn_clicked()
|
||
{
|
||
emit signalCloseWindow();
|
||
//MainWindowPageControl::getInstance()->setCurrentPage(LoginPage_E);
|
||
|
||
/*
|
||
*
|
||
*/
|
||
}
|
||
|
||
void TitleWidget::slotStateChanged(QString str)
|
||
{
|
||
ui->state_label->setText(str);
|
||
}
|
||
|
||
void TitleWidget::slotSaveUpPicture()
|
||
{
|
||
QPixmap upPicture = this->grab();
|
||
QString dirPath = QApplication::applicationDirPath() + "/DependFile/Source/trainDisplayPage";
|
||
QDir resultDir(dirPath);
|
||
if(!resultDir.exists())
|
||
qDebug()<<"保存图片失败";
|
||
if(upPicture.save(dirPath + "/upPicture.png"))
|
||
qDebug() <<dirPath + "/upPicture.png";
|
||
}
|
||
|
||
void TitleWidget::changeEvent(QEvent* event)
|
||
{
|
||
switch (event->type())
|
||
{
|
||
case QEvent::LanguageChange:
|
||
ui->retranslateUi(this);
|
||
break;
|
||
default:
|
||
QWidget::changeEvent(event);
|
||
break;
|
||
}
|
||
setUser(CurrentUserData::getInstace()->getCurrentPatientMsg());
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
void TitleWidget::on_sound_Button_clicked()
|
||
{
|
||
m_soundDialog->show();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|