From f6183c9a606aefcfd86c30a85f4be4eb84caed4a Mon Sep 17 00:00:00 2001 From: MuldeR Date: Thu, 16 Jan 2014 22:35:28 +0100 Subject: [PATCH] Prevent adding files while there are pop-up windows open. --- src/MainWindow.cpp | 17 +++++++++++++++-- src/MainWindow.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c3406a7..c2e6834 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -213,6 +213,7 @@ void CMainWindow::closeEvent(QCloseEvent *event) { if(!APPLICATION_IS_IDLE) { + qWarning("Cannot exit program at this time!"); event->ignore(); } } @@ -364,6 +365,8 @@ void CMainWindow::analyzeNextFile(void) return; } + m_status = APP_STATUS_WORKING; + //Lookup MediaInfo path const QString mediaInfoPath = getMediaInfoPath(); if(mediaInfoPath.isEmpty()) @@ -412,11 +415,14 @@ void CMainWindow::analyzeButtonClicked(void) { if(!APPLICATION_IS_IDLE) { - qWarning("Cannot process files at this time!\n"); + qWarning("Cannot open files at this time!\n"); return; } + m_status = APP_STATUS_BLOCKED; const QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Select file to analyze..."), QString(), tr("All supported media files (*.*)")); + m_status = APP_STATUS_IDLE; + if(!selectedFiles.isEmpty()) { m_pendingFiles.clear(); @@ -434,7 +440,10 @@ void CMainWindow::saveButtonClicked(void) return; } + m_status = APP_STATUS_BLOCKED; const QString selectedFile = QFileDialog::getSaveFileName(this, tr("Select file to save..."), QString(), tr("Plain Text (*.txt)")); + m_status = APP_STATUS_IDLE; + if(!selectedFile.isEmpty()) { QFile file(selectedFile); @@ -604,7 +613,7 @@ void CMainWindow::showAboutScreen(void) { if(!APPLICATION_IS_IDLE) { - qWarning("Cannot process files at this time!\n"); + qWarning("Cannot show about box at this time!\n"); return; } @@ -643,6 +652,8 @@ void CMainWindow::showAboutScreen(void) aboutBox.setEscapeButton(btn); } + m_status = APP_STATUS_BLOCKED; + forever { const int ret = aboutBox.exec(); @@ -653,6 +664,8 @@ void CMainWindow::showAboutScreen(void) } break; } + + m_status = APP_STATUS_IDLE; } void CMainWindow::updateSize(void) diff --git a/src/MainWindow.h b/src/MainWindow.h index 447e285..f397914 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -74,7 +74,8 @@ private: APP_STATUS_STARTING = 0, APP_STATUS_IDLE = 1, APP_STATUS_AWAITING = 2, - APP_STATUS_WORKING = 3 + APP_STATUS_WORKING = 3, + APP_STATUS_BLOCKED = 4 } status_t;