From 7e9f1d3dfd195089de336274721726a43b88e4e9 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 23 Aug 2016 20:35:38 -0400 Subject: Fix up the auto-creation/removal of application symlinks when apps are installed/removed during a session. --- src-qt5/core/libLumina/LuminaXDG.cpp | 9 +++++++-- src-qt5/core/libLumina/LuminaXDG.h | 2 ++ src-qt5/core/lumina-desktop/AppMenu.cpp | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index a714aa83..fc346f34 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -8,6 +8,7 @@ #include "LuminaOS.h" #include "LuminaUtils.h" #include +#include #include #include @@ -18,8 +19,8 @@ static qint64 mimechecktime; XDGDesktopList::XDGDesktopList(QObject *parent, bool watchdirs) : QObject(parent){ if(watchdirs){ watcher = new QFileSystemWatcher(this); - connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(updateList()) ); - connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(updateList()) ); + connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(watcherChanged()) ); + connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(watcherChanged()) ); }else{ watcher = 0; } @@ -29,6 +30,9 @@ XDGDesktopList::~XDGDesktopList(){ //nothing special to do here } +void XDGDesktopList::watcherChanged(){ + QTimer::singleShot(1000, this, SLOT(updateList()) ); //1 second delay before check kicks off +} void XDGDesktopList::updateList(){ //run the check routine QStringList appDirs = LXDG::systemApplicationDirs(); //get all system directories @@ -70,6 +74,7 @@ void XDGDesktopList::updateList(){ } //If this class is automatically managing the lists, update the watched files/dirs and send out notifications if(watcher!=0){ + qDebug() << "App List Updated:" << lastCheck << appschanged << newfiles << oldkeys; watcher->removePaths(QStringList() << watcher->files() << watcher->directories()); watcher->addPaths(appDirs); if(appschanged){ emit appsUpdated(); } diff --git a/src-qt5/core/libLumina/LuminaXDG.h b/src-qt5/core/libLumina/LuminaXDG.h index 887aa920..5765b2b1 100644 --- a/src-qt5/core/libLumina/LuminaXDG.h +++ b/src-qt5/core/libLumina/LuminaXDG.h @@ -92,6 +92,8 @@ public slots: private: QFileSystemWatcher *watcher; +private slots: + void watcherChanged(); signals: void appsUpdated(); }; diff --git a/src-qt5/core/lumina-desktop/AppMenu.cpp b/src-qt5/core/lumina-desktop/AppMenu.cpp index b239610a..cbf71e62 100644 --- a/src-qt5/core/lumina-desktop/AppMenu.cpp +++ b/src-qt5/core/lumina-desktop/AppMenu.cpp @@ -56,10 +56,13 @@ void AppMenu::updateAppList(){ //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); } + if( QFileInfo(desktop+filename).isSymLink() ){ QFile::remove(desktop+filename); } } tmp = sysApps->newApps; for(int i=0; ifiles.value(tmp[i]); + if(desk.isHidden || !LXDG::checkValidity(desk, false) ){ continue; } //skip this one + //qDebug() << "New App: " << tmp[i] << desk.filePath << "Hidden:" << desk.isHidden; //Create a new symlink for this file if one does not exist QString filename = tmp[i].section("/",-1); //qDebug() << "Check for symlink:" << filename; -- cgit