Available update can be checked via menu action Help/"Check for update".
This commit is contained in:
@ -2,10 +2,14 @@
|
|||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "data/settingshandler.h"
|
#include "data/settingshandler.h"
|
||||||
#include "genericcore.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)
|
MainWindow::MainWindow(QWidget* parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow) {
|
, ui(new Ui::MainWindow) {
|
||||||
@ -32,6 +36,8 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_core, &GenericCore::displayStatusMessage, this, &MainWindow::displayStatusMessage);
|
connect(m_core, &GenericCore::displayStatusMessage, this, &MainWindow::displayStatusMessage);
|
||||||
connect(this, &MainWindow::displayStatusMessage, this, &MainWindow::showStatusMessage);
|
connect(this, &MainWindow::displayStatusMessage, this, &MainWindow::showStatusMessage);
|
||||||
|
connect(this, &MainWindow::checkForUpdates, this,
|
||||||
|
&MainWindow::on_actionCheck_for_update_triggered, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
@ -49,6 +55,20 @@ void MainWindow::showStatusMessage(const QString text) {
|
|||||||
ui->statusbar->showMessage(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) {
|
void MainWindow::closeEvent(QCloseEvent* event) {
|
||||||
if (isWindowModified()) {
|
if (isWindowModified()) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
|||||||
@ -21,14 +21,17 @@ class MainWindow : public QMainWindow {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayStatusMessage(QString message);
|
void displayStatusMessage(QString message);
|
||||||
|
void checkForUpdates();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
|
||||||
|
|
||||||
void showStatusMessage(const QString text);
|
void showStatusMessage(const QString text);
|
||||||
|
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
void on_actionCheck_for_update_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
||||||
|
|||||||
@ -40,8 +40,38 @@
|
|||||||
<height>25</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menu_File">
|
||||||
|
<property name="title">
|
||||||
|
<string>&File</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menu_Edit">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menu_View">
|
||||||
|
<property name="title">
|
||||||
|
<string>&View</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menu_Help">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Help</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionCheck_for_update"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menu_File"/>
|
||||||
|
<addaction name="menu_Edit"/>
|
||||||
|
<addaction name="menu_View"/>
|
||||||
|
<addaction name="menu_Help"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<action name="actionCheck_for_update">
|
||||||
|
<property name="text">
|
||||||
|
<string>Check for &update</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in New Issue
Block a user