mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added Icon Provider class to fix bad icon saving with default QtWebKit
behaviour
This commit is contained in:
parent
c72e589b64
commit
036cb1c30b
@ -115,7 +115,8 @@ SOURCES += main.cpp\
|
||||
sidebar/historysidebar.cpp \
|
||||
desktopnotifications/desktopnotification.cpp \
|
||||
desktopnotifications/desktopnotificationsfactory.cpp \
|
||||
tools/progressbar.cpp
|
||||
tools/progressbar.cpp \
|
||||
tools/iconprovider.cpp
|
||||
|
||||
HEADERS += 3rdparty/squeezelabel.h \
|
||||
3rdparty/qtwin.h \
|
||||
@ -189,7 +190,8 @@ HEADERS += 3rdparty/squeezelabel.h \
|
||||
sidebar/historysidebar.h \
|
||||
desktopnotifications/desktopnotification.h \
|
||||
desktopnotifications/desktopnotificationsfactory.h \
|
||||
tools/progressbar.h
|
||||
tools/progressbar.h \
|
||||
tools/iconprovider.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "autofillmodel.h"
|
||||
#include "adblockmanager.h"
|
||||
#include "desktopnotificationsfactory.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
MainApplication::MainApplication(int &argc, char **argv)
|
||||
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
||||
@ -52,6 +53,7 @@ MainApplication::MainApplication(int &argc, char **argv)
|
||||
,m_autofill(0)
|
||||
,m_networkCache(new QNetworkDiskCache)
|
||||
,m_desktopNotifications(0)
|
||||
,m_iconProvider(new IconProvider)
|
||||
,m_isClosing(false)
|
||||
,m_isChanged(false)
|
||||
,m_isExited(false)
|
||||
@ -199,6 +201,9 @@ void MainApplication::loadSettings()
|
||||
m_websettings->setFontSize(QWebSettings::DefaultFixedFontSize, settings.value("FixedFontSize", m_websettings->fontSize(QWebSettings::DefaultFixedFontSize)).toInt() );
|
||||
|
||||
m_websettings->setDefaultTextEncoding("System");
|
||||
#ifdef Q_WS_X11
|
||||
m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, QIcon::fromTheme("text-plain").pixmap(16,16));
|
||||
#endif
|
||||
|
||||
if (allowPersistentStorage) m_websettings->enablePersistentStorage(m_activeProfil);
|
||||
m_websettings->setMaximumPagesInCache(maxCachedPages);
|
||||
@ -330,8 +335,10 @@ void MainApplication::quitApplication()
|
||||
|
||||
cookieJar()->saveCookies();
|
||||
m_networkmanager->saveCertExceptions();
|
||||
m_iconProvider->saveIconsToDatabase();
|
||||
m_plugins->c2f_saveSettings();
|
||||
AdBlockManager::instance()->save();
|
||||
QFile::remove(getActiveProfil() + "WebpageIcons.db");
|
||||
|
||||
quit();
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class BookmarksModel;
|
||||
class DownloadManager;
|
||||
class AutoFillModel;
|
||||
class DesktopNotificationsFactory;
|
||||
class IconProvider;
|
||||
|
||||
class MainApplication : public QtSingleApplication
|
||||
{
|
||||
@ -84,6 +85,7 @@ public:
|
||||
AutoFillModel* autoFill();
|
||||
QNetworkDiskCache* networkCache() { return m_networkCache; }
|
||||
DesktopNotificationsFactory* desktopNotifications();
|
||||
IconProvider* iconProvider() { return m_iconProvider; }
|
||||
|
||||
public slots:
|
||||
bool saveStateSlot();
|
||||
@ -118,6 +120,7 @@ private:
|
||||
AutoFillModel* m_autofill;
|
||||
QNetworkDiskCache* m_networkCache;
|
||||
DesktopNotificationsFactory* m_desktopNotifications;
|
||||
IconProvider* m_iconProvider;
|
||||
|
||||
QList<QPointer<QupZilla> > m_mainWindows;
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "clickablelabel.h"
|
||||
#include "docktitlebarwidget.h"
|
||||
#include "sidebar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "progressbar.h"
|
||||
|
||||
const QString QupZilla::VERSION = "1.0.0-b1";
|
||||
@ -214,7 +215,7 @@ void QupZilla::aboutToShowHistoryBackMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
QAction* action = m_menuBack->addAction(m_locationBar->icon(item.url()),title, this, SLOT(goAtHistoryIndex()));
|
||||
QAction* action = m_menuBack->addAction(_iconForUrl(item.url()),title, this, SLOT(goAtHistoryIndex()));
|
||||
action->setData(i);
|
||||
}
|
||||
}
|
||||
@ -235,7 +236,7 @@ void QupZilla::aboutToShowHistoryNextMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
QAction* action = m_menuForward->addAction(m_locationBar->icon(item.url()),title, this, SLOT(goAtHistoryIndex()));
|
||||
QAction* action = m_menuForward->addAction(_iconForUrl(item.url()),title, this, SLOT(goAtHistoryIndex()));
|
||||
action->setData(i);
|
||||
}
|
||||
}
|
||||
@ -259,7 +260,7 @@ void QupZilla::aboutToShowBookmarksMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
m_menuBookmarks->addAction(LocationBar::icon(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
m_menuBookmarks->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
}
|
||||
|
||||
QMenu* folderBookmarks = new QMenu(tr("Bookmarks In ToolBar"), m_menuBookmarks);
|
||||
@ -273,7 +274,7 @@ void QupZilla::aboutToShowBookmarksMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
folderBookmarks->addAction(LocationBar::icon(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
folderBookmarks->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
}
|
||||
if (folderBookmarks->isEmpty())
|
||||
folderBookmarks->addAction(tr("Empty"));
|
||||
@ -293,7 +294,7 @@ void QupZilla::aboutToShowBookmarksMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
tempFolder->addAction(LocationBar::icon(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
tempFolder->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
}
|
||||
if (tempFolder->isEmpty())
|
||||
tempFolder->addAction(tr("Empty"));
|
||||
@ -346,7 +347,7 @@ void QupZilla::aboutToShowHistoryMenu()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
m_menuHistory->addAction(LocationBar::icon(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
m_menuHistory->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,12 @@
|
||||
#include "bookmarksmanager.h"
|
||||
#include "ui_bookmarksmanager.h"
|
||||
#include "qupzilla.h"
|
||||
#include "locationbar.h"
|
||||
#include "webview.h"
|
||||
#include "bookmarkstoolbar.h"
|
||||
#include "tabwidget.h"
|
||||
#include "bookmarksmodel.h"
|
||||
#include "qtwin.h"
|
||||
|
||||
//Won't be bad idea to rewrite bookmarks access via bookmarksmodel
|
||||
#include "iconprovider.h"
|
||||
|
||||
BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -233,7 +231,7 @@ void BookmarksManager::refreshTable()
|
||||
item->setToolTip(1, url.toEncoded());
|
||||
|
||||
item->setWhatsThis(1, QString::number(id));
|
||||
item->setIcon(0, LocationBar::icon(url));
|
||||
item->setIcon(0, _iconForUrl(url));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->bookmarksTree->addTopLevelItem(item);
|
||||
}
|
||||
@ -251,7 +249,7 @@ void BookmarksManager::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
item->setText(0, bookmark.title);
|
||||
item->setText(1, bookmark.url.toEncoded());
|
||||
item->setWhatsThis(1, QString::number(bookmark.id));
|
||||
item->setIcon(0, LocationBar::icon(bookmark.url));
|
||||
item->setIcon(0, _iconForUrl(bookmark.url));
|
||||
item->setToolTip(0, bookmark.title);
|
||||
item->setToolTip(1, bookmark.url.toEncoded());
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
@ -347,7 +345,7 @@ void BookmarksManager::insertBookmark(const QUrl &url, const QString &title)
|
||||
label->setText(tr("Choose name and location of bookmark."));
|
||||
edit->setText(title);
|
||||
edit->setCursorPosition(0);
|
||||
dialog->setWindowIcon(LocationBar::icon(url));
|
||||
dialog->setWindowIcon(_iconForUrl(url));
|
||||
dialog->setWindowTitle(tr("Add New Bookmark"));
|
||||
|
||||
QSize size = dialog->size();
|
||||
|
@ -17,8 +17,8 @@
|
||||
* ============================================================ */
|
||||
#include "bookmarkstoolbar.h"
|
||||
#include "qupzilla.h"
|
||||
#include "locationbar.h"
|
||||
#include "bookmarksmodel.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent) :
|
||||
QToolBar(parent)
|
||||
@ -98,7 +98,7 @@ void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
|
||||
action->setText(title);
|
||||
action->setData(bookmark.url);
|
||||
action->setIcon(LocationBar::icon(bookmark.url));
|
||||
action->setIcon(_iconForUrl(bookmark.url));
|
||||
QToolButton* button = new QToolButton(this);
|
||||
button->setDefaultAction(action);
|
||||
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
@ -153,7 +153,7 @@ void BookmarksToolbar::bookmarkEdited(const BookmarksModel::Bookmark &before, co
|
||||
|
||||
action->setText(title);
|
||||
action->setData(after.url);
|
||||
action->setIcon(LocationBar::icon(after.url));
|
||||
action->setIcon(_iconForUrl(after.url));
|
||||
button->setToolTip(after.url.toEncoded());
|
||||
button->setWhatsThis(after.title);
|
||||
}
|
||||
@ -178,7 +178,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
|
||||
action->setText(title);
|
||||
action->setData(url);
|
||||
action->setIcon(LocationBar::icon(url));
|
||||
action->setIcon(_iconForUrl(url));
|
||||
QToolButton* button = new QToolButton(this);
|
||||
button->setDefaultAction(action);
|
||||
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
@ -220,6 +220,6 @@ void BookmarksToolbar::refreshMostVisited()
|
||||
title.truncate(40);
|
||||
title+="..";
|
||||
}
|
||||
m_menuMostVisited->addAction(LocationBar::icon(url), title, p_QupZilla, SLOT(loadActionUrl()))->setData(url);
|
||||
m_menuMostVisited->addAction(_iconForUrl(url), title, p_QupZilla, SLOT(loadActionUrl()))->setData(url);
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,15 @@
|
||||
#include "historymanager.h"
|
||||
#include "ui_historymanager.h"
|
||||
#include "qupzilla.h"
|
||||
#include "locationbar.h"
|
||||
#include "qtwin.h"
|
||||
#include "historymodel.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
,ui(new Ui::HistoryManager)
|
||||
,p_QupZilla(mainClass)
|
||||
,m_historyModel(mApp->history())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
//CENTER on scren
|
||||
@ -48,6 +50,10 @@ HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
||||
connect(ui->historyTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(ui->historyTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
|
||||
connect(m_historyModel, SIGNAL(historyEntryAdded(HistoryModel::HistoryEntry)), this, SLOT(historyEntryAdded(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryDeleted(HistoryModel::HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyClear()), ui->historyTree, SLOT(clear()));
|
||||
|
||||
//QTimer::singleShot(0, this, SLOT(refreshTable()));
|
||||
|
||||
ui->search->setInactiveText(tr("Search"));
|
||||
@ -111,15 +117,54 @@ void HistoryManager::contextMenuRequested(const QPoint &position)
|
||||
void HistoryManager::deleteItem()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->historyTree->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
if (item->text(1).isEmpty())
|
||||
if (!item || item->text(1).isEmpty())
|
||||
return;
|
||||
|
||||
QString id = item->whatsThis(1);
|
||||
QSqlQuery query;
|
||||
query.exec("DELETE FROM history WHERE id="+id);
|
||||
int id = item->whatsThis(1).toInt();
|
||||
m_historyModel->deleteHistoryEntry(id);
|
||||
}
|
||||
|
||||
void HistoryManager::historyEntryAdded(const HistoryModel::HistoryEntry &entry)
|
||||
{
|
||||
QLocale locale(getQupZilla()->activeLanguage().remove(".qm"));
|
||||
|
||||
QString localDate; //date.toString("dddd d. MMMM yyyy");
|
||||
QString month = locale.monthName(entry.date.toString("M").toInt());
|
||||
localDate = entry.date.toString(" d. ") + month + entry.date.toString(" yyyy");
|
||||
|
||||
QTreeWidgetItem* item;
|
||||
QList<QTreeWidgetItem*> findParent = ui->historyTree->findItems(localDate, 0);
|
||||
if (findParent.count() == 1) {
|
||||
item = new QTreeWidgetItem(findParent.at(0));
|
||||
} else {
|
||||
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->historyTree);
|
||||
newParent->setText(0, localDate);
|
||||
newParent->setIcon(0, QIcon(":/icons/menu/history_entry.png"));
|
||||
ui->historyTree->addTopLevelItem(newParent);
|
||||
item = new QTreeWidgetItem(newParent);
|
||||
}
|
||||
|
||||
item->setText(0, entry.title);
|
||||
item->setText(1, entry.url.toEncoded());
|
||||
item->setToolTip(0, entry.title);
|
||||
item->setToolTip(1, entry.url.toEncoded());
|
||||
|
||||
item->setWhatsThis(1, QString::number(entry.id));
|
||||
item->setIcon(0, _iconForUrl(entry.url));
|
||||
ui->historyTree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
void HistoryManager::historyEntryDeleted(const HistoryModel::HistoryEntry &entry)
|
||||
{
|
||||
QList<QTreeWidgetItem*> list = ui->historyTree->allItems();
|
||||
foreach (QTreeWidgetItem* item, list) {
|
||||
if (!item)
|
||||
continue;
|
||||
if (item->whatsThis(1).toInt() != entry.id)
|
||||
continue;
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryManager::clearHistory()
|
||||
@ -129,10 +174,8 @@ void HistoryManager::clearHistory()
|
||||
if (button != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
QSqlQuery query;
|
||||
query.exec("DELETE FROM history");
|
||||
ui->historyTree->clear();
|
||||
query.exec("VACUUM");
|
||||
m_historyModel->clearHistory();
|
||||
m_historyModel->optimizeHistory();
|
||||
}
|
||||
|
||||
void HistoryManager::refreshTable()
|
||||
@ -154,8 +197,6 @@ void HistoryManager::refreshTable()
|
||||
date = date.fromMSecsSinceEpoch(unixDate);
|
||||
|
||||
QString localDate; //date.toString("dddd d. MMMM yyyy");
|
||||
//QString day = locale.dayName(date.toString("d").toInt());
|
||||
|
||||
QString month = locale.monthName(date.toString("M").toInt());
|
||||
localDate = date.toString(" d. ") + month + date.toString(" yyyy");
|
||||
|
||||
@ -177,7 +218,7 @@ void HistoryManager::refreshTable()
|
||||
item->setToolTip(1, url.toEncoded());
|
||||
|
||||
item->setWhatsThis(1, QString::number(id));
|
||||
item->setIcon(0, LocationBar::icon(url));
|
||||
item->setIcon(0, _iconForUrl(url));
|
||||
ui->historyTree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
@ -205,6 +246,7 @@ void HistoryManager::search()
|
||||
item->setText(0, fitem->text(0));
|
||||
item->setText(1, fitem->text(1));
|
||||
item->setWhatsThis(1, fitem->whatsThis(1));
|
||||
item->setIcon(0, _iconForUrl(fitem->text(1)));
|
||||
foundItems.append(item);
|
||||
}
|
||||
ui->historyTree->clear();
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QPointer>
|
||||
|
||||
#include "historymodel.h"
|
||||
|
||||
namespace Ui {
|
||||
class HistoryManager;
|
||||
}
|
||||
@ -49,10 +51,14 @@ private slots:
|
||||
void loadInNewTab();
|
||||
void itemControlClicked(QTreeWidgetItem* item);
|
||||
|
||||
void historyEntryAdded(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryDeleted(const HistoryModel::HistoryEntry &entry);
|
||||
|
||||
private:
|
||||
QupZilla* getQupZilla();
|
||||
Ui::HistoryManager* ui;
|
||||
QPointer<QupZilla> p_QupZilla;
|
||||
HistoryModel* m_historyModel;
|
||||
};
|
||||
|
||||
#endif // HISTORYMANAGER_H
|
||||
|
@ -53,6 +53,15 @@ int HistoryModel::addHistoryEntry(const QString &url, QString &title)
|
||||
query.bindValue(1, url);
|
||||
query.bindValue(2, title);
|
||||
query.exec();
|
||||
|
||||
int id = query.lastInsertId().toInt();
|
||||
HistoryEntry entry;
|
||||
entry.id = id;
|
||||
entry.count = 1;
|
||||
entry.date = QDateTime::currentDateTime();
|
||||
entry.url = url;
|
||||
entry.title = title;
|
||||
emit historyEntryAdded(entry);
|
||||
} else {
|
||||
query.prepare("UPDATE history SET count = count + 1, date=?, title=? WHERE url=?");
|
||||
query.bindValue(0, QDateTime::currentMSecsSinceEpoch());
|
||||
@ -67,6 +76,7 @@ int HistoryModel::addHistoryEntry(WebView* view)
|
||||
{
|
||||
if (!m_isSaving)
|
||||
return -2;
|
||||
|
||||
QString url = view->url().toString();
|
||||
QString title = view->title();
|
||||
return addHistoryEntry(url, title);
|
||||
@ -75,22 +85,39 @@ int HistoryModel::addHistoryEntry(WebView* view)
|
||||
bool HistoryModel::deleteHistoryEntry(int index)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
|
||||
query.bindValue(0, index);
|
||||
query.exec();
|
||||
if (!query.next())
|
||||
return false;
|
||||
HistoryEntry entry;
|
||||
entry.id = query.value(0).toInt();
|
||||
entry.count = query.value(1).toInt();
|
||||
entry.date = QDateTime::fromMSecsSinceEpoch(query.value(2).toLongLong());
|
||||
entry.url = query.value(3).toUrl();
|
||||
entry.title = query.value(4).toString();
|
||||
|
||||
query.prepare("DELETE FROM history WHERE id=?");
|
||||
query.bindValue(0, index);
|
||||
if (query.exec())
|
||||
if (query.exec()) {
|
||||
emit historyEntryDeleted(entry);
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryModel::deleteHistoryEntry(const QString &url, const QString &title)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("DELETE FROM history WHERE url=? AND title=?");
|
||||
query.prepare("SELECT id FROM history WHERE url=? AND title=?");
|
||||
query.bindValue(0, url);
|
||||
query.bindValue(1, title);
|
||||
if (query.exec())
|
||||
return true;
|
||||
else return false;
|
||||
query.exec();
|
||||
if (query.next()) {
|
||||
int id = query.value(0).toInt();
|
||||
return deleteHistoryEntry(id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryModel::optimizeHistory()
|
||||
@ -102,7 +129,11 @@ bool HistoryModel::optimizeHistory()
|
||||
bool HistoryModel::clearHistory()
|
||||
{
|
||||
QSqlQuery query;
|
||||
return query.exec("DELETE FROM history");
|
||||
if (query.exec("DELETE FROM history")) {
|
||||
emit historyClear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HistoryModel::setSaving(bool state)
|
||||
|
@ -18,10 +18,11 @@
|
||||
#ifndef HISTORYMODEL_H
|
||||
#define HISTORYMODEL_H
|
||||
|
||||
#include "QtSql/QSqlDatabase"
|
||||
#include "QSqlQuery"
|
||||
#include "QDateTime"
|
||||
#include "QFile"
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QUrl>
|
||||
|
||||
class QupZilla;
|
||||
class WebView;
|
||||
@ -31,6 +32,14 @@ class HistoryModel : public QObject
|
||||
public:
|
||||
HistoryModel(QupZilla* mainClass, QObject* parent = 0);
|
||||
|
||||
struct HistoryEntry {
|
||||
int id;
|
||||
int count;
|
||||
QDateTime date;
|
||||
QUrl url;
|
||||
QString title;
|
||||
};
|
||||
|
||||
int addHistoryEntry(WebView* view);
|
||||
int addHistoryEntry(const QString &url, QString &title);
|
||||
bool deleteHistoryEntry(int index);
|
||||
@ -43,6 +52,11 @@ public:
|
||||
|
||||
void loadSettings();
|
||||
|
||||
signals:
|
||||
void historyEntryAdded(HistoryModel::HistoryEntry entry);
|
||||
void historyEntryDeleted(HistoryModel::HistoryEntry entry);
|
||||
void historyClear();
|
||||
|
||||
private:
|
||||
bool m_isSaving;
|
||||
QupZilla* p_QupZilla;
|
||||
|
@ -152,31 +152,6 @@ void LocationBar::rssIconClicked()
|
||||
rss->showAt(this);
|
||||
}
|
||||
|
||||
QIcon LocationBar::icon(const QUrl &url)
|
||||
{
|
||||
QUrl url2 = url.scheme() + "://" + url.host();
|
||||
url2.host().remove("www");
|
||||
|
||||
QIcon icon = QWebSettings::iconForUrl(url);
|
||||
if (icon.isNull())
|
||||
icon = QWebSettings::iconForUrl(url2);
|
||||
|
||||
if (icon.isNull())
|
||||
icon = QWebSettings::iconForUrl(url2.host().prepend("www"));
|
||||
|
||||
if (!icon.isNull())
|
||||
return icon.pixmap(16, 16);
|
||||
if (icon.isNull()) {
|
||||
QPixmap pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic);
|
||||
if (pixmap.isNull()) {
|
||||
pixmap = QPixmap(":icons/locationbar/unknownpage.png");
|
||||
QWebSettings::setWebGraphic(QWebSettings::DefaultFrameIconGraphic, pixmap);
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
void LocationBar::showUrl(const QUrl &url, bool empty)
|
||||
{
|
||||
if (url.isEmpty() && empty)
|
||||
@ -221,7 +196,7 @@ void LocationBar::siteIconChanged()
|
||||
icon_ = p_QupZilla->weView()->siteIcon();
|
||||
|
||||
if (icon_.isNull()) {
|
||||
m_siteIcon->setIcon(QIcon(":icons/locationbar/unknownpage.png"));
|
||||
m_siteIcon->setIcon(QIcon(QIcon::fromTheme("text-plain").pixmap(16,16)));
|
||||
} else {
|
||||
// QIcon icon(*icon_);
|
||||
m_siteIcon->setIcon(QIcon(icon_.pixmap(16,16)));
|
||||
|
@ -43,7 +43,6 @@ class LocationBar : public LineEdit
|
||||
public:
|
||||
explicit LocationBar(QupZilla* mainClass, QWidget* parent = 0);
|
||||
~LocationBar();
|
||||
static QIcon icon(const QUrl &url);
|
||||
|
||||
void loadSettings();
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
* ============================================================ */
|
||||
#include "locationcompleter.h"
|
||||
#include "locationbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "mainapplication.h"
|
||||
|
||||
LocationCompleter::LocationCompleter(QObject* parent) :
|
||||
QCompleter(parent)
|
||||
@ -89,7 +91,7 @@ void LocationCompleter::loadInitialHistory()
|
||||
QStandardItem* findUrl = new QStandardItem();
|
||||
QString url = query.value(1).toUrl().toEncoded();
|
||||
|
||||
iconText->setIcon(LocationBar::icon(query.value(1).toUrl()).pixmap(16,16));
|
||||
iconText->setIcon(_iconForUrl(query.value(1).toUrl()).pixmap(16,16));
|
||||
iconText->setText(query.value(0).toString().replace("\n","").append("\n"+url));
|
||||
|
||||
findUrl->setText(url);
|
||||
@ -121,7 +123,7 @@ void LocationCompleter::refreshCompleter(QString string)
|
||||
QStandardItem* findUrl = new QStandardItem();
|
||||
QString url = query.value(1).toUrl().toEncoded();
|
||||
|
||||
iconText->setIcon(LocationBar::icon(query.value(1).toUrl()).pixmap(16,16));
|
||||
iconText->setIcon(_iconForUrl(query.value(1).toUrl()).pixmap(16,16));
|
||||
iconText->setText(query.value(0).toString().replace("\n","").append("\n"+url));
|
||||
|
||||
findUrl->setText(url);
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "webview.h"
|
||||
#include "webpage.h"
|
||||
#include "qtwin.h"
|
||||
#include "desktopnotificationsfactory.h"
|
||||
|
||||
AboutDialog::AboutDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
@ -39,7 +38,6 @@ AboutDialog::AboutDialog(QWidget* parent) :
|
||||
connect(ui->authorsButton, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
||||
|
||||
showAbout();
|
||||
|
||||
}
|
||||
|
||||
void AboutDialog::buttonClicked()
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include "rssmanager.h"
|
||||
#include "ui_rssmanager.h"
|
||||
#include "qupzilla.h"
|
||||
#include "locationbar.h"
|
||||
#include "tabwidget.h"
|
||||
#include "mainapplication.h"
|
||||
#include "treewidget.h"
|
||||
#include "qtwin.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -91,10 +91,8 @@ void RSSManager::refreshTable()
|
||||
item->setText(0, tr("Loading..."));
|
||||
tree->addTopLevelItem(item);
|
||||
|
||||
QIcon icon = LocationBar::icon(address);
|
||||
QIcon icon = _iconForUrl(address);
|
||||
|
||||
if (icon.pixmap(16,16).toImage() == QIcon(":/icons/locationbar/unknownpage.png").pixmap(16,16).toImage())
|
||||
icon = QIcon(":/icons/menu/rss.png");
|
||||
ui->tabWidget->setTabIcon(i, icon );
|
||||
beginToLoadSlot(address);
|
||||
i++;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "mainapplication.h"
|
||||
#include "ui_bookmarkssidebar.h"
|
||||
#include "qupzilla.h"
|
||||
#include "locationbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "webview.h"
|
||||
#include "bookmarkstoolbar.h"
|
||||
#include "tabwidget.h"
|
||||
@ -125,7 +125,7 @@ void BookmarksSideBar::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
item->setText(0, bookmark.title);
|
||||
item->setText(1, bookmark.url.toEncoded());
|
||||
item->setWhatsThis(0, QString::number(bookmark.id));
|
||||
item->setIcon(0, LocationBar::icon(bookmark.url));
|
||||
item->setIcon(0, _iconForUrl(bookmark.url));
|
||||
item->setToolTip(0, bookmark.url.toEncoded());
|
||||
|
||||
if (bookmark.folder != "unsorted")
|
||||
@ -242,7 +242,7 @@ void BookmarksSideBar::refreshTable()
|
||||
// item->setToolTip(1, url.toEncoded());
|
||||
|
||||
item->setWhatsThis(0, QString::number(id));
|
||||
item->setIcon(0, LocationBar::icon(url));
|
||||
item->setIcon(0, _iconForUrl(url));
|
||||
ui->bookmarksTree->addTopLevelItem(item);
|
||||
}
|
||||
ui->bookmarksTree->expandAll();
|
||||
|
@ -1,11 +1,14 @@
|
||||
#include "historysidebar.h"
|
||||
#include "ui_historysidebar.h"
|
||||
#include "qupzilla.h"
|
||||
#include "historymodel.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
HistorySideBar::HistorySideBar(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
,ui(new Ui::HistorySideBar)
|
||||
,p_QupZilla(mainClass)
|
||||
,m_historyModel(mApp->history())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->historyTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
@ -13,7 +16,9 @@ HistorySideBar::HistorySideBar(QupZilla* mainClass, QWidget* parent) :
|
||||
connect(ui->historyTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
connect(ui->search, SIGNAL(textEdited(QString)), this, SLOT(search()));
|
||||
|
||||
new QShortcut(QKeySequence("Del"), this, SLOT(deleteItem()), 0, Qt::WidgetWithChildrenShortcut);
|
||||
connect(m_historyModel, SIGNAL(historyEntryAdded(HistoryModel::HistoryEntry)), this, SLOT(historyEntryAdded(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryDeleted(HistoryModel::HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyClear()), ui->historyTree, SLOT(clear()));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(refreshTable()));
|
||||
}
|
||||
@ -49,8 +54,6 @@ void HistorySideBar::contextMenuRequested(const QPoint &position)
|
||||
QMenu menu;
|
||||
menu.addAction(tr("Open link in actual tab"), p_QupZilla, SLOT(loadActionUrl()))->setData(link);
|
||||
menu.addAction(tr("Open link in new tab"), this, SLOT(loadInNewTab()))->setData(link);
|
||||
menu.addSeparator();
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Remove Entry"), this, SLOT(deleteItem()));
|
||||
|
||||
@ -68,10 +71,51 @@ void HistorySideBar::deleteItem()
|
||||
if (item->text(1).isEmpty())
|
||||
return;
|
||||
|
||||
QString id = item->whatsThis(1);
|
||||
QSqlQuery query;
|
||||
query.exec("DELETE FROM history WHERE id="+id);
|
||||
int id = item->whatsThis(1).toInt();
|
||||
m_historyModel->deleteHistoryEntry(id);
|
||||
}
|
||||
|
||||
void HistorySideBar::historyEntryAdded(const HistoryModel::HistoryEntry &entry)
|
||||
{
|
||||
QLocale locale(p_QupZilla->activeLanguage().remove(".qm"));
|
||||
|
||||
QString localDate; //date.toString("dddd d. MMMM yyyy");
|
||||
QString month = locale.monthName(entry.date.toString("M").toInt());
|
||||
localDate = entry.date.toString(" d. ") + month + entry.date.toString(" yyyy");
|
||||
|
||||
QTreeWidgetItem* item;
|
||||
QList<QTreeWidgetItem*> findParent = ui->historyTree->findItems(localDate, 0);
|
||||
if (findParent.count() == 1) {
|
||||
item = new QTreeWidgetItem(findParent.at(0));
|
||||
} else {
|
||||
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->historyTree);
|
||||
newParent->setText(0, localDate);
|
||||
newParent->setIcon(0, QIcon(":/icons/menu/history_entry.png"));
|
||||
ui->historyTree->addTopLevelItem(newParent);
|
||||
item = new QTreeWidgetItem(newParent);
|
||||
}
|
||||
|
||||
item->setText(0, entry.title);
|
||||
item->setText(1, entry.url.toEncoded());
|
||||
item->setToolTip(0, entry.title);
|
||||
item->setToolTip(1, entry.url.toEncoded());
|
||||
|
||||
item->setWhatsThis(1, QString::number(entry.id));
|
||||
item->setIcon(0, _iconForUrl(entry.url));
|
||||
ui->historyTree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
void HistorySideBar::historyEntryDeleted(const HistoryModel::HistoryEntry &entry)
|
||||
{
|
||||
QList<QTreeWidgetItem*> list = ui->historyTree->allItems();
|
||||
foreach (QTreeWidgetItem* item, list) {
|
||||
if (!item)
|
||||
continue;
|
||||
if (item->whatsThis(1).toInt() != entry.id)
|
||||
continue;
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void HistorySideBar::search()
|
||||
@ -94,7 +138,7 @@ void HistorySideBar::search()
|
||||
item->setText(0, fitem->text(0));
|
||||
item->setText(1, fitem->text(1));
|
||||
item->setWhatsThis(1, fitem->whatsThis(1));
|
||||
item->setIcon(0, LocationBar::icon(QUrl(fitem->text(1))));
|
||||
item->setIcon(0, _iconForUrl(fitem->text(1)));
|
||||
foundItems.append(item);
|
||||
}
|
||||
ui->historyTree->clear();
|
||||
@ -144,7 +188,7 @@ void HistorySideBar::refreshTable()
|
||||
item->setToolTip(1, url.toEncoded());
|
||||
|
||||
item->setWhatsThis(1, QString::number(id));
|
||||
item->setIcon(0, LocationBar::icon(url));
|
||||
item->setIcon(0, _iconForUrl(url));
|
||||
ui->historyTree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QPointer>
|
||||
#include <QShortcut>
|
||||
|
||||
#include "historymodel.h"
|
||||
|
||||
namespace Ui {
|
||||
class HistorySideBar;
|
||||
}
|
||||
@ -30,9 +32,13 @@ private slots:
|
||||
void loadInNewTab();
|
||||
void itemControlClicked(QTreeWidgetItem* item);
|
||||
|
||||
void historyEntryAdded(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryDeleted(const HistoryModel::HistoryEntry &entry);
|
||||
|
||||
private:
|
||||
Ui::HistorySideBar* ui;
|
||||
QPointer<QupZilla> p_QupZilla;
|
||||
HistoryModel* m_historyModel;
|
||||
};
|
||||
|
||||
#endif // HISTORYSIDEBAR_H
|
||||
|
88
src/tools/iconprovider.cpp
Normal file
88
src/tools/iconprovider.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#include "iconprovider.h"
|
||||
#include "webview.h"
|
||||
|
||||
IconProvider::IconProvider(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setInterval(30*1000);
|
||||
m_timer->start();
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(saveIconsToDatabase()));
|
||||
}
|
||||
|
||||
void IconProvider::saveIcon(WebView *view)
|
||||
{
|
||||
Icon item;
|
||||
item.icon = view->icon();
|
||||
item.url = view->url();
|
||||
|
||||
if (item.icon.isNull())
|
||||
return;
|
||||
|
||||
foreach (Icon ic, m_iconBuffer) {
|
||||
if (ic.url == item.url && ic.icon.pixmap(16,16).toImage() == item.icon.pixmap(16,16).toImage())
|
||||
return;
|
||||
}
|
||||
|
||||
m_iconBuffer.append(item);
|
||||
}
|
||||
|
||||
QIcon IconProvider::iconForUrl(const QUrl &url)
|
||||
{
|
||||
foreach (Icon ic, m_iconBuffer) {
|
||||
if (ic.url == url)
|
||||
return ic.icon;
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT icon FROM icons WHERE url = ?");
|
||||
query.bindValue(0, url.toEncoded());
|
||||
query.exec();
|
||||
if (query.next()) {
|
||||
QIcon image;
|
||||
QByteArray bArray = QByteArray::fromBase64(query.value(0).toByteArray());
|
||||
QBuffer buffer(&bArray);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
QDataStream in(&buffer);
|
||||
in >> image;
|
||||
buffer.close();
|
||||
|
||||
if (!image.isNull())
|
||||
return image;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
return QIcon::fromTheme("text-plain");
|
||||
#else
|
||||
return QIcon(":icons/other/unknownpage.png");
|
||||
#endif
|
||||
}
|
||||
|
||||
void IconProvider::saveIconsToDatabase()
|
||||
{
|
||||
foreach (Icon ic, m_iconBuffer) {
|
||||
QByteArray bArray;
|
||||
QBuffer buffer(&bArray);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
QDataStream out(&buffer);
|
||||
out << ic.icon;
|
||||
buffer.close();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT id FROM icons WHERE url = ?");
|
||||
query.bindValue(0, ic.url.toEncoded());
|
||||
query.exec();
|
||||
|
||||
if (query.next())
|
||||
query.prepare("UPDATE icons SET icon = ? WHERE url = ?");
|
||||
else
|
||||
query.prepare("INSERT INTO icons (icon, url) VALUES (?,?)");
|
||||
|
||||
query.bindValue(0, bArray.toBase64());
|
||||
query.bindValue(1, ic.url.toEncoded());
|
||||
query.exec();
|
||||
}
|
||||
|
||||
m_iconBuffer.clear();
|
||||
}
|
||||
|
38
src/tools/iconprovider.h
Normal file
38
src/tools/iconprovider.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef ICONPROVIDER_H
|
||||
#define ICONPROVIDER_H
|
||||
|
||||
#define _iconForUrl(url) mApp->iconProvider()->iconForUrl(url)
|
||||
|
||||
#include <QObject>
|
||||
#include <QIcon>
|
||||
#include <QUrl>
|
||||
#include <QSqlQuery>
|
||||
#include <QBuffer>
|
||||
#include <QTimer>
|
||||
|
||||
class WebView;
|
||||
class IconProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IconProvider(QObject* parent = 0);
|
||||
void saveIcon(WebView* view);
|
||||
QIcon iconForUrl(const QUrl &url);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void saveIconsToDatabase();
|
||||
|
||||
private:
|
||||
QTimer* m_timer;
|
||||
struct Icon {
|
||||
QUrl url;
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
QList<Icon> m_iconBuffer;
|
||||
|
||||
};
|
||||
|
||||
#endif // ICONPROVIDER_H
|
@ -20,7 +20,7 @@
|
||||
#include "qupzilla.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbar.h"
|
||||
#include "locationbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "mainapplication.h"
|
||||
#include "webtab.h"
|
||||
#include "clickablelabel.h"
|
||||
@ -172,7 +172,7 @@ void TabWidget::aboutToShowTabsMenu()
|
||||
if (view == actView)
|
||||
action->setIcon(QIcon(":/icons/menu/circle.png"));
|
||||
else
|
||||
action->setIcon(LocationBar::icon(view->url()));
|
||||
action->setIcon(_iconForUrl(view->url()));
|
||||
if (view->title().isEmpty()) {
|
||||
if (view->isLoading()) {
|
||||
action->setText(tr("Loading..."));
|
||||
@ -212,7 +212,7 @@ int TabWidget::addView(QUrl url, const QString &title, OpenUrlIn openIn, bool se
|
||||
int index = addTab(new WebTab(p_QupZilla),"");
|
||||
setTabText(index, title);
|
||||
weView(index)->animationLoading(index, true)->movie()->stop();
|
||||
weView(index)->animationLoading(index, false)->setPixmap(LocationBar::icon(url).pixmap(16,16));
|
||||
weView(index)->animationLoading(index, false)->setPixmap(_iconForUrl(url).pixmap(16,16));
|
||||
|
||||
if (openIn == TabWidget::NewSelectedTab) {
|
||||
setCurrentIndex(index);
|
||||
|
@ -140,7 +140,7 @@ void WebPage::addAdBlockRule(const QString &filter, const QUrl &url)
|
||||
m_adBlockedEntries.append(entry);
|
||||
}
|
||||
|
||||
bool WebPage::extension(const Extension &extension, const ExtensionOption* option, ExtensionReturn* output)
|
||||
bool WebPage::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output)
|
||||
{
|
||||
if (extension == ChooseMultipleFilesExtension)
|
||||
return QWebPage::extension(extension, option, output);
|
||||
|
@ -48,8 +48,8 @@ public:
|
||||
void setSSLCertificate(const QSslCertificate &cert);
|
||||
QSslCertificate sslCertificate();
|
||||
QString userAgentForUrl(const QUrl &url) const;
|
||||
bool supportsExtension(const Extension &extension) const { return (extension == ErrorPageExtension); }
|
||||
bool extension(const Extension &extension, const ExtensionOption* option, ExtensionReturn* output);
|
||||
virtual bool supportsExtension(Extension extension) const { return (extension == ErrorPageExtension); }
|
||||
virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
|
||||
void addAdBlockRule(const QString &filter, const QUrl &url);
|
||||
QList<AdBlockedEntry> adBlockedEntries() { return m_adBlockedEntries; }
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "mainapplication.h"
|
||||
#include "tabbar.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "iconprovider.h"
|
||||
#include "webtab.h"
|
||||
|
||||
WebView::WebView(QupZilla* mainClass, QWidget* parent)
|
||||
@ -80,8 +81,8 @@ WebView::WebView(QupZilla* mainClass, QWidget* parent)
|
||||
|
||||
void WebView::slotIconChanged()
|
||||
{
|
||||
mApp->iconProvider()->saveIcon(this);
|
||||
m_siteIcon = icon();
|
||||
// iconChanged();
|
||||
}
|
||||
|
||||
WebPage* WebView::webPage() const
|
||||
@ -242,7 +243,7 @@ void WebView::iconChanged()
|
||||
if (!icon_.isNull())
|
||||
animationLoading(tabIndex(), false)->setPixmap(icon_.pixmap(16,16));
|
||||
else
|
||||
animationLoading(tabIndex(), false)->setPixmap(QIcon(":icons/locationbar/unknownpage.png").pixmap(16,16));
|
||||
animationLoading(tabIndex(), false)->setPixmap(QIcon::fromTheme("text-plain").pixmap(16,16));
|
||||
|
||||
if (isCurrent())
|
||||
emit siteIconChanged();
|
||||
@ -254,7 +255,7 @@ QIcon WebView::siteIcon()
|
||||
return icon();
|
||||
if (!m_siteIcon.isNull())
|
||||
return m_siteIcon;
|
||||
return LocationBar::icon(url());
|
||||
return _iconForUrl(url());
|
||||
}
|
||||
|
||||
void WebView::linkHovered(const QString &link, const QString &title, const QString &content)
|
||||
|
Loading…
Reference in New Issue
Block a user