aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/LSession.cpp
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2018-04-27 13:43:29 -0400
committerZackaryWelch <welch.zackary@gmail.com>2018-04-27 13:43:29 -0400
commit0793bddd026d7b2e9bfcf6e33ad76674adb89fce (patch)
treec740c7e24827b07db81e1373ffe882f7801f231a /src-qt5/core/lumina-desktop/LSession.cpp
parentMerge branch 'master' of http://github.com/trueos/lumina (diff)
parentMake sure the libreoffice icons are no longer bypassed. Use the ones in the c... (diff)
downloadlumina-0793bddd026d7b2e9bfcf6e33ad76674adb89fce.tar.gz
lumina-0793bddd026d7b2e9bfcf6e33ad76674adb89fce.tar.bz2
lumina-0793bddd026d7b2e9bfcf6e33ad76674adb89fce.zip
Merge branch 'master' of http://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/core/lumina-desktop/LSession.cpp')
-rw-r--r--src-qt5/core/lumina-desktop/LSession.cpp66
1 files changed, 63 insertions, 3 deletions
diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp
index fe399e40..1e686e51 100644
--- a/src-qt5/core/lumina-desktop/LSession.cpp
+++ b/src-qt5/core/lumina-desktop/LSession.cpp
@@ -95,6 +95,64 @@ LSession::~LSession(){
}
}
+//Static function so everything can get the same icon name
+QString LSession::batteryIconName(int charge, bool charging){
+ int icon = -1;
+ if (charge > 90) { icon = 4; }
+ else if (charge > 70) { icon = 3; }
+ else if (charge > 20) { icon = 2; }
+ else if (charge > 5) { icon = 1; }
+ else if (charge > 0 ) { icon = 0; }
+ if(charging){ icon = icon+10; }
+ QStringList iconList;
+ switch (icon) {
+ case 0:
+ iconList << "battery-20" << "battery-020" << "battery-empty" << "battery-caution";
+ break;
+ case 1:
+ iconList << "battery-40" << "battery-040" << "battery-low" << "battery-caution";
+ break;
+ case 2:
+ iconList << "battery-60" << "battery-060" << "battery-good";
+ break;
+ case 3:
+ iconList << "battery-80" << "battery-080" << "battery-good";
+ break;
+ case 4:
+ iconList << "battery-100" << "battery-full";
+ break;
+ case 10:
+ iconList << "battery-20-charging" << "battery-020-charging" << "battery-empty-charging" << "battery-caution-charging"
+ << "battery-charging-20" << "battery-charging-020" << "battery-charging-empty" << "battery-charging-caution";
+ break;
+ case 11:
+ iconList << "battery-40-charging" << "battery-040-charging" << "battery-low-charging" << "battery-caution-charging"
+ << "battery-charging-40" << "battery-charging-040" << "battery-charging-low" << "battery-charging-caution";
+ break;
+ case 12:
+ iconList << "battery-60-charging" << "battery-060-charging" << "battery-good-charging"
+ << "battery-charging-60" << "battery-charging-060" << "battery-charging-good";
+ break;
+ case 13:
+ iconList << "battery-80-charging" << "battery-080-charging" << "battery-good-charging"
+ << "battery-charging-80" << "battery-charging-080" << "battery-charging-good";
+ break;
+ case 14:
+ if(charge==100){ iconList << "battery-full-charged"; }
+ iconList << "battery-100-charging" << "battery-full-charging"
+ << "battery-charging-100" << "battery-charging-full";
+ break;
+ default:
+ iconList << "battery-unknown" << "battery-missing";
+ break;
+ }
+ iconList << "battery"; //generic battery icon
+ for(int i=0; i<iconList.length(); i++){
+ if( QIcon::hasThemeIcon(iconList[i]) ){ return iconList[i]; }
+ }
+ return ""; //no icon found
+}
+
void LSession::setupSession(){
//Seed random number generator (if needed)
qsrand( QTime::currentTime().msec() );
@@ -205,7 +263,8 @@ void LSession::CleanupSession(){
if(vol>=0){ sessionsettings->setValue("last_session_state/audio_volume", vol); }
bool playaudio = sessionsettings->value("PlayLogoutAudio",true).toBool();
if( playaudio ){
- QString sfile = sessionsettings->value("audiofiles/logout", LOS::LuminaShare()+"Logout.ogg").toString();
+ QString sfile = sessionsettings->value("audiofiles/logout", "").toString();
+ if(sfile.isEmpty() || !QFile::exists(sfile)){ sfile = LOS::LuminaShare()+"Logout.ogg"; }
playAudioFile(sfile);
}
//Stop the background system tray (detaching/closing apps as necessary)
@@ -242,7 +301,7 @@ void LSession::CleanupSession(){
// this will leave the wallpapers up for a few moments (preventing black screens)
}
//Now wait a moment for things to close down before quitting
- if(playaudio){
+ if(playaudio && mediaObj!=0){
//wait a max of 5 seconds for audio to finish
bool waitmore = true;
for(int i=0; i<100 && waitmore; i++){
@@ -312,7 +371,8 @@ void LSession::launchStartupApps(){
//Now play the login music since we are finished
if(sessionsettings->value("PlayStartupAudio",true).toBool()){
- QString sfile = sessionsettings->value("audiofiles/login", LOS::LuminaShare()+"Login.ogg").toString();
+ QString sfile = sessionsettings->value("audiofiles/login", "").toString();
+ if(sfile.isEmpty() || !QFile::exists(sfile)){ sfile = LOS::LuminaShare()+"Login.ogg"; }
playAudioFile(sfile);
}
//qDebug() << "[DESKTOP INIT FINISHED]";
bgstack15