diff --git a/app/gui/oven_control/engineermenuwindow.cpp b/app/gui/oven_control/engineermenuwindow.cpp index 5c11de0..f4a5bcc 100644 --- a/app/gui/oven_control/engineermenuwindow.cpp +++ b/app/gui/oven_control/engineermenuwindow.cpp @@ -25,6 +25,8 @@ EngineerMenuWindow::EngineerMenuWindow(QWidget *parent) : ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); + child = Q_NULLPTR; + connect(ui->backButton, SIGNAL(clicked()), this, SLOT(close())); foreach (QPushButton *button, findChildren()) @@ -40,6 +42,12 @@ EngineerMenuWindow::~EngineerMenuWindow() delete ui; } +void EngineerMenuWindow::killChild() +{ + if (child) + child->deleteLater(); +} + void EngineerMenuWindow::keyPressEvent(QKeyEvent *event) { switch (event->key()) @@ -75,11 +83,19 @@ void EngineerMenuWindow::keyReleaseEvent(QKeyEvent *event) } } +void EngineerMenuWindow::onChildDestroyed(QObject *destroyed) +{ + if (destroyed == child) + child = NULL; +} + void EngineerMenuWindow::on_serviceHistoryButton_clicked() { ServiceHistoryMain *w = new ServiceHistoryMain(this); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); + + newChild(w); } void EngineerMenuWindow::on_operationTimeButton_clicked() @@ -87,6 +103,8 @@ void EngineerMenuWindow::on_operationTimeButton_clicked() OperationTimeMain *w = new OperationTimeMain(this); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); + + newChild(w); } void EngineerMenuWindow::on_realDataButton_clicked() @@ -94,6 +112,8 @@ void EngineerMenuWindow::on_realDataButton_clicked() RealtimeMain* w = new RealtimeMain(this); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); + + newChild(w); } void EngineerMenuWindow::on_functionTestButton_clicked() @@ -102,6 +122,8 @@ void EngineerMenuWindow::on_functionTestButton_clicked() w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); + + newChild(w); } void EngineerMenuWindow::on_engAdjustButton_clicked() @@ -111,21 +133,22 @@ void EngineerMenuWindow::on_engAdjustButton_clicked() w->showFullScreen(); w->raise(); + newChild(w); } void EngineerMenuWindow::on_stdConfigButton_clicked() { QDialog* dlg; QString usbPath=""; - if(!FileProcessor::detectUSB(usbPath)){ + if(FileProcessor::detectUSB(usbPath)) + dlg = new FileProcessDlg(this, Define::config_standard_info_upload, false); + else dlg = new UsbCheckPopupDlg(this); - dlg->exec(); - } - if(FileProcessor::detectUSB(usbPath)){ - qDebug() << "standard upload exe"; - dlg = new FileProcessDlg(this,Define::config_standard_info_upload, false); - dlg->exec(); - } + + dlg->showFullScreen(); + dlg->raise(); + + newChild(dlg); } void EngineerMenuWindow::on_modelTypeConfigButton_clicked() @@ -134,6 +157,14 @@ void EngineerMenuWindow::on_modelTypeConfigButton_clicked() w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); + + newChild(w); +} + +void EngineerMenuWindow::newChild(QWidget *w) +{ + child = w; + connect(w, SIGNAL(destroyed(QObject*)), SLOT(onChildDestroyed(QObject*))); } void EngineerMenuWindow::onEncoderLeft() diff --git a/app/gui/oven_control/engineermenuwindow.h b/app/gui/oven_control/engineermenuwindow.h index 88cbdb0..2156822 100644 --- a/app/gui/oven_control/engineermenuwindow.h +++ b/app/gui/oven_control/engineermenuwindow.h @@ -16,28 +16,30 @@ public: explicit EngineerMenuWindow(QWidget *parent = 0); ~EngineerMenuWindow(); + void killChild(); + protected: void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); private slots: - void on_serviceHistoryButton_clicked(); + void onChildDestroyed(QObject *destroyed); + void on_serviceHistoryButton_clicked(); void on_operationTimeButton_clicked(); - void on_realDataButton_clicked(); - void on_functionTestButton_clicked(); - void on_engAdjustButton_clicked(); - void on_stdConfigButton_clicked(); - void on_modelTypeConfigButton_clicked(); private: Ui::EngineerMenuWindow *ui; + QWidget *child; + + void newChild(QWidget *w); + QWidget *pushed = NULL; void onEncoderLeft(); diff --git a/app/gui/oven_control/mainwindow.cpp b/app/gui/oven_control/mainwindow.cpp index 9e618ce..25af5ea 100644 --- a/app/gui/oven_control/mainwindow.cpp +++ b/app/gui/oven_control/mainwindow.cpp @@ -67,7 +67,6 @@ void MainWindow::killChild() bool MainWindow::killChildCook() { - if (instance->child && !instance->child->inherits("ConfigWindow")) { qDebug() << "kill child"; @@ -75,7 +74,13 @@ bool MainWindow::killChildCook() instance->child->deleteLater(); return true; } - else return false; + else + return false; +} + +EngineerMenuWindow *MainWindow::getEngineerMenuWindow() +{ + return instance->findChild(); } void MainWindow::keyPressEvent(QKeyEvent *event) diff --git a/app/gui/oven_control/mainwindow.h b/app/gui/oven_control/mainwindow.h index 2f0d407..bff3a5c 100644 --- a/app/gui/oven_control/mainwindow.h +++ b/app/gui/oven_control/mainwindow.h @@ -4,6 +4,7 @@ #include #include "define.h" +#include "engineermenuwindow.h" namespace Ui { class MainWindow; @@ -23,6 +24,7 @@ public: static void jump(QMainWindow *newChild); static void killChild(); static bool killChildCook(); + static EngineerMenuWindow *getEngineerMenuWindow(); protected: void keyPressEvent(QKeyEvent *event);