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
|
|
|
#include <QWidget>
|
2014-03-07 18:03:42 +01:00
|
|
|
#include <QStyle>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QImage>
|
2011-04-25 20:56:45 +02:00
|
|
|
#include <QUrl>
|
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QTimer;
|
|
|
|
class QIcon;
|
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
class WebView;
|
2014-03-07 18:03:42 +01:00
|
|
|
class AutoSaver;
|
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
|
2014-02-19 22:12:32 +01:00
|
|
|
class 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:
|
2014-03-07 18:24:13 +01:00
|
|
|
explicit IconProvider();
|
2012-04-22 20:51:28 +02:00
|
|
|
|
2011-04-25 20:56:45 +02:00
|
|
|
void saveIcon(WebView* view);
|
2012-04-22 20:51:28 +02:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
QPixmap bookmarkIcon() const;
|
|
|
|
void setBookmarkIcon(const QPixmap &pixmap);
|
2011-04-28 18:31:48 +02:00
|
|
|
|
2014-03-24 16:08:33 +01:00
|
|
|
// QStyle equivalent
|
2014-03-07 18:03:42 +01:00
|
|
|
static QIcon standardIcon(QStyle::StandardPixmap icon);
|
2014-03-24 16:08:33 +01:00
|
|
|
|
|
|
|
static QIcon newTabIcon();
|
|
|
|
static QIcon newWindowIcon();
|
|
|
|
static QIcon privateBrowsingIcon();
|
|
|
|
static QIcon settingsIcon();
|
2011-07-30 17:57:14 +02:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
// Icon for empty page
|
|
|
|
static QIcon emptyWebIcon();
|
|
|
|
static QImage emptyWebImage();
|
2011-09-30 21:44:18 +02:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
// Icon for url (only available for urls in history)
|
|
|
|
static QIcon iconForUrl(const QUrl &url);
|
2014-03-15 19:36:03 +01:00
|
|
|
static QImage imageForUrl(const QUrl &url);
|
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
// Icon for domain (only available for urls in history)
|
|
|
|
static QIcon iconForDomain(const QUrl &url);
|
2014-03-15 19:36:03 +01:00
|
|
|
static QImage imageForDomain(const QUrl &url);
|
2012-03-13 17:51:06 +01:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
static IconProvider* instance();
|
2011-04-25 20:56:45 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void saveIconsToDatabase();
|
2014-03-07 18:03:42 +01:00
|
|
|
void clearIconsDatabase();
|
2011-04-25 20:56:45 +02:00
|
|
|
|
|
|
|
private:
|
2014-03-07 18:03:42 +01:00
|
|
|
typedef QPair<QUrl, QImage> BufferedIcon;
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
QIcon iconFromImage(const QImage &image);
|
2012-04-22 20:51:28 +02:00
|
|
|
|
|
|
|
QImage m_emptyWebImage;
|
|
|
|
QPixmap m_bookmarkIcon;
|
2014-03-07 18:03:42 +01:00
|
|
|
QVector<BufferedIcon> m_iconBuffer;
|
2011-04-25 20:56:45 +02:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
AutoSaver* m_autoSaver;
|
2011-04-25 20:56:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ICONPROVIDER_H
|