aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Shalygin <[email protected]>2017-05-07 16:21:11 +0200
committerMark Gaiser <[email protected]>2017-05-07 16:21:11 +0200
commit7a7dfffba98d383821c39ac68de6e8aabe45b7ed (patch)
tree026ea675bbc811639667f67f8994fe3acf7b1783
parent0a6be721e4e35b54c2fba6a59243eea3c5d912d4 (diff)
Implement QPlatformTheme::fileIconPixmap() to make QFileIconProvider work.
CCMAIL: [email protected] Differential Revision: https://phabricator.kde.org/D5538
-rw-r--r--src/platformtheme/kdeplatformtheme.cpp17
-rw-r--r--src/platformtheme/kdeplatformtheme.h10
2 files changed, 27 insertions, 0 deletions
diff --git a/src/platformtheme/kdeplatformtheme.cpp b/src/platformtheme/kdeplatformtheme.cpp
index 704f176..994e1f2 100644
--- a/src/platformtheme/kdeplatformtheme.cpp
+++ b/src/platformtheme/kdeplatformtheme.cpp
@@ -50,6 +50,7 @@
#include <KStandardGuiItem>
#include <KLocalizedString>
#include <KWindowSystem>
+#include <KIO/Global>
#if QT_VERSION >= QT_VERSION_CHECK(5,7,0)
#include "qdbusmenubar_p.h"
@@ -109,6 +110,22 @@ QVariant KdePlatformTheme::themeHint(QPlatformTheme::ThemeHint hintType) const
}
}
+QIcon KdePlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
+{
+ if (iconOptions.testFlag(DontUseCustomDirectoryIcons) && fileInfo.isDir()) {
+ return QIcon::fromTheme(QLatin1String("inode-directory"));
+ }
+
+ return QIcon::fromTheme(KIO::iconNameForUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())));
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
+QPixmap KdePlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, QPlatformTheme::IconOptions iconOptions) const
+{
+ return fileIcon(fileInfo, iconOptions).pixmap(size.toSize(), QIcon::Normal);
+}
+#endif
+
const QPalette *KdePlatformTheme::palette(Palette type) const
{
QPalette *palette = m_hints->palette(type);
diff --git a/src/platformtheme/kdeplatformtheme.h b/src/platformtheme/kdeplatformtheme.h
index 7835439..74f97ff 100644
--- a/src/platformtheme/kdeplatformtheme.h
+++ b/src/platformtheme/kdeplatformtheme.h
@@ -43,6 +43,16 @@ public:
~KdePlatformTheme();
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions iconOptions) const override;
+#else
+ QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
+ QPlatformTheme::IconOptions iconOptions) const override;
+ // this will be the implementation
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions iconOptions) const;
+#endif
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
QIconEngine *createIconEngine(const QString &iconName) const Q_DECL_OVERRIDE;