From a766bffd85e1707a0642c956b25c40ffa52a349b Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 19 Oct 2024 12:29:49 +0200 Subject: [PATCH] added 'suspend' button --- mainwindow.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5d4e9c2..94f1b25 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1633,7 +1633,14 @@ void MainWindow::on_actionPause_downloads_triggered() { quint64 processID = this->downloading.process->processId(); QString fileStr = "/proc/" + QString::number(processID) + "/task/" + QString::number(processID) + "/children"; - static QMessageBox *msgBox; + static QMessageBox msgBox; + + //msgBox = new QMessageBox(this); + msgBox.setIcon( QMessageBox::Warning ); + msgBox.setText("Download suspended"); + //QPushButton *btnCancel = msgBox->addButton( "Cancel", QMessageBox::RejectRole ); + //msgBox.setAttribute(Qt::WA_DeleteOnClose); // delete pointer after close + msgBox.setModal(false); info (DEBUGMACRO, "downloading state : " + QString::fromUtf8((this->downloading.paused==0)?"running":"paused")); info (DEBUGMACRO, "Downloading process ID : " + QString::number(processID)); @@ -1656,7 +1663,10 @@ void MainWindow::on_actionPause_downloads_triggered() info(DEBUGMACRO, "resuming failed : " + QString::number(errno)); } - msgBox->close(); + if (msgBox.isVisible()) + { + msgBox.close(); + } this->downloading.paused = false; }else { @@ -1665,13 +1675,8 @@ void MainWindow::on_actionPause_downloads_triggered() { info(DEBUGMACRO, "resuming failed : " + QString::number(errno)); } - msgBox = new QMessageBox(this); - msgBox->setIcon( QMessageBox::Warning ); - msgBox->setText("Download suspended"); - //QPushButton *btnCancel = msgBox->addButton( "Cancel", QMessageBox::RejectRole ); - msgBox->setAttribute(Qt::WA_DeleteOnClose); // delete pointer after close - msgBox->setModal(false); - msgBox->show(); + + msgBox.show(); this->downloading.paused = true; }