Skip to content

Commit b83b95a

Browse files
committed
python_install_dialog: require user to restart app after python support installed
Signed-off-by: Jack Lau <[email protected]>
1 parent 9b53249 commit b83b95a

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/component/src/python_install_dialog.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "python_install_dialog.h"
1919
#include <QMessageBox>
20+
#include <QProcess>
21+
#include <QCoreApplication>
2022

2123
PythonInstallDialog::PythonInstallDialog(QWidget *parent)
2224
: QDialog(parent)
@@ -187,12 +189,30 @@ void PythonInstallDialog::OnPackagesInstalled() {
187189
progressBar->setValue(100);
188190
statusLabel->setText(tr("Installation complete! AI Processing is now ready."));
189191

190-
QMessageBox::information(
191-
this,
192-
tr("Success"),
193-
tr("Python and all required packages have been installed successfully.\n\n"
194-
"You can now use AI Processing features.")
195-
);
192+
QMessageBox msgBox(this);
193+
msgBox.setIcon(QMessageBox::Information);
194+
msgBox.setWindowTitle(tr("Installation Complete"));
195+
msgBox.setText(tr(
196+
"Python and all required packages have been installed successfully.\n\n"
197+
"A restart is required to enable AI Processing features."
198+
));
199+
200+
QPushButton *restartButton =
201+
msgBox.addButton(tr("Restart Now"), QMessageBox::AcceptRole);
202+
QPushButton *laterButton =
203+
msgBox.addButton(tr("Restart Later"), QMessageBox::RejectRole);
204+
205+
msgBox.exec();
206+
207+
if (msgBox.clickedButton() == restartButton) {
208+
// Relaunch the application
209+
const QString program = QCoreApplication::applicationFilePath();
210+
const QStringList arguments = QCoreApplication::arguments();
211+
212+
QProcess::startDetached(program, arguments);
213+
QCoreApplication::quit();
214+
return;
215+
}
196216

197217
accept();
198218
}

0 commit comments

Comments
 (0)