From bd87d69b5c64a80a209e5cd8e3f0c7fac608c87c Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 18 Aug 2016 15:50:49 -0400 Subject: Add in pending update detection/skipping ability to the main logout window (not the start menu options yet). --- src-qt5/core/lumina-desktop/LSession.cpp | 8 ++++---- src-qt5/core/lumina-desktop/LSession.h | 4 ++-- src-qt5/core/lumina-desktop/SystemWindow.cpp | 30 +++++++++++++++++++++++----- src-qt5/core/lumina-desktop/SystemWindow.h | 3 ++- 4 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src-qt5/core/lumina-desktop') diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index 28b7eb2d..434bfd2d 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -299,15 +299,15 @@ void LSession::StartLogout(){ QCoreApplication::exit(0); } -void LSession::StartShutdown(){ +void LSession::StartShutdown(bool skipupdates){ CleanupSession(); - LOS::systemShutdown(); + LOS::systemShutdown(skipupdates); QCoreApplication::exit(0); } -void LSession::StartReboot(){ +void LSession::StartReboot(bool skipupdates){ CleanupSession(); - LOS::systemRestart(); + LOS::systemRestart(skipupdates); QCoreApplication::exit(0); } diff --git a/src-qt5/core/lumina-desktop/LSession.h b/src-qt5/core/lumina-desktop/LSession.h index f9e2acb3..c19b3f09 100644 --- a/src-qt5/core/lumina-desktop/LSession.h +++ b/src-qt5/core/lumina-desktop/LSession.h @@ -140,8 +140,8 @@ private: public slots: void StartLogout(); - void StartShutdown(); - void StartReboot(); + void StartShutdown(bool skipupdates = false); + void StartReboot(bool skipupdates = false); void reloadIconTheme(); diff --git a/src-qt5/core/lumina-desktop/SystemWindow.cpp b/src-qt5/core/lumina-desktop/SystemWindow.cpp index 74538404..1c0b59a5 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.cpp +++ b/src-qt5/core/lumina-desktop/SystemWindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ ui->setupUi(this); //load the designer file @@ -49,22 +50,41 @@ void SystemWindow::updateWindow(){ this->move(center.x() - this->width()/2, center.y() - this->height()/2); } +bool SystemWindow::promptAboutUpdates(bool &skip){ + QString pending = LOS::systemPendingUpdates(); + if(pending.isEmpty()){ skip = false; } //continue without skip + else{ + QMessageBox dlg(QMessageBox::Question, tr("Apply Updates?"), tr("You have system updates waiting to be applied! Do you wish to install them now?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this); + dlg.setDetailedText(pending); + dlg.setDefaultButton(QMessageBox::Yes); + dlg.show(); + int ret = dlg.exec(); + if(ret == QMessageBox::Cancel){ return false; } //do not continue + else{ skip = (ret==QMessageBox::No); } + } + return true; +} + void SystemWindow::sysLogout(){ - this->hide(); + this->close(); LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartLogout()) ); } void SystemWindow::sysRestart(){ - this->hide(); + bool skip = false; + if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled + this->close(); LSession::processEvents(); - QTimer::singleShot(0, LSession::handle(), SLOT(StartReboot()) ); + LSession::handle()->StartReboot(skip); } void SystemWindow::sysShutdown(){ - this->hide(); + bool skip = false; + if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled + this->close(); LSession::processEvents(); - QTimer::singleShot(0, LSession::handle(), SLOT(StartShutdown()) ); + LSession::handle()->StartShutdown(skip); } void SystemWindow::sysSuspend(){ diff --git a/src-qt5/core/lumina-desktop/SystemWindow.h b/src-qt5/core/lumina-desktop/SystemWindow.h index 98617f79..bbef36a3 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.h +++ b/src-qt5/core/lumina-desktop/SystemWindow.h @@ -25,7 +25,8 @@ private: Ui::SystemWindow *ui; //void closeAllWindows(); - + bool promptAboutUpdates(bool &skip); //main bool return: continue/cancel, skip: skip updates or not + private slots: void sysLogout(); -- cgit