diff options
Diffstat (limited to 'src-qt5')
7 files changed, 179 insertions, 64 deletions
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; i<temps.length(); i++){ if(temps[i].contains(".acpi.") || temps[i].contains(".cpu")){ @@ -383,7 +390,7 @@ int LOS::CPUUsagePercent(){ //Returns: Overall percentage of the amount of CPU c tot += 100.0L - ( (100.0L*result[i].toLong())/sum ); //remember IDLE is the last of the five values per CPU } return qRound(tot/cpnum); - + } int LOS::MemoryUsagePercent(){ @@ -407,14 +414,14 @@ QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for ea info[i].replace("\t"," "); if(i==1){ labs = info[i].split(" ", QString::SkipEmptyParts); }//the labels for each column else{ - QStringList data = info[i].split(" ",QString::SkipEmptyParts); //data[0] is always the device + QStringList data = info[i].split(" ",QString::SkipEmptyParts); //data[0] is always the device //qDebug() << "Data Line:" << data; if(data.length()>2 && 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 @@ <rect> <x>0</x> <y>0</y> - <width>289</width> - <height>135</height> + <width>458</width> + <height>306</height> </rect> </property> <property name="windowTitle"> @@ -100,6 +100,71 @@ </layout> </item> <item> + <widget class="QFrame" name="frame_update"> + <property name="styleSheet"> + <string notr="true">QFrame{ background-color: rgba(150,150,0,50); }</string> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QToolButton" name="tool_restart_updates"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Update Now</string> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Updates ready to install</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> 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 @@ <rect> <x>0</x> <y>0</y> - <width>181</width> - <height>405</height> + <width>336</width> + <height>466</height> </rect> </property> <property name="windowTitle"> @@ -42,7 +42,7 @@ <item> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> - <number>4</number> + <number>3</number> </property> <widget class="QWidget" name="page_main"> <layout class="QVBoxLayout" name="verticalLayout_2"> @@ -142,8 +142,8 @@ <rect> <x>0</x> <y>0</y> - <width>179</width> - <height>208</height> + <width>334</width> + <height>102</height> </rect> </property> </widget> @@ -438,8 +438,8 @@ <rect> <x>0</x> <y>0</y> - <width>179</width> - <height>299</height> + <width>334</width> + <height>277</height> </rect> </property> </widget> @@ -1003,6 +1003,31 @@ </widget> </item> <item> + <widget class="QToolButton" name="tool_restart_updates"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="styleSheet"> + <string notr="true">QToolButton{ background-color: rgba(150,150,0,100); }</string> + </property> + <property name="text"> + <string>Update and Restart</string> + </property> + <property name="icon"> + <iconset theme="system-reboot"/> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> <widget class="QToolButton" name="tool_shutdown"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> @@ -1033,7 +1058,7 @@ <item> <widget class="QLabel" name="label_updating"> <property name="text"> - <string>(System Performing Updates)</string> + <string>(System Preparing Updates)</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -1099,8 +1124,8 @@ <rect> <x>0</x> <y>0</y> - <width>167</width> - <height>345</height> + <width>308</width> + <height>351</height> </rect> </property> </widget> |