diff options
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 35 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 34 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp | 9 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h | 1 |
4 files changed, 54 insertions, 25 deletions
diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index c9874605..39eae307 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -11,6 +11,7 @@ #include <QDebug> //can't read xbrightness settings - assume invalid until set static int screenbrightness = -1; +static int audiovolume = -1; QString LOS::OSName(){ return "FreeBSD"; } @@ -95,14 +96,31 @@ void LOS::setScreenBrightness(int percent){ //Read the current volume int LOS::audioVolume(){ //Returns: audio volume as a percentage (0-100, with -1 for errors) - QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines - int out = -1; - if(!info.isEmpty()){ - int L = info.section(":",1,1).toInt(); - int R = info.section(":",2,2).toInt(); - if(L>R){ out = L; } - else{ out = R; } + int out = audiovolume; + if(out < 0){ + //First time session check: Load the last setting for this user + QString info = LUtils::readFile(QDir::homePath()+"/.lumina/.currentvolume").join(""); + if(!info.isEmpty()){ + out = info.simplified().toInt(); + audiovolume = out; //unset this internal flag + return out; + } } + + //probe the system for the current volume (other utils could be changing it) + QString info = LUtils::getCmdOutput("mixer -S vol").join(":").simplified(); //ignores any other lines + if(!info.isEmpty()){ + int L = info.section(":",1,1).toInt(); + int R = info.section(":",2,2).toInt(); + if(L>R){ out = L; } + else{ out = R; } + if(out != audiovolume){ + //Volume changed by other utility: adjust the saved value as well + LUtils::writeFile(QDir::homePath()+"/.lumina/.currentvolume", QStringList() << QString::number(out), true); + } + audiovolume = out; + } + return out; } @@ -115,13 +133,16 @@ void LOS::setAudioVolume(int percent){ int L = info.section(":",1,1).toInt(); int R = info.section(":",2,2).toInt(); int diff = L-R; + if((percent == L) && (L==R)){ return; } //already set to that volume if(diff<0){ R=percent; L=percent+diff; } //R Greater else{ L=percent; R=percent-diff; } //L Greater or equal //Check bounds if(L<0){L=0;}else if(L>100){L=100;} if(R<0){R=0;}else if(R>100){R=100;} //Run Command + audiovolume = percent; //save for checking later LUtils::runCmd("mixer vol "+QString::number(L)+":"+QString::number(R)); + LUtils::writeFile(QDir::homePath()+"/.lumina/.currentvolume", QStringList() << QString::number(percent), true); } } diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 994faad8..8b05b5ef 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -112,6 +112,15 @@ void LSession::setupSession(){ if(DEBUG){ qDebug() << " - Init SettingsMenu:" << timer->elapsed();} settingsmenu = new SettingsMenu(); + //Re-load the screen brightness and volume settings from the previous session + qDebug() << " - Loading previous settings"; + int tmp = LOS::audioVolume(); + LOS::setAudioVolume(tmp); + qDebug() << " - - Audio Volume:" << QString::number(tmp)+"%"; + tmp = LOS::ScreenBrightness(); + LOS::setScreenBrightness( tmp ); + qDebug() << " - - Screen Brightness:" << QString::number(tmp)+"%"; + //Now setup the system watcher for changes qDebug() << " - Initialize file system watcher"; if(DEBUG){ qDebug() << " - Init QFileSystemWatcher:" << timer->elapsed();} @@ -209,6 +218,17 @@ int LSession::VersionStringToNumber(QString version){ void LSession::launchStartupApps(){ //First start any system-defined startups, then do user defined qDebug() << "Launching startup applications"; + //Now play the login music + if(sessionsettings->value("PlayStartupAudio",true).toBool()){ + //Make sure to re-set the system volume to the last-used value at outset + int vol = LOS::audioVolume(); + if(vol>=0){ LOS::setAudioVolume(vol); } + LSession::playAudioFile(LOS::LuminaShare()+"Login.ogg"); + } + //Enable Numlock + if(sessionsettings->value("EnableNumlock",false).toBool()){ + QProcess::startDetached("numlockx on"); + } //First create the list of all possible locations in order of precedence // NOTE: Lumina/system defaults should be launched earlier due to possible system admin utilities QStringList filelist; @@ -235,19 +255,10 @@ void LSession::launchStartupApps(){ entries.removeDuplicates(); //Just in case something is duplicated between system/user defaults for(int i=0; i<entries.length(); i++){ qDebug() << " - Starting Application:" << entries[i]; - LSession::LaunchApplication(entries[i]); + LSession::LaunchApplication(entries[i]); + LSession::processEvents(); } - //Now play the login music - if(sessionsettings->value("PlayStartupAudio",true).toBool()){ - //Make sure to re-set the system volume to the last-used value at outset - int vol = LOS::audioVolume(); - if(vol>=0){ LOS::setAudioVolume(vol); } - LSession::playAudioFile(LOS::LuminaShare()+"Login.ogg"); - } - if(sessionsettings->value("EnableNumlock",false).toBool()){ - QProcess::startDetached("numlockx on"); - } //Now get any XDG startup applications and launch them QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles(); for(int i=0; i<xdgapps.length(); i++){ @@ -258,6 +269,7 @@ void LSession::launchStartupApps(){ //Don't update the mouse cursor QProcess::startDetached("lumina-open \""+xdgapps[i].filePath+"\""); } + LSession::processEvents(); } } diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp index b470f191..0cf053fa 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp @@ -12,13 +12,12 @@ LSysMenuQuick::LSysMenuQuick(QWidget *parent) : QWidget(parent), ui(new Ui::LSysMenuQuick){ ui->setupUi(this); - settings = new QSettings("panel-plugins","systemdashboard"); brighttimer = new QTimer(this); brighttimer->setSingleShot(true); brighttimer->setInterval(50); //50ms delay in setting the new value - //Now reset the initial saved settings (if any) - LOS::setScreenBrightness( settings->value("screenbrightness",100).toInt() ); //default to 100% - LOS::setAudioVolume( settings->value("audiovolume", 100).toInt() ); //default to 100% + //Now reset the initial saved settings (this is handles by the LOS/session now - 4/22/15) + UpdateMenu(); //do this once before all the signals/slots are connected below + //Now setup the connections connect(ui->slider_volume, SIGNAL(valueChanged(int)), this, SLOT(volSliderChanged()) ); connect(ui->slider_brightness, SIGNAL(valueChanged(int)), this, SLOT(brightSliderChanged()) ); @@ -102,7 +101,6 @@ void LSysMenuQuick::UpdateMenu(){ void LSysMenuQuick::volSliderChanged(){ int val = ui->slider_volume->value(); LOS::setAudioVolume(val); - settings->setValue("audiovolume",val); QString txt = QString::number(val)+"%"; if(val<100){ txt.prepend(" "); } //make sure no widget resizing ui->label_vol_text->setText( txt ); @@ -131,7 +129,6 @@ void LSysMenuQuick::brightSliderChanged(){ void LSysMenuQuick::setCurrentBrightness(){ int val = ui->slider_brightness->value(); LOS::setScreenBrightness(val); - settings->setValue("screenbrightness",val); QString txt = QString::number(val)+"%"; if(val<100){ txt.prepend(" "); } //make sure no widget resizing ui->label_bright_text->setText( txt ); diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h index 816eb009..a9580cce 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h @@ -31,7 +31,6 @@ public: private: Ui::LSysMenuQuick *ui; - QSettings *settings; QTimer *brighttimer; QString getRemainingTime(); //battery time left |