aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2018-08-22 18:10:20 -0400
committerKen Moore <moorekou@gmail.com>2018-08-22 18:10:20 -0400
commit4e30c44daf54e313024b1e2ce6e5bcc003cb7bac (patch)
tree1bd4292176c8ee56492a7dfd9135590fa404ce6e /src-qt5/core/libLumina
parentFix up the port template for lumina-pdf (diff)
downloadlumina-4e30c44daf54e313024b1e2ce6e5bcc003cb7bac.tar.gz
lumina-4e30c44daf54e313024b1e2ce6e5bcc003cb7bac.tar.bz2
lumina-4e30c44daf54e313024b1e2ce6e5bcc003cb7bac.zip
A few fixes for Lumina:
1. Adjust the pkg-plist for FreeBSD to include the trident-dark color file. 2. Add a new function for fetching XDG standard directory paths (and create dir as needed) 3. Setup the desktop and lib classes to use the XDG standard path function now. 4. Add a bunch of fallback icons if the "start-here-lumina" icon could not be found in the current theme. These are all based on the OS name. 5. Ensure we run "xdg-user-dirs-update" before launching the session (if it is installed). This is used for the main standard dir detection. 6. Ensure that start-lumina-desktop *always* starts a new desktop session (bypassing any existing lock files for the desktop session).
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r--src-qt5/core/libLumina/LDesktopUtils.cpp3
-rw-r--r--src-qt5/core/libLumina/LFileInfo.cpp15
-rw-r--r--src-qt5/core/libLumina/LUtils.cpp67
-rw-r--r--src-qt5/core/libLumina/LUtils.h6
-rw-r--r--src-qt5/core/libLumina/LuminaXDG.cpp13
5 files changed, 95 insertions, 9 deletions
diff --git a/src-qt5/core/libLumina/LDesktopUtils.cpp b/src-qt5/core/libLumina/LDesktopUtils.cpp
index fb44531a..fa272e8e 100644
--- a/src-qt5/core/libLumina/LDesktopUtils.cpp
+++ b/src-qt5/core/libLumina/LDesktopUtils.cpp
@@ -354,7 +354,8 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){
}
tmp = sysDefaults.filter("desktoplinks_");
- QString desktopFolder = QDir::homePath()+"/Desktop/"; //need to make this translatable and dynamic later
+ QString desktopFolder = LUtils::standardDirectory(LUtils::Desktop);
+ desktopFolder.append("/");
for(int i=0; i<tmp.length(); i++){
if(tmp[i].startsWith("#") || !tmp[i].contains("=") ){ continue; }
QString var = tmp[i].section("=",0,0).toLower().simplified();
diff --git a/src-qt5/core/libLumina/LFileInfo.cpp b/src-qt5/core/libLumina/LFileInfo.cpp
index d4e0cfde..8ca90979 100644
--- a/src-qt5/core/libLumina/LFileInfo.cpp
+++ b/src-qt5/core/libLumina/LFileInfo.cpp
@@ -35,19 +35,20 @@ void LFileInfo::loadExtraInfo(){
desk = 0;
c_uid = geteuid();
//Now load the extra information
- if(this->absoluteFilePath().startsWith("/net/") || this->isDir() ){
+ QString abspath = this->absoluteFilePath();
+ if( this->isDir() ){
mime = "inode/directory";
//Special directory icons
QString name = this->fileName().toLower();
- if(name=="desktop"){ iconList << "user-desktop"; }
+ if(name=="desktop" || abspath == LUtils::standardDirectory(LUtils::Desktop, false) ){ iconList << "user-desktop"; }
else if(name=="tmp"){ iconList << "folder-temp"; }
- else if(name=="video" || name=="videos"){ iconList << "folder-video" << "camera-photo-film" ; }
- else if(name=="music" || name=="audio"){ iconList << "folder-sound" << "media-playlist-audio"; }
+ else if(name=="video" || name=="videos" || abspath == LUtils::standardDirectory(LUtils::Videos, false)){ iconList << "folder-video" << "camera-photo-film" ; }
+ else if(name=="music" || name=="audio" || abspath == LUtils::standardDirectory(LUtils::Music, false)){ iconList << "folder-sound" << "media-playlist-audio"; }
else if(name=="projects" || name=="devel"){ iconList << "folder-development"; }
else if(name=="notes"){ iconList << "folder-txt" << "note-multiple-outline" << "note-multiple"; }
- else if(name=="downloads"){ iconList << "folder-downloads" << "folder-download"; }
- else if(name=="documents"){ iconList << "folder-documents"; }
- else if(name=="images" || name=="pictures"){ iconList << "folder-image"; }
+ else if(name=="downloads" || abspath == LUtils::standardDirectory(LUtils::Downloads, false)){ iconList << "folder-downloads" << "folder-download"; }
+ else if(name=="documents" || abspath == LUtils::standardDirectory(LUtils::Documents, false)){ iconList << "folder-documents"; }
+ else if(name=="images" || name=="pictures" || abspath == LUtils::standardDirectory(LUtils::Pictures, false)){ iconList << "folder-image"; }
else if(this->absoluteFilePath().startsWith("/net/")){ iconList << "folder-remote"; }
else if( !this->isReadable() ){ iconList << "folder-locked"<< "folder-lock"; }
iconList << "folder";
diff --git a/src-qt5/core/libLumina/LUtils.cpp b/src-qt5/core/libLumina/LUtils.cpp
index 6ca8b679..7ff64adc 100644
--- a/src-qt5/core/libLumina/LUtils.cpp
+++ b/src-qt5/core/libLumina/LUtils.cpp
@@ -43,6 +43,73 @@
//=============
// LUtils Functions
//=============
+
+//Return the path to one of the XDG standard directories
+QString LUtils::standardDirectory(StandardDir dir, bool createAsNeeded){
+// enum StandardDir {Desktop, Documents, Downloads, Music, Pictures, PublicShare, Templates, Videos}
+ QString var="XDG_%1_DIR";
+ QString defval="$HOME";
+ QString val;
+ switch (dir){
+ case Desktop:
+ var = var.arg("DESKTOP");
+ defval.append("/Desktop");
+ break;
+ case Documents:
+ var = var.arg("DOCUMENTS");
+ defval.append("/Documents");
+ break;
+ case Downloads:
+ var = var.arg("DOWNLOAD");
+ defval.append("/Downloads");
+ break;
+ case Music:
+ var = var.arg("MUSIC");
+ defval.append("/Music");
+ break;
+ case Pictures:
+ var = var.arg("PICTURES");
+ defval.append("/Pictures");
+ break;
+ case PublicShare:
+ var = var.arg("PUBLICSHARE");
+ break;
+ case Templates:
+ var = var.arg("TEMPLATES");
+ break;
+ case Videos:
+ var = var.arg("VIDEOS");
+ defval.append("/Videos");
+ break;
+ }
+ //Read the XDG user dirs file (if it exists)
+ QString configdir = getenv("XDG_DATA_HOME");
+ if(configdir.isEmpty()){ configdir = QDir::homePath()+"/.config"; }
+ QString conffile=configdir+"/user-dirs.dirs";
+ if(QFile::exists(conffile)){
+ static QStringList _contents;
+ static QDateTime _lastread;
+ if(_contents.isEmpty() || _lastread < QFileInfo(conffile).lastModified()){
+ _contents = LUtils::readFile(conffile);
+ _lastread = QDateTime::currentDateTime();
+ }
+ QStringList match = _contents.filter(var+"=");
+ if(!match.isEmpty()){
+ val = match.first().section("=",-1).simplified();
+ if(val.startsWith("\"")){ val = val.remove(0,1); }
+ if(val.endsWith("\"")){ val.chop(1); }
+ }
+ }
+ //Now check the value and return it
+ if(val.isEmpty()){ val = defval; }; //use the default value
+ val = val.replace("$HOME", QDir::homePath());
+ if(createAsNeeded && !QFile::exists(val) ){
+ QDir dir;
+ dir.mkpath(val);
+ }
+ return val;
+}
+
QString LUtils::runCommand(bool &success, QString command, QStringList arguments, QString workdir, QStringList env){
QProcess proc;
proc.setProcessChannelMode(QProcess::MergedChannels); //need output
diff --git a/src-qt5/core/libLumina/LUtils.h b/src-qt5/core/libLumina/LUtils.h
index ee04c023..f808f8c1 100644
--- a/src-qt5/core/libLumina/LUtils.h
+++ b/src-qt5/core/libLumina/LUtils.h
@@ -29,9 +29,13 @@
class LUtils{
public:
+ enum StandardDir {Desktop, Documents, Downloads, Music, Pictures, PublicShare, Templates, Videos};
+
+ //Return the path to one of the XDG standard directories
+ static QString standardDirectory(StandardDir dir, bool createAsNeeded = true);
//Run an external command and return output & exit code
- static QString runCommand(bool &success, QString command, QStringList arguments = QStringList(), QString workdir = "", QStringList env = QStringList());
+ static QString runCommand(bool &success, QString command, QStringList arguments = QStringList(), QString workdir = "", QStringList env = QStringList());
//Run an external command and return the exit code
static int runCmd(QString cmd, QStringList args = QStringList());
diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp
index 7b87cf37..7726eed3 100644
--- a/src-qt5/core/libLumina/LuminaXDG.cpp
+++ b/src-qt5/core/libLumina/LuminaXDG.cpp
@@ -859,6 +859,19 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){
//if(tmp.isNull()){ tmp = QIcon::fromTheme(fallback); }
}
if(!tmp.isNull() && tmp.name()==iconName){ return tmp; } //found this in the theme
+ else if(iconName=="start-here-lumina"){
+ //Additional fallback options for the OS-branded icon
+ QString osname = LOS::OSName().simplified().toLower();
+ QStringList possible; possible << "distributor-logo-"+osname << osname;
+ QStringList words;
+ if(osname.contains(" ")){ words = osname.split(" "); }
+ else if(osname.contains("-")){ words = osname.split("-"); }
+ for(int i=0; i<words.length(); i++){ possible << "distributor-logo-"+words[i] << words[i]; }
+ //qDebug() << "Looking for possible OS icons:" << possible;
+ for(int i=0; i<possible.length(); i++){
+ if(QIcon::hasThemeIcon(possible[i])){ return QIcon::fromTheme(possible[i]); }
+ }
+ }
if(!fallback.isEmpty() && QIcon::hasThemeIcon(fallback)){ tmp = QIcon::fromTheme(fallback); return tmp; } //found this in the theme
bgstack15