aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-cpp/framework-OSInterface_private.cpp
diff options
context:
space:
mode:
authorq5sys <jt@xsystems.com>2017-12-12 23:04:25 -0500
committerq5sys <jt@xsystems.com>2017-12-12 23:04:25 -0500
commitf586583f69a6b54f7d9e40459c3df22405011e78 (patch)
treef413f2955dae26c1e9b0cc6505a80dad2f1b63d6 /src-qt5/src-cpp/framework-OSInterface_private.cpp
parentmake portlint happy (diff)
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-f586583f69a6b54f7d9e40459c3df22405011e78.tar.gz
lumina-f586583f69a6b54f7d9e40459c3df22405011e78.tar.bz2
lumina-f586583f69a6b54f7d9e40459c3df22405011e78.zip
Merge branch 'master' of http://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/src-cpp/framework-OSInterface_private.cpp')
-rw-r--r--src-qt5/src-cpp/framework-OSInterface_private.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp
index bd2d17b5..23db9a6c 100644
--- a/src-qt5/src-cpp/framework-OSInterface_private.cpp
+++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp
@@ -54,3 +54,39 @@ void OSInterface::connectNetman(){
connect(netman, SIGNAL(requestFinished(QNetworkReply*)), this, SLOT(netRequestFinished(QNetworkReply*)) );
connect(netman, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(netSslErrors(QNetworkReply*, const QList<QSslError>&)) );
}
+
+// External Media Management (if system uses *.desktop shortcuts)
+void OSInterface::setupMediaWatcher(){
+ //Create/connect the watcher if needed
+ if(watcher == 0){ watcher = new QFileSystemWatcher(); connectWatcher(); }
+ QStringList dirs = this->mediaDirectories();
+ if(dirs.isEmpty()){ return; } //nothing to do
+ //Make sure each directory is scanned **right now** (if it exists)
+ for(int i=0; i<dirs.length(); i++){
+ if(QFile::exists(dirs[i])){
+ handleMediaDirChange(dirs[i]);
+ }
+ }
+}
+
+bool OSInterface::handleMediaDirChange(QString dir){ //returns true if directory was handled
+ if( !this->mediaDirectories().contains(dir) ){ return false; } //not a media directory
+ QDir qdir(dir);
+ QStringList files = qdir.entryList(QStringList() << "*.desktop", QDir::Files, QDir::Name);
+ for(int i=0; i<files.length(); i++){ files[i] = qdir.absoluteFilePath(files[i]); }
+ QString key = "media_files/"+dir;
+ if(files.isEmpty() && INFO.contains(key)){ INFO.remove(key); emit mediaShortcutsChanged(); } //no files for this directory at the moment
+ else{ INFO.setValue("media_files/"+dir, files); emit mediaShortcutsChanged(); } //save these file paths for later
+ //Make sure the directory is still watched (sometimes the dir is removed/recreated on modification)
+ if(!watcher->directories().contains(dir)){ watcher->addPath(dir); }
+ return true;
+}
+
+QStringList OSInterface::autoHandledMediaFiles(){
+ QStringList files;
+ QStringList keys = INFO.keys().filter("media_files/");
+ for(int i=0; i<keys.length(); i++){
+ if(keys[i].startsWith("media_files/")){ files.append( INFO[keys[i]] ); }
+ }
+ return files;
+}
bgstack15