From 797d7aa72350ce2aee59c271b1c66a49e468e263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 10 Sep 2018 12:16:22 +0200 Subject: [PATCH] Control via themes when do we have to use native icons for folders. --- YACReaderLibrary/db/folder_model.cpp | 31 ++++++++++++++-------------- YACReaderLibrary/theme.h | 7 +++++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index a789c3b3..d1583c45 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -54,9 +54,10 @@ #include "db_helper.h" #include "qnaturalsorting.h" #include "yacreader_global_gui.h" +#include "theme.h" + #include "QsLog.h" -#ifdef Q_OS_MAC #include QIcon finishedFolderIcon; void drawMacOSXFinishedFolderIcon() @@ -92,7 +93,6 @@ void drawMacOSXFinishedFolderIcon() } finishedFolderIcon.addPixmap(pixSelectedOn, QIcon::Selected, QIcon::On); } -#endif #define ROOT 1 @@ -155,22 +155,23 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const } if (role == Qt::DecorationRole) { -#ifdef Q_OS_MAC - if (item->data(FolderModel::Finished).toBool()) { - if (finishedFolderIcon.isNull()) { - drawMacOSXFinishedFolderIcon(); - } + if (Theme::currentTheme().useNativeFolderIcons) { + if (item->data(FolderModel::Finished).toBool()) { + if (finishedFolderIcon.isNull()) { + drawMacOSXFinishedFolderIcon(); + } - return QVariant(finishedFolderIcon); + return QVariant(finishedFolderIcon); + } + else { + return QVariant(QFileIconProvider().icon(QFileIconProvider::Folder)); + } } else { - return QVariant(QFileIconProvider().icon(QFileIconProvider::Folder)); + if (item->data(FolderModel::Finished).toBool()) + return QVariant(YACReader::noHighlightedIcon(":/images/sidebar/folder_finished.png")); + else + return QVariant(YACReader::noHighlightedIcon(":/images/sidebar/folder.png")); } -#else - if (item->data(FolderModel::Finished).toBool()) - return QVariant(YACReader::noHighlightedIcon(":/images/sidebar/folder_finished.png")); - else - return QVariant(YACReader::noHighlightedIcon(":/images/sidebar/folder.png")); -#endif } if (role == FolderModel::CompletedRole) diff --git a/YACReaderLibrary/theme.h b/YACReaderLibrary/theme.h index 96e8f4b3..0a07d87a 100644 --- a/YACReaderLibrary/theme.h +++ b/YACReaderLibrary/theme.h @@ -20,6 +20,8 @@ public: t.itemLibrarySelectedStyleSheet = "color: white; background-color:#91c4f4; border-bottom:1px solid #91c4f4;"; t.itemLibraryNoSelectedStyleSheet = "background-color:transparent;"; + + t.useNativeFolderIcons = true; } else { t.isMacosNative = false; @@ -29,6 +31,8 @@ public: t.itemLibrarySelectedStyleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;"; t.itemLibraryNoSelectedStyleSheet = "background-color:transparent; color:#DDDFDF;"; + + t.useNativeFolderIcons = false; } return t; @@ -45,6 +49,9 @@ public: //library item QString itemLibrarySelectedStyleSheet; QString itemLibraryNoSelectedStyleSheet; + + //tree folders + bool useNativeFolderIcons; }; #endif // THEME_H