/* ============================================================ * QupZilla - WebKit based browser * Copyright (C) 2010-2014 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ #ifndef ICONPROVIDER_H #define ICONPROVIDER_H #include #include #include #include #include "qzcommon.h" class QTimer; class QIcon; class WebView; class AutoSaver; // Needs to be QWidget subclass, otherwise qproperty- setting won't work class QUPZILLA_EXPORT IconProvider : public QWidget { Q_OBJECT Q_PROPERTY(QPixmap bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon) public: explicit IconProvider(); void saveIcon(WebView* view); QPixmap bookmarkIcon() const; void setBookmarkIcon(const QPixmap &pixmap); // QStyle equivalents static QIcon standardIcon(QStyle::StandardPixmap icon); static QIcon iconFromTheme(const QString &icon); // Icon for empty page static QIcon emptyWebIcon(); static QImage emptyWebImage(); // Icon for url (only available for urls in history) static QIcon iconForUrl(const QUrl &url); // Icon for domain (only available for urls in history) static QIcon iconForDomain(const QUrl &url); static IconProvider* instance(); public slots: void saveIconsToDatabase(); void clearIconsDatabase(); private: typedef QPair BufferedIcon; QIcon iconFromImage(const QImage &image); QImage m_emptyWebImage; QPixmap m_bookmarkIcon; QVector m_iconBuffer; AutoSaver* m_autoSaver; }; #endif // ICONPROVIDER_H