diff --git a/include/appimageupdaterdialog.hpp b/include/appimageupdaterdialog.hpp index 1b817b1..5748eb4 100644 --- a/include/appimageupdaterdialog.hpp +++ b/include/appimageupdaterdialog.hpp @@ -82,7 +82,7 @@ class AppImageUpdaterDialog : public QDialog { }; AppImageUpdaterDialog(QPixmap img = QPixmap(), - QWidget *parent = nullptr, int flags = Default); + QWidget *parent = nullptr, int flags = Default, int delaySecs = 10); ~AppImageUpdaterDialog(); public Q_SLOTS: @@ -111,6 +111,7 @@ class AppImageUpdaterDialog : public QDialog { private: bool b_Busy = false; + int delay = 0; int p_Flags = 0; QString m_ApplicationName; QString s_CurrentAppImagePath; /* Used only for error dialog box. */ diff --git a/src/appimageupdaterdialog.cc b/src/appimageupdaterdialog.cc index 6c732b1..f5a9a9b 100644 --- a/src/appimageupdaterdialog.cc +++ b/src/appimageupdaterdialog.cc @@ -39,9 +39,10 @@ using namespace AppImageUpdaterBridge; -AppImageUpdaterDialog::AppImageUpdaterDialog(QPixmap img, QWidget *parent, int flags) +AppImageUpdaterDialog::AppImageUpdaterDialog(QPixmap img, QWidget *parent, int flags, int delaySecs) : QDialog(parent), - p_Flags(flags) { + p_Flags(flags), + delay(delaySecs) { bool found = false; m_Ui.reset(new Ui::AppImageUpdaterDialog); @@ -88,8 +89,7 @@ AppImageUpdaterDialog::~AppImageUpdaterDialog() { } void AppImageUpdaterDialog::init(AppImageDeltaRevisioner *revisioner, - const QString &applicationName) { - + const QString &applicationName){ getMethod(this, "doInit(QObject*,const QString&)") .invoke(this, Qt::QueuedConnection, Q_ARG(QObject*, revisioner),Q_ARG(QString,applicationName)); } @@ -254,14 +254,22 @@ void AppImageUpdaterDialog::handleFinished(QJsonObject newVersion, QString oldVe bool show = p_Flags & ShowFinishedDialog; if(show) { - QString currentAppImageName = QFileInfo(oldVersionPath).fileName(); + auto curinfo = QFileInfo(oldVersionPath); + QString currentAppImageName = curinfo.fileName(); + QString currentAppImageAbsPath = curinfo.absolutePath(); + QMessageBox box(this); box.setWindowTitle(QString::fromUtf8("Update Completed!")); - box.setText(QString::fromUtf8("Update completed successfully for ") + + box.setIcon(QMessageBox::Information); + box.setDetailedText( + QString::fromUtf8("Old version is at: ") + + currentAppImageAbsPath + QString::fromUtf8("/") + currentAppImageName + + QString::fromUtf8("\n\n") + + QString::fromUtf8("New version is saved at: ") + + newVersion["AbsolutePath"].toString()); + box.setText(QString::fromUtf8("Update completed successfully for ") + currentAppImageName + - QString::fromUtf8(", the new version is saved at '") + - newVersion["AbsolutePath"].toString() + - QString::fromUtf8("', do you want to open it?")); + QString::fromUtf8(", do you want to launch the new version? View details for more information.")); box.addButton(QMessageBox::Yes); box.addButton(QMessageBox::No); execute = (box.exec() == QMessageBox::Yes); @@ -278,7 +286,15 @@ void AppImageUpdaterDialog::handleFinished(QJsonObject newVersion, QString oldVe info.permissions()); } } - QProcess::startDetached(newVersion["AbsolutePath"].toString()); + QProcess::startDetached("sh", + QStringList() + << "-c" + << ( + QString::fromUtf8("sleep ") + + QString::number(delay) + + QString::fromUtf8("; ") + + newVersion["AbsolutePath"].toString() + )); emit quit(); } hide();