Skip to content

Commit f449c33

Browse files
committed
Prompt before closing while process is running
1 parent 5a9d88d commit f449c33

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/mainwindow.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4127,6 +4127,22 @@ void MainWindow::comboUser_currentIndexChanged(int index)
41274127
displayFlatpaks(true);
41284128
}
41294129

4130+
void MainWindow::closeEvent(QCloseEvent *event)
4131+
{
4132+
if (cmd.state() != QProcess::NotRunning) {
4133+
if (QMessageBox::warning(this, tr("Quit?"),
4134+
tr("Process still running, quitting might leave the system in an unstable "
4135+
"state.<p><b>Are you sure you want to exit MX Package Installer?</b>"),
4136+
QMessageBox::Yes, QMessageBox::No)
4137+
== QMessageBox::No) {
4138+
event->ignore();
4139+
return;
4140+
}
4141+
cleanup();
4142+
}
4143+
event->accept();
4144+
}
4145+
41304146
// Process keystrokes
41314147
void MainWindow::keyPressEvent(QKeyEvent *event)
41324148
{

src/mainwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
**********************************************************************/
2525
#pragma once
2626

27+
#include <QCloseEvent>
2728
#include <QCommandLineParser>
2829
#include <QAction>
2930
#include <QFile>
@@ -86,6 +87,7 @@ class MainWindow : public QDialog
8687
~MainWindow() override;
8788

8889
protected:
90+
void closeEvent(QCloseEvent *event) override;
8991
void keyPressEvent(QKeyEvent *event) override;
9092

9193
signals:

0 commit comments

Comments
 (0)