aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LDesktopUtils.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2018-01-02 22:18:34 +0000
committerWeblate <noreply@weblate.org>2018-01-02 22:18:34 +0000
commit4bf6d3f38634dbb517055444a22d824d6eba99d8 (patch)
treebbe3e3e511f37222cdd9db145bde2f41a35e1260 /src-qt5/core/libLumina/LDesktopUtils.cpp
parentTranslated using Weblate (Danish) (diff)
parentMerge remote-tracking branch 'origin/master' (diff)
downloadlumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.tar.gz
lumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.tar.bz2
lumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/libLumina/LDesktopUtils.cpp')
-rw-r--r--src-qt5/core/libLumina/LDesktopUtils.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/src-qt5/core/libLumina/LDesktopUtils.cpp b/src-qt5/core/libLumina/LDesktopUtils.cpp
index 69d4ba52..5595532a 100644
--- a/src-qt5/core/libLumina/LDesktopUtils.cpp
+++ b/src-qt5/core/libLumina/LDesktopUtils.cpp
@@ -13,10 +13,8 @@
#include "LuminaThemes.h"
-static QStringList fav;
-
QString LDesktopUtils::LuminaDesktopVersion(){
- QString ver = "1.4.0";
+ QString ver = "1.4.1";
#ifdef GIT_VERSION
ver.append( QString(" (Git Revision: %1)").arg(GIT_VERSION) );
#endif
@@ -80,22 +78,23 @@ QStringList LDesktopUtils::infoQuickPlugin(QString ID){ //Returns: [Name, Descri
}
QStringList LDesktopUtils::listFavorites(){
- static QDateTime lastRead;
- QDateTime cur = QDateTime::currentDateTime();
- if(lastRead.isNull() || lastRead<QFileInfo( QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/favorites.list").lastModified()){
+ //static QDateTime lastRead;
+ QStringList fav;
+ //QDateTime cur = QDateTime::currentDateTime();
+ //if(lastRead.isNull() || fav.isEmpty() || lastRead<QFileInfo( QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/favorites.list").lastModified()){
fav = LUtils::readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/favorites.list");
fav.removeAll(""); //remove any empty lines
fav.removeDuplicates();
- lastRead = cur;
- }
-
+ //lastRead = cur;
+ //}
return fav;
}
bool LDesktopUtils::saveFavorites(QStringList list){
list.removeDuplicates();
+ //qDebug() << "Save Favorites:" << list;
bool ok = LUtils::writeFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/favorites.list", list, true);
- if(ok){ fav = list; } //also save internally in case of rapid write/read of the file
+ //if(ok){ fav = list; } //also save internally in case of rapid write/read of the file
return ok;
}
@@ -116,11 +115,13 @@ bool LDesktopUtils::addFavorite(QString path, QString name){
else{ type = LXDG::findAppMimeForFile(path); }
//Assign a name if none given
if(name.isEmpty()){ name = info.fileName(); }
+ //qDebug() << "Add Favorite:" << path << type << name;
//Now add it to the list
QStringList favs = LDesktopUtils::listFavorites();
+ //qDebug() << "Current Favorites:" << favs;
bool found = false;
for(int i=0; i<favs.length(); i++){
- if(favs[i].endsWith("::::"+path)){ favs[i] = name+"::::"+type+"::::"+path; }
+ if(favs[i].endsWith("::::"+path)){ favs[i] = name+"::::"+type+"::::"+path; found = true; }
}
if(!found){ favs << name+"::::"+type+"::::"+path; }
return LDesktopUtils::saveFavorites(favs);
@@ -143,8 +144,15 @@ void LDesktopUtils::upgradeFavorites(int){ //fromoldversionnumber
void LDesktopUtils::LoadSystemDefaults(bool skipOS){
//Will create the Lumina configuration files based on the current system template (if any)
qDebug() << "Loading System Defaults";
+ //Ensure that the settings directory exists
+ QString setdir = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop";
+ if(!QFile::exists(setdir)){
+ QDir dir;
+ dir.mkpath(setdir);
+ }
+
bool skipmime = QFile::exists( QString(getenv("XDG_CONFIG_HOME"))+"/lumina-mimapps.list" );
- qDebug() << " - Skipping mimetype default apps" << skipmime;
+ //qDebug() << " - Skipping mimetype default apps" << skipmime;
QStringList sysDefaults;
if(!skipOS){ sysDefaults = LUtils::readFile(LOS::AppPrefix()+"etc/luminaDesktop.conf"); }
if(sysDefaults.isEmpty() && !skipOS){ sysDefaults = LUtils::readFile(LOS::AppPrefix()+"etc/luminaDesktop.conf.dist"); }
@@ -187,6 +195,8 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
if(var.endsWith("_ifexists") ){
var = var.remove("_ifexists"); //remove this flag from the variable
//Check if the value exists (absolute path only)
+ val = LUtils::AppToAbsolute(val);
+ //qDebug() << "Checking if favorite app exists:" << val;
if(!QFile::exists(val)){ continue; } //skip this line - value/file does not exist
}
@@ -231,20 +241,23 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
if(tmp[i].startsWith("#") || !tmp[i].contains("=") ){ continue; }
QString var = tmp[i].section("=",0,0).toLower().simplified();
QString val = tmp[i].section("=",1,1).section("#",0,0).simplified();
+ qDebug() << "Mime entry:" << var << val;
if(val.isEmpty()){ continue; }
QString istrue = (val.toLower()=="true") ? "true": "false";
//Change in 0.8.5 - use "_" instead of "." within variables names - need backwards compat for a little while
if(var.contains(".")){ var.replace(".","_"); }
//Now parse the variable and put the value in the proper file
- val = LUtils::AppToAbsolute(val);
//Special handling for values which need to exist first
if(var.endsWith("_ifexists") ){
var = var.remove("_ifexists"); //remove this flag from the variable
+ val = LUtils::AppToAbsolute(val);
+ //qDebug() << "Checking if Mime app exists:" << val;
//Check if the value exists (absolute path only)
if(!QFile::exists(val)){ continue; } //skip this line - value/file does not exist
}
//Now turn this variable into the mimetype only
var = var.section("_default_",1,-1);
+ //qDebug() << " - Set Default Mime:" << var << val;
LXDG::setDefaultAppForMime(var, val);
}
@@ -326,6 +339,7 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
tmp = sysDefaults.filter("favorites_");
if(tmp.isEmpty()){ tmp = sysDefaults.filter("favorites."); }
for(int i=0; i<tmp.length(); i++){
+ //qDebug() << "Found Favorite Entry:" << tmp[i];
if(tmp[i].startsWith("#") || !tmp[i].contains("=") ){ continue; }
QString var = tmp[i].section("=",0,0).toLower().simplified();
QString val = tmp[i].section("=",1,1).section("#",0,0).simplified();
@@ -334,7 +348,7 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
//Now parse the variable and put the value in the proper file
qDebug() << "Favorite entry:" << var << val;
val = LUtils::AppToAbsolute(val); //turn any relative files into absolute
- if(var=="favorites_add_ifexists" && QFile::exists(val)){ qDebug() << " - Exists/Adding:"; LDesktopUtils::addFavorite(val); }
+ if(var=="favorites_add_ifexists" && QFile::exists(val)){ qDebug() << " - Exists/Adding:" << val; LDesktopUtils::addFavorite(val); }
else if(var=="favorites_add"){ qDebug() << " - Adding:"; LDesktopUtils::addFavorite(val); }
else if(var=="favorites_remove"){ qDebug() << " - Removing:"; LDesktopUtils::removeFavorite(val); }
}
@@ -385,6 +399,7 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
if(var.contains(".")){ var.replace(".","_"); }
//Now parse the variable and put the value in the proper file
if(var=="theme_themefile"){ themesettings[0] = val; }
+ else if(var=="theme_styles"){ LTHEME::setCurrentStyles( val.split(",",QString::SkipEmptyParts) ); }
else if(var=="theme_colorfile"){ themesettings[1] = val; }
else if(var=="theme_iconset"){ themesettings[2] = val; }
else if(var=="theme_font"){ themesettings[3] = val; }
@@ -425,12 +440,6 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
}
//qDebug() << " - Final Theme Color:" << themesettings[1];
- //Ensure that the settings directory exists
- QString setdir = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop";
- if(!QFile::exists(setdir)){
- QDir dir;
- dir.mkpath(setdir);
- }
//Now save the settings files
if(setTheme){
LTHEME::setCurrentSettings( themesettings[0], themesettings[1], themesettings[2], themesettings[3], themesettings[4]);
@@ -538,7 +547,7 @@ bool LDesktopUtils::checkUserFiles(QString lastversion, QString currentversion){
newtheme.setValue("Interface/desktop_stylesheets", QStringList() << enginedir+"desktop_qss/Glass.qss");
}
newtheme.setValue("Appearance/style", "Fusion");
- newtheme.setValue("Interface/stylesheets", QStringList() << enginedir+"qss/tooltip-simple.qss" << enginedir+"qss/scrollbar-simple.qss" << enginedir+"qss/sliders-simple.qss");
+ newtheme.setValue("Interface/stylesheets", QStringList() << enginedir+"qss/tooltip-simple.qss" << enginedir+"qss/scrollbar-simple.qss" << enginedir+"qss/sliders-simple.qss" << enginedir+"qss/traynotification-simple.qss");
newtheme.sync(); //flush this to file right now
} //end check for theme file existance
}
@@ -569,7 +578,7 @@ bool LDesktopUtils::checkUserFiles(QString lastversion, QString currentversion){
}
int LDesktopUtils::VersionStringToNumber(QString version){
- version = version.section("-",0,0); //trim any extra labels off the end
+ version = version.section("_",0,0).section("-",0,0); //trim any extra labels off the end
int maj, mid, min; //major/middle/minor version numbers (<Major>.<Middle>.<Minor>)
maj = mid = min = 0;
bool ok = true;
bgstack15