separated start gui button into start and stop to prevent multiple click syndrome

This commit is contained in:
maliakal_d 2018-03-27 17:49:01 +02:00
parent fe2ba8621b
commit 252e924f92
8 changed files with 153 additions and 125 deletions

View File

@ -133,44 +133,6 @@
</property>
</widget>
</widget>
<widget class="QPushButton" name="btnStartStop">
<property name="geometry">
<rect>
<x>30</x>
<y>289</y>
<width>319</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Starts or Stops Acquisition</string>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/start.png</normaloff>:/icons/images/start.png</iconset>
</property>
<property name="shortcut">
<string>Shift+Space</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QFrame" name="frameTimeResolved">
<property name="geometry">
<rect>
@ -999,6 +961,107 @@ Frame period between exposures.
</layout>
</widget>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>297</y>
<width>318</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnStart">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Starts Acquisition</string>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/start.png</normaloff>:/icons/images/start.png</iconset>
</property>
<property name="shortcut">
<string>Shift+Space</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnStop">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Stops Acquisition</string>
</property>
<property name="text">
<string>Stop</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/stop.png</normaloff>:/icons/images/stop.png</iconset>
</property>
<property name="shortcut">
<string>Shift+Space</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>spinNumMeasurements</tabstop>

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorGui
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: b8bdbf4da61f95b88893b02ddabc2491b16fa10f
Revision: 492
Repsitory UUID: fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41
Revision: 493
Branch: developer
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3746
Last Changed Date: 2018-03-26 17:27:44.000000002 +0200 ./src/qTabSettings.cpp
Last Changed Rev: 3747
Last Changed Date: 2018-03-27 17:30:53.000000002 +0200 ./include/qTabMeasurement.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "b8bdbf4da61f95b88893b02ddabc2491b16fa10f"
#define GITREPUUID "fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3746
#define GITDATE 0x20180326
#define GITREV 0x3747
#define GITDATE 0x20180327
#define GITBRANCH "developer"

View File

@ -617,7 +617,6 @@ void saveErrorSignal(QString);
void AcquisitionErrorSignal(QString);
void UpdatePlotSignal();
void GainPlotSignal(bool);
void AcquisitionFinishedSignal();
};

View File

@ -50,14 +50,14 @@ public:
*/
void SetExpertMode(bool enable);
/** Returns the status of the Start/Stop Acquisition button
/** Returns the status of the acquisition in gui
*/
bool GetStartStatus(){return btnStartStop->isChecked();};
bool GetStartStatus(){return (!btnStart->isEnabled());};
/** Click the Start/Stop Acquisition button
* This is used if this command came from gui client
*/
void ClickStartStop(){btnStartStop->click();myPlot->SetClientInitiated();};
void ClickStartStop(){startAcquisition();myPlot->SetClientInitiated();};
/** Returns progress bar value */
int GetProgress(){return progressBar->value();};
@ -65,10 +65,6 @@ public:
public slots:
/** Unconnects start/stop button when acquisition is finished
*/
void AcquisitionFinished();
/** update plot is finished,
* changes start/stop text and enables/disables all widgets
*/
@ -131,9 +127,13 @@ private slots:
*/
void setRunIndex(int index);
/** starts/stops Acquisition
/** starts Acquisition
*/
void startStopAcquisition();
void startAcquisition();
/** stops Acquisition
*/
void stopAcquisition();
/** Set number of frames
* @param val number of frames to be set
@ -193,8 +193,6 @@ private:
QPalette red;
/** expert mode */
bool expertMode;
QIcon *iconStart;
QIcon *iconStop;
/** to access items in settings combobox */
QStandardItemModel* model;

View File

@ -336,7 +336,6 @@ void qDetectorMain::Initialization(){
// Plotting
// When the acquisition is finished, must update the meas tab
connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs()));
connect(myPlot, SIGNAL(AcquisitionFinishedSignal()), tab_measurement, SLOT(AcquisitionFinished()));
connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished()));
//This should not be called as it will change file name to measurement when run finished
//connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh()));

View File

@ -1296,7 +1296,6 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
#ifdef VERBOSE
cout << "\nEntering Acquisition Finished with status " ;
#endif
emit AcquisitionFinishedSignal();
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
#ifdef VERBOSE
cout << status.toAscii().constData() << " and progress " << currentProgress << endl;

View File

@ -94,12 +94,6 @@ void qTabMeasurement::SetupWidgetWindow(){
chkFile->setChecked(myDet->enableWriteToFile());
dispFileName->setEnabled(myDet->enableWriteToFile());
//creating the icons for the buttons
iconStart = new QIcon(":/icons/images/start.png");
iconStop = new QIcon(":/icons/images/stop.png");
//Timer to update the progress bar
progressTimer = new QTimer(this);
@ -267,8 +261,10 @@ void qTabMeasurement::Initialization(){
connect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName()));
//File Index
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
//Start/Stop Acquisition
connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition()));
//Start Acquisition
connect(btnStart, SIGNAL(clicked()), this, SLOT(startAcquisition()));
//Stop Acquisition
connect(btnStop, SIGNAL(clicked()), this, SLOT(stopAcquisition()));
//Timing Mode
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));//
//progress bar
@ -309,24 +305,21 @@ void qTabMeasurement::Enable(bool enable){
frameNotTimeResolved->setEnabled(enable);
//shortcut each time, else it doesnt work a second time
btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8));
btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::startStopAcquisition(){
if(btnStartStop->isChecked()){
void qTabMeasurement::startAcquisition(){
btnStart->setEnabled(false);
//if file write enabled and output dir doesnt exist
if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){
if(qDefs::Message(qDefs::QUESTION,
"<nobr>Your data will not be saved.</nobr><br><nobr>Disable File write and Proceed with acquisition anyway?</nobr>",
"qTabMeasurement::startStopAcquisition") == slsDetectorDefs::FAIL){
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStartStop->click();
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
"qTabMeasurement::startAcquisition") == slsDetectorDefs::FAIL){
btnStart->setEnabled(true);
return;
}else{
//done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui
@ -340,44 +333,25 @@ void qTabMeasurement::startStopAcquisition(){
#ifdef VERBOSE
cout << endl << endl << "Starting Acquisition" << endl;
#endif
//btnStartStop->setStyleSheet("color:red");
btnStartStop->setText("Stop");
btnStartStop->setIcon(*iconStop);
lblProgressIndex->setText(QString::number(0));
Enable(0);
progressBar->setValue(0);
progressTimer->start(100);
emit StartSignal();
}else{
#ifdef VERBOSE
cout << "Stopping Acquisition" << endl<< endl;
#endif
//emit StopSignal(); commented out to prevent undefined state
myDet->stopAcquisition();
/* commented out to prevent undefined state
myDet->waitForReceiverReadToFinish();
UpdateProgress();
//spin index
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
spinIndex->setValue(myDet->getFileIndex());
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
progressTimer->stop();
btnStartStop->setText("Start");
btnStartStop->setIcon(*iconStart);
btnStartStop->setChecked(false);
Enable(1);*/
}
qDefs::checkErrorMessage(myDet,"qTabMeasurement::startStopAcquisition");
qDefs::checkErrorMessage(myDet,"qTabMeasurement::startAcquisition");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::AcquisitionFinished(){
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStartStop->setText("Wait");
void qTabMeasurement::stopAcquisition(){
#ifdef VERBOSE
cout << "Stopping Acquisition" << endl<< endl;
#endif
myDet->stopAcquisition();
qDefs::checkErrorMessage(myDet,"qTabMeasurement::stopAcquisition");
}
@ -391,12 +365,8 @@ void qTabMeasurement::UpdateFinished(){
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
progressTimer->stop();
/*disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); done in AcquisitionFinished() already */
btnStartStop->setText("Start");
btnStartStop->setIcon(*iconStart);
btnStartStop->setChecked(false);
Enable(1);
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStart->setEnabled(true);
qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateFinished");
}