2011-04-27 09:05:54 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2011-04-27 09:05:54 +02:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-04-25 20:56:45 +02:00
|
|
|
#ifndef ICONPROVIDER_H
|
|
|
|
#define ICONPROVIDER_H
|
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
#define qIconProvider IconProvider::instance()
|
|
|
|
#define _iconForUrl(url) qIconProvider->iconFromImage(qIconProvider->iconForUrl(url))
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
#include <QWidget>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QImage>
|
2011-04-25 20:56:45 +02:00
|
|
|
#include <QUrl>
|
2011-09-30 21:44:18 +02:00
|
|
|
#include <QStyle>
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include "qz_namespace.h"
|
|
|
|
|
|
|
|
class QTimer;
|
|
|
|
class QIcon;
|
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
class WebView;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
// Needs to be QWidget subclass, otherwise qproperty- setting won't work
|
|
|
|
class QT_QUPZILLA_EXPORT IconProvider : public QWidget
|
2011-04-25 20:56:45 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-04-22 20:51:28 +02:00
|
|
|
Q_PROPERTY(QPixmap bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon)
|
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
public:
|
2012-04-22 20:51:28 +02:00
|
|
|
explicit IconProvider(QWidget* parent = 0);
|
|
|
|
|
|
|
|
static IconProvider* instance();
|
2011-10-21 23:26:34 +02:00
|
|
|
|
2012-01-17 19:27:24 +01:00
|
|
|
void clearIconDatabase();
|
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
void saveIcon(WebView* view);
|
2012-01-17 19:27:24 +01:00
|
|
|
QImage iconForUrl(const QUrl &url);
|
|
|
|
QImage iconForDomain(const QUrl &url);
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
QIcon iconFromImage(const QImage &image);
|
|
|
|
|
|
|
|
QIcon iconFromBase64(const QByteArray &data);
|
|
|
|
QByteArray iconToBase64(const QIcon &icon);
|
2011-04-28 18:31:48 +02:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
QIcon standardIcon(QStyle::StandardPixmap icon);
|
|
|
|
QIcon fromTheme(const QString &icon);
|
2011-07-30 17:57:14 +02:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
QIcon emptyWebIcon();
|
|
|
|
QImage emptyWebImage();
|
2011-09-30 21:44:18 +02:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
QPixmap bookmarkIcon();
|
|
|
|
void setBookmarkIcon(const QPixmap &pixmap);
|
2012-03-13 17:51:06 +01:00
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void saveIconsToDatabase();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer* m_timer;
|
2011-10-28 17:52:42 +02:00
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
struct Icon {
|
|
|
|
QUrl url;
|
2012-01-17 19:27:24 +01:00
|
|
|
QImage image;
|
2011-04-25 20:56:45 +02:00
|
|
|
};
|
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
static IconProvider* s_instance;
|
|
|
|
|
|
|
|
QImage m_emptyWebImage;
|
|
|
|
QPixmap m_bookmarkIcon;
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2013-02-26 12:56:11 +01:00
|
|
|
QVector<Icon> m_iconBuffer;
|
2011-04-25 20:56:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ICONPROVIDER_H
|