This commit is contained in:
curtis
2024-11-25 17:15:44 +08:00
commit 32e5360a91
3749 changed files with 1432905 additions and 0 deletions

View File

@@ -0,0 +1,301 @@
#include "cmainwindow.h"
#include "ui_cmainwindow.h"
#include "mainwindowpagecontrol.h"
#include "currentuserdata.h"
#include <QDebug>
#include <QTimer>
#include <windows.h>
#include <QHBoxLayout>
#include <QProcess>
#include "gamecontrol.h"
#include "fescontroldialog.h"
CMainWindow::CMainWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::CMainWindow),
m_gameDisplayPage(NULL),
gamedialog(NULL),
grabWindowTimer(NULL)
{
ui->setupUi(this);
ui->title_Widget->hide();
ui->stackedWidget->setGeometry(0,0,1920,1080);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
qRegisterMetaType<E_PAGENAME>("E_PAGENAME");
connect(MainWindowPageControl::getInstance(),SIGNAL(signalSwitchPage(E_PAGENAME)),this,SLOT(slotSwitchPage(E_PAGENAME)));
connect(CurrentUserData::getInstace(),SIGNAL(signalUserChanged()),this,SLOT(slotCurrentUserChanged()));
//默认为主界面
// setAttribute(Qt::WA_DeleteOnClose,false);
ui->stackedWidget->setCurrentIndex(0);
m_gameDisplayPage = new GameDisplayPage();
connect(m_gameDisplayPage,SIGNAL(signalGameStateChanged(int8_t)),this,SLOT(slotGameStateChanged(int8_t)));
m_Process = new QProcess();
connect(ui->title_Widget,SIGNAL(signalCloseWindow()),this,SLOT(closeWindow()));
gamedialog = new QDialog;
m_loginWidget = new LoginWidget();
gamedialog->stackUnder(m_gameDisplayPage);
grabWindowTimer = new QTimer();
connect(grabWindowTimer,SIGNAL(timeout()),this,SLOT(slotGrabWindow()));
connect(ui->FES_Page,SIGNAL(signalStartGame()),ui->FESCar_Page,SLOT(slotStartGame()));
//从参数界面传递到训练界面
connect(ui->trainParam_Page,&TrainingParamSetting::signalTrainParamChanged,ui->FESCar_Page,&ArmOrLeg::slotRecvTrainParamChanged);
//训练页面发消息让tittle页面保存截图
connect(ui->FESCar_Page,&ArmOrLeg::saveUpPictureSignal,ui->title_Widget,&TitleWidget::slotSaveUpPicture);
//从训练界面传递到参数界面
connect(ui->FESCar_Page,&ArmOrLeg::signalBicycleParamChanged,ui->trainParam_Page,&TrainingParamSetting::slotBicycleParamChanged);
//训练界面打开,跟新游戏配置默认参数
connect(ui->Main_Page,&TrainManager::signalOpenTrainManagerPage,ui->trainParam_Page,&TrainingParamSetting::slotResetParam);
// connect(m_loginWidget,SIGNAL(signalCloseApp),this,SLOT(closeWindow()));
}
CMainWindow::~CMainWindow()
{
if(gamedialog)
delete gamedialog;
if(m_gameDisplayPage)
delete m_gameDisplayPage;
if(grabWindowTimer)
delete grabWindowTimer;
delete ui;
}
void CMainWindow::switchPage(E_PAGENAME E_Page)
{
switch(E_Page)
{
case MainPage_E:
gamedialog->close();
ui->stackedWidget->setGeometry(0,0,1920,1080);
ui->stackedWidget->setCurrentWidget(ui->Main_Page);
ui->title_Widget->hide();
qDebug() <<"来到了主页";
emit ui->Main_Page->signalOpenTrainManagerPage();
break;
case TrainingPage_E://游戏训练界面
// ui->stackedWidget->setCurrentWidget(ui->game_Page);
startGame_Btn_clicked();
// QTimer::singleShot(1000,this,SLOT(slot_Timerout()));//同上,就是参数不同
break;
case UserPage_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->userMsg_Page);
ui->title_Widget->show();
break;
case SettingPage_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->setting_Page);
ui->title_Widget->show();
break;
case BicycleParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
//qDebug() <<"普通单车";
ui->FESCar_Page->setTrainType(0);
ui->title_Widget->setTrainType(0);
ui->trainParam_Page->setTrainType(0);
ui->stackedWidget->setCurrentWidget(ui->FESCar_Page);
ui->title_Widget->show();
break;
case FesBicycleParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
//qDebug() <<"FES单车";
ui->FESCar_Page->setTrainType(1);
ui->title_Widget->setTrainType(1);
ui->trainParam_Page->setTrainType(1);
ui->stackedWidget->setCurrentWidget(ui->FESCar_Page);
ui->title_Widget->show();
break;
case FesParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->title_Widget->setTrainType(0);
ui->FES_Page->switchPage(ONLY_FES_E);
ui->stackedWidget->setCurrentWidget(ui->FES_Page);
ui->title_Widget->show();
break;
case BicycleToFes_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->FES_Page->switchPage(BICYCLE_FES_E);
ui->stackedWidget->setCurrentWidget(ui->FES_Page);
ui->title_Widget->show();
break;
case TrainingParamSetting_E: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->trainParam_Page);
ui->title_Widget->show();
break;
case BrainTraining: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->Brain_Page);
ui->title_Widget->show();
break;
case visionTrain: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->Vision_Page);
ui->title_Widget->show();
break;
default:
break;
}
}
void CMainWindow::slotSwitchPage(E_PAGENAME page)
{
switchPage(page);
ui->title_Widget->setTitleByPage(page);
}
void CMainWindow::slotCurrentUserChanged()
{
ui->title_Widget->setUser(CurrentUserData::getInstace()->getCurrentPatientMsg());
}
void CMainWindow::startGame_Btn_clicked()
{
connect(m_Process,&QProcess::errorOccurred,[=](QProcess::ProcessError error){qDebug()<<error;});
// connect(m_Process,QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished),[this]
// (int exitCode,QProcess::ExitStatus exitStatus){
// m_exitCode = exitCode;
// m_exitStatus = exitStatus;
// qDebug()<<"m_exitCode"<<m_exitCode<<"m_exitStatus"<<m_exitStatus;
// });
QString destPath = GameControl::getInstance()->getCurrentGameMsg().gamePath + GameControl::getInstance()->getCurrentGameMsg().gameName;
startGame(destPath);
grabWindowTimer->start(300);
}
void CMainWindow::slotGrabWindow()
{
WId hwnd = 0;
if(1 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ001_SingleplayerBicycleRace");
else if(2 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ002_MultiplayerBicycleRace_LBY");
else if(3 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ003_MultiplayerRaceSciFi");
else if(4 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ004_CatchFish");
if(IsHungAppWindow(HWND(hwnd)))
{
qDebug()<<"正在运行";
}
if(hwnd > 0)
{
grabWindowTimer->stop();
m_window = QWindow::fromWinId(hwnd);
container = createWindowContainer(m_window,this);
gamedialog->setWindowFlags(Qt::FramelessWindowHint);
QGridLayout *hLayout = new QGridLayout(this);
hLayout->setMargin(0);
hLayout->addWidget(container);
if(gamedialog->layout() != NULL)
delete gamedialog->layout();
gamedialog->setLayout(hLayout);
gamedialog->show();
gamedialog->resize(1920,980);
gamedialog->move(0,100);
// m_gameDisplayPage->show();
}
}
void CMainWindow::slotGameStateChanged(int8_t state)
{
switch(state)
{
case 0: //停止游戏
{
m_gameDisplayPage->close();
gamedialog->close();
slotSwitchPage(MainPage_E);
}
break;
case 1: //开始游戏
m_gameDisplayPage->show();
break;
}
}
void CMainWindow::closeWindow()
{
//关闭所有设备
qDebug()<<"运行了";
FesControlDialog::getInstance()->turnoffDevice(1,1);
this->close();
}
void CMainWindow::startGame(QString path)
{
//1.开启游戏进程
if(path.isEmpty())
return;
QString hardDisk = path.mid(0,2);
hardDisk.append("\n\r");
QString gameName = path.mid(path.lastIndexOf('/')+1);
gameName.prepend("start ");
gameName.append("\n\r");
QString gamePath = path.mid(0,path.lastIndexOf('/'));
gamePath.prepend("cd ");
gamePath.append("\n\r");
m_Process->start("cmd.exe");
//切换盘符
m_Process->write(hardDisk.toLatin1());
//进入文件夹
m_Process->write(gamePath.toLatin1());
//开启进程
m_Process->write(gameName.toLatin1());
m_Process->write("exit\n\r");
m_Process->waitForFinished();
m_Process->close();
//2.关闭设备复位中的界面
}
void CMainWindow::slot_Timerout()
{
// m_gameDisplayPage->show();
}
void CMainWindow::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
signalShowCompleted();
}
void CMainWindow::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,66 @@
#ifndef CMAINWINDOW_H
#define CMAINWINDOW_H
#include <QWidget>
#include "dataformate.h"
#include "loginwidget.h"
//#include "fessetting.h"
#include "gamedisplaypage.h"
#include <QProcess>
#include <QWindow>
#include "loginwidget.h"
class QProcess;
namespace Ui {
class CMainWindow;
}
class CMainWindow : public QWidget
{
Q_OBJECT
public:
explicit CMainWindow(QWidget *parent = nullptr);
~CMainWindow();
public slots:
void slotSwitchPage(E_PAGENAME);
void slot_Timerout();
protected:
void showEvent(QShowEvent *event);
virtual void changeEvent(QEvent* event);
signals:
void signalShowCompleted();
private slots:
void slotCurrentUserChanged();
void startGame_Btn_clicked();
void slotGameStateChanged(int8_t state);
void closeWindow();
void slotGrabWindow();
private:
void switchPage(E_PAGENAME);
void startGame(QString path);
private:
Ui::CMainWindow *ui;
LoginWidget *loginDialog;
// QProcess *process;
int m_exitCode;
QProcess::ExitStatus m_exitStatus;
QWindow *m_window;
GameDisplayPage *m_gameDisplayPage;
QProcess* m_Process;
QWidget *container;
QDialog *gamedialog;
QTimer *grabWindowTimer;
LoginWidget *m_loginWidget;
};
#endif // CMAINWINDOW_H

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CMainWindow</class>
<widget class="QWidget" name="CMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="TitleWidget" name="title_Widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QStackedWidget" name="stackedWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>100</y>
<width>1920</width>
<height>980</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="TrainManager" name="Main_Page">
<property name="styleSheet">
<string notr="true">background-color:transparent;</string>
</property>
</widget>
<widget class="eyeTrainWidget" name="Vision_Page"/>
<widget class="brainTrain" name="Brain_Page"/>
<widget class="ArmOrLeg" name="FESCar_Page"/>
<widget class="FesSetting" name="FES_Page"/>
<widget class="SettingWidget" name="setting_Page"/>
<widget class="UserManager" name="userMsg_Page"/>
<widget class="QWidget" name="login_Page"/>
<widget class="QWidget" name="game_Page">
<widget class="QWidget" name="game_widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1921</width>
<height>980</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Image/background1.png);
</string>
</property>
</widget>
</widget>
<widget class="TrainingParamSetting" name="trainParam_Page"/>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>TitleWidget</class>
<extends>QWidget</extends>
<header>titlewidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>UserManager</class>
<extends>QWidget</extends>
<header>usermanager.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SettingWidget</class>
<extends>QWidget</extends>
<header>settingwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TrainManager</class>
<extends>QWidget</extends>
<header>trainmanager.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FesSetting</class>
<extends>QWidget</extends>
<header>fessetting.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ArmOrLeg</class>
<extends>QWidget</extends>
<header>armorleg.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TrainingParamSetting</class>
<extends>QWidget</extends>
<header>trainingparamsetting.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>brainTrain</class>
<extends>QWidget</extends>
<header>braintrain.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>eyeTrainWidget</class>
<extends>QWidget</extends>
<header>eyetrainwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,254 @@
#include "loginwidget.h"
#include "ui_loginwidget.h"
#include <QSettings>
#include <QDir>
#include "passworddialog.h"
#include "dataformate.h"
#include <QDebug>
#include <QProcess>
#include "fescontroldialog.h"
#include "cmainwindow.h"
#include "languagemanager.h"
LoginWidget::LoginWidget(QDialog *parent) :
QDialog(parent),
ui(new Ui::LoginWidget),
passworldDialog(nullptr)
{
//PC版默认密码111111TV版默认密码666666
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
//设置为模态对话框
// setModal(true);
connect(this,&LoginWidget::signalResult,this,&LoginWidget::done);
// setAttribute(Qt::WA_DeleteOnClose,true);
ui->userNameTips_Label->setVisible(false);
ui->passwordTips_Label->setVisible(false);
passworldDialog = new PasswordDialog();
m_shutdownDialog = new ShutdeonDialog();
ui->password_LineEdit->setEchoMode(QLineEdit::Password);
// ui->password_LineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
ui->remember_RadioButton->setChecked(true);
QString dirPath = "./DependFile/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "remberIDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
QString password = iniSetting.value("password").toString();
QString userName = iniSetting.value("userName").toString();
ui->userName_LineEdit->setText(userName);
ui->password_LineEdit->setText(password);
ui->forgetPasswordTips_Label->setVisible(false);
m_timer = new QTimer(this);
m_bleItem = new BLEItem();
connect(m_timer,SIGNAL(timeout()),this,SLOT(slotCleanTimes()));
// qDebug()<<"password"<< ui->userName_LineEdit->text()<<ui->password_LineEdit->text();
// connect(this,SIGNAL(signalCloseApp(),FesControlDialog::getInstance(),FesControlDialog::getInstance()->);
/*
#ifdef NORMALEXE
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upDown_limp.jpg);");
#endif
*/
#ifdef ONLYUPLIMP
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upLimp.png);");
#endif
#ifdef ONLYDOWNLIMP
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/downLimp.png);");
#endif
}
LoginWidget::~LoginWidget()
{
if(passworldDialog)
delete passworldDialog;
if(m_shutdownDialog)
delete m_shutdownDialog;
if(m_bleItem)
delete m_bleItem;
delete ui;
}
void LoginWidget::slotShowCompleted()
{
this->close();
}
void LoginWidget::slotCleanTimes()
{
m_clockTime = 0;
}
void LoginWidget::on_forgetPassword_Btn_clicked()
{
//弹出提示框,告知获取密码的方式
ui->forgetPasswordTips_Label->setText(tr("请联系管理员获取初始密码"));
ui->forgetPasswordTips_Label->setVisible(true);
}
void LoginWidget::on_confirm_Btn_clicked()
{
QString dirPath = "./DependFile/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "IDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
QString password = iniSetting.value("password").toString();
QString userName = iniSetting.value("userName").toString();
qDebug()<<userName<<password;
QString rememberConfFile(dirPath + "remberIDconf.ini");
QSettings remIniSetting(confFile, QSettings::IniFormat);
QString remPassword = iniSetting.value("password").toString();
QString remUserName = iniSetting.value("userName").toString();
if(ui->userName_LineEdit->text() != userName)
{
ui->userNameTips_Label->setVisible(true);
ui->userNameTips_Label->setText(tr("用户名输入错误"));
return;
}
if(ui->password_LineEdit->text() != password)
{
ui->passwordTips_Label->setVisible(true);
ui->passwordTips_Label->setText(tr("密码输入错误"));
return;
}
//设置返回值结果
emit signalResult(1);
if(ui->remember_RadioButton->isChecked())
{
QString confFile(dirPath + "remberIDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
iniSetting.setValue("password",ui->password_LineEdit->text());
iniSetting.setValue("userName",ui->userName_LineEdit->text());
}
}
void LoginWidget::on_userName_LineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
ui->userNameTips_Label->setVisible(false);
ui->forgetPasswordTips_Label->setVisible(false);
}
void LoginWidget::on_password_LineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
ui->passwordTips_Label->setVisible(false);
ui->forgetPasswordTips_Label->setVisible(false);
}
void LoginWidget::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
{
ui->retranslateUi(this);
}
break;
default:
QWidget::changeEvent(event);
break;
}
m_clockTime = 0;
}
void LoginWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
if(language == Chinese_E)
{
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company.png);");
QFont font;
font.setFamily("黑体");
font.setPointSize(18);
ui->productionName_Label->setFont(font);
}
//
else if(language == English_E)
{
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company_En.png);");
//
QFont font;
font.setFamily("Arial");
font.setPointSize(18);
ui->productionName_Label->setFont(font);
}
}
void LoginWidget::on_pushButton_clicked()
{
m_shutdownDialog->exec(); //关闭窗口
qDebug()<<"关机值:"<< m_shutdownDialog->getResult();
if(m_shutdownDialog->getResult() == 0)
return;
else
{
FesControlDialog::getInstance()->turnoffDevice(1,1);
Sleep(100);
// FesControlDialog::getInstance()->turnoffDevice(1,1);
QCoreApplication::quit(); //关闭程序
Sleep(3500); //睡眠
}
// emit signalCloseWindow();
/*
QString program = "C:/WINDOWS/system32/shutdown.exe";
QStringList arguments;
arguments << "-s";
QProcess *myProcess = new QProcess();
myProcess->start(program,arguments);
*/
system("shutdown -s -t 00");
}
void LoginWidget::on_company_Label_clicked()
{
m_clockTime++;
if(m_clockTime == 1)
m_timer->start(5000);
qDebug()<<m_clockTime;
if(m_clockTime == 10)
{
//m_bleItem->setDeviceState(false);
FesControlDialog::getInstance()->turnoffDevice(1,1);
Sleep(100);
// emit signalCloseApp();
//FesControlDialog::getInstance()->turnoffDevice(1,1);
QApplication *app;
app->exit(0);
this->close();
//关闭所有设备
//FesControlDialog::getInstance()->turnoffDevice(1,1);
//emit signalCloseApp();
}
}

View File

@@ -0,0 +1,57 @@
#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H
#include <QDialog>
#include <QTimer>
#include "shutdeondialog.h"
#include "BLEItem.h"
class PasswordDialog;
namespace Ui {
class LoginWidget;
}
class LoginWidget : public QDialog
{
Q_OBJECT
public:
explicit LoginWidget(QDialog *parent = nullptr);
~LoginWidget();
signals:
void signalResult(int);
signals:
void signalCloseApp();
void signalCloseWindow();
protected:
virtual void changeEvent(QEvent* event);
virtual void showEvent(QShowEvent *event);
public slots:
void slotShowCompleted();
void slotCleanTimes();
private slots:
void on_forgetPassword_Btn_clicked();
void on_confirm_Btn_clicked();
void on_userName_LineEdit_textChanged(const QString &arg1);
void on_password_LineEdit_textChanged(const QString &arg1);
void on_pushButton_clicked();
void on_company_Label_clicked();
private:
Ui::LoginWidget *ui;
PasswordDialog *passworldDialog;
ShutdeonDialog *m_shutdownDialog;
QTimer *m_timer;
int m_clockTime;
BLEItem *m_bleItem;
};
#endif // LOGINWIDGET_H

View File

@@ -0,0 +1,433 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoginWidget</class>
<widget class="QWidget" name="LoginWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>110</x>
<y>110</y>
<width>1700</width>
<height>860</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #F7F7F7;
border-radius: 20px;
}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>810</x>
<y>0</y>
<width>850</width>
<height>1020</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_2{background:#F7F7F7;
border-radius: 20px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>95</x>
<y>650</y>
<width>670</width>
<height>100</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #07A8E7;
border-radius: 45px;
color:white;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QLabel" name="passwordTips_Label">
<property name="geometry">
<rect>
<x>140</x>
<y>470</y>
<width>171</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string>密码输入错误</string>
</property>
</widget>
<widget class="QRadioButton" name="remember_RadioButton">
<property name="geometry">
<rect>
<x>480</x>
<y>530</y>
<width>391</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>记住密码</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="forgetPassword_Btn">
<property name="geometry">
<rect>
<x>100</x>
<y>528</y>
<width>301</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;</string>
</property>
<property name="text">
<string>忘记密码</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>335</x>
<y>110</y>
<width>231</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>35</pointsize>
</font>
</property>
<property name="text">
<string>登录</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="userNameTips_Label">
<property name="geometry">
<rect>
<x>140</x>
<y>320</y>
<width>171</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string>用户名输入错误</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>95</x>
<y>230</y>
<width>670</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_3{border-radius: 45px;
background:white;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLineEdit" name="userName_LineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>12</y>
<width>501</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>35</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;</string>
</property>
<property name="text">
<string>xyyl</string>
</property>
<property name="placeholderText">
<string>请输入用户名</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>95</x>
<y>380</y>
<width>670</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_4{border-radius: 45px;
background:white;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLineEdit" name="password_LineEdit">
<property name="geometry">
<rect>
<x>70</x>
<y>6</y>
<width>561</width>
<height>80</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;
color:#999999 ;</string>
</property>
<property name="text">
<string>666666</string>
</property>
<property name="placeholderText">
<string>请输入密码</string>
</property>
</widget>
</widget>
<widget class="QLabel" name="forgetPasswordTips_Label">
<property name="geometry">
<rect>
<x>120</x>
<y>600</y>
<width>711</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>860</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_5{
background: #FFFFFF;
border-radius: 20px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="productionName_Label">
<property name="geometry">
<rect>
<x>89</x>
<y>730</y>
<width>621</width>
<height>100</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>上下肢主被动康复训练仪</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>230</x>
<y>140</y>
<width>401</width>
<height>507</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/login/upDownLimp.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="company_Label_2_invalid">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>230</width>
<height>57</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/login/company.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="company_Label">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>230</width>
<height>57</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border:none;
border-image: url(:/DependFile/Source/login/company.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox_5</zorder>
<zorder>groupBox_2</zorder>
</widget>
<widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_6{background: #07A8E7;
border: 1px solid #979797;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>90</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;
border-image: url(:/DependFile/Source/MainPage/shutdown.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox_6</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,146 @@
#include <QApplication>
#include "cdatabaseinterface.h"
#include <QFile>
#include <QDebug>
#include <QMessageBox>
//#include "loginwidget.h"
#include "cmainwindow.h"
#include "readconfig.h"
#include "loginwidget.h"
#include "gamecontrol.h"
#include <QSharedMemory>
#include <QMutex>
#include <QFile>
#include <QObject>
#include "fescontroldialog.h"
#include <QSettings>
void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
static QMutex mutex;
mutex.lock();
QString text;
switch(type)
{
case QtDebugMsg:
text = QString("Debug:");
break;
case QtWarningMsg:
text = QString("Warning:");
break;
case QtCriticalMsg:
text = QString("Critical:");
break;
case QtFatalMsg:
text = QString("Fatal:");
}
QString context_info = QString("File:(%1) Line:(%2)").arg(QString(context.file)).arg(context.line);
QString current_date_time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss ddd");
QString current_date = QString("(%1)").arg(current_date_time);
QString message = QString("%1 %2 %3 %4").arg(text).arg(context_info).arg(msg).arg(current_date);
QFile file("log.txt");
file.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream text_stream(&file);
text_stream << message << "\r\n";
file.flush();
file.close();
mutex.unlock();
}
#include <QDir>
#include <QSettings>
//设置程序自启动 appPath程序路径
void SetProcessAutoRunSelf(const QString &appPath)
{
//注册表路径需要使用双反斜杠如果是32位系统要使用QSettings::Registry32Format
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::Registry64Format);
//以程序名称作为注册表中的键
//根据键获取对应的值(程序路径)
QFileInfo fInfo(appPath);
QString name = fInfo.baseName();
QString path = settings.value(name).toString();
//如果注册表中的路径和当前程序路径不一样,
//则表示没有设置自启动或自启动程序已经更换了路径
//toNativeSeparators的意思是将"/"替换为"\"
QString newPath = QDir::toNativeSeparators(appPath);
if (path != newPath)
{
settings.setValue(name, newPath);
qDebug() <<"添加快捷启动注册表HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run,";
}
}
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("tgtsml"));
//qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QApplication a(argc, argv);
//Qt开机自启动
//SetProcessAutoRunSelf(qApp->applicationFilePath());
#ifdef DEBUGON
qInstallMessageHandler(outputMessage);
#endif
//数据库读取
if(!CDatabaseInterface::getInstance()->openDB("./DependFile/DBFile/UpLow.db","QSQLITE"))
qDebug()<<"UpLow.db open failed!";
//配置文件读取
if(!ReadConfig::getInstance()->readConfigFile())
{
qDebug()<<"配置文件读取失败";
return -1;
}
//读取游戏配置文件
GameControl::getInstance()->readGameConfigMsg();
//设置全局样式表
QFile file("./DependFile/QSS/app.txt");
if(file.open(QFile::ReadOnly))
{
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
file.close();
}
else
{
QMessageBox::warning(NULL, "warning", "totalqss Open failed", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
}
QSharedMemory sharedMemory;
sharedMemory.setKey("main_Window");
if(sharedMemory.attach())
{
QMessageBox::warning(NULL, "Warning", ("不可重复开启进程"));
return 0;
}
LoginWidget login;//
CMainWindow w;
if(sharedMemory.create(1))
{
QObject::connect(&w,SIGNAL(signalShowCompleted()),&login,SLOT(slotShowCompleted()));
login.setWindowModality(Qt::WindowModal);//
login.exec(); //
w.show();
}
QObject::connect(&a,&QApplication::aboutToQuit,[](){
FesControlDialog::getInstance()->turnoffDevice(1,1);
});
return a.exec();
}

View File

@@ -0,0 +1,19 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QListView>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
// , ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->setView(new QListView());
//设置无边框
// ui->comboBox_2->setView(new QListView());
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@@ -0,0 +1,21 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@@ -0,0 +1,499 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>190</x>
<y>140</y>
<width>113</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>80</x>
<y>350</y>
<width>471</width>
<height>131</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background:white;}</string>
</property>
<property name="title">
<string>GroupBox</string>
</property>
<widget class="QSlider" name="horizontalSlider">
<property name="geometry">
<rect>
<x>50</x>
<y>60</y>
<width>351</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">/**********首先指定是水平还是竖直*不添加此代码,下方不起作用******/
QSlider::groove:horizontal {
border: 0px solid #bbb;
}
/*1.滑动过的槽设计参数*/
QSlider::sub-page:horizontal {
/*槽颜色*/
background: #05F6CC;
/*外环区域倒圆角度*/
border-radius: 4px;
/*上遮住区域高度*/
margin-top:14px;
/*下遮住区域高度*/
margin-bottom:14px;
/*width在这里无效不写即可*/
/*****/
margin-left:8px;
}
/*2.未滑动过的槽设计参数*/
QSlider::add-page:horizontal {
/*槽颜色*/
background: #ECEBEB;
/*外环大小0px就是不显示默认也是0*/
border: 0px solid #777;
/*外环区域倒圆角度*/
border-radius: 4px;
/*上遮住区域高度*/
margin-top:14px;
/*下遮住区域高度*/
margin-bottom:14px;
margin-right:8px;
}
QSlider::handle:horizontal {
width: 43px;
background:transparent;
background-image: url(:/DependFile/Source/channel/slder.png);
margin: -0px -0px -0px -0px;
}
</string>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>420</x>
<y>150</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">/* 未下拉时QComboBox的样式 */
QComboBox {
border: 1px solid gray; /* 边框 */
border-radius: 3px; /* 圆角 */
padding: 1px 18px 1px 3px; /* 字体填衬 */
color: #000;
background: transparent;
}
/* 下拉后,整个下拉窗体样式 */
QComboBox QAbstractItemView {
outline: 2px solid gray; /* 选定项的虚框 */
border: 1px solid yellow; /* 整个下拉窗体的边框 */
color: black;
background-color: white; /* 整个下拉窗体的背景色 */
selection-background-color: lightgreen; /* 整个下拉窗体被选中项的背景色 */
}
/* 下拉后,整个下拉窗体每项的样式-此项起作用后,整个下拉窗体的样式则被顶替了 */
QComboBox QAbstractItemView::item {
height: 50px; /* 项的高度设置pComboBox-&gt;setView(new QListView());后,该项才起作用) */
font: normal normal 25px &quot;黑体&quot;;/********字体未起作用***********/
}
/* 下拉后,整个下拉窗体越过每项的样式 */
QComboBox QAbstractItemView::item:hover {
color: #FFFFFF;
background-color: lightgreen; /* 整个下拉窗体越过每项的背景色 */
}
/* 下拉后,整个下拉窗体被选择的每项的样式 */
QComboBox QAbstractItemView::item:selected {
color: #FFFFFF;
background-color: lightgreen;
}
/* QComboBox中的垂直滚动条 */
QComboBox QAbstractScrollArea QScrollBar:vertical {
width: 10px;
background-color: #d0d2d4; /* 空白区域的背景色 灰色green */
}
QComboBox QAbstractScrollArea QScrollBar::handle:vertical {
border-radius: 5px; /* 圆角 */
background: rgb(160,160,160); /* 小方块的背景色深灰lightblue */
}
QComboBox QAbstractScrollArea QScrollBar::handle:vertical:hover {
background: rgb(90, 91, 93); /* 越过小方块的背景色yellow */
}
/* 下拉框样式 */
QComboBox::drop-down {
subcontrol-origin: padding; /* 子控件在父元素中的原点矩形。如果未指定此属性则默认为padding。 */
subcontrol-position: top right; /* 下拉框的位置(右上) */
width: 25px; /* 下拉框的宽度 */
border-left-width: 1px; /* 下拉框的左边界线宽度 */
border-left-color: darkgray; /* 下拉框的左边界线颜色 */
border-left-style: solid; /* 下拉框的左边界线为实线 */
border-top-right-radius: 3px; /* 下拉框的右上边界线的圆角半径应和整个QComboBox右上边界线的圆角半径一致 */
border-bottom-right-radius: 3px; /* 同上 */
}
</string>
</property>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
</widget>
<widget class="QRadioButton" name="radioButton">
<property name="geometry">
<rect>
<x>190</x>
<y>250</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator:unchecked{
image: url(:/DependFile/Source/radioButton/normal.png);
width:20;
height:20
}
QRadioButton::indicator:checked{
image: url(:/DependFile/Source/radioButton/checked.png);
width:20;
height:20
}
</string>
</property>
<property name="text">
<string>RadioButton</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_2">
<property name="geometry">
<rect>
<x>590</x>
<y>150</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>-1</pointsize>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">/* 未下拉时QComboBox的样式 */
QComboBox {
border: 1px solid gray; /* 边框 */
border-radius: 3px; /* 圆角 */
padding: 1px 18px 1px 3px; /* 字体填衬 */
color: #000;
font: 20px &quot;黑体&quot;;
background: transparent;
}
/* 下拉后,整个下拉窗体样式 */
QComboBox QAbstractItemView {
outline: 0px solid gray; /* 选定项的虚框 */
border: 0px solid gray; /* 整个下拉窗体的边框 */
color: black;
background-color: #C3E4F3; /* 整个下拉窗体的背景色 */
selection-background-color: lightgreen; /* 整个下拉窗体被选中项的背景色 */
font: 20px &quot;黑体&quot;;
}
/* 下拉后,整个下拉窗体每项的样式 */
QComboBox QAbstractItemView::item {
height: 50px; /* 项的高度设置pComboBox-&gt;setView(new QListView());后,该项才起作用) */
}</string>
</property>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,42 @@
#include "mainwindowpagecontrol.h"
#include <QDebug>
MainWindowPageControl* MainWindowPageControl::m_pageControlInterface = NULL;
MainWindowPageControl::MainWindowPageControl(QObject *parent) : QObject(parent)
{
ST_runningFlag.evaluateFlag = false;
ST_runningFlag.gameFlag = false;
ST_runningFlag.moveRangeFlag = false;
ST_runningFlag.trainModeFlag = false;
ST_runningFlag.trainRecordFlag = false;
}
MainWindowPageControl* MainWindowPageControl::getInstance()
{
if(m_pageControlInterface == NULL)
{
m_pageControlInterface = new MainWindowPageControl();
}
return m_pageControlInterface;
}
void MainWindowPageControl::setCurrentPage(int pageIndex)
{
m_currentPageIndex = pageIndex;
emit signalSwitchPage((E_PAGENAME)pageIndex);
}
void MainWindowPageControl::setMainWindowBtnsLock(bool isLock)
{
emit signalSetBtnsLock(isLock);
}
int MainWindowPageControl::getCurrentPageIndex()
{
return m_currentPageIndex;
}
void MainWindowPageControl::setPageIndex(int pageIndex)
{
m_currentPageIndex = pageIndex;
}

View File

@@ -0,0 +1,50 @@
#ifndef MAINWINDOWPAGECONTROL_H
#define MAINWINDOWPAGECONTROL_H
/*************该类主要用于管理页面间的切换***************/
#include "dataformate.h"
#include <QObject>
class MainWindowPageControl : public QObject
{
Q_OBJECT
public:
static MainWindowPageControl* getInstance();
/****设置当前页面****
* @int pageIndex 目标页面
* *************/
void setCurrentPage(int pageIndex);
//各个模块是否解锁
void setMainWindowBtnsLock(bool);
//获取当前页面下标
int getCurrentPageIndex();
//只修改页面所以,不发送槽函数
void setPageIndex(int pageIndex);
signals:
void signalSwitchPage(E_PAGENAME pageIndex);
void signalSetBtnsLock(bool);
//关闭当前运行的练习
void signalTurnOffRunning(int pageIndex);
private:
explicit MainWindowPageControl(QObject *parent = nullptr);
static MainWindowPageControl* m_pageControlInterface;
int m_currentPageIndex; //当前页面下标
//各界面状态
struct
{
bool moveRangeFlag;
bool trainModeFlag;
bool gameFlag;
bool evaluateFlag;
bool trainRecordFlag;
}ST_runningFlag;
};
#endif // MAINWINDOWPAGECONTROL_H

View File

@@ -0,0 +1,357 @@
#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->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();
}

View File

@@ -0,0 +1,75 @@
#ifndef TITLEWIDGET_H
#define TITLEWIDGET_H
#include <QWidget>
#include <QLabel>
#include "dbforrmate.h"
#include "dataformate.h"
#include <QTimer>
#include "sounddialog.h"
namespace Ui {
class TitleWidget;
}
class TitleWidget : public QWidget
{
Q_OBJECT
public:
explicit TitleWidget(QWidget *parent = nullptr);
~TitleWidget();
//设置当前用户
void setUser(const ST_PatientMsg&);
//设置wifi信号强度
void setSignalStrength(int value);
//设置标题
void setTitleByPage(E_PAGENAME);
//设置界面从属状态
/*****设置训练类型****
* 参数@int8_t type 0-单踏车 1-FES踏车
* *****/
void setTrainType(int8_t type);
void setBackBtnVisible(bool);
void slotSaveUpPicture();//保存上截图
protected:
virtual void changeEvent(QEvent* event);
signals:
void signalCloseWindow();
private slots:
void slotBackClicked();
void on_user_Btn_clicked();
void slotCheckTimer();
void on_quit_Btn_clicked();
void slotStateChanged(QString);
//void on_back1_Btn_clicked();
// void on_pushButton_clicked();
void on_sound_Button_clicked();
//void on_back2_Btn_clicked();
//void on_back1_Btn_clicked();
private:
void showWIFI();
private:
Ui::TitleWidget *ui;
int8_t m_trainType;
QTimer *checkTimer;
SoundDialog *m_soundDialog;
//
};
#endif // TITLEWIDGET_H

View File

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TitleWidget</class>
<widget class="QWidget" name="TitleWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="title_Label">
<property name="geometry">
<rect>
<x>570</x>
<y>0</y>
<width>621</width>
<height>101</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:white;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="signal_Label">
<property name="geometry">
<rect>
<x>1620</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/signal/titleSignal.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="user_Btn">
<property name="geometry">
<rect>
<x>1700</x>
<y>20</y>
<width>170</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">#user_Btn{background: #FFFFFF;
border-radius: 30px;
color:#05A6EC;}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="wifiSignal_Label">
<property name="geometry">
<rect>
<x>1500</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #05A6EC;border:none;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="back2_Btn">
<property name="geometry">
<rect>
<x>85</x>
<y>14</y>
<width>131</width>
<height>70</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:white;
border:2px;</string>
</property>
<property name="text">
<string>返回</string>
</property>
</widget>
<widget class="QPushButton" name="back1_Btn">
<property name="geometry">
<rect>
<x>37</x>
<y>24</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/signal/back.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="quit_Btn">
<property name="geometry">
<rect>
<x>60</x>
<y>20</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/quit.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="state_label">
<property name="geometry">
<rect>
<x>1400</x>
<y>70</y>
<width>301</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="wifiSignal2_Label">
<property name="geometry">
<rect>
<x>1430</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="sound_Button">
<property name="geometry">
<rect>
<x>1550</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/sound.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox</zorder>
<zorder>title_Label</zorder>
<zorder>signal_Label</zorder>
<zorder>user_Btn</zorder>
<zorder>wifiSignal_Label</zorder>
</widget>
<resources/>
<connections/>
</ui>