1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Show star icon in completer when item is from bookmarks.

- IconProvider has no longer static members
- new macro qIconProvider for accessing IconProvider instance
This commit is contained in:
nowrep 2012-04-22 20:51:28 +02:00
parent 64bdafde87
commit 2055621f2a
35 changed files with 163 additions and 97 deletions

View File

@ -113,6 +113,12 @@
qproperty-multiIcon: url(images/tabbar-addtab.png); qproperty-multiIcon: url(images/tabbar-addtab.png);
} }
/*IconProvider*/
IconProvider
{
qproperty-bookmarkIcon: url(images/star-a.png);
}
/*LocationBar*/ /*LocationBar*/
#locationbar #locationbar
{ {

View File

@ -123,6 +123,12 @@
background: url(images/transp.png); background: url(images/transp.png);
} }
/*IconProvider*/
IconProvider
{
qproperty-bookmarkIcon: url(images/star.png);
}
/*LocationBar*/ /*LocationBar*/
#locationbar #locationbar
{ {

View File

@ -106,6 +106,12 @@
background: url(images/transp.png); background: url(images/transp.png);
} }
/*IconProvider*/
IconProvider
{
qproperty-bookmarkIcon: url(images/star-a.png);
}
/*LocationBar*/ /*LocationBar*/
#locationbar #locationbar
{ {

View File

@ -108,6 +108,12 @@
qproperty-multiIcon: url(images/tabbar-addtab.png); qproperty-multiIcon: url(images/tabbar-addtab.png);
} }
/*IconProvider*/
IconProvider
{
qproperty-bookmarkIcon: url(images/star-a.png);
}
/*LocationBar*/ /*LocationBar*/
#locationbar #locationbar
{ {

View File

@ -118,6 +118,12 @@
qproperty-multiIcon: url(images/tabbar-addtab.png); qproperty-multiIcon: url(images/tabbar-addtab.png);
} }
/*IconProvider*/
IconProvider
{
qproperty-bookmarkIcon: url(images/star-a.png);
}
/*LocationBar*/ /*LocationBar*/
#locationbar #locationbar
{ {

View File

@ -78,7 +78,6 @@ MainApplication::MainApplication(int &argc, char** argv)
, m_autofill(0) , m_autofill(0)
, m_networkCache(new QNetworkDiskCache(this)) , m_networkCache(new QNetworkDiskCache(this))
, m_desktopNotifications(0) , m_desktopNotifications(0)
, m_iconProvider(new IconProvider(this))
, m_searchEnginesManager(0) , m_searchEnginesManager(0)
, m_dbWriter(new DatabaseWriter(this)) , m_dbWriter(new DatabaseWriter(this))
, m_isClosing(false) , m_isClosing(false)
@ -348,7 +347,7 @@ void MainApplication::loadSettings()
m_websettings->setFontSize(QWebSettings::MinimumLogicalFontSize, settings.value("MinimumLogicalFontSize", m_websettings->fontSize(QWebSettings::MinimumLogicalFontSize)).toInt()); m_websettings->setFontSize(QWebSettings::MinimumLogicalFontSize, settings.value("MinimumLogicalFontSize", m_websettings->fontSize(QWebSettings::MinimumLogicalFontSize)).toInt());
settings.endGroup(); settings.endGroup();
m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, IconProvider::emptyWebIcon().pixmap(16, 16)); m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, qIconProvider->emptyWebIcon().pixmap(16, 16));
m_websettings->setWebGraphic(QWebSettings::MissingImageGraphic, QPixmap()); m_websettings->setWebGraphic(QWebSettings::MissingImageGraphic, QPixmap());
// Allows to load files from qrc: scheme in qupzilla: pages // Allows to load files from qrc: scheme in qupzilla: pages
@ -612,7 +611,7 @@ void MainApplication::saveSettings()
m_networkmanager->saveCertificates(); m_networkmanager->saveCertificates();
m_plugins->c2f_saveSettings(); m_plugins->c2f_saveSettings();
m_plugins->speedDial()->saveSettings(); m_plugins->speedDial()->saveSettings();
m_iconProvider->saveIconsToDatabase(); qIconProvider->saveIconsToDatabase();
AdBlockManager::instance()->save(); AdBlockManager::instance()->save();
QFile::remove(currentProfilePath() + "WebpageIcons.db"); QFile::remove(currentProfilePath() + "WebpageIcons.db");

View File

@ -95,7 +95,6 @@ public:
SearchEnginesManager* searchEnginesManager(); SearchEnginesManager* searchEnginesManager();
QNetworkDiskCache* networkCache() { return m_networkCache; } QNetworkDiskCache* networkCache() { return m_networkCache; }
DesktopNotificationsFactory* desktopNotifications(); DesktopNotificationsFactory* desktopNotifications();
IconProvider* iconProvider() { return m_iconProvider; }
DatabaseWriter* dbWriter() { return m_dbWriter; } DatabaseWriter* dbWriter() { return m_dbWriter; }
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
@ -139,7 +138,6 @@ private:
AutoFillModel* m_autofill; AutoFillModel* m_autofill;
QNetworkDiskCache* m_networkCache; QNetworkDiskCache* m_networkCache;
DesktopNotificationsFactory* m_desktopNotifications; DesktopNotificationsFactory* m_desktopNotifications;
IconProvider* m_iconProvider;
SearchEnginesManager* m_searchEnginesManager; SearchEnginesManager* m_searchEnginesManager;
DatabaseWriter* m_dbWriter; DatabaseWriter* m_dbWriter;

View File

@ -361,10 +361,10 @@ void QupZilla::setupMenu()
m_actionShowFullScreen->setCheckable(true); m_actionShowFullScreen->setCheckable(true);
m_actionShowFullScreen->setShortcut(QKeySequence("F11")); m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool))); connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
m_actionStop = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), this); m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), this);
connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop())); connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop()));
m_actionStop->setShortcut(QKeySequence("Esc")); m_actionStop->setShortcut(QKeySequence("Esc"));
m_actionReload = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this); m_actionReload = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this);
connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload())); connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload()));
m_actionReload->setShortcut(QKeySequence("F5")); m_actionReload->setShortcut(QKeySequence("F5"));
QAction* actionEncoding = new QAction(tr("Character &Encoding"), this); QAction* actionEncoding = new QAction(tr("Character &Encoding"), this);
@ -402,9 +402,9 @@ void QupZilla::setupMenu()
* History Menu * * History Menu *
****************/ ****************/
m_menuHistory = new Menu(tr("Hi&story")); m_menuHistory = new Menu(tr("Hi&story"));
m_menuHistory->addAction(IconProvider::standardIcon(QStyle::SP_ArrowBack), tr("&Back"), this, SLOT(goBack()))->setShortcut(QKeySequence("Ctrl+Left")); m_menuHistory->addAction(qIconProvider->standardIcon(QStyle::SP_ArrowBack), tr("&Back"), this, SLOT(goBack()))->setShortcut(QKeySequence("Ctrl+Left"));
m_menuHistory->addAction(IconProvider::standardIcon(QStyle::SP_ArrowForward), tr("&Forward"), this, SLOT(goNext()))->setShortcut(QKeySequence("Ctrl+Right")); m_menuHistory->addAction(qIconProvider->standardIcon(QStyle::SP_ArrowForward), tr("&Forward"), this, SLOT(goNext()))->setShortcut(QKeySequence("Ctrl+Right"));
m_menuHistory->addAction(IconProvider::fromTheme("go-home"), tr("&Home"), this, SLOT(goHome()))->setShortcut(QKeySequence("Alt+Home")); m_menuHistory->addAction(qIconProvider->fromTheme("go-home"), tr("&Home"), this, SLOT(goHome()))->setShortcut(QKeySequence("Alt+Home"));
m_menuHistory->addAction(QIcon(":/icons/menu/history.png"), tr("Show &All History"), this, SLOT(showHistoryManager()))->setShortcut(QKeySequence("Ctrl+Shift+H")); m_menuHistory->addAction(QIcon(":/icons/menu/history.png"), tr("Show &All History"), this, SLOT(showHistoryManager()))->setShortcut(QKeySequence("Ctrl+Shift+H"));
m_menuHistory->addSeparator(); m_menuHistory->addSeparator();
connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu())); connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu()));
@ -429,7 +429,7 @@ void QupZilla::setupMenu()
m_menuBookmarks = new Menu(tr("&Bookmarks")); m_menuBookmarks = new Menu(tr("&Bookmarks"));
m_menuBookmarks->addAction(tr("Bookmark &This Page"), this, SLOT(bookmarkPage()))->setShortcut(QKeySequence("Ctrl+D")); m_menuBookmarks->addAction(tr("Bookmark &This Page"), this, SLOT(bookmarkPage()))->setShortcut(QKeySequence("Ctrl+D"));
m_menuBookmarks->addAction(tr("Bookmark &All Tabs"), this, SLOT(bookmarkAllTabs())); m_menuBookmarks->addAction(tr("Bookmark &All Tabs"), this, SLOT(bookmarkAllTabs()));
m_menuBookmarks->addAction(IconProvider::fromTheme("user-bookmarks"), tr("Organize &Bookmarks"), this, SLOT(showBookmarksManager()))->setShortcut(QKeySequence("Ctrl+Shift+O")); m_menuBookmarks->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("Organize &Bookmarks"), this, SLOT(showBookmarksManager()))->setShortcut(QKeySequence("Ctrl+Shift+O"));
m_menuBookmarks->addSeparator(); m_menuBookmarks->addSeparator();
connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu())); connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu()));
@ -739,7 +739,7 @@ void QupZilla::aboutToShowBookmarksMenu()
while (query.next()) { while (query.next()) {
QString title = query.value(0).toString(); QString title = query.value(0).toString();
const QUrl &url = query.value(1).toUrl(); const QUrl &url = query.value(1).toUrl();
const QIcon &icon = IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray())); const QIcon &icon = qIconProvider->iconFromImage(QImage::fromData(query.value(2).toByteArray()));
if (title.length() > 40) { if (title.length() > 40) {
title.truncate(40); title.truncate(40);
title += ".."; title += "..";
@ -759,7 +759,7 @@ void QupZilla::aboutToShowBookmarksMenu()
while (query.next()) { while (query.next()) {
QString title = query.value(0).toString(); QString title = query.value(0).toString();
const QUrl &url = query.value(1).toUrl(); const QUrl &url = query.value(1).toUrl();
const QIcon &icon = IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray())); const QIcon &icon = qIconProvider->iconFromImage(QImage::fromData(query.value(2).toByteArray()));
if (title.length() > 40) { if (title.length() > 40) {
title.truncate(40); title.truncate(40);
title += ".."; title += "..";
@ -789,7 +789,7 @@ void QupZilla::aboutToShowBookmarksMenu()
while (query2.next()) { while (query2.next()) {
QString title = query2.value(0).toString(); QString title = query2.value(0).toString();
const QUrl &url = query2.value(1).toUrl(); const QUrl &url = query2.value(1).toUrl();
const QIcon &icon = IconProvider::iconFromImage(QImage::fromData(query2.value(2).toByteArray())); const QIcon &icon = qIconProvider->iconFromImage(QImage::fromData(query2.value(2).toByteArray()));
if (title.length() > 40) { if (title.length() > 40) {
title.truncate(40); title.truncate(40);
title += ".."; title += "..";
@ -1789,7 +1789,7 @@ bool QupZilla::quitApp()
dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count())); dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count()));
dialog.setCheckBoxText(tr("Don't ask again")); dialog.setCheckBoxText(tr("Don't ask again"));
dialog.setWindowTitle(tr("There are still open tabs")); dialog.setWindowTitle(tr("There are still open tabs"));
dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning)); dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
if (dialog.exec() != QDialog::Accepted) { if (dialog.exec() != QDialog::Accepted) {
return false; return false;
} }

View File

@ -33,7 +33,7 @@ AutoFillNotification::AutoFillNotification(const QUrl &url, const QByteArray &da
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(widget()); ui->setupUi(widget());
ui->label->setText(tr("Do you want QupZilla to remember the password for <b>%1</b> on %2?").arg(user, url.host())); ui->label->setText(tr("Do you want QupZilla to remember the password for <b>%1</b> on %2?").arg(user, url.host()));
ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember())); connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember()));
connect(ui->never, SIGNAL(clicked()), this, SLOT(never())); connect(ui->never, SIGNAL(clicked()), this, SLOT(never()));

View File

@ -308,7 +308,7 @@ void BookmarksManager::refreshTable()
QUrl url = query.value(1).toUrl(); QUrl url = query.value(1).toUrl();
int id = query.value(2).toInt(); int id = query.value(2).toInt();
QString folder = query.value(3).toString(); QString folder = query.value(3).toString();
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query.value(4).toByteArray())); QIcon icon = qIconProvider->iconFromImage(QImage::fromData(query.value(4).toByteArray()));
QTreeWidgetItem* item = new QTreeWidgetItem(); QTreeWidgetItem* item = new QTreeWidgetItem();
if (folder == "bookmarksMenu") { if (folder == "bookmarksMenu") {
folder = _bookmarksMenu; folder = _bookmarksMenu;
@ -350,7 +350,7 @@ void BookmarksManager::refreshTable()
QString title = query2.value(0).toString(); QString title = query2.value(0).toString();
QUrl url = query2.value(1).toUrl(); QUrl url = query2.value(1).toUrl();
int id = query2.value(2).toInt(); int id = query2.value(2).toInt();
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query2.value(3).toByteArray())); QIcon icon = qIconProvider->iconFromImage(QImage::fromData(query2.value(3).toByteArray()));
QTreeWidgetItem* item = new QTreeWidgetItem(newItem); QTreeWidgetItem* item = new QTreeWidgetItem(newItem);
item->setText(0, title); item->setText(0, title);
@ -378,7 +378,7 @@ void BookmarksManager::addBookmark(const BookmarksModel::Bookmark &bookmark)
item->setText(0, bookmark.title); item->setText(0, bookmark.title);
item->setText(1, bookmark.url.toEncoded()); item->setText(1, bookmark.url.toEncoded());
item->setData(0, Qt::UserRole + 10, bookmark.id); item->setData(0, Qt::UserRole + 10, bookmark.id);
item->setIcon(0, IconProvider::iconFromImage(bookmark.image)); item->setIcon(0, qIconProvider->iconFromImage(bookmark.image));
item->setToolTip(0, bookmark.title); item->setToolTip(0, bookmark.title);
item->setToolTip(1, bookmark.url.toEncoded()); item->setToolTip(1, bookmark.url.toEncoded());
item->setFlags(item->flags() | Qt::ItemIsEditable); item->setFlags(item->flags() | Qt::ItemIsEditable);

View File

@ -161,7 +161,7 @@ bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const Q
QImage image = icon.pixmap(16, 16).toImage(); QImage image = icon.pixmap(16, 16).toImage();
if (image.isNull()) { if (image.isNull()) {
image = IconProvider::emptyWebImage(); image = qIconProvider->emptyWebImage();
} }
if (!isFolder(folder)) { if (!isFolder(folder)) {

View File

@ -74,7 +74,7 @@ void BookmarksToolbar::customContextMenuRequested(const QPoint &pos)
QMenu menu; QMenu menu;
menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage())); menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage()));
menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager())); menu.addAction(qIconProvider->fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager()));
menu.addSeparator(); menu.addSeparator();
QAction act(tr("Show Most &Visited"), this); QAction act(tr("Show Most &Visited"), this);
act.setCheckable(true); act.setCheckable(true);
@ -107,11 +107,11 @@ void BookmarksToolbar::showBookmarkContextMenu(const QPoint &pos)
QVariant buttonPointer = qVariantFromValue((void*) button); QVariant buttonPointer = qVariantFromValue((void*) button);
QMenu menu; QMenu menu;
menu.addAction(IconProvider::fromTheme("go-next"), tr("Move right"), this, SLOT(moveRight()))->setData(buttonPointer); menu.addAction(qIconProvider->fromTheme("go-next"), tr("Move right"), this, SLOT(moveRight()))->setData(buttonPointer);
menu.addAction(IconProvider::fromTheme("go-previous"), tr("Move left"), this, SLOT(moveLeft()))->setData(buttonPointer); menu.addAction(qIconProvider->fromTheme("go-previous"), tr("Move left"), this, SLOT(moveLeft()))->setData(buttonPointer);
menu.addAction(tr("Edit bookmark"), this, SLOT(editBookmark()))->setData(buttonPointer); menu.addAction(tr("Edit bookmark"), this, SLOT(editBookmark()))->setData(buttonPointer);
menu.addSeparator(); menu.addSeparator();
menu.addAction(IconProvider::fromTheme("list-remove"), tr("Remove bookmark"), this, SLOT(removeButton()))->setData(buttonPointer); menu.addAction(qIconProvider->fromTheme("list-remove"), tr("Remove bookmark"), this, SLOT(removeButton()))->setData(buttonPointer);
//Prevent choosing first option with double rightclick //Prevent choosing first option with double rightclick
QPoint position = button->mapToGlobal(pos); QPoint position = button->mapToGlobal(pos);
@ -404,7 +404,7 @@ void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark)
ToolButton* button = new ToolButton(this); ToolButton* button = new ToolButton(this);
button->setText(title); button->setText(title);
button->setData(v); button->setData(v);
button->setIcon(IconProvider::iconFromImage(bookmark.image)); button->setIcon(qIconProvider->iconFromImage(bookmark.image));
button->setToolButtonStyle(m_toolButtonStyle); button->setToolButtonStyle(m_toolButtonStyle);
button->setToolTip(bookmark.url.toEncoded()); button->setToolTip(bookmark.url.toEncoded());
button->setAutoRaise(true); button->setAutoRaise(true);
@ -471,7 +471,7 @@ void BookmarksToolbar::bookmarkEdited(const BookmarksModel::Bookmark &before, co
button->setText(title); button->setText(title);
button->setData(v); button->setData(v);
button->setIcon(IconProvider::iconFromImage(after.image)); button->setIcon(qIconProvider->iconFromImage(after.image));
button->setToolTip(after.url.toEncoded()); button->setToolTip(after.url.toEncoded());
return; return;
} }
@ -502,7 +502,7 @@ void BookmarksToolbar::refreshBookmarks()
ToolButton* button = new ToolButton(this); ToolButton* button = new ToolButton(this);
button->setText(title); button->setText(title);
button->setData(v); button->setData(v);
button->setIcon(IconProvider::iconFromImage(bookmark.image)); button->setIcon(qIconProvider->iconFromImage(bookmark.image));
button->setToolButtonStyle(m_toolButtonStyle); button->setToolButtonStyle(m_toolButtonStyle);
button->setToolTip(bookmark.url.toEncoded()); button->setToolTip(bookmark.url.toEncoded());
button->setAutoRaise(true); button->setAutoRaise(true);
@ -565,7 +565,7 @@ void BookmarksToolbar::aboutToShowFolderMenu()
title += ".."; title += "..";
} }
Action* act = new Action(IconProvider::iconFromImage(b.image), title); Action* act = new Action(qIconProvider->iconFromImage(b.image), title);
act->setData(b.url); act->setData(b.url);
connect(act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl())); connect(act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
connect(act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewNotSelectedTab())); connect(act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewNotSelectedTab()));
@ -588,7 +588,7 @@ void BookmarksToolbar::dropEvent(QDropEvent* e)
QString title = mime->text(); QString title = mime->text();
QUrl url = mime->urls().at(0); QUrl url = mime->urls().at(0);
QIcon icon = IconProvider::iconFromImage(qvariant_cast<QImage>(mime->imageData())); QIcon icon = qIconProvider->iconFromImage(qvariant_cast<QImage>(mime->imageData()));
m_bookmarksModel->saveBookmark(url, title, icon, "bookmarksToolbar"); m_bookmarksModel->saveBookmark(url, title, icon, "bookmarksToolbar");
} }

View File

@ -103,7 +103,7 @@ void BookmarksImportDialog::startFetchingIcons()
m_fetcher = new BookmarksImportIconFetcher(); m_fetcher = new BookmarksImportIconFetcher();
m_fetcher->moveToThread(m_fetcherThread); m_fetcher->moveToThread(m_fetcherThread);
QIcon defaultIcon = IconProvider::emptyWebIcon(); QIcon defaultIcon = qIconProvider->emptyWebIcon();
QIcon folderIcon = style()->standardIcon(QStyle::SP_DirIcon); QIcon folderIcon = style()->standardIcon(QStyle::SP_DirIcon);
QHash<QString, QTreeWidgetItem*> hash; QHash<QString, QTreeWidgetItem*> hash;
@ -267,7 +267,7 @@ void BookmarksImportDialog::addExportedBookmarks()
db.transaction(); db.transaction();
foreach(const Bookmark & b, m_exportedBookmarks) { foreach(const Bookmark & b, m_exportedBookmarks) {
model->saveBookmark(b.url, b.title, IconProvider::iconFromImage(b.image), b.folder); model->saveBookmark(b.url, b.title, qIconProvider->iconFromImage(b.image), b.folder);
} }
db.commit(); db.commit();

View File

@ -65,7 +65,7 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
ui->setupUi(this); ui->setupUi(this);
setMaximumWidth(525); setMaximumWidth(525);
ui->button->setPixmap(IconProvider::standardIcon(QStyle::SP_BrowserStop).pixmap(20, 20)); ui->button->setPixmap(qIconProvider->standardIcon(QStyle::SP_BrowserStop).pixmap(20, 20));
ui->fileName->setText(m_fileName); ui->fileName->setText(m_fileName);
ui->downloadInfo->setText(tr("Remaining time unavailable")); ui->downloadInfo->setText(tr("Remaining time unavailable"));
ui->fileIcon->setPixmap(fileIcon); ui->fileIcon->setPixmap(fileIcon);
@ -338,7 +338,7 @@ void DownloadItem::customContextMenuRequested(const QPoint &pos)
menu.addAction(tr("Go to Download Page"), this, SLOT(goToDownloadPage()))->setEnabled(!m_downloadPage.isEmpty()); menu.addAction(tr("Go to Download Page"), this, SLOT(goToDownloadPage()))->setEnabled(!m_downloadPage.isEmpty());
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Download Link"), this, SLOT(copyDownloadLink())); menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Download Link"), this, SLOT(copyDownloadLink()));
menu.addSeparator(); menu.addSeparator();
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("Cancel downloading"), this, SLOT(stop()))->setEnabled(m_downloading); menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("Cancel downloading"), this, SLOT(stop()))->setEnabled(m_downloading);
menu.addAction(QIcon::fromTheme("list-remove"), tr("Clear"), this, SLOT(clear()))->setEnabled(!m_downloading); menu.addAction(QIcon::fromTheme("list-remove"), tr("Clear"), this, SLOT(clear()))->setEnabled(!m_downloading);
if (m_downloading || ui->downloadInfo->text().startsWith(tr("Cancelled")) || ui->downloadInfo->text().startsWith(tr("Error"))) { if (m_downloading || ui->downloadInfo->text().startsWith(tr("Cancelled")) || ui->downloadInfo->text().startsWith(tr("Error"))) {

View File

@ -17,6 +17,7 @@
* ============================================================ */ * ============================================================ */
#include "locationcompleterdelegate.h" #include "locationcompleterdelegate.h"
#include "locationcompleterview.h" #include "locationcompleterview.h"
#include "iconprovider.h"
#include <QPainter> #include <QPainter>
#include <QApplication> #include <QApplication>
@ -49,20 +50,20 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI
int leftPosition = m_padding * 2; int leftPosition = m_padding * 2;
int rightPosition = opt.rect.right() - m_padding; int rightPosition = opt.rect.right() - m_padding;
// if (m_view->ignoreSelectedFlag()) { opt.state &= ~QStyle::State_MouseOver;
// if (opt.state.testFlag(QStyle::State_MouseOver)) {
if (m_view->hoveredIndex() == index) { if (m_view->hoveredIndex() == index) {
opt.state |= QStyle::State_Selected; opt.state |= QStyle::State_Selected;
} }
else { else {
opt.state &= ~QStyle::State_Selected; opt.state &= ~QStyle::State_Selected;
} }
// }
const QPalette::ColorRole colorRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text; const QPalette::ColorRole colorRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text;
const QPalette::ColorRole colorLinkRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Link; const QPalette::ColorRole colorLinkRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Link;
// Draw background // Draw background
painter->fillRect(opt.rect, Qt::white);
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w);
// Draw icon // Draw icon
@ -87,6 +88,15 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI
const QString &link = opt.fontMetrics.elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, linkRect.width()); const QString &link = opt.fontMetrics.elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, linkRect.width());
painter->setFont(opt.font); painter->setFont(opt.font);
style->drawItemText(painter, linkRect, Qt::TextSingleLine | Qt::AlignLeft, opt.palette, true, link, colorLinkRole); style->drawItemText(painter, linkRect, Qt::TextSingleLine | Qt::AlignLeft, opt.palette, true, link, colorLinkRole);
// Draw star to bookmark items
if (index.data(Qt::UserRole + 1).toBool()) {
const QPixmap starPixmap = qIconProvider->bookmarkIcon();
QSize starSize = starPixmap.size();
QPoint pos(rightPosition - starSize.width(), opt.rect.top() + m_padding);
QRect starRect(pos, starSize);
painter->drawPixmap(starRect, starPixmap);
}
} }
QSize LocationCompleterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const QSize LocationCompleterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const

View File

@ -57,9 +57,10 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
QStandardItem* item = new QStandardItem(); QStandardItem* item = new QStandardItem();
const QUrl &url = query.value(0).toUrl(); const QUrl &url = query.value(0).toUrl();
item->setIcon(qIconProvider->iconFromImage(QImage::fromData(query.value(2).toByteArray())));
item->setText(url.toEncoded()); item->setText(url.toEncoded());
item->setData(query.value(1), Qt::UserRole); item->setData(query.value(1), Qt::UserRole);
item->setIcon(IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray()))); item->setData(QVariant(true), Qt::UserRole + 1); // From bookmarks
appendRow(item); appendRow(item);
urlList.append(url); urlList.append(url);
@ -84,6 +85,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
item->setIcon(_iconForUrl(url)); item->setIcon(_iconForUrl(url));
item->setText(url.toEncoded()); item->setText(url.toEncoded());
item->setData(query.value(1), Qt::UserRole); item->setData(query.value(1), Qt::UserRole);
item->setData(QVariant(false), Qt::UserRole + 1);
appendRow(item); appendRow(item);
} }
@ -103,6 +105,7 @@ void LocationCompleterModel::showMostVisited()
item->setIcon(_iconForUrl(url)); item->setIcon(_iconForUrl(url));
item->setText(url.toEncoded()); item->setText(url.toEncoded());
item->setData(query.value(1), Qt::UserRole); item->setData(query.value(1), Qt::UserRole);
item->setData(QVariant(false), Qt::UserRole + 1);
appendRow(item); appendRow(item);
} }

View File

@ -41,7 +41,7 @@
#include <QClipboard> #include <QClipboard>
LocationBar::LocationBar(QupZilla* mainClass) LocationBar::LocationBar(QupZilla* mainClass)
: LineEdit() : LineEdit(mainClass)
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
, m_webView(0) , m_webView(0)
, m_menu(new QMenu(this)) , m_menu(new QMenu(this))
@ -240,7 +240,7 @@ void LocationBar::siteIconChanged()
void LocationBar::clearIcon() void LocationBar::clearIcon()
{ {
m_siteIcon->setIcon(IconProvider::emptyWebIcon()); m_siteIcon->setIcon(qIconProvider->emptyWebIcon());
} }
void LocationBar::setPrivacy(bool state) void LocationBar::setPrivacy(bool state)

View File

@ -205,7 +205,7 @@ void NavigationBar::aboutToShowHistoryBackMenu()
if (item.isValid() && lastUrl != item.url()) { if (item.isValid() && lastUrl != item.url()) {
QString title = titleForUrl(item.title(), item.url()); QString title = titleForUrl(item.title(), item.url());
const QIcon &icon = iconForPage(item.url(), IconProvider::standardIcon(QStyle::SP_ArrowBack)); const QIcon &icon = iconForPage(item.url(), qIconProvider->standardIcon(QStyle::SP_ArrowBack));
Action* act = new Action(icon, title); Action* act = new Action(icon, title);
act->setData(i); act->setData(i);
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex())); connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
@ -242,7 +242,7 @@ void NavigationBar::aboutToShowHistoryNextMenu()
if (item.isValid() && lastUrl != item.url()) { if (item.isValid() && lastUrl != item.url()) {
QString title = titleForUrl(item.title(), item.url()); QString title = titleForUrl(item.title(), item.url());
const QIcon &icon = iconForPage(item.url(), IconProvider::standardIcon(QStyle::SP_ArrowForward)); const QIcon &icon = iconForPage(item.url(), qIconProvider->standardIcon(QStyle::SP_ArrowForward));
Action* act = new Action(icon, title); Action* act = new Action(icon, title);
act->setData(i); act->setData(i);
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex())); connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));

View File

@ -35,7 +35,7 @@
QIcon SearchEnginesManager::iconForSearchEngine(const QUrl &url) QIcon SearchEnginesManager::iconForSearchEngine(const QUrl &url)
{ {
QIcon ic = IconProvider::iconFromImage(mApp->iconProvider()->iconForDomain(url)); QIcon ic = qIconProvider->iconFromImage(qIconProvider->iconForDomain(url));
if (ic.isNull()) { if (ic.isNull()) {
ic = QIcon(":icons/menu/search-icon.png"); ic = QIcon(":icons/menu/search-icon.png");
} }
@ -65,7 +65,7 @@ void SearchEnginesManager::loadSettings()
while (query.next()) { while (query.next()) {
Engine en; Engine en;
en.name = query.value(0).toString(); en.name = query.value(0).toString();
en.icon = IconProvider::iconFromBase64(query.value(1).toByteArray()); en.icon = qIconProvider->iconFromBase64(query.value(1).toByteArray());
en.url = query.value(2).toString(); en.url = query.value(2).toString();
en.shortcut = query.value(3).toString(); en.shortcut = query.value(3).toString();
en.suggestionsUrl = query.value(4).toString(); en.suggestionsUrl = query.value(4).toString();
@ -407,7 +407,7 @@ void SearchEnginesManager::saveSettings()
foreach(const Engine & en, m_allEngines) { foreach(const Engine & en, m_allEngines) {
query.prepare("INSERT INTO search_engines (name, icon, url, shortcut, suggestionsUrl, suggestionsParameters) VALUES (?, ?, ?, ?, ?, ?)"); query.prepare("INSERT INTO search_engines (name, icon, url, shortcut, suggestionsUrl, suggestionsParameters) VALUES (?, ?, ?, ?, ?, ?)");
query.bindValue(0, en.name); query.bindValue(0, en.name);
query.bindValue(1, IconProvider::iconToBase64(en.icon)); query.bindValue(1, qIconProvider->iconToBase64(en.icon));
query.bindValue(2, en.url); query.bindValue(2, en.url);
query.bindValue(3, en.shortcut); query.bindValue(3, en.shortcut);
query.bindValue(4, en.suggestionsUrl); query.bindValue(4, en.suggestionsUrl);

View File

@ -85,7 +85,7 @@ void ClearPrivateData::clearCache()
void ClearPrivateData::clearIcons() void ClearPrivateData::clearIcons()
{ {
mApp->webSettings()->clearIconDatabase(); mApp->webSettings()->clearIconDatabase();
mApp->iconProvider()->clearIconDatabase(); qIconProvider->clearIconDatabase();
} }
void ClearPrivateData::clearFlash() void ClearPrivateData::clearFlash()

View File

@ -94,7 +94,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
m_actionPaste->setShortcut(QKeySequence("Ctrl+V")); m_actionPaste->setShortcut(QKeySequence("Ctrl+V"));
QMenu* menuView = new QMenu(tr("View")); QMenu* menuView = new QMenu(tr("View"));
menuView->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("Reload"), this, SLOT(reload()))->setShortcut(QKeySequence("F5")); menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("Reload"), this, SLOT(reload()))->setShortcut(QKeySequence("F5"));
menuView->addSeparator(); menuView->addSeparator();
menuView->addAction(tr("Editable"), this, SLOT(setTextEditable()))->setCheckable(true); menuView->addAction(tr("Editable"), this, SLOT(setTextEditable()))->setCheckable(true);
menuView->addAction(tr("Word Wrap"), this, SLOT(setTextWordWrap()))->setCheckable(true); menuView->addAction(tr("Word Wrap"), this, SLOT(setTextWordWrap()))->setCheckable(true);

View File

@ -31,11 +31,11 @@ SourceViewerSearch::SourceViewerSearch(SourceViewer* parent)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(widget()); ui->setupUi(widget());
ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
ui->next->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); ui->next->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowForward));
ui->previous->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack)); ui->previous->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowBack));
ui->lineEdit->setFocus(); ui->lineEdit->setFocus();
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(next())); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(next()));

View File

@ -45,7 +45,7 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
, m_view(0) , m_view(0)
{ {
m_siteIcon = new PopupSiteIcon(this); m_siteIcon = new PopupSiteIcon(this);
m_siteIcon->setIcon(IconProvider::emptyWebIcon()); m_siteIcon->setIcon(qIconProvider->emptyWebIcon());
m_siteIcon->setFixedSize(20, 26); m_siteIcon->setFixedSize(20, 26);
addWidget(m_siteIcon, LineEdit::LeftSide); addWidget(m_siteIcon, LineEdit::LeftSide);

View File

@ -49,7 +49,7 @@ RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent)
m_reloadButton = new QToolButton(this); m_reloadButton = new QToolButton(this);
m_reloadButton->setAutoRaise(true); m_reloadButton->setAutoRaise(true);
m_reloadButton->setToolTip(tr("Reload")); m_reloadButton->setToolTip(tr("Reload"));
m_reloadButton->setIcon(IconProvider::standardIcon(QStyle::SP_BrowserReload)); m_reloadButton->setIcon(qIconProvider->standardIcon(QStyle::SP_BrowserReload));
ui->tabWidget->setCornerWidget(m_reloadButton); ui->tabWidget->setCornerWidget(m_reloadButton);
@ -85,7 +85,7 @@ void RSSManager::refreshTable()
while (query.next()) { while (query.next()) {
QUrl address = query.value(0).toUrl(); QUrl address = query.value(0).toUrl();
QString title = query.value(1).toString(); QString title = query.value(1).toString();
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray())); QIcon icon = qIconProvider->iconFromImage(QImage::fromData(query.value(2).toByteArray()));
TreeWidget* tree = new TreeWidget(); TreeWidget* tree = new TreeWidget();
tree->setHeaderLabel(tr("News")); tree->setHeaderLabel(tr("News"));
tree->setContextMenuPolicy(Qt::CustomContextMenu); tree->setContextMenuPolicy(Qt::CustomContextMenu);
@ -385,7 +385,7 @@ bool RSSManager::addRssFeed(const QUrl &url, const QString &title, const QIcon &
if (!query.next()) { if (!query.next()) {
QImage image = icon.pixmap(16, 16).toImage(); QImage image = icon.pixmap(16, 16).toImage();
if (image == IconProvider::emptyWebImage()) { if (image == qIconProvider->emptyWebImage()) {
image.load(":icons/other/feed.png"); image.load(":icons/other/feed.png");
} }

View File

@ -27,7 +27,7 @@ RSSNotification::RSSNotification(QString host, QWidget* parent)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(widget()); ui->setupUi(widget());
ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
ui->label->setText(QupZilla::tr("You have successfully added RSS feed \"%1\".").arg(host)); ui->label->setText(QupZilla::tr("You have successfully added RSS feed \"%1\".").arg(host));
connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager())); connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager()));

View File

@ -131,7 +131,7 @@ void BookmarksSideBar::addBookmark(const BookmarksModel::Bookmark &bookmark)
item->setText(0, bookmark.title); item->setText(0, bookmark.title);
item->setText(1, bookmark.url.toEncoded()); item->setText(1, bookmark.url.toEncoded());
item->setData(0, Qt::UserRole + 10, bookmark.id); item->setData(0, Qt::UserRole + 10, bookmark.id);
item->setIcon(0, IconProvider::iconFromImage(bookmark.image)); item->setIcon(0, qIconProvider->iconFromImage(bookmark.image));
item->setToolTip(0, bookmark.url.toEncoded()); item->setToolTip(0, bookmark.url.toEncoded());
if (bookmark.folder != "unsorted") { if (bookmark.folder != "unsorted") {
@ -244,7 +244,7 @@ void BookmarksSideBar::refreshTable()
QUrl url = query.value(1).toUrl(); QUrl url = query.value(1).toUrl();
int id = query.value(2).toInt(); int id = query.value(2).toInt();
QString folder = query.value(3).toString(); QString folder = query.value(3).toString();
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query.value(4).toByteArray())); QIcon icon = qIconProvider->iconFromImage(QImage::fromData(query.value(4).toByteArray()));
QTreeWidgetItem* item; QTreeWidgetItem* item;
if (folder == "bookmarksMenu") { if (folder == "bookmarksMenu") {
folder = _bookmarksMenu; folder = _bookmarksMenu;

View File

@ -22,7 +22,7 @@ DockTitleBarWidget::DockTitleBarWidget(const QString &title, QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
closeButton->setIcon(QIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton).pixmap(16, 16))); closeButton->setIcon(QIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton).pixmap(16, 16)));
label->setText(title); label->setText(title);
connect(closeButton, SIGNAL(clicked()), parent, SLOT(close())); connect(closeButton, SIGNAL(clicked()), parent, SLOT(close()));

View File

@ -23,10 +23,10 @@
#include <QTimer> #include <QTimer>
#include <QBuffer> #include <QBuffer>
QImage IconProvider::m_emptyWebImage; IconProvider* IconProvider::s_instance = 0;
IconProvider::IconProvider(QObject* parent) IconProvider::IconProvider(QWidget* parent)
: QObject(parent) : QWidget(parent)
{ {
m_timer = new QTimer(this); m_timer = new QTimer(this);
m_timer->setInterval(10 * 1000); m_timer->setInterval(10 * 1000);
@ -35,6 +35,15 @@ IconProvider::IconProvider(QObject* parent)
connect(m_timer, SIGNAL(timeout()), this, SLOT(saveIconsToDatabase())); connect(m_timer, SIGNAL(timeout()), this, SLOT(saveIconsToDatabase()));
} }
IconProvider *IconProvider::instance()
{
if (!s_instance) {
s_instance = new IconProvider;
}
return s_instance;
}
void IconProvider::saveIcon(WebView* view) void IconProvider::saveIcon(WebView* view)
{ {
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
@ -210,6 +219,16 @@ QImage IconProvider::emptyWebImage()
return m_emptyWebImage; return m_emptyWebImage;
} }
QPixmap IconProvider::bookmarkIcon()
{
return m_bookmarkIcon;
}
void IconProvider::setBookmarkIcon(const QPixmap &pixmap)
{
m_bookmarkIcon = pixmap;
}
QIcon IconProvider::iconFromImage(const QImage &image) QIcon IconProvider::iconFromImage(const QImage &image)
{ {
if (m_emptyWebImage.isNull()) { if (m_emptyWebImage.isNull()) {
@ -245,7 +264,3 @@ QByteArray IconProvider::iconToBase64(const QIcon &icon)
buffer.close(); buffer.close();
return bArray.toBase64(); return bArray.toBase64();
} }
IconProvider::~IconProvider()
{
}

View File

@ -18,9 +18,10 @@
#ifndef ICONPROVIDER_H #ifndef ICONPROVIDER_H
#define ICONPROVIDER_H #define ICONPROVIDER_H
#define _iconForUrl(url) IconProvider::iconFromImage(mApp->iconProvider()->iconForUrl(url)) #define qIconProvider IconProvider::instance()
#define _iconForUrl(url) qIconProvider->iconFromImage(qIconProvider->iconForUrl(url))
#include <QObject> #include <QWidget>
#include <QImage> #include <QImage>
#include <QUrl> #include <QUrl>
#include <QStyle> #include <QStyle>
@ -32,12 +33,16 @@ class QIcon;
class WebView; class WebView;
class QT_QUPZILLA_EXPORT IconProvider : public QObject // Needs to be QWidget subclass, otherwise qproperty- setting won't work
class QT_QUPZILLA_EXPORT IconProvider : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QPixmap bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon)
public: public:
explicit IconProvider(QObject* parent = 0); explicit IconProvider(QWidget* parent = 0);
~IconProvider();
static IconProvider* instance();
void clearIconDatabase(); void clearIconDatabase();
@ -45,16 +50,19 @@ public:
QImage iconForUrl(const QUrl &url); QImage iconForUrl(const QUrl &url);
QImage iconForDomain(const QUrl &url); QImage iconForDomain(const QUrl &url);
static QIcon iconFromImage(const QImage &image); QIcon iconFromImage(const QImage &image);
static QIcon iconFromBase64(const QByteArray &data); QIcon iconFromBase64(const QByteArray &data);
static QByteArray iconToBase64(const QIcon &icon); QByteArray iconToBase64(const QIcon &icon);
static QIcon standardIcon(QStyle::StandardPixmap icon); QIcon standardIcon(QStyle::StandardPixmap icon);
static QIcon fromTheme(const QString &icon); QIcon fromTheme(const QString &icon);
static QIcon emptyWebIcon(); QIcon emptyWebIcon();
static QImage emptyWebImage(); QImage emptyWebImage();
QPixmap bookmarkIcon();
void setBookmarkIcon(const QPixmap &pixmap);
signals: signals:
@ -69,9 +77,12 @@ private:
QImage image; QImage image;
}; };
static QImage m_emptyWebImage; static IconProvider* s_instance;
QList<Icon> m_iconBuffer;
QImage m_emptyWebImage;
QPixmap m_bookmarkIcon;
QList<Icon> m_iconBuffer;
}; };
#endif // ICONPROVIDER_H #endif // ICONPROVIDER_H

View File

@ -33,9 +33,9 @@ SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(widget()); ui->setupUi(widget());
ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
ui->next->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); ui->next->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowForward));
ui->previous->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack)); ui->previous->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowBack));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(findNext())); connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(findNext()));

View File

@ -138,10 +138,10 @@ void TabBar::contextMenuRequested(const QPoint &position)
return; return;
} }
if (p_QupZilla->weView(m_clickedTab)->isLoading()) { if (p_QupZilla->weView(m_clickedTab)->isLoading()) {
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab())); menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab()));
} }
else { else {
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab())); menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab()));
} }
menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab())); menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab()));

View File

@ -196,7 +196,7 @@ void TabbedWebView::showIcon()
QIcon icon_ = icon(); QIcon icon_ = icon();
if (icon_.isNull()) { if (icon_.isNull()) {
icon_ = IconProvider::emptyWebIcon(); icon_ = qIconProvider->emptyWebIcon();
} }
m_tabWidget->setTabIcon(tabIndex(), icon_); m_tabWidget->setTabIcon(tabIndex(), icon_);

View File

@ -280,7 +280,7 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT
locBar->setWebView(webView); locBar->setWebView(webView);
setTabText(index, title); setTabText(index, title);
setTabIcon(index, IconProvider::emptyWebIcon()); setTabIcon(index, qIconProvider->emptyWebIcon());
if (openFlags & Qz::NT_SelectedTab) { if (openFlags & Qz::NT_SelectedTab) {
setCurrentIndex(index); setCurrentIndex(index);

View File

@ -304,7 +304,7 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
dialog.setText(text); dialog.setText(text);
dialog.setCheckBoxText(tr("Remember my choice for this protocol")); dialog.setCheckBoxText(tr("Remember my choice for this protocol"));
dialog.setWindowTitle(tr("External Protocol Request")); dialog.setWindowTitle(tr("External Protocol Request"));
dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxQuestion)); dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxQuestion));
switch (dialog.exec()) { switch (dialog.exec()) {
case QDialog::Accepted: case QDialog::Accepted:
@ -654,8 +654,8 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
QString errString = file.readAll(); QString errString = file.readAll();
errString.replace("%TITLE%", tr("Failed loading page")); errString.replace("%TITLE%", tr("Failed loading page"));
errString.replace("%IMAGE%", qz_pixmapToByteArray(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45))); errString.replace("%IMAGE%", qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45)));
errString.replace("%FAVICON%", qz_pixmapToByteArray(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16, 16))); errString.replace("%FAVICON%", qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16, 16)));
errString.replace("%BOX-BORDER%", "qrc:html/box-border.png"); errString.replace("%BOX-BORDER%", "qrc:html/box-border.png");
errString.replace("%HEADING%", errorString); errString.replace("%HEADING%", errorString);
@ -771,7 +771,7 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
dialog.setWindowTitle(title); dialog.setWindowTitle(title);
dialog.setText(msg); dialog.setText(msg);
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs")); dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxInformation)); dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxInformation));
dialog.exec(); dialog.exec();
m_blockAlerts = dialog.isChecked(); m_blockAlerts = dialog.isChecked();

View File

@ -352,7 +352,7 @@ void WebView::slotIconChanged()
m_siteIcon = icon(); m_siteIcon = icon();
m_siteIconUrl = url(); m_siteIconUrl = url();
mApp->iconProvider()->saveIcon(this); qIconProvider->saveIcon(this);
} }
} }
@ -613,8 +613,8 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
pageAction(QWebPage::Paste)->setIcon(QIcon::fromTheme("edit-paste")); pageAction(QWebPage::Paste)->setIcon(QIcon::fromTheme("edit-paste"));
pageAction(QWebPage::SelectAll)->setIcon(QIcon::fromTheme("edit-select-all")); pageAction(QWebPage::SelectAll)->setIcon(QIcon::fromTheme("edit-select-all"));
m_actionReload = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this); m_actionReload = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this);
m_actionStop = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this); m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this);
connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload())); connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload()));
connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop())); connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop()));
@ -698,11 +698,11 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
QWebFrame* frameAtPos = page()->frameAt(pos); QWebFrame* frameAtPos = page()->frameAt(pos);
QAction* action = menu->addAction(tr("&Back"), this, SLOT(back())); QAction* action = menu->addAction(tr("&Back"), this, SLOT(back()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack)); action->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowBack));
action->setEnabled(history()->canGoBack()); action->setEnabled(history()->canGoBack());
action = menu->addAction(tr("&Forward"), this, SLOT(forward())); action = menu->addAction(tr("&Forward"), this, SLOT(forward()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); action->setIcon(qIconProvider->standardIcon(QStyle::SP_ArrowForward));
action->setEnabled(history()->canGoForward()); action->setEnabled(history()->canGoForward());
menu->addAction(m_actionReload); menu->addAction(m_actionReload);
@ -715,7 +715,7 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
frameMenu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame())); frameMenu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame()));
frameMenu->addAction(QIcon(":/icons/menu/popup.png"), tr("Show this frame in new &tab"), this, SLOT(loadClickedFrameInNewTab())); frameMenu->addAction(QIcon(":/icons/menu/popup.png"), tr("Show this frame in new &tab"), this, SLOT(loadClickedFrameInNewTab()));
frameMenu->addSeparator(); frameMenu->addSeparator();
frameMenu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame())); frameMenu->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame()));
frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame())); frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
frameMenu->addSeparator(); frameMenu->addSeparator();
frameMenu->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this, SLOT(clickedFrameZoomIn())); frameMenu->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this, SLOT(clickedFrameZoomIn()));
@ -728,7 +728,7 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
} }
menu->addSeparator(); menu->addSeparator();
menu->addAction(IconProvider::fromTheme("user-bookmarks"), tr("Book&mark page"), this, SLOT(bookmarkLink())); menu->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("Book&mark page"), this, SLOT(bookmarkLink()));
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(downloadPage())); menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(downloadPage()));
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy page link"), this, SLOT(copyLinkToClipboard()))->setData(url()); menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy page link"), this, SLOT(copyLinkToClipboard()))->setData(url());
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send page link..."), this, SLOT(sendPageByMail())); menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send page link..."), this, SLOT(sendPageByMail()));
@ -757,7 +757,7 @@ void WebView::createLinkContextMenu(QMenu* menu, const QWebHitTestResult &hitTes
menu->addAction(QIcon(":/icons/menu/popup.png"), tr("Open link in new &tab"), this, SLOT(openUrlInBackgroundTab()))->setData(hitTest.linkUrl()); menu->addAction(QIcon(":/icons/menu/popup.png"), tr("Open link in new &tab"), this, SLOT(openUrlInBackgroundTab()))->setData(hitTest.linkUrl());
menu->addAction(QIcon::fromTheme("window-new"), tr("Open link in new &window"), this, SLOT(openUrlInNewWindow()))->setData(hitTest.linkUrl()); menu->addAction(QIcon::fromTheme("window-new"), tr("Open link in new &window"), this, SLOT(openUrlInNewWindow()))->setData(hitTest.linkUrl());
menu->addSeparator(); menu->addSeparator();
menu->addAction(IconProvider::fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(hitTest.linkUrl()); menu->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(hitTest.linkUrl());
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadUrlToDisk()))->setData(hitTest.linkUrl()); menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadUrlToDisk()))->setData(hitTest.linkUrl());
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(hitTest.linkUrl()); menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(hitTest.linkUrl());
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.linkUrl()); menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.linkUrl());