Available update can be checked via menu action Help/"Check for update".

This commit is contained in:
2025-10-31 15:31:33 +01:00
parent dd8847d63a
commit 43df76c88f
3 changed files with 55 additions and 2 deletions

View File

@ -2,10 +2,14 @@
#include "./ui_mainwindow.h"
#include <QCloseEvent>
#include <QMessageBox>
#include "data/settingshandler.h"
#include "genericcore.h"
static QString updateTextClean = "Do you want to update the application now?";
static QString updateTextDirty = "Do you want to save the tasks & update the application now?";
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow) {
@ -32,6 +36,8 @@ MainWindow::MainWindow(QWidget* parent)
connect(m_core, &GenericCore::displayStatusMessage, this, &MainWindow::displayStatusMessage);
connect(this, &MainWindow::displayStatusMessage, this, &MainWindow::showStatusMessage);
connect(this, &MainWindow::checkForUpdates, this,
&MainWindow::on_actionCheck_for_update_triggered, Qt::QueuedConnection);
}
MainWindow::~MainWindow() {
@ -49,6 +55,20 @@ void MainWindow::showStatusMessage(const QString text) {
ui->statusbar->showMessage(text);
}
void MainWindow::on_actionCheck_for_update_triggered() {
showStatusMessage("Checking for update...");
const bool updateAvailable = m_core->isApplicationUpdateAvailable();
if (updateAvailable) {
const QString text = isWindowModified() ? updateTextDirty : updateTextClean;
const QMessageBox::StandardButton clickedButton = QMessageBox::question(
this, tr("Update available."), text, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (clickedButton == QMessageBox::Yes) {
m_core->triggerApplicationUpdate();
close();
}
}
}
void MainWindow::closeEvent(QCloseEvent* event) {
if (isWindowModified()) {
QMessageBox msgBox;