diff options
author | Kris Moore <kris@pcbsd.org> | 2014-09-04 11:42:13 -0400 |
---|---|---|
committer | Kris Moore <kris@pcbsd.org> | 2014-09-04 11:42:13 -0400 |
commit | 71737f70949bd25f9aa8bc4e7d03039ba83c6cb1 (patch) | |
tree | ab29e864d1ae59d10cc6875af9541e3ad306b2fb /lumina-fm/MimeIconProvider.h | |
parent | Initial commit (diff) | |
download | lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.gz lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.bz2 lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.zip |
Initial import of the lumina code from pcbsd git repo
Diffstat (limited to 'lumina-fm/MimeIconProvider.h')
-rw-r--r-- | lumina-fm/MimeIconProvider.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lumina-fm/MimeIconProvider.h b/lumina-fm/MimeIconProvider.h new file mode 100644 index 00000000..7f330820 --- /dev/null +++ b/lumina-fm/MimeIconProvider.h @@ -0,0 +1,54 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the Icon provider for files based on mime types +//=========================================== +#ifndef _LUMINA_FILE_MANAGER_ICON_PROVIDER_H +#define _LUMINA_FILE_MANAGER_ICON_PROVIDER_H + +#include <QFileIconProvider> +#include <QIcon> +#include <QString> +#include <QFileInfo> + +#include <LuminaXDG.h> + +class MimeIconProvider : public QFileIconProvider{ + +public: + MimeIconProvider() : QFileIconProvider(){ + } + ~MimeIconProvider(){} + + QIcon icon(const QFileInfo &info) const{ + if(info.isDir()){ + return LXDG::findIcon("folder",""); + }else if(info.isFile()){ + if(info.suffix()=="png" || info.suffix()=="jpg"){ + return QIcon(info.absoluteFilePath()); + }else{ + return LXDG::findMimeIcon(info.suffix()); + } + }else{ + return LXDG::findIcon("unknown",""); + } + } + + QString type(const QFileInfo &info) const{ + if(info.isDir()){ + return QObject::tr("Directory"); + }else if(info.completeBaseName().isEmpty() || info.suffix().isEmpty() ){ + return QObject::tr("Unknown"); //hidden file without an extension + }else if(info.suffix()=="desktop"){ + return QObject::tr("Application"); + }else{ + return info.suffix().toUpper(); + } + } + +}; + +#endif
\ No newline at end of file |