2021-10-09 16:38:34 +08:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
#include <qtabwidget.h>
|
|
|
|
|
#include <QSizePolicy>
|
|
|
|
|
#include <QHBoxLayout>
|
2021-10-12 17:42:09 +08:00
|
|
|
#include <src/event/EventCenter.h>
|
2021-10-09 16:38:34 +08:00
|
|
|
#include "tabformwidget.h"
|
|
|
|
|
#include "SelectFormWidget.h"
|
|
|
|
|
#include "ScanFormWidget.h"
|
2021-10-13 17:40:21 +08:00
|
|
|
#include "guimessagedialog.h"
|
|
|
|
|
#include "device/DeviceManager.h"
|
2021-11-19 13:20:17 +08:00
|
|
|
#include "loginwindow.h"
|
|
|
|
|
#include <QTextEdit>
|
|
|
|
|
#include <QScrollBar>
|
2021-11-23 09:21:36 +08:00
|
|
|
#include "models/User.h"
|
|
|
|
|
#include "AdminSettingForm.h"
|
2021-11-26 10:48:08 +08:00
|
|
|
#include "appvals/AppGlobalValues.h"
|
2021-11-19 13:20:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::QMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
std::cout << msg.toStdString().c_str() << std::endl;
|
|
|
|
|
|
|
|
|
|
//QByteArray localMsg = msg.toLocal8Bit();
|
|
|
|
|
//switch (type) {
|
|
|
|
|
//case QtDebugMsg:
|
|
|
|
|
// fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
|
// break;
|
|
|
|
|
//case QtInfoMsg:
|
|
|
|
|
// fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
|
// break;
|
|
|
|
|
//case QtWarningMsg:
|
|
|
|
|
// fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
|
// break;
|
|
|
|
|
//case QtCriticalMsg:
|
|
|
|
|
// fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
|
// break;
|
|
|
|
|
//case QtFatalMsg:
|
|
|
|
|
// fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
|
// abort();
|
|
|
|
|
//}
|
|
|
|
|
}
|
2021-10-09 16:38:34 +08:00
|
|
|
|
2021-10-25 15:00:09 +08:00
|
|
|
MainWindow::MainWindow(QWidget* parent) :
|
|
|
|
|
QMainWindow(parent),
|
|
|
|
|
ui(new Ui::MainWindow)
|
2021-10-09 16:38:34 +08:00
|
|
|
{
|
2021-10-25 15:00:09 +08:00
|
|
|
const QString style = "*{background-color:#3c3c3c; color:white;margin:0;font-size:16px;}"
|
|
|
|
|
"QTabBar::tab {\n"
|
|
|
|
|
"height:60px;"
|
|
|
|
|
"width:300px;"
|
|
|
|
|
"font-size: 25px;"
|
|
|
|
|
"background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\"\n"
|
|
|
|
|
"stop: 0 #333333, stop: 1.0 #555555);"
|
|
|
|
|
"border: 2px solid #505050;\n"
|
|
|
|
|
"border-bottom-left-radius: 50%;\n"
|
|
|
|
|
"border-bottom-right-radius: 50%;\n"
|
|
|
|
|
"min-width: 8ex;\n"
|
|
|
|
|
"padding: 2px;\n"
|
|
|
|
|
"}"
|
|
|
|
|
"QTabBar::tab:selected, QTabBar::tab:hover {"
|
|
|
|
|
"border-top:5px solid #4a88c7;\n"
|
|
|
|
|
"background: #505050;}"
|
|
|
|
|
"QTabWidget::pane{margin:0}"
|
|
|
|
|
"QLineEdit{min-height:36px;max-height:36px; border:1px solid silver}"
|
|
|
|
|
"QLineEdit:enabled{background-color: #515151}"
|
|
|
|
|
"QDateEdit{min-height:36px;max-height:36px; border:1px solid silver}"
|
|
|
|
|
"QDateEdit:enabled{background-color: #515151}"
|
2021-11-19 13:20:17 +08:00
|
|
|
//"QTextEdit{background-attachment: scroll; }"
|
2021-10-25 15:00:09 +08:00
|
|
|
"QTextEdit:enabled{background-color: #515151}"
|
|
|
|
|
"QComboBox{text-align:center;min-height:36px;max-height:36px; border:1px solid silver}"
|
|
|
|
|
"QComboBox:enabled{background-color: #515151}"
|
|
|
|
|
"QComboBox::drop-down{width:20px}"
|
|
|
|
|
"QComboBox QAbstractItemView{min-width:120px;}"
|
|
|
|
|
"QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;}"
|
2021-11-19 13:20:17 +08:00
|
|
|
//"QScrollBar:vertical {min-width: 50px;}"
|
2021-10-25 15:00:09 +08:00
|
|
|
"QLabel{color:white; font-weight:bold; font-size:16px;}\n"
|
2021-11-26 10:48:08 +08:00
|
|
|
"QLabel#sliderPickerLabel{color:silver;padding:0;background:#505050;font-weight:normal;font-size:50px;}\n"
|
2021-10-25 15:00:09 +08:00
|
|
|
"QWidget#topbarWidget{min-height:36px;max-height:36px;}\n"
|
|
|
|
|
"QWidget#contentWidget{border-top:1px solid #515151;}\n"
|
|
|
|
|
"QWidget#commandWidget{min-height:123px;max-height:123px;border-top:1px solid #515151; border-bottom:1px solid #323232;}\n"
|
|
|
|
|
"QLabel#logo{min-width:30px;max-width:30px}\n"
|
|
|
|
|
"QLabel#company{min-width:150px;max-width:150px; }\n"
|
2021-11-12 14:32:22 +08:00
|
|
|
"QLabel#systemMsgBar{min-width:500px;}"
|
|
|
|
|
"QLabel#warn{color:#CCCC00;background:transparent;font-size:20px;}"
|
2021-10-25 15:00:09 +08:00
|
|
|
"QWidget QWidget#statusBarWidget{min-width:300px;}\n"
|
|
|
|
|
"QWidget QToolButton{border:none;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}\n"
|
|
|
|
|
"QToolButton#btn_main{border:2px solid #0078d8;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}\n"
|
|
|
|
|
"QWidget QToolButton:disabled{color:#606060 }\n"
|
|
|
|
|
"QWidget QToolButton:hover{background:#505050;}\n"
|
|
|
|
|
"QWidget QToolButton:checked{border:5px solid darkorange;padding:0px;}"
|
|
|
|
|
"QWidget#editcmdWidget{min-height:83px;max-height:83px;}"
|
|
|
|
|
"QWidget#verSpaceLine{ border-right:1px solid #0078d8;}"
|
2021-11-26 10:48:08 +08:00
|
|
|
"QWidget#topBottomLine{ border-top:2px solid #0078d8;border-bottom:2px solid #0078d8;background:transparent}"
|
2021-10-25 15:00:09 +08:00
|
|
|
//蒙版Dialog
|
|
|
|
|
"QDialog QWidget#innerWidget{ background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
|
|
|
|
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);"
|
|
|
|
|
"border-radius:20px;border:5px solid #0078d8; }"
|
2021-11-11 14:12:00 +08:00
|
|
|
"QDialog#MessageDialog QWidget QWidget{ background:transparent;color:#3078d8}"
|
|
|
|
|
"QDialog#MessageDialog QWidget QWidget QLabel{ font-size:30px}"
|
|
|
|
|
"#spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;}"
|
|
|
|
|
//FormDialog
|
|
|
|
|
"QPushButton{border:1px solid silver ;padding-left:50px;padding-right:50px; border-radius:5px; min-height:28px; max-height:28px; background:#4c5052}"
|
|
|
|
|
"QPushButton#btnOK{background:#365880; font-weight:bold}"
|
|
|
|
|
"QDialog#formDialog{border:3px solid silver; border-radius:8px}"
|
2021-11-26 10:48:08 +08:00
|
|
|
"QWidget#slider_one{border:1px solid silver; border-radius:8px}"
|
2021-11-11 14:12:00 +08:00
|
|
|
"QWidget#formWidget QLabel#endline{border-bottom:1px solid silver}"
|
|
|
|
|
"QWidget#formWidget QLabel#title{font-size:30px; }"
|
2021-11-23 09:21:36 +08:00
|
|
|
"QListView{border:none;margin:5px; font-weight:bold}"
|
|
|
|
|
"QListView::item{background:#4c5052;min-height:30px; border:1px solid silver; border-radius:5px}"
|
|
|
|
|
"QListView::item:selected{background:#365880; font-weight:bold;color:white}"
|
2021-11-26 10:48:08 +08:00
|
|
|
"QHeaderView::section{background-color:#595959;"
|
|
|
|
|
"min-height:50px;max-height:50px;"
|
|
|
|
|
"font-weight:Bold; font-size:16px; border:1px solid #323232;}"
|
|
|
|
|
"QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);}"
|
|
|
|
|
"QHeaderView::section:vertical{min-height:36px;max-height:36px;}"
|
|
|
|
|
"QWidget#edit_patient{min-width:300px;max-width:300px;}"
|
|
|
|
|
"QTableView{border:none}"
|
|
|
|
|
"QTableView{alternate-background-color: #595959;selection-color:white;selection-background-color:#0078d8}"
|
|
|
|
|
"QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;}"
|
|
|
|
|
"QToolButton#sexBtn:disabled{color:silver}"
|
|
|
|
|
"QWidget#sexpanelwidget{border:1px solid silver;}"
|
|
|
|
|
"QWidget#sexpanelwidget:enabled{background-color: #515151;}"
|
|
|
|
|
"QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;}"
|
2021-10-25 15:00:09 +08:00
|
|
|
;
|
|
|
|
|
this->setStyleSheet(style);
|
|
|
|
|
ui->setupUi(this);
|
2021-11-23 09:21:36 +08:00
|
|
|
tab = new QTabWidget(this);
|
2021-10-25 15:00:09 +08:00
|
|
|
tab->setTabPosition(QTabWidget::South);
|
|
|
|
|
tab->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
connect(EventCenter::Default(), &EventCenter::PatientSelected, [=](QObject* sender, QObject* data) {
|
|
|
|
|
tab->setCurrentIndex(1);
|
|
|
|
|
});
|
|
|
|
|
SelectFormWidget* select_form = new SelectFormWidget(this);
|
|
|
|
|
tab->addTab(select_form, "Select");
|
|
|
|
|
ScanFormWidget* scan_form = new ScanFormWidget(this);
|
|
|
|
|
tab->addTab(scan_form, "Scan");
|
|
|
|
|
TabFormWidget* verify_form = new TabFormWidget(this);
|
|
|
|
|
tab->addTab(verify_form, "Verify");
|
|
|
|
|
tab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
QHBoxLayout* layout = new QHBoxLayout();
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->addWidget(tab);
|
2021-11-19 13:20:17 +08:00
|
|
|
|
2021-10-25 15:00:09 +08:00
|
|
|
ui->centralWidget->setLayout(layout);
|
|
|
|
|
this->setWindowFlags(Qt::Window);
|
|
|
|
|
connect(EventCenter::Default(), &EventCenter::GUIErrorRaise, [=](QObject*, QObject* msg) {
|
2021-12-03 14:22:50 +08:00
|
|
|
QString str;
|
|
|
|
|
if (msg) {
|
|
|
|
|
str = *(QString *) msg;
|
|
|
|
|
} else {
|
|
|
|
|
str = "Something went error!";
|
|
|
|
|
}
|
|
|
|
|
if (str.isEmpty()) return;
|
|
|
|
|
//新模式,分级
|
|
|
|
|
if (str[1] == ' ') {
|
|
|
|
|
char c = str[0].toLower().toLatin1();
|
|
|
|
|
switch (c) {
|
|
|
|
|
//WARN 级别
|
|
|
|
|
case 'w': {
|
|
|
|
|
char buff[4] = {0, 0, 0, 0};
|
|
|
|
|
buff[0] = str[2].toLatin1();
|
|
|
|
|
buff[1] = str[3].toLatin1();
|
|
|
|
|
buff[2] = str[4].toLatin1();
|
|
|
|
|
buff[3] = str[5].toLatin1();
|
|
|
|
|
QByteArray bytes(buff);
|
|
|
|
|
EventCenter::Default()->triggerEvent(GUIEvents::WarnStateFlagChange, nullptr,(QObject*)(&bytes));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//ERROR 级别
|
|
|
|
|
case 'e':
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//默认旧模式
|
|
|
|
|
if (!msgDialog) {
|
2021-11-02 10:31:04 +08:00
|
|
|
msgDialog = new GUIMessageDialog;
|
|
|
|
|
msgDialog->setStyleSheet(style);
|
|
|
|
|
}
|
2021-12-03 14:22:50 +08:00
|
|
|
if (msg) {
|
|
|
|
|
QString *str = (QString *) msg;
|
|
|
|
|
msgDialog->showMessage(*str);
|
|
|
|
|
} else {
|
|
|
|
|
msgDialog->showMessage("Something went error!");
|
|
|
|
|
}
|
|
|
|
|
msgDialog->stopLoading();
|
2021-10-27 16:03:10 +08:00
|
|
|
msgDialog->showExitButton();
|
2021-10-27 10:39:34 +08:00
|
|
|
// msgDialog->showFullScreen();
|
2021-10-27 16:03:10 +08:00
|
|
|
if (msgDialog->isHidden())msgDialog->show();
|
2021-12-03 14:22:50 +08:00
|
|
|
});
|
2021-10-25 15:00:09 +08:00
|
|
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationStart, [=](QObject*, QObject* msg) {
|
2021-10-27 16:03:10 +08:00
|
|
|
if (msgDialog){
|
|
|
|
|
msgDialog->hide();
|
|
|
|
|
delete msgDialog;
|
|
|
|
|
}
|
|
|
|
|
msgDialog = new GUIMessageDialog(this);
|
2021-10-25 15:00:09 +08:00
|
|
|
if (msg)
|
|
|
|
|
{
|
|
|
|
|
QString* str = (QString*)msg;
|
|
|
|
|
msgDialog->showMessage(*str);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
msgDialog->hideMessage();
|
|
|
|
|
}
|
|
|
|
|
msgDialog->hideExitButton();
|
|
|
|
|
msgDialog->startLoading();
|
2021-10-27 10:39:34 +08:00
|
|
|
// msgDialog->showFullScreen();
|
2021-10-27 16:03:10 +08:00
|
|
|
if (msgDialog->isHidden())msgDialog->show();
|
2021-10-25 15:00:09 +08:00
|
|
|
});
|
|
|
|
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress, [=](QObject*, QObject* msg) {
|
|
|
|
|
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
|
|
|
|
if (msg)
|
|
|
|
|
{
|
|
|
|
|
QVariant* var = (QVariant*)msg;
|
|
|
|
|
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat() * 100.0f)));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
msgDialog->hideMessage();
|
|
|
|
|
}
|
2021-10-27 10:39:34 +08:00
|
|
|
// msgDialog->showFullScreen();
|
2021-10-27 16:03:10 +08:00
|
|
|
if (msgDialog->isHidden())msgDialog->show();
|
2021-10-25 15:00:09 +08:00
|
|
|
});
|
|
|
|
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
|
|
|
|
|
if (!msgDialog) return;
|
2021-10-27 16:03:10 +08:00
|
|
|
if (!msgDialog->isHidden())msgDialog->accept();
|
|
|
|
|
delete msgDialog;
|
|
|
|
|
msgDialog = nullptr;
|
2021-10-25 15:00:09 +08:00
|
|
|
});
|
2021-11-19 13:20:17 +08:00
|
|
|
connect(EventCenter::Default(), &EventCenter::RequestLogin, [=](QObject*, QObject* msg) {
|
|
|
|
|
this->requestLogin();
|
|
|
|
|
});
|
2021-11-23 09:21:36 +08:00
|
|
|
DeviceManager::Default()->initDevice();
|
2021-10-25 15:00:09 +08:00
|
|
|
centerWidgetHide();
|
2021-11-26 10:48:08 +08:00
|
|
|
screenTimer = new QTimer(this);
|
|
|
|
|
connect(screenTimer, SIGNAL(timeout()), this, SLOT(coverScreen()));
|
|
|
|
|
screenTimer->start(counter);
|
2021-10-09 16:38:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
2021-10-25 15:00:09 +08:00
|
|
|
delete ui;
|
2021-11-19 13:20:17 +08:00
|
|
|
delete redir;
|
2021-10-09 16:38:34 +08:00
|
|
|
}
|
2021-10-21 14:18:26 +08:00
|
|
|
|
2021-11-26 10:48:08 +08:00
|
|
|
void MainWindow::coverScreen()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (AppGlobalValues::InProcessing().toBool()) {
|
|
|
|
|
refreshTimer();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
screenTimer->stop();
|
|
|
|
|
requestLogin();
|
|
|
|
|
qDebug() << "coverScreen()";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshTimer()
|
|
|
|
|
{
|
|
|
|
|
screenTimer->stop();
|
|
|
|
|
screenTimer->start(counter);
|
|
|
|
|
}
|
2021-10-21 14:18:26 +08:00
|
|
|
void MainWindow::centerWidgetHide() {
|
2021-11-19 13:20:17 +08:00
|
|
|
ui->centralWidget->setVisible(false);
|
2021-10-21 14:18:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::centerWidgetShow() {
|
2021-11-23 09:21:36 +08:00
|
|
|
if (User::Current()->isAdmin() )
|
|
|
|
|
{
|
|
|
|
|
if (admin_tab_index == -1)
|
|
|
|
|
{
|
|
|
|
|
AdminSettingForm * form = new AdminSettingForm(this);
|
|
|
|
|
admin_tab_index = tab->addTab(form,"Admin");
|
|
|
|
|
}
|
|
|
|
|
} else{
|
|
|
|
|
if (admin_tab_index != -1){
|
|
|
|
|
tab->removeTab(admin_tab_index);
|
|
|
|
|
admin_tab_index = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-19 13:20:17 +08:00
|
|
|
qApp->processEvents();
|
|
|
|
|
ui->centralWidget->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTextEdit* MainWindow::getEdit()
|
|
|
|
|
{
|
|
|
|
|
return this->console;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::requestLogin() {
|
|
|
|
|
LoginWindow l(this);
|
2021-11-26 10:48:08 +08:00
|
|
|
l.setWindowModality(Qt::WindowModal);
|
2021-11-19 13:20:17 +08:00
|
|
|
l.showFullScreen();
|
|
|
|
|
this->centerWidgetHide();
|
|
|
|
|
while(l.result() != QDialog::Accepted)
|
|
|
|
|
{
|
|
|
|
|
l.exec();
|
|
|
|
|
}
|
|
|
|
|
this->centerWidgetShow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::debugConsoleOn() {
|
|
|
|
|
QTextEdit* text_edit = new QTextEdit(this);
|
|
|
|
|
ui->centralWidget->layout()->addWidget(text_edit);
|
|
|
|
|
const QString edit_style =
|
|
|
|
|
"QScrollBar:vertical{border: 0px solid grey; background:#2d2d2d; width: 15px; margin: 0px 0 0px 0; }"
|
|
|
|
|
"QScrollBar::handle:vertical{background:#5a5a5a;min-height: 25px;}"
|
|
|
|
|
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical{background:#2d2d2d;}";
|
|
|
|
|
text_edit->verticalScrollBar()->setStyleSheet(edit_style);
|
|
|
|
|
//clear buffer before redirect;
|
|
|
|
|
this->console = text_edit;
|
2021-10-21 14:18:26 +08:00
|
|
|
}
|