From 1579e3832280752fcd2225503baa86b98bb665c6 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Thu, 9 Feb 2023 18:40:47 -0500 Subject: [PATCH] polished the UI flow --- mainwindow.cpp | 40 +++++++++++++++++----------------------- mainwindow.h | 3 ++- scope.cpp | 1 - scope.h | 3 +++ 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 3747350..16435e3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -61,15 +61,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ bnOpenScope = new QPushButton("Open scope", this); bnOpenScope->setEnabled(false); - connect(bnOpenScope, &QPushButton::clicked, this, [=](){ - if( digi ){ - if( !scope ){ - scope = new Scope(digi, nDigi, readDataThread, this); - }else{ - scope->show(); - } - } - }); + connect(bnOpenScope, &QPushButton::clicked, this, &MainWindow::OpenScope); bnOpenDigitizers = new QPushButton("Open Digitizers", this); connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(OpenDigitizers())); @@ -85,7 +77,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ bnSOLSettings = new QPushButton("SOLARIS Settings", this); bnSOLSettings->setEnabled(false); - //QPushButton * newScope = new QPushButton("Scope2", this); + //QPushButton * bnCustomCommand = new QPushButton("Command line", this); layout1->addWidget(bnProgramSettings, 0, 0); @@ -97,7 +89,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ layout1->addWidget(bnOpenDigitizers, 1, 1); layout1->addWidget(bnCloseDigitizers, 1, 2, 1, 2); - //layout1->addWidget(newScope, 2, 0); layout1->addWidget(bnDigiSettings, 2, 1); layout1->addWidget(bnSOLSettings, 2, 2, 1, 2); @@ -107,7 +98,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ layout1->setColumnStretch(2, 1); layout1->setColumnStretch(3, 1); - } @@ -231,8 +221,6 @@ void MainWindow::StartACQ(){ bnStopACQ->setEnabled(true); bnOpenScope->setEnabled(false); - //updateTraceThread->start(); - LogMsg("end of " + QString::fromStdString(__func__)); } @@ -299,15 +287,6 @@ void MainWindow::OpenDigitizers(){ bnOpenDigitizers->setEnabled(false); bnOpenDigitizers->setStyleSheet(""); - ///// set scope digitizer - //allowChange = false; - //cbScopeDigi->clear(); ///this will also trigger QComboBox::currentIndexChanged - //cbScopeCh->clear(); - //for( int i = 0 ; i < nDigi; i++) { - // cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i); - //} - //allowChange = true; - } void MainWindow::CloseDigitizers(){ @@ -346,6 +325,21 @@ void MainWindow::CloseDigitizers(){ } //^###################################################################### Open Scope +void MainWindow::OpenScope(){ + + if( digi ){ + if( !scope ){ + scope = new Scope(digi, nDigi, readDataThread, this); + connect(scope, &Scope::CloseWindow, this, [=](){ + bnStartACQ->setEnabled(true); + }); + }else{ + scope->show(); + } + } + + bnStartACQ->setEnabled(false); +} //^###################################################################### Open digitizer setting panel void MainWindow::OpenDigitizersSettings(){ diff --git a/mainwindow.h b/mainwindow.h index 74383c9..eeb42f2 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -38,7 +38,8 @@ private slots: void OpenDigitizers(); void CloseDigitizers(); - + + void OpenScope(); void OpenDigitizersSettings(); void ProgramSettings(); diff --git a/scope.cpp b/scope.cpp index 51dc92e..402d93f 100644 --- a/scope.cpp +++ b/scope.cpp @@ -339,7 +339,6 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat QPushButton * bnClose = new QPushButton("Close", this); layout->addWidget(bnClose, rowID, 5); - connect(bnClose, &QPushButton::clicked, this, &Scope::StopScope); connect(bnClose, &QPushButton::clicked, this, &Scope::close); diff --git a/scope.h b/scope.h index 0f365c7..ae3ae4a 100644 --- a/scope.h +++ b/scope.h @@ -37,11 +37,14 @@ private slots: void closeEvent(QCloseEvent * event){ StopScope(); + emit CloseWindow(); event->accept(); } signals: + void CloseWindow(); + private: Digitizer2Gen ** digi;