From 13f244c54d69fdb857ccd317a16d2cdf0bc80c09 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 26 Sep 2016 09:49:04 -0400 Subject: Make sure that the extra lumina utilities check/set the XDG_* environment variables as needed. This allows things like icons to be found/used when LTE is launched via sudo (for instance). --- src-qt5/core/libLumina/LuminaThemes.cpp | 4 + src-qt5/core/libLumina/LuminaUtils.cpp | 1 + src-qt5/core/libLumina/LuminaXDG.cpp | 336 -------------------------------- 3 files changed, 5 insertions(+), 336 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/core/libLumina/LuminaThemes.cpp b/src-qt5/core/libLumina/LuminaThemes.cpp index b6c18cf0..03dfb771 100644 --- a/src-qt5/core/libLumina/LuminaThemes.cpp +++ b/src-qt5/core/libLumina/LuminaThemes.cpp @@ -15,6 +15,8 @@ #include #include +#include "LuminaXDG.h" + #include //Stuff necesary for Qt Cursor Reloads @@ -292,6 +294,8 @@ QStringList LTHEME::CustomEnvSettings(bool useronly){ //view all the key=value s } void LTHEME::LoadCustomEnvSettings(){ + //Also ensure that the normal XDG_* environment variables are setup (will not overwrite them if already there) + LXDG::setEnvironmentVars(); //will push the custom settings into the environment (recommended before loading the initial QApplication) QStringList info = LTHEME::CustomEnvSettings(false); //all settings if(info.isEmpty()){ diff --git a/src-qt5/core/libLumina/LuminaUtils.cpp b/src-qt5/core/libLumina/LuminaUtils.cpp index dd4c75c4..8a35be6b 100644 --- a/src-qt5/core/libLumina/LuminaUtils.cpp +++ b/src-qt5/core/libLumina/LuminaUtils.cpp @@ -214,6 +214,7 @@ QString LUtils::PathToAbsolute(QString path){ } return path; } + QString LUtils::AppToAbsolute(QString path){ if(path.startsWith("~/")){ path = path.replace("~/", QDir::homePath()+"/" ); } if(path.startsWith("/") || QFile::exists(path)){ return path; } diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index 96f77ff9..790b386e 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -586,287 +586,6 @@ bool LFileInfo::isAVFile(){ //==== LXDG Functions ==== -/*XDGDesktop *LXDG::loadDesktopFile(QString filePath, bool& ok, QObject *parent){ - //Create the outputs - ok=false; - XDGDesktop *DF = new XDGDesktop(parent); - DF->isHidden=false; - DF->useTerminal=false; - DF->startupNotify=false; - DF->type = XDGDesktop::APP; - DF->filePath = filePath; - DF->lastRead = QDateTime::currentDateTime(); - DF->exec = DF->tryexec = ""; // just to make sure this is initialized - - //Get the current localization code - QString lang = QLocale::system().name(); //lang code - QString slang = lang.section("_",0,0); //short lang code - - //Read in the File - bool insection=false; - bool inaction=false; - QStringList file = LUtils::readFile(filePath); - if(file.isEmpty()){ return DF; } - //if(filePath.contains("pcbsd")){ qDebug() << "Check File:" << filePath << lang << slang; } - XDGDesktopAction CDA; //current desktop action - for(int i=0; iactions << CDA; CDA = XDGDesktopAction(); } - }else if(line.startsWith("[")){ insection=false; inaction = false; } - //Now check if this is the beginning of a section - if(line=="[Desktop Entry]"){ insection=true; continue; } - else if(line.startsWith("[Desktop Action ")){ - //Grab the ID of the action out of the label - CDA.ID = line.section("]",0,0).section("Desktop Action",1,1).simplified(); - inaction = true; - continue; - }else if( (!insection && !inaction) || line.startsWith("#")){ continue; } - //Now parse out the file - line = line.simplified(); - QString var = line.section("=",0,0).simplified(); - QString loc = var.section("[",1,1).section("]",0,0).simplified(); // localization - var = var.section("[",0,0).simplified(); //remove the localization - QString val = line.section("=",1,50).simplified(); - //------------------- - if(var=="Name"){ - if(insection){ - if(DF->name.isEmpty() && loc.isEmpty()){ DF->name = val; } - else if(DF->name.isEmpty() && loc==slang){ DF->name = val; } //short locale code - else if(loc == lang){ DF->name = val; } - }else if(inaction){ - if(CDA.name.isEmpty() && loc.isEmpty()){ CDA.name = val; } - else if(CDA.name.isEmpty() && loc==slang){ CDA.name = val; } //short locale code - else if(loc == lang){ CDA.name = val; } - } - //hasName = true; - }else if(var=="GenericName" && insection){ - if(DF->genericName.isEmpty() && loc.isEmpty()){ DF->genericName = val; } - else if(DF->genericName.isEmpty() && loc==slang){ DF->genericName = val; } //short locale code - else if(loc == lang){ DF->genericName = val; } - }else if(var=="Comment" && insection){ - if(DF->comment.isEmpty() && loc.isEmpty()){ DF->comment = val; } - else if(DF->comment.isEmpty() && loc==slang){ DF->comment = val; } //short locale code - else if(loc == lang){ DF->comment = val; } - }else if(var=="Icon"){ - if(insection){ - if(DF->icon.isEmpty() && loc.isEmpty()){ DF->icon = val; } - else if(DF->icon.isEmpty() && loc==slang){ DF->icon = val; } //short locale code - else if(loc == lang){ DF->icon = val; } - }else if(inaction){ - if(CDA.icon.isEmpty() && loc.isEmpty()){ CDA.icon = val; } - else if(CDA.icon.isEmpty() && loc==slang){ CDA.icon = val; } //short locale code - else if(loc == lang){ CDA.icon = val; } - } - } - else if( (var=="TryExec") && (DF->tryexec.isEmpty()) && insection) { DF->tryexec = val; } - else if(var=="Exec"){ - if(insection && DF->exec.isEmpty() ){ DF->exec = val; } - else if(inaction && CDA.exec.isEmpty() ){ CDA.exec = val; } - } - else if( (var=="Path") && (DF->path.isEmpty() ) && insection){ DF->path = val; } - else if(var=="NoDisplay" && !DF->isHidden && insection){ DF->isHidden = (val.toLower()=="true"); } - else if(var=="Hidden" && !DF->isHidden && insection){ DF->isHidden = (val.toLower()=="true"); } - else if(var=="Categories" && insection){ DF->catList = val.split(";",QString::SkipEmptyParts); } - else if(var=="OnlyShowIn" && insection){ DF->showInList = val.split(";",QString::SkipEmptyParts); } - else if(var=="NotShowIn" && insection){ DF->notShowInList = val.split(";",QString::SkipEmptyParts); } - else if(var=="Terminal" && insection){ DF->useTerminal= (val.toLower()=="true"); } - else if(var=="Actions" && insection){ DF->actionList = val.split(";",QString::SkipEmptyParts); } - else if(var=="MimeType" && insection){ DF->mimeList = val.split(";",QString::SkipEmptyParts); } - else if(var=="Keywords" && insection){ - if(DF->keyList.isEmpty() && loc.isEmpty()){ DF->keyList = val.split(";",QString::SkipEmptyParts); } - else if(loc == lang){ DF->keyList = val.split(";",QString::SkipEmptyParts); } - } - else if(var=="StartupNotify" && insection){ DF->startupNotify = (val.toLower()=="true"); } - else if(var=="StartupWMClass" && insection){ DF->startupWM = val; } - else if(var=="URL" && insection){ DF->url = val;} - else if(var=="Type" && insection){ - if(val.toLower()=="application"){ DF->type = XDGDesktop::APP; } - else if(val.toLower()=="link"){ DF->type = XDGDesktop::LINK; } - else if(val.toLower()=="dir"){ DF->type = XDGDesktop::DIR; } - else{ DF->type = XDGDesktop::BAD; } //Unknown type - //hasType = true; - } - } //end reading file - file.clear(); //done with contents of file - //If there are OnlyShowIn desktops listed, add them to the name - if( !DF->showInList.isEmpty() && !DF->showInList.contains("Lumina", Qt::CaseInsensitive) ){ - DF->name.append(" ("+DF->showInList.join(", ")+")"); - } - //Quick fix for showing "wine" applications (which quite often don't list a category, or have other differences) - if(DF->catList.isEmpty() && filePath.contains("/wine/")){ - DF->catList << "Wine"; //Internal Lumina category only (not in XDG specs as of 11/14/14) - //Also add a fix for the location of Wine icons - if( !DF->icon.isEmpty() ){ - QStringList sizes; sizes << "256x256" << "128x128" << "64x64" << "48x48" << "32x32" << "16x16"; - QString upath = QDir::homePath()+"/.local/share/icons/hicolor/%1/apps/%2.png"; - //qDebug() << "Wine App: Check icon" << upath; - for(int i=0; iicon)) ){ - DF->icon = upath.arg(sizes[i],DF->icon); - //qDebug() << " - Found Icon:" << DF->icon; - break; - } - } - } - } - //Return the structure - ok = true; //was able to open/read the file - validity determined later - return DF; -}*/ - -/*bool LXDG::saveDesktopFile(XDGDesktop dFile, bool merge){ - qDebug() << "Save Desktop File:" << dFile.filePath << "Merge:" << merge; - bool autofile = dFile.filePath.contains("/autostart/"); //use the "Hidden" field instead of the "NoDisplay" - int insertloc = -1; - QStringList info; - if(QFile::exists(dFile.filePath) && merge){ - //Load the existing file and merge in in any changes - info = LUtils::readFile(dFile.filePath); - //set a couple flags based on the contents before we start iterating through - // - determine if a translated field was changed (need to remove all the now-invalid translations) - bool clearName, clearComment, clearGName; - QString tmp = ""; - if(!info.filter("Name=").isEmpty()){ tmp = info.filter("Name=").first().section("=",1,50); } - clearName=(tmp!=dFile.name); - tmp.clear(); - if(!info.filter("Comment=").isEmpty()){ tmp = info.filter("Comment=").first().section("=",1,50); } - clearComment=(tmp!=dFile.comment); - tmp.clear(); - if(!info.filter("GenericName=").isEmpty()){ tmp = info.filter("GenericName=").first().section("=",1,50); } - clearGName=(tmp!=dFile.genericName); - //Now start iterating through the file and changing fields as necessary - bool insection = false; - for(int i=0; i