164 lines
5.0 KiB
C++
164 lines
5.0 KiB
C++
|
#include "mainwidget.h"
|
|||
|
#include <QVBoxLayout>
|
|||
|
#include <QtDebug>
|
|||
|
#include <QMenu>
|
|||
|
#include <QTimer>
|
|||
|
#include <QDateTime>
|
|||
|
#include <QMessageBox>
|
|||
|
#include <QApplication>
|
|||
|
#include "headwidget.h"
|
|||
|
#include "frmLogin.h"
|
|||
|
#include "frmPermis.h"
|
|||
|
#include "frmAbout.h"
|
|||
|
|
|||
|
MainWidget::MainWidget(QWidget *parent) : QWidget(parent)
|
|||
|
{
|
|||
|
this->resize(1360, 768);
|
|||
|
this->setWindowFlags(this->windowFlags() |
|
|||
|
Qt::FramelessWindowHint |
|
|||
|
Qt::WindowSystemMenuHint);
|
|||
|
m_pHeadWidget = new HeadWidget(this);
|
|||
|
m_pHeadWidget->setFixedHeight(36);
|
|||
|
dataVar::m_pWindow = new MainWindow(this);
|
|||
|
dataVar::m_pWindow->setVisible(true);
|
|||
|
auto *vlay = new QVBoxLayout(this);
|
|||
|
vlay->setSpacing(0);
|
|||
|
vlay->setContentsMargins(0,0,0,0);
|
|||
|
vlay->addWidget(m_pHeadWidget);
|
|||
|
vlay->addWidget(dataVar::m_pWindow, 1);
|
|||
|
connect(dataVar::fProItemTab, &frmProItemTab::sig_AllCycleStop, dataVar::m_pWindow, &MainWindow::slot_AllCycleStop);
|
|||
|
connect(this, &MainWidget::sig_Quit, m_pHeadWidget, &HeadWidget::shot_Quit);
|
|||
|
connect(m_pHeadWidget, &HeadWidget::sigColor, this, &MainWidget::doColorMenu);
|
|||
|
connect(m_pHeadWidget, &HeadWidget::sigMinimized, this, &MainWidget::showMinimized);
|
|||
|
connect(m_pHeadWidget, &HeadWidget::sigClose, this, &MainWidget::doClose, Qt::DirectConnection);
|
|||
|
connect(m_pHeadWidget, &HeadWidget::sigToggleMaximized, this, &MainWidget::doToggleMaximized);
|
|||
|
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
connect(dataVar::m_pWindow, &MainWindow::sig_LoginSignal, this, &MainWidget::slot_Login);
|
|||
|
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
connect(dataVar::m_pWindow, &MainWindow::sig_PermisSet, this, &MainWidget::slot_Permis);
|
|||
|
//<2F><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
connect(dataVar::m_pWindow, &MainWindow::sig_AboutSignal, this, &MainWidget::slot_About);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::doClose()
|
|||
|
{
|
|||
|
QMessageBox *msgBox = new QMessageBox(this);
|
|||
|
msgBox->setIcon(QMessageBox::Question);
|
|||
|
msgBox->setWindowTitle("<EFBFBD><EFBFBD>ʾ!");
|
|||
|
msgBox->setText("~~<7E><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD>뿪ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?~~");
|
|||
|
QPushButton *btn_sure = msgBox->addButton("ȷ<EFBFBD><EFBFBD>", QMessageBox::ButtonRole::YesRole);
|
|||
|
QPushButton *bun_cancel = msgBox->addButton("ȡ<EFBFBD><EFBFBD>", QMessageBox::ButtonRole::NoRole);
|
|||
|
btn_sure->setStyleSheet("QPushButton{background-color:rgb(125,125,125);border:5px solid gray;font-size:15px;color:white;}");
|
|||
|
bun_cancel->setStyleSheet("QPushButton{background-color:rgb(125,125,125);border:5px solid gray;font-size:15px;color:white;}");
|
|||
|
msgBox->setStyleSheet("color:black;font-size:16px;");
|
|||
|
if (msgBox->exec())
|
|||
|
{
|
|||
|
msgBox->deleteLater();
|
|||
|
btn_sure->deleteLater();
|
|||
|
bun_cancel->deleteLater();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_pHeadWidget->close();
|
|||
|
m_pHeadWidget->deleteLater();
|
|||
|
dataVar::m_pWindow->close();
|
|||
|
this->close();
|
|||
|
emit sig_Quit();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setLogo(const QString &imgFile, const QString &name)
|
|||
|
{
|
|||
|
m_pHeadWidget->setLogo(imgFile, name);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setTitle(const QString &info)
|
|||
|
{
|
|||
|
m_pHeadWidget->setTitle(info);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setEnabelHeadMove(bool can_move)
|
|||
|
{
|
|||
|
m_pHeadWidget->setEnabelMove(can_move);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setToolDockWidget(QWidget *w)
|
|||
|
{
|
|||
|
dataVar::m_pWindow->setToolDockWidget(w);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setFlowDockWidget(QWidget *w)
|
|||
|
{
|
|||
|
dataVar::m_pWindow->setFlowDockWidget(w);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setLogDockWidget(QWidget *w)
|
|||
|
{
|
|||
|
dataVar::m_pWindow->setLogDockWidget(w);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setStatusInfo(const QString &info)
|
|||
|
{
|
|||
|
dataVar::m_pWindow->setStatusInfo(info);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::setCenterWidget(QWidget *w)
|
|||
|
{
|
|||
|
dataVar::m_pWindow->setCenterWidget(w);
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::doToggleMaximized()
|
|||
|
{
|
|||
|
if(this->isMaximized())
|
|||
|
this->showNormal();
|
|||
|
else
|
|||
|
this->showMaximized();
|
|||
|
}
|
|||
|
|
|||
|
void MainWidget::doColorMenu(const QPoint &pos)
|
|||
|
{
|
|||
|
if(!m_pColorMenu)
|
|||
|
{
|
|||
|
m_pColorMenu = new QMenu(this);
|
|||
|
QAction* greenAc = m_pColorMenu->addAction("<EFBFBD><EFBFBD>ɫ");
|
|||
|
QAction *blueAc = m_pColorMenu->addAction("<EFBFBD><EFBFBD>ɫ");
|
|||
|
QAction *redAc = m_pColorMenu->addAction("<EFBFBD><EFBFBD>ɫ");
|
|||
|
greenAc->setData("rgb(33,115,70)");
|
|||
|
blueAc->setData("rgb(43, 87, 154)");
|
|||
|
redAc->setData("rgb(183, 71, 42)");
|
|||
|
greenAc->setCheckable(true);
|
|||
|
greenAc->setChecked(true);
|
|||
|
blueAc->setCheckable(true);
|
|||
|
redAc->setCheckable(true);
|
|||
|
QActionGroup *pGroup = new QActionGroup(this);
|
|||
|
pGroup->setExclusive(true);
|
|||
|
pGroup->addAction(greenAc);
|
|||
|
pGroup->addAction(blueAc);
|
|||
|
pGroup->addAction(redAc);
|
|||
|
connect(pGroup, &QActionGroup::triggered, this, [this](QAction *ac){
|
|||
|
m_pHeadWidget->setBgColor(ac->data().toString());});
|
|||
|
}
|
|||
|
m_pColorMenu->exec(pos);
|
|||
|
}
|
|||
|
|
|||
|
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
|||
|
void MainWidget::slot_Login()
|
|||
|
{
|
|||
|
frmLogin *fLogin = new frmLogin(this);
|
|||
|
fLogin->exec();
|
|||
|
}
|
|||
|
|
|||
|
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void MainWidget::slot_Permis()
|
|||
|
{
|
|||
|
frmPermis* fPermis = new frmPermis(this);
|
|||
|
fPermis->exec();
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD>
|
|||
|
void MainWidget::slot_About()
|
|||
|
{
|
|||
|
frmAbout *fAbout = new frmAbout(this);
|
|||
|
fAbout->exec();
|
|||
|
}
|