wip
This commit is contained in:
@@ -54,7 +54,12 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
|
|||||||
background-color: #3049F4;
|
background-color: #3049F4;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
QObject::connect(install, &QPushButton::clicked, this, &Updater::installUpdate);
|
|
||||||
|
QObject::connect(connect, &QPushButton::clicked, [=]() {
|
||||||
|
countdownTimer->stop();
|
||||||
|
setCurrentWidget(wifi);
|
||||||
|
});
|
||||||
|
|
||||||
hlayout->addWidget(install);
|
hlayout->addWidget(install);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +119,20 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
|
|||||||
addWidget(wifi);
|
addWidget(wifi);
|
||||||
addWidget(progress);
|
addWidget(progress);
|
||||||
|
|
||||||
|
// Initialize the countdown timer and value
|
||||||
|
countdownValue = 5; // 5 seconds countdown
|
||||||
|
countdownTimer = new QTimer(this);
|
||||||
|
countdownTimer->setInterval(1000); // 1 second interval
|
||||||
|
|
||||||
|
// Connect the timer's timeout signal to update the countdown and button text
|
||||||
|
QObject::connect(countdownTimer, &QTimer::timeout, this, &Updater::updateCountdown);
|
||||||
|
|
||||||
|
// Start the countdown
|
||||||
|
countdownTimer->start();
|
||||||
|
|
||||||
|
// Set initial button text
|
||||||
|
install->setText(tr("Install (5)"));
|
||||||
|
|
||||||
setStyleSheet(R"(
|
setStyleSheet(R"(
|
||||||
* {
|
* {
|
||||||
color: white;
|
color: white;
|
||||||
@@ -142,8 +161,16 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
|
|||||||
background-color: #364DEF;
|
background-color: #364DEF;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
Updater::installUpdate();
|
void Updater::updateCountdown() {
|
||||||
|
countdownValue--;
|
||||||
|
if (countdownValue > 0) {
|
||||||
|
install->setText(tr("Install (%1)").arg(countdownValue));
|
||||||
|
} else {
|
||||||
|
countdownTimer->stop();
|
||||||
|
installUpdate(); // Assuming this is the method that starts the update
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::installUpdate() {
|
void Updater::installUpdate() {
|
||||||
|
|||||||
@@ -26,4 +26,7 @@ private:
|
|||||||
QProgressBar *bar;
|
QProgressBar *bar;
|
||||||
QPushButton *reboot;
|
QPushButton *reboot;
|
||||||
QWidget *prompt, *wifi, *progress;
|
QWidget *prompt, *wifi, *progress;
|
||||||
|
QTimer *countdownTimer;
|
||||||
|
int countdownValue;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user