From 36f7dae7d983ab89532fb6613e75cf4491065e66 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 17 Nov 2017 12:34:27 -0500 Subject: Get rid of the updates available dialog/prompt in Lumina. Replace it with an extra "reboot w/ updates" button in both the start menu and the system logout window. --- src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp | 51 +++++++++------- src-qt5/core/lumina-desktop/SystemWindow.cpp | 34 +++++++---- src-qt5/core/lumina-desktop/SystemWindow.h | 11 ++-- src-qt5/core/lumina-desktop/SystemWindow.ui | 69 +++++++++++++++++++++- .../panel-plugins/systemstart/StartMenu.cpp | 22 +++++-- .../panel-plugins/systemstart/StartMenu.h | 11 ++-- .../panel-plugins/systemstart/StartMenu.ui | 45 ++++++++++---- 7 files changed, 179 insertions(+), 64 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp index 29a58ec9..4c801112 100644 --- a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp +++ b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp @@ -85,7 +85,7 @@ QStringList LOS::ExternalDevicePaths(){ int LOS::ScreenBrightness(){ //First run a quick check to ensure this is not a VirtualBox VM (no brightness control) static int goodsys = -1; //This will not change over time - only check/set once - if(goodsys<0){ + if(goodsys<0){ //Make sure we are not running in VirtualBox (does not work in a VM) QStringList info = LUtils::getCmdOutput("pciconf -lv"); if( info.filter("VirtualBox", Qt::CaseInsensitive).isEmpty() ){ goodsys = 1; } @@ -103,8 +103,8 @@ int LOS::ScreenBrightness(){ } } //If it gets to this point, then we have a valid (but new) installation - if(screenbrightness<0){ screenbrightness = 100; } //default value for systems - return screenbrightness; + if(screenbrightness<0){ screenbrightness = 100; } //default value for systems + return screenbrightness; } //Set screen brightness @@ -149,10 +149,10 @@ int LOS::audioVolume(){ //Returns: audio volume as a percentage (0-100, with -1 if(out < 0){ //First time session check: Load the last setting for this user QString info = LUtils::readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/.currentvolume").join(""); - if(!info.isEmpty()){ - out = info.simplified().toInt(); + if(!info.isEmpty()){ + out = info.simplified().toInt(); audiovolume = out; //reset this internal flag - return out; + return out; } } bool remoteSession = !QString(getenv("PICO_CLIENT_LOGIN")).isEmpty(); @@ -173,7 +173,7 @@ int LOS::audioVolume(){ //Returns: audio volume as a percentage (0-100, with -1 //Volume changed by other utility: adjust the saved value as well LUtils::writeFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/.currentvolume", QStringList() << QString::number(out), true); } - audiovolume = out; + audiovolume = out; } } return out; @@ -222,7 +222,7 @@ void LOS::changeAudioVolume(int percentdiff){ //Run Command LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); } - } + } } //Check if a graphical audio mixer is installed @@ -260,24 +260,31 @@ void LOS::systemShutdown(bool skipupdates){ //start poweroff sequence //System Restart void LOS::systemRestart(bool skipupdates){ //start reboot sequence - if(skipupdates){QProcess::startDetached("shutdown -ro now"); } - else{ QProcess::startDetached("shutdown -r now"); } + bool activeupdates = !LUtils::readFile("/etc/defaults/vendor.conf").filter("trueos_active_update=\"YES\"").isEmpty(); + if(skipupdates){ + QProcess::startDetached("shutdown -ro now"); + }else{ + if(activeupdates && LUtils::isValidBinary("pc-updatemanager") && LOS::systemPendingUpdates().isEmpty()){ QProcess::startDetached("pc-updatemanager startupdate"); } + else{ QProcess::startDetached("shutdown -r now"); } + } } //Check for suspend support bool LOS::systemCanSuspend(){ - //This will only function on TrueOS - //(permissions issues on standard FreeBSD unless setup a special way) - bool ok = QFile::exists("/usr/local/bin/pc-sysconfig"); + QString state = LUtils::getCmdOutput("sysctl hw.acpi.suspend_state").join("").simplified(); + bool ok = LUtils::getCmdOutput("sysctl hw.acpi.supported_sleep_state").join("").split(" ",QString::SkipEmptyParts).contains(state); + /*bool ok = QFile::exists("/usr/local/bin/pc-sysconfig"); if(ok){ ok = LUtils::getCmdOutput("pc-sysconfig systemcansuspend").join("").toLower().contains("true"); - } + }*/ return ok; } //Put the system into the suspend state void LOS::systemSuspend(){ - QProcess::startDetached("pc-sysconfig suspendsystem"); + QString state = LUtils::getCmdOutput("sysctl hw.acpi.suspend_state").join("").simplified(); + //QProcess::startDetached("pc-sysconfig suspendsystem"); + QProcess::startDetached("acpiconf", QStringList() << "-s" << state ); } //Battery Availability @@ -289,8 +296,8 @@ bool LOS::hasBattery(){ //Battery Charge Level int LOS::batteryCharge(){ //Returns: percent charge (0-100), anything outside that range is counted as an error int charge = LUtils::getCmdOutput("apm -l").join("").toInt(); - if(charge > 100){ charge = -1; } //invalid charge - return charge; + if(charge > 100){ charge = -1; } //invalid charge + return charge; } //Battery Charging State @@ -328,11 +335,11 @@ QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as QStringList LOS::CPUTemperatures(){ //Returns: List containing the temperature of any CPU's ("50C" for example) static QStringList vars = QStringList(); QStringList temps; - if(vars.isEmpty()){ + if(vars.isEmpty()){ temps = LUtils::getCmdOutput("sysctl -i dev.cpu").filter(".temperature:"); //try direct readings first if(temps.isEmpty()){ temps = LUtils::getCmdOutput("sysctl -i hw.acpi").filter(".temperature:"); } // then try acpi values }else{ temps = LUtils::getCmdOutput("sysctl "+vars.join(" ")); vars.clear(); } - + temps.sort(); for(int i=0; i2 && labs.length()>2){ out << fmt.arg(data[0], data[1]+" "+labs[1], data[2]+" "+labs[2]); } } } - + return out; } diff --git a/src-qt5/core/lumina-desktop/SystemWindow.cpp b/src-qt5/core/lumina-desktop/SystemWindow.cpp index c709bb2a..dbcec2a2 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.cpp +++ b/src-qt5/core/lumina-desktop/SystemWindow.cpp @@ -29,6 +29,7 @@ SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ connect(ui->tool_suspend, SIGNAL(clicked()), this, SLOT(sysSuspend()) ); connect(ui->push_cancel, SIGNAL(clicked()), this, SLOT(sysCancel()) ); connect(ui->push_lock, SIGNAL(clicked()), this, SLOT(sysLock()) ); + connect(ui->tool_restart_updates, SIGNAL(clicked()), this, SLOT(sysUpdate()) ); //Disable buttons if necessary updateWindow(); ui->tool_suspend->setVisible(LOS::systemCanSuspend()); //does not change with time - just do a single check @@ -46,6 +47,7 @@ void SystemWindow::updateWindow(){ bool ok = LOS::userHasShutdownAccess(); ui->tool_restart->setEnabled(ok); ui->tool_shutdown->setEnabled(ok); + ui->frame_update->setVisible( !LOS::systemPendingUpdates().isEmpty() ); //Center this window on the current screen QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen this->move(center.x() - this->width()/2, center.y() - this->height()/2); @@ -74,21 +76,29 @@ void SystemWindow::sysLogout(){ LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartLogout()) ); } - + void SystemWindow::sysRestart(){ - bool skip = false; - if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled - this->close(); - LSession::processEvents(); - LSession::handle()->StartReboot(skip); + //bool skip = false; + //if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled + //this->close(); + //LSession::processEvents(); + LSession::handle()->StartReboot(true); +} + +void SystemWindow::sysUpdate(){ + //bool skip = false; + //if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled + //this->close(); + //LSession::processEvents(); + LSession::handle()->StartReboot(false); } - + void SystemWindow::sysShutdown(){ - bool skip = false; - if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled - this->close(); - LSession::processEvents(); - LSession::handle()->StartShutdown(skip); + //bool skip = false; + //if(!promptAboutUpdates(skip)){ this->close(); return; } //cancelled + //this->close(); + //LSession::processEvents(); + LSession::handle()->StartShutdown(); } void SystemWindow::sysSuspend(){ diff --git a/src-qt5/core/lumina-desktop/SystemWindow.h b/src-qt5/core/lumina-desktop/SystemWindow.h index bbef36a3..ad67c7e4 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.h +++ b/src-qt5/core/lumina-desktop/SystemWindow.h @@ -5,9 +5,6 @@ #include "ui_SystemWindow.h" - - - namespace Ui{ class SystemWindow; }; @@ -29,17 +26,17 @@ private: private slots: void sysLogout(); - + void sysRestart(); - + void sysUpdate(); void sysShutdown(); - + void sysSuspend(); void sysCancel(){ this->close(); } - + void sysLock(); }; diff --git a/src-qt5/core/lumina-desktop/SystemWindow.ui b/src-qt5/core/lumina-desktop/SystemWindow.ui index 49beb0d9..6108815b 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.ui +++ b/src-qt5/core/lumina-desktop/SystemWindow.ui @@ -6,8 +6,8 @@ 0 0 - 289 - 135 + 458 + 306 @@ -99,6 +99,71 @@ + + + + QFrame{ background-color: rgba(150,150,0,50); } + + + QFrame::StyledPanel + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Update Now + + + + 32 + 32 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + Updates ready to install + + + Qt::AlignCenter + + + true + + + + + + diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index beaa5d92..272bf0fa 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -507,6 +507,7 @@ void StartMenu::on_stackedWidget_currentChanged(int val){ tmp = LOS::audioVolume(); ui->frame_audio->setVisible(tmp >= 0); if(tmp >= 0){ ui->slider_volume->setValue(tmp); } + }else if(page == ui->page_leave){ if( !ui->frame_leave_system->whatsThis().isEmpty() ){ //This frame is allowed/visible - need to adjust the shutdown detection @@ -514,6 +515,7 @@ void StartMenu::on_stackedWidget_currentChanged(int val){ ui->tool_restart->setEnabled(!updating); ui->tool_shutdown->setEnabled(!updating); ui->label_updating->setVisible(updating); //to let the user know *why* they can't shutdown/restart right now + ui->tool_restart_updates->setVisible(!updating && !LOS::systemPendingUpdates().isEmpty() ); } ui->frame_leave_suspend->setVisible( LOS::systemCanSuspend() ); } @@ -590,17 +592,25 @@ void StartMenu::on_tool_logout_clicked(){ void StartMenu::on_tool_restart_clicked(){ emit CloseMenu(); QCoreApplication::processEvents(); - bool skipupdates = false; - if( !promptAboutUpdates(skipupdates) ){ return; } - LSession::handle()->StartReboot(skipupdates); + //bool skipupdates = false; + //if( !promptAboutUpdates(skipupdates) ){ return; } + LSession::handle()->StartReboot(true); +} + +void StartMenu::on_tool_restart_update_clicked(){ + emit CloseMenu(); + QCoreApplication::processEvents(); + //bool skipupdates = false; + //if( !promptAboutUpdates(skipupdates) ){ return; } + LSession::handle()->StartReboot(false); } void StartMenu::on_tool_shutdown_clicked(){ emit CloseMenu(); QCoreApplication::processEvents(); - bool skipupdates = false; - if( !promptAboutUpdates(skipupdates) ){ return; } - LSession::handle()->StartShutdown(skipupdates); + //bool skipupdates = false; + //if( !promptAboutUpdates(skipupdates) ){ return; } + LSession::handle()->StartShutdown(); } void StartMenu::on_tool_suspend_clicked(){ diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h index e2dbb273..41bc3ec4 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h @@ -73,6 +73,7 @@ private slots: void on_tool_lock_clicked(); void on_tool_logout_clicked(); void on_tool_restart_clicked(); + void on_tool_restart_update_clicked(); void on_tool_shutdown_clicked(); void on_tool_suspend_clicked(); @@ -80,17 +81,17 @@ private slots: void on_slider_volume_valueChanged(int); void on_tool_launch_mixer_clicked(); void on_tool_mute_audio_clicked(); - + //Screen Brightness void on_slider_bright_valueChanged(int); - + //Workspace void on_tool_set_nextwkspace_clicked(); void on_tool_set_prevwkspace_clicked(); - + //Locale void on_combo_locale_currentIndexChanged(int); - + //Search void on_line_search_textEdited(QString); void startSearch(); @@ -99,7 +100,7 @@ private slots: signals: void CloseMenu(); void UpdateQuickLaunch(QStringList); - + }; #endif diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui index d374bfce..500b6559 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui @@ -6,8 +6,8 @@ 0 0 - 181 - 405 + 336 + 466 @@ -42,7 +42,7 @@ - 4 + 3 @@ -142,8 +142,8 @@ 0 0 - 179 - 208 + 334 + 102 @@ -438,8 +438,8 @@ 0 0 - 179 - 299 + 334 + 277 @@ -1002,6 +1002,31 @@ + + + + + 0 + 0 + + + + QToolButton{ background-color: rgba(150,150,0,100); } + + + Update and Restart + + + + + + Qt::ToolButtonTextBesideIcon + + + true + + + @@ -1033,7 +1058,7 @@ - (System Performing Updates) + (System Preparing Updates) Qt::AlignCenter @@ -1099,8 +1124,8 @@ 0 0 - 167 - 345 + 308 + 351 -- cgit