diff options
-rw-r--r-- | src-qt5/core/libLumina/LFileInfo.cpp | 109 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LFileInfo.h | 51 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.cpp | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.h | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.pri | 8 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/global-includes.h | 1 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/Globals.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fileinfo/MainUI.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 9 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/DirData.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.h | 1 |
12 files changed, 176 insertions, 15 deletions
diff --git a/src-qt5/core/libLumina/LFileInfo.cpp b/src-qt5/core/libLumina/LFileInfo.cpp new file mode 100644 index 00000000..f7a7fbe3 --- /dev/null +++ b/src-qt5/core/libLumina/LFileInfo.cpp @@ -0,0 +1,109 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2013-2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LFileInfo.h" +#include <LUtils.h> + +LFileInfo::LFileInfo() : QFileInfo(){ + desk = 0; +} + +LFileInfo::LFileInfo(QString filepath) : QFileInfo(){ //overloaded contructor + this->setFile(filepath); + loadExtraInfo(); +} + +LFileInfo::LFileInfo(QFileInfo info) : QFileInfo(){ //overloaded contructor + this->swap(info); //use the given QFileInfo without re-loading it + loadExtraInfo(); +} +LFileInfo::~LFileInfo(){ + if(desk!=0){ desk->deleteLater(); } +} + +//Need some extra information not usually available by a QFileInfo +void LFileInfo::loadExtraInfo(){ + if(desk!=0){ desk->deleteLater(); } + desk = 0; + //Now load the extra information + if(this->absoluteFilePath().startsWith("/net/") || this->isDir() ){ + mime = "inode/directory"; + //Special directory icons + QString name = this->fileName().toLower(); + if(name=="desktop"){ icon = "user-desktop"; } + else if(name=="tmp"){ icon = "folder-temp"; } + else if(name=="video" || name=="videos"){ icon = "folder-video"; } + else if(name=="music" || name=="audio"){ icon = "folder-sound"; } + else if(name=="projects" || name=="devel"){ icon = "folder-development"; } + else if(name=="notes"){ icon = "folder-txt"; } + else if(name=="downloads"){ icon = "folder-downloads"; } + else if(name=="documents"){ icon = "folder-documents"; } + else if(name=="images" || name=="pictures"){ icon = "folder-image"; } + else if(this->absoluteFilePath().startsWith("/net/")){ icon = "folder-shared"; } + else if( !this->isReadable() ){ icon = "folder-locked"; } + }else if( this->suffix()=="desktop"){ + mime = "application/x-desktop"; + icon = "application-x-desktop"; //default value + desk = new XDGDesktop(this->absoluteFilePath(), 0); + if(desk->type!=XDGDesktop::BAD){ + //use the specific desktop file info (if possible) + if(!desk->icon.isEmpty()){ icon = desk->icon; } + } + }else{ + //Generic file, just determine the mimetype + mime = LXDG::findAppMimeForFile(this->fileName()); + } +} + +//Functions for accessing the extra information +// -- Return the mimetype for the file +QString LFileInfo::mimetype(){ + if(mime=="inode/directory"){ return ""; } + else{ return mime; } +} + +// -- Return the icon to use for this file +QString LFileInfo::iconfile(){ + if(!icon.isEmpty()){ + return icon; + }else if(!mime.isEmpty()){ + QString tmp = mime; + tmp.replace("/","-"); + return tmp; + }else if(this->isExecutable()){ + return "application-x-executable"; + } + return ""; //Fall back to nothing +} + +// -- Check if this is an XDG desktop file +bool LFileInfo::isDesktopFile(){ + if(desk==0){ return false; } + return (!desk->filePath.isEmpty()); +} + +// -- Allow access to the XDG desktop data structure +XDGDesktop* LFileInfo::XDG(){ + return desk; +} + +// -- Check if this is a readable video file (for thumbnail support) +bool LFileInfo::isVideo(){ + if(!mime.startsWith("video/")){ return false; } + //Check the hardcoded list of known supported video formats to see if the thumbnail can be generated + return ( !LUtils::videoExtensions().filter(this->suffix().toLower()).isEmpty() ); +} + +// -- Check if this is a readable image file +bool LFileInfo::isImage(){ + if(!mime.startsWith("image/")){ return false; } //quick return for non-image files + //Check the Qt subsystems to see if this image file can be read + return ( !LUtils::imageExtensions().filter(this->suffix().toLower()).isEmpty() ); +} + +bool LFileInfo::isAVFile(){ + return (mime.startsWith("audio/") || mime.startsWith("video/") ); +} diff --git a/src-qt5/core/libLumina/LFileInfo.h b/src-qt5/core/libLumina/LFileInfo.h new file mode 100644 index 00000000..4fbf6353 --- /dev/null +++ b/src-qt5/core/libLumina/LFileInfo.h @@ -0,0 +1,51 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2013-2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// File Information simplification class (combine QFileInfo with XDGDesktop) +// Need some extra information not usually available by a QFileInfo +// ======================== +#ifndef _LUMINA_LIBRARY_FILE_INFO_H +#define _LUMINA_LIBRARY_FILE_INFO_H + +#include <LuminaXDG.h> +#include <QString> +#include <QFileInfo> + +class LFileInfo : public QFileInfo{ +private: + QString mime, icon; + XDGDesktop *desk; + + void loadExtraInfo(); + +public: + //Couple overloaded contructors + LFileInfo(); + LFileInfo(QString filepath); + LFileInfo(QFileInfo info); + ~LFileInfo(); + + //Functions for accessing the extra information + // -- Return the mimetype for the file + QString mimetype(); + + // -- Return the icon file to use for this file + QString iconfile(); //Note: This string is auto-formatted for use in the LXDG::findIcon() routine. + + // -- Check if this is an XDG desktop file + bool isDesktopFile(); + + // -- Allow access to the internal XDG desktop data structure + XDGDesktop* XDG(); + + //Other file type identification routines + bool isImage(); //Is a readable image file (for thumbnail support) + bool isVideo(); //Is a readable video file (for thumbnail support) + bool isAVFile(); //Is an audio/video file +}; +typedef QList<LFileInfo> LFileInfoList; + +#endif diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index cf9e0af2..1991a82d 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -629,7 +629,7 @@ void XDGDesktopList::populateMenu(QMenu *topmenu, bool byCategory){ //==== LFileInfo Functions ==== //Need some extra information not usually available by a QFileInfo -void LFileInfo::loadExtraInfo(){ +/*void LFileInfo::loadExtraInfo(){ desk = 0; //Now load the extra information if( this->suffix().isEmpty() && (this->absoluteFilePath().startsWith("/net/") || this->isDir()) ){ @@ -722,7 +722,7 @@ bool LFileInfo::isImage(){ bool LFileInfo::isAVFile(){ return (mime.startsWith("audio/") || mime.startsWith("video/") ); -} +}*/ //==== LXDG Functions ==== diff --git a/src-qt5/core/libLumina/LuminaXDG.h b/src-qt5/core/libLumina/LuminaXDG.h index 0f7e7c48..066f0462 100644 --- a/src-qt5/core/libLumina/LuminaXDG.h +++ b/src-qt5/core/libLumina/LuminaXDG.h @@ -128,7 +128,7 @@ signals: // File Information simplification class (combine QFileInfo with XDGDesktop) // Need some extra information not usually available by a QFileInfo // ======================== -class LFileInfo : public QFileInfo{ +/*class LFileInfo : public QFileInfo{ private: QString mime, icon; XDGDesktop *desk; @@ -162,7 +162,7 @@ public: bool isVideo(); //Is a readable video file (for thumbnail support) bool isAVFile(); //Is an audio/video file }; -typedef QList<LFileInfo> LFileInfoList; +typedef QList<LFileInfo> LFileInfoList;*/ // ================================ // Collection of FreeDesktop standards interaction routines diff --git a/src-qt5/core/libLumina/LuminaXDG.pri b/src-qt5/core/libLumina/LuminaXDG.pri index 6f3a2b7c..1a8a8368 100644 --- a/src-qt5/core/libLumina/LuminaXDG.pri +++ b/src-qt5/core/libLumina/LuminaXDG.pri @@ -1,10 +1,12 @@ QT *= multimedia svg #LUtils Files -SOURCES *= $${PWD}/LuminaXDG.cpp -HEADERS *= $${PWD}/LuminaXDG.h +SOURCES *= $${PWD}/LuminaXDG.cpp \ + $${PWD}/LFileInfo.cpp +HEADERS *= $${PWD}/LuminaXDG.h \ + $${PWD}/LFileInfo.h -INCLUDEPATH *= ${PWD} +INCLUDEPATH *= $${PWD} #include LUtils and LuminaOS include(LUtils.pri) diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h index 91604362..40987ad4 100644 --- a/src-qt5/core/lumina-desktop-unified/global-includes.h +++ b/src-qt5/core/lumina-desktop-unified/global-includes.h @@ -78,6 +78,7 @@ #include <NativeEventFilter.h> #include <XDGMime.h> #include <LIconCache.h> +#include <LFileInfo.h> //Setup any global defines (no classes or global objects: use "global-objects.h" for that) diff --git a/src-qt5/core/lumina-desktop/Globals.h b/src-qt5/core/lumina-desktop/Globals.h index 15e7a4b6..43ea3a87 100644 --- a/src-qt5/core/lumina-desktop/Globals.h +++ b/src-qt5/core/lumina-desktop/Globals.h @@ -11,6 +11,7 @@ #include <LuminaXDG.h> #include <LuminaOS.h> #include <LDesktopUtils.h> +#include <LFileInfo.h> #include <QWidgetAction> #include <QMenu> diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h index d7b17207..3990f643 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h +++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h @@ -17,6 +17,7 @@ #include <QMediaPlayer> #include <LVideoSurface.h> #include <LVideoLabel.h> +#include <LFileInfo.h> #include <QElapsedTimer> #include <QFuture> diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 0f4a0abe..db2bbcb4 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -19,14 +19,7 @@ #include <LVideoSurface.h> #include <LVideoLabel.h> #include <LuminaXDG.h> -/*class FileItem{ -public: - QString name; - QByteArray icon; - - FileItem(){} - ~FileItem(){}; -};*/ +#include <LFileInfo.h> class Browser : public QObject{ Q_OBJECT diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h index b17ad588..b88d8d2e 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -13,6 +13,7 @@ #include <QThread> #include <LVideoWidget.h> +#include <LFileInfo.h> #include "Browser.h" #include "widgets/DDListWidgets.h" diff --git a/src-qt5/desktop-utils/lumina-fm/DirData.h b/src-qt5/desktop-utils/lumina-fm/DirData.h index 528a82d6..3ef65299 100644 --- a/src-qt5/desktop-utils/lumina-fm/DirData.h +++ b/src-qt5/desktop-utils/lumina-fm/DirData.h @@ -17,6 +17,7 @@ #include <LuminaXDG.h> #include <LUtils.h> +#include <LFileInfo.h> #define ZSNAPDIR QString("/.zfs/snapshot/") diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.h b/src-qt5/desktop-utils/lumina-fm/MainUI.h index 04b80f28..b17ec690 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.h +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.h @@ -47,6 +47,7 @@ // libLumina includes #include <LuminaXDG.h> #include <LuminaOS.h> +#include <LFileInfo.h> // Local includes //#include "FODialog.h" //file operation dialog |