diff options
author | Ken Moore <ken@ixsystems.com> | 2017-01-12 09:01:36 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-01-12 09:01:36 -0500 |
commit | 9855075377ffc2d417855d574f7bce4d1b57d1ec (patch) | |
tree | 238746dca85ef958c8f6f923367b434c9e490de4 /src-qt5/core | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-9855075377ffc2d417855d574f7bce4d1b57d1ec.tar.gz lumina-9855075377ffc2d417855d574f7bce4d1b57d1ec.tar.bz2 lumina-9855075377ffc2d417855d574f7bce4d1b57d1ec.zip |
Add the ability to show "/media/*" shortcuts on the Lumina desktop. This will be very useful for systems that auto-create dirs in /media when devices are attached to the system, and mount-on-demand when browsing into that directory (*SPOILERS*).
Diffstat (limited to 'src-qt5/core')
4 files changed, 18 insertions, 1 deletions
diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp index de7d086e..d4ebaa7f 100644 --- a/src-qt5/core/lumina-desktop/LDesktop.cpp +++ b/src-qt5/core/lumina-desktop/LDesktop.cpp @@ -221,6 +221,7 @@ void LDesktop::InitDesktop(){ connect(QApplication::instance(), SIGNAL(DesktopConfigChanged()), this, SLOT(SettingsChanged()) ); connect(QApplication::instance(), SIGNAL(DesktopFilesChanged()), this, SLOT(UpdateDesktop()) ); + connect(QApplication::instance(), SIGNAL(MediaFilesChanged()), this, SLOT(UpdateDesktop()) ); connect(QApplication::instance(), SIGNAL(LocaleChanged()), this, SLOT(LocaleChanged()) ); connect(QApplication::instance(), SIGNAL(WorkspaceChanged()), this, SLOT(UpdateBackground()) ); //if(DEBUG){ qDebug() << "Create bgWindow"; } @@ -373,6 +374,13 @@ void LDesktop::UpdateDesktop(){ filelist << files[i].absoluteFilePath(); } } + //Also show anything available in the /media directory + QDir media("/media"); + QStringList mediadirs = media.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + for(int i=0; i<mediadirs.length(); i++){ + filelist << media.absoluteFilePath(mediadirs[i]); + } + qDebug() << "Found media Dirs:" << mediadirs; UpdateDesktopPluginArea(); bgDesktop->LoadItems(plugins, filelist); } diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index a4cc12a7..8143f260 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -159,6 +159,8 @@ void LSession::setupSession(){ //Try to watch the localized desktop folder too if(QFile::exists(QDir::homePath()+"/"+tr("Desktop"))){ watcherChange( QDir::homePath()+"/"+tr("Desktop") ); } watcherChange( QDir::homePath()+"/Desktop" ); + //And watch the /media directory + if(QFile::exists("/media")){ watcherChange("/media"); } //connect internal signals/slots connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherChange(QString)) ); @@ -339,6 +341,8 @@ void LSession::watcherChange(QString changed){ 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(); + }else if(changed.toLower() == "/media"){ + emit MediaFilesChanged(); }else if(changed.endsWith("favorites.list")){ emit FavoritesChanged(); } //Now ensure this file was not removed from the watcher if(!watcher->files().contains(changed) && !watcher->directories().contains(changed)){ diff --git a/src-qt5/core/lumina-desktop/LSession.h b/src-qt5/core/lumina-desktop/LSession.h index bd93289a..8f799cd0 100644 --- a/src-qt5/core/lumina-desktop/LSession.h +++ b/src-qt5/core/lumina-desktop/LSession.h @@ -186,6 +186,7 @@ signals: void SessionConfigChanged(); void FavoritesChanged(); void DesktopFilesChanged(); + void MediaFilesChanged(); void WorkspaceChanged(); }; diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 3be19faa..c8ecf2c8 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -58,7 +58,11 @@ void AppLauncherPlugin::loadButton(){ QFileInfo info(path); button->setWhatsThis(info.absoluteFilePath()); if(info.isDir()){ - button->setIcon( LXDG::findIcon("folder","") ); + if(path.startsWith("/media/")){ + //Could add device ID parsing here to determine what "type" of device it is - will be OS-specific though + button->setIcon( LXDG::findIcon("drive-removable-media","") ); + } + else{ button->setIcon( LXDG::findIcon("folder","") ); } }else if(LUtils::imageExtensions().contains(info.suffix().toLower()) ){ QPixmap pix; if(pix.load(path)){ button->setIcon( QIcon(pix.scaled(256,256)) ); } //max size for thumbnails in memory |