diff options
author | Ken Moore <moorekou@gmail.com> | 2016-08-18 13:48:50 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-08-18 13:48:50 -0400 |
commit | f48e3c027fad213ede48896d808d4facb089acd6 (patch) | |
tree | ab9c46416b550620c232342df075c82f367baf3a /src-qt5 | |
parent | Setup the desktop to use the new XDGDesktopList directly (disables a lot of t... (diff) | |
download | lumina-f48e3c027fad213ede48896d808d4facb089acd6.tar.gz lumina-f48e3c027fad213ede48896d808d4facb089acd6.tar.bz2 lumina-f48e3c027fad213ede48896d808d4facb089acd6.zip |
Add the ability for Lumina to automatically add/remove symlinks from the ~/Desktop for applications that are installed/removed while the user session is active.
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/lumina-desktop/AppMenu.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/AppMenu.cpp b/src-qt5/core/lumina-desktop/AppMenu.cpp index f1b16daa..b239610a 100644 --- a/src-qt5/core/lumina-desktop/AppMenu.cpp +++ b/src-qt5/core/lumina-desktop/AppMenu.cpp @@ -40,6 +40,32 @@ void AppMenu::updateAppList(){ this->clear(); APPS.clear(); XDGDesktopList *sysApps = LXDG:: systemAppsList(); + //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(); } + } + } + //qDebug() << "Update Desktop Folder:" << desktop << sysApps->removedApps << sysApps->newApps; + QStringList tmp = sysApps->removedApps; + for(int i=0; i<tmp.length() && !desktop.isEmpty(); i++){ + //Remove any old symlinks first + QString filename = tmp[i].section("/",-1); + //qDebug() << "Check for symlink:" << filename; + if(QFile::exists(desktop+filename) && QFileInfo(desktop+filename).isSymLink() ){ QFile::remove(desktop+filename); } + } + tmp = sysApps->newApps; + for(int i=0; i<tmp.length() && !desktop.isEmpty(); i++){ + //Create a new symlink for this file if one does not exist + QString filename = tmp[i].section("/",-1); + //qDebug() << "Check for symlink:" << filename; + if(!QFile::exists(desktop+filename) ){ QFile::link(tmp[i], desktop+filename); } + } + } QList<XDGDesktop> allfiles = sysApps->apps(false,false); //only valid, non-hidden apps APPS = LXDG::sortDesktopCats(allfiles); APPS.insert("All", LXDG::sortDesktopNames(allfiles)); |