From 2f80ca55eff17e9a39f0581ab88bc2775e17d0df Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 27 Jan 2016 12:44:19 +0100 Subject: [PATCH] IconProvider: Prefer theme icon for bookmarks --- .../navigation/completer/locationcompleterdelegate.cpp | 8 ++++---- src/lib/tools/iconprovider.cpp | 8 ++++---- src/lib/tools/iconprovider.h | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/navigation/completer/locationcompleterdelegate.cpp b/src/lib/navigation/completer/locationcompleterdelegate.cpp index 1958e5b79..4ef9126b3 100644 --- a/src/lib/navigation/completer/locationcompleterdelegate.cpp +++ b/src/lib/navigation/completer/locationcompleterdelegate.cpp @@ -88,12 +88,12 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI // Draw star to bookmark items int starPixmapWidth = 0; if (index.data(LocationCompleterModel::BookmarkRole).toBool()) { - const QPixmap starPixmap = IconProvider::instance()->bookmarkIcon(); - QSize starSize = starPixmap.size(); + const QIcon icon = IconProvider::instance()->bookmarkIcon(); + const QSize starSize(16, 16); starPixmapWidth = starSize.width(); - QPoint pos(rightPosition - starPixmapWidth, opt.rect.top() + m_padding); + QPoint pos(rightPosition - starPixmapWidth, center - starSize.height() / 2); QRect starRect(pos, starSize); - painter->drawPixmap(starRect, starPixmap); + painter->drawPixmap(starRect, icon.pixmap(starSize)); } const QString searchText = index.data(LocationCompleterModel::SearchStringRole).toString(); diff --git a/src/lib/tools/iconprovider.cpp b/src/lib/tools/iconprovider.cpp index 8a520ff74..84d260b64 100644 --- a/src/lib/tools/iconprovider.cpp +++ b/src/lib/tools/iconprovider.cpp @@ -63,14 +63,14 @@ void IconProvider::saveIcon(WebView* view) m_iconBuffer.append(item); } -QPixmap IconProvider::bookmarkIcon() const +QIcon IconProvider::bookmarkIcon() const { - return m_bookmarkIcon; + return QIcon::fromTheme(QSL("bookmarks"), m_bookmarkIcon); } -void IconProvider::setBookmarkIcon(const QPixmap &pixmap) +void IconProvider::setBookmarkIcon(const QIcon &icon) { - m_bookmarkIcon = pixmap; + m_bookmarkIcon = icon; } QIcon IconProvider::standardIcon(QStyle::StandardPixmap icon) diff --git a/src/lib/tools/iconprovider.h b/src/lib/tools/iconprovider.h index 177d92c3f..c2e85b59e 100644 --- a/src/lib/tools/iconprovider.h +++ b/src/lib/tools/iconprovider.h @@ -34,15 +34,15 @@ class AutoSaver; class QUPZILLA_EXPORT IconProvider : public QWidget { Q_OBJECT - Q_PROPERTY(QPixmap bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon) + Q_PROPERTY(QIcon bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon) public: explicit IconProvider(); void saveIcon(WebView* view); - QPixmap bookmarkIcon() const; - void setBookmarkIcon(const QPixmap &pixmap); + QIcon bookmarkIcon() const; + void setBookmarkIcon(const QIcon &icon); // QStyle equivalent static QIcon standardIcon(QStyle::StandardPixmap icon); @@ -76,7 +76,7 @@ private: QIcon iconFromImage(const QImage &image); QImage m_emptyWebImage; - QPixmap m_bookmarkIcon; + QIcon m_bookmarkIcon; QVector m_iconBuffer; AutoSaver* m_autoSaver;