diff options
Diffstat (limited to 'src-qt5/core')
-rw-r--r-- | src-qt5/core/libLumina/LDesktopUtils.cpp | 3 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LFileInfo.cpp | 15 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LUtils.cpp | 67 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LUtils.h | 6 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.cpp | 13 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/AppMenu.cpp | 10 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/LDesktop.cpp | 3 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/LSession.cpp | 7 | ||||
-rw-r--r-- | src-qt5/core/lumina-session/session.cpp | 8 |
9 files changed, 107 insertions, 25 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 diff --git a/src-qt5/core/lumina-desktop/AppMenu.cpp b/src-qt5/core/lumina-desktop/AppMenu.cpp index 9ad51c93..136636e9 100644 --- a/src-qt5/core/lumina-desktop/AppMenu.cpp +++ b/src-qt5/core/lumina-desktop/AppMenu.cpp @@ -45,14 +45,8 @@ void AppMenu::updateAppList(){ APPS.clear(); //NOTE: Don't delete these pointers - the pointers are managed by the sysApps class and these are just references to them //qDebug() << "New Apps List:"; if(LSession::handle()->sessionSettings()->value("AutomaticDesktopAppLinks",true).toBool() && !lastHashUpdate.isNull() ){ - QString desktop = QDir::homePath()+"/"+tr("Desktop")+"/"; //translated desktop folder - if(!QFile::exists(desktop)){ - desktop = QDir::homePath()+"/Desktop/"; //desktop folder - if(!QFile::exists(desktop)){ - desktop = QDir::homePath()+"/desktop/"; //lowercase desktop folder - if(!QFile::exists(desktop)){ desktop.clear(); } - } - } + QString desktop = LUtils::standardDirectory(LUtils::Desktop); + desktop.append("/"); //qDebug() << "Update Desktop Folder:" << desktop << sysApps->removedApps << sysApps->newApps; QStringList tmp = sysApps->removedApps; for(int i=0; i<tmp.length() && !desktop.isEmpty(); i++){ diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp index 4f0ce447..ad66e7ba 100644 --- a/src-qt5/core/lumina-desktop/LDesktop.cpp +++ b/src-qt5/core/lumina-desktop/LDesktop.cpp @@ -685,8 +685,7 @@ void LDesktop::PasteInDesktop(){ } } //Now go through and paste all the designated files - QString desktop = QDir::homePath()+"/"+tr("Desktop"); //translated form - if(!QFile::exists(desktop)){ desktop = QDir::homePath()+"/Desktop"; } //default/untranslated form + QString desktop = LUtils::standardDirectory(LUtils::Desktop); for(int i=0; i<files.length(); i++){ QString path = files[i].section("::::",1,-1); if(!QFile::exists(path)){ continue; } //does not exist any more - move on to next diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index 4a8a6794..7f7cc443 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -210,7 +210,7 @@ void LSession::setupSession(){ //Initialize the desktops splash.showScreen("desktop"); if(DEBUG){ qDebug() << " - Init Desktops:" << timer->elapsed();} - desktopFiles = QDir(QDir::homePath()+"/Desktop").entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDir::Name | QDir::IgnoreCase | QDir::DirsFirst); + desktopFiles = QDir(LUtils::standardDirectory(LUtils::Desktop)).entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDir::Name | QDir::IgnoreCase | QDir::DirsFirst); updateDesktops(); //if(DEBUG){ qDebug() << " - Process Events (6x):" << timer->elapsed();} //for(int i=0; i<6; i++){ LSession::processEvents(); } //Run through this a few times so the interface systems get up and running @@ -227,8 +227,7 @@ void LSession::setupSession(){ watcherChange( confdir+"/fluxbox-keys" ); watcherChange( confdir+"/favorites.list" ); //Try to watch the localized desktop folder too - if(QFile::exists(QDir::homePath()+"/"+tr("Desktop"))){ watcherChange( QDir::homePath()+"/"+tr("Desktop") ); } - watcherChange( QDir::homePath()+"/Desktop" ); + watcherChange( LUtils::standardDirectory(LUtils::Desktop) ); //And watch the /media directory, and /run/media/USERNAME directory if(QFile::exists("/media")){ watcherChange("/media"); } QString userMedia = QString("/run/media/%1").arg(QDir::homePath().split("/").takeLast()); @@ -419,7 +418,7 @@ void LSession::watcherChange(QString changed){ } emit SessionConfigChanged(); }else if(changed.endsWith("desktopsettings.conf") ){ emit DesktopConfigChanged(); } - else if(changed == QDir::homePath()+"/Desktop" || changed == QDir::homePath()+"/"+tr("Desktop") ){ + else if(changed == LUtils::standardDirectory(LUtils::Desktop) ){ desktopFiles = QDir(changed).entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs ,QDir::Name | QDir::IgnoreCase | QDir::DirsFirst); if(DEBUG){ qDebug() << "New Desktop Files:" << desktopFiles.length(); } emit DesktopFilesChanged(); diff --git a/src-qt5/core/lumina-session/session.cpp b/src-qt5/core/lumina-session/session.cpp index c4707626..7ecebdcc 100644 --- a/src-qt5/core/lumina-session/session.cpp +++ b/src-qt5/core/lumina-session/session.cpp @@ -141,6 +141,10 @@ void LSession::start(bool unified){ setenv("QT_QPA_PLATFORMTHEME","lthemeengine", true); setenv("QT_NO_GLIB", "1", 1); //Disable the glib event loop within Qt at runtime (performance hit + bugs) unsetenv("QT_AUTO_SCREEN_SCALE_FACTOR"); //need exact-pixel measurements (no fake scaling) + if(LUtils::isValidBinary("xdg-user-dirs-update")){ + //Make sure the XDG user directories are created as needed first + QProcess::execute("xdg-user-dirs-update"); + } if(!unified){ QSettings sessionsettings("lumina-desktop","sessionsettings"); @@ -181,13 +185,13 @@ void LSession::start(bool unified){ startProcess("wm", WM); } //Desktop Next - startProcess("runtime","lumina-desktop"); + startProcess("runtime","lumina-desktop -new-instance"); //ScreenSaver if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); } }else{ //unified process setupCompositor(true); //required for Lumina 2 - startProcess("runtime","lumina-desktop-unified"); + startProcess("runtime","lumina-desktop-unified -new-instance"); } } |