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

Removed use of whatsThis() and other code cleanups

This commit is contained in:
nowrep 2012-03-13 17:51:06 +01:00
parent 3a9c4f104b
commit f590ad1925
30 changed files with 204 additions and 222 deletions

View File

@ -91,7 +91,7 @@ void AdBlockDialog::deleteRule()
return;
}
int offset = item->whatsThis(0).toInt();
int offset = item->data(0, Qt::UserRole + 10).toInt();
m_manager->subscription()->removeRule(offset);
treeWidget->deleteItem(item);
refresh();
@ -156,7 +156,7 @@ void AdBlockDialog::refresh()
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(0, (rule.filter().startsWith("!")) ? Qt::Unchecked : Qt::Checked);
item->setText(0, rule.filter());
item->setWhatsThis(0, QString::number(index - 1));
item->setData(0, Qt::UserRole + 10, index - 1);
if (rule.filter().startsWith("!")) {
item->setFont(0, italicFont);
}
@ -175,7 +175,7 @@ void AdBlockDialog::itemChanged(QTreeWidgetItem* item)
m_itemChangingBlock = true;
if (item->checkState(0) == Qt::Unchecked && !item->text(0).startsWith("!")) { //Disable rule
int offset = item->whatsThis(0).toInt();
int offset = item->data(0, Qt::UserRole + 10).toInt();
QFont italicFont;
italicFont.setItalic(true);
item->setFont(0, italicFont);
@ -186,7 +186,7 @@ void AdBlockDialog::itemChanged(QTreeWidgetItem* item)
}
else if (item->checkState(0) == Qt::Checked && item->text(0).startsWith("!")) { //Enable rule
int offset = item->whatsThis(0).toInt();
int offset = item->data(0, Qt::UserRole + 10).toInt();
item->setFont(0, QFont());
QString newText = item->text(0).mid(1);
item->setText(0, newText);
@ -196,7 +196,7 @@ void AdBlockDialog::itemChanged(QTreeWidgetItem* item)
}
else { //Custom rule has been changed
int offset = item->whatsThis(0).toInt();
int offset = item->data(0, Qt::UserRole + 10).toInt();
AdBlockRule rul(item->text(0));
m_manager->subscription()->replaceRule(rul, offset);
@ -219,7 +219,7 @@ void AdBlockDialog::addCustomRule()
m_itemChangingBlock = true;
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, newRule);
item->setWhatsThis(0, QString::number(offset));
item->setData(0, Qt::UserRole + 10, offset);
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(0, Qt::Checked);

View File

@ -159,7 +159,7 @@ void BookmarksManager::itemChanged(QTreeWidgetItem* item)
QString name = item->text(0);
QUrl url = QUrl::fromEncoded(item->text(1).toUtf8());
int id = item->whatsThis(1).toInt();
int id = item->data(0, Qt::UserRole + 10).toInt();
ui->bookmarksTree->deleteItem(item);
m_bookmarksModel->editBookmark(id, name, url, "");
@ -193,7 +193,7 @@ void BookmarksManager::deleteItem()
return;
}
int id = item->whatsThis(1).toInt();
int id = item->data(0, Qt::UserRole + 10).toInt();
m_bookmarksModel->removeBookmark(id);
}
@ -209,7 +209,9 @@ void BookmarksManager::moveBookmark()
return;
}
if (QAction* action = qobject_cast<QAction*>(sender())) {
m_bookmarksModel->editBookmark(item->whatsThis(1).toInt(), item->text(0), QUrl(), action->data().toString());
int id = item->data(0, Qt::UserRole + 10).toInt();
m_bookmarksModel->editBookmark(id, item->text(0), QUrl(), action->data().toString());
}
}
@ -323,7 +325,7 @@ void BookmarksManager::refreshTable()
item->setToolTip(0, title);
item->setToolTip(1, url.toEncoded());
item->setWhatsThis(1, QString::number(id));
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, icon);
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->bookmarksTree->addTopLevelItem(item);
@ -351,7 +353,7 @@ void BookmarksManager::refreshTable()
item->setToolTip(0, title);
item->setToolTip(1, url.toEncoded());
item->setWhatsThis(1, QString::number(id));
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, icon);
item->setFlags(item->flags() | Qt::ItemIsEditable);
}
@ -370,7 +372,7 @@ void BookmarksManager::addBookmark(const BookmarksModel::Bookmark &bookmark)
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, bookmark.title);
item->setText(1, bookmark.url.toEncoded());
item->setWhatsThis(1, QString::number(bookmark.id));
item->setData(0, Qt::UserRole + 10, bookmark.id);
item->setIcon(0, IconProvider::iconFromImage(bookmark.image));
item->setToolTip(0, bookmark.title);
item->setToolTip(1, bookmark.url.toEncoded());
@ -420,7 +422,10 @@ void BookmarksManager::removeBookmark(const BookmarksModel::Bookmark &bookmark)
if (!item) {
continue;
}
if (item->text(0) == bookmark.title && item->whatsThis(1) == QString::number(bookmark.id)) {
int id = item->data(0, Qt::UserRole + 10).toInt();
if (item->text(0) == bookmark.title && id == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
return;
}
@ -432,7 +437,9 @@ void BookmarksManager::removeBookmark(const BookmarksModel::Bookmark &bookmark)
return;
}
QTreeWidgetItem* item = list.at(0);
if (item && item->whatsThis(1) == QString::number(bookmark.id)) {
int id = item->data(0, Qt::UserRole + 10).toInt();
if (item && id == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
}
}
@ -450,7 +457,10 @@ void BookmarksManager::removeBookmark(const BookmarksModel::Bookmark &bookmark)
if (!item) {
continue;
}
if (item->text(0) == bookmark.title && item->whatsThis(1) == QString::number(bookmark.id)) {
int id = item->data(0, Qt::UserRole + 10).toInt();
if (item->text(0) == bookmark.title && id == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
return;
}

View File

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

View File

@ -407,7 +407,6 @@ void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark)
button->setToolButtonStyle(m_toolButtonStyle);
button->setToolTip(bookmark.url.toEncoded());
button->setAutoRaise(true);
button->setWhatsThis(bookmark.title);
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, SIGNAL(clicked()), this, SLOT(loadClickedBookmark()));
@ -473,7 +472,6 @@ void BookmarksToolbar::bookmarkEdited(const BookmarksModel::Bookmark &before, co
button->setData(v);
button->setIcon(IconProvider::iconFromImage(after.image));
button->setToolTip(after.url.toEncoded());
button->setWhatsThis(after.title);
return;
}
}
@ -506,7 +504,6 @@ void BookmarksToolbar::refreshBookmarks()
button->setIcon(IconProvider::iconFromImage(bookmark.image));
button->setToolButtonStyle(m_toolButtonStyle);
button->setToolTip(bookmark.url.toEncoded());
button->setWhatsThis(bookmark.title);
button->setAutoRaise(true);
button->setContextMenuPolicy(Qt::CustomContextMenu);

View File

@ -103,7 +103,7 @@ void BookmarksImportDialog::startFetchingIcons()
m_fetcher = new BookmarksImportIconFetcher();
m_fetcher->moveToThread(m_fetcherThread);
QIcon defaultIcon = QIcon(QWebSettings::globalSettings()->webGraphic(QWebSettings::DefaultFrameIconGraphic));
QIcon defaultIcon = IconProvider::emptyWebIcon();
QIcon folderIcon = style()->standardIcon(QStyle::SP_DirIcon);
QHash<QString, QTreeWidgetItem*> hash;

View File

@ -84,7 +84,7 @@ void CookieManager::removeCookie()
QList<QNetworkCookie> allCookies = mApp->cookieJar()->getAllCookies();
if (current->text(1).isEmpty()) { //Remove whole cookie group
QString domain = current->whatsThis(0);
const QString &domain = current->data(0, Qt::UserRole + 10).toString();
foreach(const QNetworkCookie & cookie, allCookies) {
if (cookie.domain() == domain || cookie.domain() == domain.mid(1)) {
allCookies.removeOne(cookie);
@ -171,7 +171,7 @@ void CookieManager::slotRefreshTable()
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->cookieTree);
newParent->setText(0, cookieDomain);
newParent->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
newParent->setWhatsThis(0, cookie.domain());
newParent->setData(0, Qt::UserRole + 10, cookie.domain());
ui->cookieTree->addTopLevelItem(newParent);
hash[cookieDomain] = newParent;

View File

@ -140,7 +140,7 @@ void HistoryManager::deleteItem()
continue;
}
int id = children->whatsThis(1).toInt();
int id = children->data(0, Qt::UserRole + 10).toInt();
list.append(id);
m_ignoredIds.append(id);
@ -153,7 +153,7 @@ void HistoryManager::deleteItem()
ui->historyTree->deleteItems(items);
}
else {
int id = item->whatsThis(1).toInt();
int id = item->data(0, Qt::UserRole + 10).toInt();
list.append(id);
m_ignoredIds.append(id);
@ -204,7 +204,7 @@ void HistoryManager::historyEntryAdded(const HistoryEntry &entry)
item->setToolTip(0, entry.title);
item->setToolTip(1, entry.url.toEncoded());
item->setWhatsThis(1, QString::number(entry.id));
item->setData(0, Qt::UserRole + 10, entry.id);
item->setIcon(0, _iconForUrl(entry.url));
ui->historyTree->prependToParentItem(parentItem, item);
}
@ -221,7 +221,7 @@ void HistoryManager::historyEntryDeleted(const HistoryEntry &entry)
if (!item) {
continue;
}
if (item->whatsThis(1).toInt() != entry.id) {
if (item->data(0, Qt::UserRole + 10).toInt() != entry.id) {
continue;
}
ui->historyTree->deleteItem(item);
@ -304,7 +304,7 @@ void HistoryManager::slotRefreshTable()
item->setToolTip(0, title);
item->setToolTip(1, url.toEncoded());
item->setWhatsThis(1, QString::number(id));
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, _iconForUrl(url));
ui->historyTree->addTopLevelItem(item);
@ -321,31 +321,6 @@ void HistoryManager::slotRefreshTable()
void HistoryManager::search(const QString &searchText)
{
ui->historyTree->filterString(searchText);
// if (searchText.isEmpty()) {
// refreshTable();
// return;
// }
// refreshTable();
// ui->historyTree->setUpdatesEnabled(false);
// QList<QTreeWidgetItem*> items = ui->historyTree->findItems("*" + searchText + "*", Qt::MatchRecursive | Qt::MatchWildcard);
// QList<QTreeWidgetItem*> foundItems;
// foreach(QTreeWidgetItem * fitem, items) {
// if (fitem->text(1).isEmpty()) {
// continue;
// }
// QTreeWidgetItem* item = new QTreeWidgetItem();
// 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();
// ui->historyTree->addTopLevelItems(foundItems);
// ui->historyTree->setUpdatesEnabled(true);
}
void HistoryManager::optimizeDb()

View File

@ -37,6 +37,7 @@
#include "rssicon.h"
#include "downicon.h"
#include "globalfunctions.h"
#include "iconprovider.h"
#include <QClipboard>
@ -232,7 +233,7 @@ void LocationBar::siteIconChanged()
void LocationBar::clearIcon()
{
m_siteIcon->setIcon(QIcon(QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic)));
m_siteIcon->setIcon(IconProvider::emptyWebIcon());
}
void LocationBar::setPrivacy(bool state)

View File

@ -19,6 +19,7 @@
#include "popupwebview.h"
#include "toolbutton.h"
#include "globalfunctions.h"
#include "iconprovider.h"
class QT_QUPZILLA_EXPORT PopupSiteIcon : public QWidget
{
@ -44,7 +45,7 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
, m_view(0)
{
m_siteIcon = new PopupSiteIcon(this);
m_siteIcon->setIcon(QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic));
m_siteIcon->setIcon(IconProvider::emptyWebIcon());
m_siteIcon->setFixedSize(20, 26);
addWidget(m_siteIcon, LineEdit::LeftSide);

View File

@ -53,16 +53,19 @@ AutoFillManager::AutoFillManager(QWidget* parent)
void AutoFillManager::loadPasswords()
{
ui->showPasswords->setText(tr("Show Passwords"));
QSqlQuery query;
query.exec("SELECT server, username, password, id FROM autofill");
ui->treePass->clear();
while (query.next()) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treePass);
item->setText(0, query.value(0).toString());
item->setText(1, query.value(1).toString());
item->setText(2, "*****");
item->setWhatsThis(0, query.value(3).toString());
item->setWhatsThis(1, query.value(2).toString());
item->setData(0, Qt::UserRole + 10, query.value(3).toString());
item->setData(0, Qt::UserRole + 11, query.value(2).toString());
ui->treePass->addTopLevelItem(item);
}
@ -71,7 +74,7 @@ void AutoFillManager::loadPasswords()
while (query.next()) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeExcept);
item->setText(0, query.value(0).toString());
item->setWhatsThis(0, query.value(1).toString());
item->setData(0, Qt::UserRole + 10, query.value(1).toString());
ui->treeExcept->addTopLevelItem(item);
}
}
@ -106,7 +109,8 @@ void AutoFillManager::showPasswords()
if (!item) {
continue;
}
item->setText(2, item->whatsThis(1));
item->setText(2, item->data(0, Qt::UserRole + 11).toString());
}
ui->showPasswords->setText(tr("Hide Passwords"));
@ -118,7 +122,7 @@ void AutoFillManager::removePass()
if (!curItem) {
return;
}
QString id = curItem->whatsThis(0);
QString id = curItem->data(0, Qt::UserRole + 10).toString();
QSqlQuery query;
query.exec("DELETE FROM autofill WHERE id=" + id);
@ -146,12 +150,12 @@ void AutoFillManager::editPass()
return;
}
bool ok;
QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"), QLineEdit::Normal, curItem->whatsThis(1), &ok);
QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"), QLineEdit::Normal, curItem->data(0, Qt::UserRole + 11).toString(), &ok);
if (ok && !text.isEmpty()) {
QSqlQuery query;
query.prepare("SELECT data, password FROM autofill WHERE id=?");
query.addBindValue(curItem->whatsThis(0));
query.addBindValue(curItem->data(0, Qt::UserRole + 10).toString());
query.exec();
query.next();
@ -162,13 +166,14 @@ void AutoFillManager::editPass()
query.prepare("UPDATE autofill SET data=?, password=? WHERE id=?");
query.bindValue(0, data);
query.bindValue(1, text);
query.bindValue(2, curItem->whatsThis(0));
query.bindValue(2, curItem->data(0, Qt::UserRole + 10).toString());
query.exec();
if (m_passwordsShown) {
curItem->setText(1, text);
curItem->setText(2, text);
}
curItem->setWhatsThis(1, text);
curItem->setData(0, Qt::UserRole + 11, text);
}
}
@ -178,7 +183,7 @@ void AutoFillManager::removeExcept()
if (!curItem) {
return;
}
QString id = curItem->whatsThis(0);
QString id = curItem->data(0, Qt::UserRole + 10).toString();
QSqlQuery query;
query.exec("DELETE FROM autofill_exceptions WHERE id=" + id);

View File

@ -417,8 +417,9 @@ void Preferences::showStackedPage(QListWidgetItem* item)
if (!item) {
return;
}
ui->caption->setText("<b>" + item->text() + "</b>");
ui->stackedWidget->setCurrentIndex(item->whatsThis().toInt());
ui->stackedWidget->setCurrentIndex(ui->listWidget->currentRow());
setNotificationPreviewVisible(ui->stackedWidget->currentIndex() == 8);
}

View File

@ -96,89 +96,56 @@
<property name="text">
<string>General</string>
</property>
<property name="whatsThis">
<string notr="true">0</string>
</property>
</item>
<item>
<property name="text">
<string>Appearance</string>
</property>
<property name="whatsThis">
<string notr="true">1</string>
</property>
</item>
<item>
<property name="text">
<string>Tabs</string>
</property>
<property name="whatsThis">
<string notr="true">2</string>
</property>
</item>
<item>
<property name="text">
<string>Browsing</string>
</property>
<property name="whatsThis">
<string notr="true">3</string>
</property>
</item>
<item>
<property name="text">
<string>Fonts</string>
</property>
<property name="whatsThis">
<string notr="true">4</string>
</property>
</item>
<item>
<property name="text">
<string>Downloads</string>
</property>
<property name="whatsThis">
<string notr="true">5</string>
</property>
</item>
<item>
<property name="text">
<string>Password Manager</string>
</property>
<property name="whatsThis">
<string notr="true">6</string>
</property>
</item>
<item>
<property name="text">
<string>Privacy</string>
</property>
<property name="whatsThis">
<string notr="true">7</string>
</property>
</item>
<item>
<property name="text">
<string>Notifications</string>
</property>
<property name="whatsThis">
<string notr="true">8</string>
</property>
</item>
<item>
<property name="text">
<string>Extensions</string>
</property>
<property name="whatsThis">
<string notr="true">9</string>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
</property>
<property name="whatsThis">
<string notr="true">10</string>
</property>
</item>
</widget>
</item>

View File

@ -85,7 +85,7 @@ void SSLManager::refreshCAList()
QListWidgetItem* item = new QListWidgetItem(ui->caList);
item->setText(CertificateInfoWidget::certificateItemText(cert));
item->setWhatsThis(QString::number(m_caCerts.indexOf(cert)));
item->setData(Qt::UserRole + 10, m_caCerts.indexOf(cert));
ui->caList->addItem(item);
}
@ -102,7 +102,7 @@ void SSLManager::refreshLocalList()
foreach(const QSslCertificate & cert, m_localCerts) {
QListWidgetItem* item = new QListWidgetItem(ui->localList);
item->setText(CertificateInfoWidget::certificateItemText(cert));
item->setWhatsThis(QString::number(m_localCerts.indexOf(cert)));
item->setData(Qt::UserRole + 10, m_localCerts.indexOf(cert));
ui->localList->addItem(item);
}
@ -124,7 +124,7 @@ void SSLManager::showCaCertInfo()
return;
}
QSslCertificate cert = m_caCerts.at(item->whatsThis().toInt());
QSslCertificate cert = m_caCerts.at(item->data(Qt::UserRole + 10).toInt());
showCertificateInfo(cert);
}
@ -135,7 +135,7 @@ void SSLManager::showLocalCertInfo()
return;
}
QSslCertificate cert = m_localCerts.at(item->whatsThis().toInt());
QSslCertificate cert = m_localCerts.at(item->data(Qt::UserRole + 10).toInt());
showCertificateInfo(cert);
}
@ -163,7 +163,7 @@ void SSLManager::deleteCertificate()
return;
}
QSslCertificate cert = m_localCerts.at(item->whatsThis().toInt());
QSslCertificate cert = m_localCerts.at(item->data(Qt::UserRole + 10).toInt());
m_localCerts.removeOne(cert);
mApp->networkManager()->removeLocalCertificate(cert);
refreshLocalList();

View File

@ -151,7 +151,7 @@ void RSSManager::addFeed()
return;
}
addRssFeed(url.toString(), tr("New feed"), _iconForUrl(url));
addRssFeed(url, tr("New feed"), _iconForUrl(url));
refreshTable();
}
@ -253,10 +253,10 @@ void RSSManager::loadFeed(QTreeWidgetItem* item)
if (!item) {
return;
}
if (item->whatsThis(0).isEmpty()) {
if (item->toolTip(0).isEmpty()) {
return;
}
getQupZilla()->loadAddress(QUrl(item->whatsThis(0)));
getQupZilla()->loadAddress(QUrl(item->toolTip(0)));
}
void RSSManager::controlLoadFeed(QTreeWidgetItem* item)
@ -264,10 +264,10 @@ void RSSManager::controlLoadFeed(QTreeWidgetItem* item)
if (!item) {
return;
}
if (item->whatsThis(0).isEmpty()) {
if (item->toolTip(0).isEmpty()) {
return;
}
getQupZilla()->tabWidget()->addView(QUrl(item->whatsThis(0)), Qz::NT_NotSelectedTab);
getQupZilla()->tabWidget()->addView(QUrl(item->toolTip(0)), Qz::NT_NotSelectedTab);
}
void RSSManager::loadFeedInNewTab()
@ -347,7 +347,6 @@ void RSSManager::finished()
if (xml.qualifiedName() == "item") {
QTreeWidgetItem* item = new QTreeWidgetItem;
item->setText(0, titleString);
item->setWhatsThis(0, linkString);
item->setIcon(0, QIcon(":/icons/other/feed.png"));
item->setToolTip(0, linkString);
treeWidget->addTopLevelItem(item);
@ -373,22 +372,25 @@ void RSSManager::finished()
}
}
bool RSSManager::addRssFeed(const QString &address, const QString &title, const QIcon &icon)
bool RSSManager::addRssFeed(const QUrl &url, const QString &title, const QIcon &icon)
{
if (address.isEmpty()) {
if (url.isEmpty()) {
return false;
}
QSqlQuery query;
query.exec("SELECT id FROM rss WHERE address='" + address + "'");
query.prepare("SELECT id FROM rss WHERE address=?");
query.addBindValue(url);
query.exec();
if (!query.next()) {
QImage image = icon.pixmap(16, 16).toImage();
QByteArray iconData;
if (image == QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage()) {
if (image == IconProvider::emptyWebImage()) {
image.load(":icons/other/feed.png");
}
query.prepare("INSERT INTO rss (address, title, icon) VALUES(?,?,?)");
query.bindValue(0, address);
query.bindValue(0, url);
query.bindValue(1, title);
QByteArray ba;
QBuffer buffer(&ba);

View File

@ -46,7 +46,7 @@ public:
explicit RSSManager(QupZilla* mainClass, QWidget* parent = 0);
~RSSManager();
bool addRssFeed(const QString &address, const QString &title, const QIcon &icon);
bool addRssFeed(const QUrl &url, const QString &title, const QIcon &icon);
void setMainWindow(QupZilla* window);
public slots:

View File

@ -46,8 +46,8 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
for (int i = 0; i < links.count(); i++) {
QWebElement element = links.at(i);
QString title = element.attribute("title");
QString href = element.attribute("href");
if (href.isEmpty()) {
const QUrl url = QUrl::fromEncoded(element.attribute("href").toUtf8());
if (url.isEmpty()) {
continue;
}
@ -57,13 +57,14 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
QPushButton* button = new QPushButton(this);
button->setText(tr("Add"));
button->setWhatsThis(href);
button->setToolTip(title);
button->setProperty("rss-url", url);
QLabel* label = new QLabel(this);
#ifndef KDE
label->setPalette(pal);
#endif
label->setText(title);
ui->gridLayout->addWidget(label, i, 0);
ui->gridLayout->addWidget(button, i, 1);
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
@ -83,22 +84,12 @@ void RSSWidget::addRss()
return;
}
if (QPushButton* button = qobject_cast<QPushButton*>(sender())) {
QUrl url = QUrl(button->whatsThis());
QString urlString = button->whatsThis();
if (url.host().isEmpty()) {
if (!urlString.startsWith("/")) {
urlString = "/" + urlString;
}
urlString = m_view->url().host() + urlString;
QUrl temp(urlString);
if (temp.scheme().isEmpty()) {
urlString = "http://" + urlString;
}
temp = QUrl(urlString);
if (temp.scheme().isEmpty() || temp.host().isEmpty()) {
return;
}
QUrl url = button->property("rss-url").toUrl();
if (url.isRelative()) {
url = m_view->page()->mainFrame()->baseUrl().resolved(url);
}
if (!url.isValid()) {
return;
}
@ -111,7 +102,7 @@ void RSSWidget::addRss()
title = button->toolTip();
}
if (mApp->rssManager()->addRssFeed(urlString, title, m_view->icon())) {
if (mApp->rssManager()->addRssFeed(url, title, m_view->icon())) {
RSSNotification* notif = new RSSNotification(title, m_view);
m_view->addNotification(notif);
close();

View File

@ -97,7 +97,7 @@ void BookmarksSideBar::deleteItem()
return;
}
int id = item->whatsThis(0).toInt();
int id = item->data(0, Qt::UserRole + 10).toInt();
m_bookmarksModel->removeBookmark(id);
}
@ -130,7 +130,7 @@ void BookmarksSideBar::addBookmark(const BookmarksModel::Bookmark &bookmark)
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, bookmark.title);
item->setText(1, bookmark.url.toEncoded());
item->setWhatsThis(0, QString::number(bookmark.id));
item->setData(0, Qt::UserRole + 10, bookmark.id);
item->setIcon(0, IconProvider::iconFromImage(bookmark.image));
item->setToolTip(0, bookmark.url.toEncoded());
@ -153,7 +153,7 @@ void BookmarksSideBar::removeBookmark(const BookmarksModel::Bookmark &bookmark)
return;
}
QTreeWidgetItem* item = list.at(0);
if (item && item->whatsThis(0) == QString::number(bookmark.id)) {
if (item && item->data(0, Qt::UserRole + 10).toInt() == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
}
}
@ -171,7 +171,7 @@ void BookmarksSideBar::removeBookmark(const BookmarksModel::Bookmark &bookmark)
if (!item) {
continue;
}
if (item->text(0) == bookmark.title && item->whatsThis(0) == QString::number(bookmark.id)) {
if (item->text(0) == bookmark.title && item->data(0, Qt::UserRole + 10).toInt() == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
return;
}
@ -270,7 +270,7 @@ void BookmarksSideBar::refreshTable()
item->setText(1, url.toEncoded());
item->setToolTip(0, url.toEncoded());
item->setWhatsThis(0, QString::number(id));
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, icon);
ui->bookmarksTree->addTopLevelItem(item);
}

View File

@ -145,7 +145,7 @@ void HistorySideBar::historyEntryAdded(const HistoryEntry &entry)
item->setText(1, entry.url.toEncoded());
item->setToolTip(0, entry.url.toEncoded());
item->setWhatsThis(1, QString::number(entry.id));
item->setData(0, Qt::UserRole + 10, entry.id);
item->setIcon(0, _iconForUrl(entry.url));
ui->historyTree->prependToParentItem(parentItem, item);
}
@ -157,7 +157,7 @@ void HistorySideBar::historyEntryDeleted(const HistoryEntry &entry)
if (!item) {
continue;
}
if (item->whatsThis(1).toInt() != entry.id) {
if (item->data(0, Qt::UserRole + 10).toInt() != entry.id) {
continue;
}
ui->historyTree->deleteItem(item);
@ -222,7 +222,7 @@ void HistorySideBar::slotRefreshTable()
item->setText(1, url.toEncoded());
item->setToolTip(0, url.toEncoded());
item->setWhatsThis(1, QString::number(id));
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, _iconForUrl(url));
ui->historyTree->addTopLevelItem(item);

View File

@ -23,6 +23,8 @@
#include <QTimer>
#include <QBuffer>
QImage IconProvider::m_emptyWebImage;
IconProvider::IconProvider(QObject* parent)
: QObject(parent)
{
@ -44,7 +46,7 @@ void IconProvider::saveIcon(WebView* view)
item.image = view->icon().pixmap(16, 16).toImage();
item.url = view->url();
if (item.image == QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage()) {
if (item.image == IconProvider::emptyWebImage()) {
return;
}
@ -73,7 +75,7 @@ QImage IconProvider::iconForUrl(const QUrl &url)
return QImage::fromData(query.value(0).toByteArray());
}
return QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage();
return IconProvider::emptyWebImage();
}
QImage IconProvider::iconForDomain(const QUrl &url)
@ -210,8 +212,26 @@ QIcon IconProvider::fromTheme(const QString &icon)
}
}
QIcon IconProvider::emptyWebIcon()
{
return QPixmap::fromImage(m_emptyWebImage);
}
QImage IconProvider::emptyWebImage()
{
if (m_emptyWebImage.isNull()) {
m_emptyWebImage = fromTheme("text-plain").pixmap(16, 16).toImage();
}
return m_emptyWebImage;
}
QIcon IconProvider::iconFromImage(const QImage &image)
{
if (m_emptyWebImage.isNull()) {
m_emptyWebImage = fromTheme("text-plain").pixmap(16, 16).toImage();
}
return QIcon(QPixmap::fromImage(image));
}
@ -228,7 +248,7 @@ QIcon IconProvider::iconFromBase64(const QByteArray &data)
if (!image.isNull()) {
return image;
}
return QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic);
return IconProvider::emptyWebIcon();
}
QByteArray IconProvider::iconToBase64(const QIcon &icon)

View File

@ -54,6 +54,9 @@ public:
static QPixmap standardPixmap(QStyle::StandardPixmap icon);
static QIcon fromTheme(const QString &icon);
static QIcon emptyWebIcon();
static QImage emptyWebImage();
signals:
public slots:
@ -67,6 +70,7 @@ private:
QImage image;
};
static QImage m_emptyWebImage;
QList<Icon> m_iconBuffer;
};

View File

@ -136,7 +136,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
ui->certLabel->setText(tr("<b>Your connection to this page is not secured!</b>"));
}
connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(ui->listWidget, SIGNAL(currentRowChanged(int)), ui->stackedWidget, SLOT(setCurrentIndex(int)));
connect(ui->secDetailsButton, SIGNAL(clicked()), this, SLOT(securityDetailsClicked()));
connect(ui->saveButton, SIGNAL(clicked(QAbstractButton*)), this, SLOT(downloadImage()));
@ -240,15 +240,6 @@ void SiteInfo::securityDetailsClicked()
ui->listWidget->setCurrentRow(2);
}
void SiteInfo::itemChanged(QListWidgetItem* item)
{
if (!item) {
return;
}
int index = item->whatsThis().toInt();
ui->stackedWidget->setCurrentIndex(index);
}
SiteInfo::~SiteInfo()
{
delete ui;

View File

@ -45,7 +45,6 @@ public:
static QString showCertInfo(const QString &string);
private slots:
void itemChanged(QListWidgetItem* item);
void showImagePreview(QTreeWidgetItem* item);
void securityDetailsClicked();

View File

@ -53,25 +53,16 @@
<property name="text">
<string>General</string>
</property>
<property name="whatsThis">
<string notr="true">0</string>
</property>
</item>
<item>
<property name="text">
<string>Media</string>
</property>
<property name="whatsThis">
<string notr="true">1</string>
</property>
</item>
<item>
<property name="text">
<string>Security</string>
</property>
<property name="whatsThis">
<string notr="true">2</string>
</property>
</item>
</widget>
</item>

View File

@ -408,6 +408,15 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
QTabBar::mouseReleaseEvent(event);
}
void TabBar::wheelEvent(QWheelEvent *event)
{
if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) {
return;
}
QTabBar::wheelEvent(event);
}
void TabBar::dragEnterEvent(QDragEnterEvent* event)
{
const QMimeData* mime = event->mimeData();

View File

@ -79,6 +79,7 @@ private:
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent *event);
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);

View File

@ -161,7 +161,7 @@ void TabbedWebView::slotLoadStarted()
m_rssChecked = false;
emit rssChanged(false);
animationLoading(tabIndex(), true);
m_tabWidget->startTabAnimation(tabIndex());
if (title().isNull()) {
m_tabWidget->setTabText(tabIndex(), tr("Loading..."));
@ -172,10 +172,7 @@ void TabbedWebView::slotLoadStarted()
void TabbedWebView::slotLoadFinished()
{
QMovie* mov = animationLoading(tabIndex(), false)->movie();
if (mov) {
mov->stop();
}
m_tabWidget->stopTabAnimation(tabIndex());
showIcon();
QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));
@ -185,41 +182,6 @@ void TabbedWebView::slotLoadFinished()
}
}
QLabel* TabbedWebView::animationLoading(int index, bool addMovie)
{
if (index == -1) {
return 0;
}
QLabel* loadingAnimation = qobject_cast<QLabel*>(m_tabWidget->getTabBar()->tabButton(index, QTabBar::LeftSide));
if (!loadingAnimation) {
loadingAnimation = new QLabel();
}
if (addMovie && !loadingAnimation->movie()) {
QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), loadingAnimation);
movie->setSpeed(70);
loadingAnimation->setMovie(movie);
movie->start();
}
else if (loadingAnimation->movie()) {
loadingAnimation->movie()->stop();
}
m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, 0);
m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, loadingAnimation);
return loadingAnimation;
}
void TabbedWebView::stopAnimation()
{
QMovie* mov = animationLoading(tabIndex(), false)->movie();
if (mov) {
mov->stop();
}
showIcon();
}
void TabbedWebView::setIp(const QHostInfo &info)
{
if (info.addresses().isEmpty()) {
@ -252,12 +214,11 @@ void TabbedWebView::showIcon()
}
QIcon icon_ = icon();
if (!icon_.isNull()) {
animationLoading(tabIndex(), false)->setPixmap(icon_.pixmap(16, 16));
}
else {
animationLoading(tabIndex(), false)->setPixmap(IconProvider::fromTheme("text-plain").pixmap(16, 16));
if (icon_.isNull()) {
icon_ = IconProvider::emptyWebIcon();
}
m_tabWidget->setTabIcon(tabIndex(), icon_);
}
void TabbedWebView::linkHovered(const QString &link, const QString &title, const QString &content)

View File

@ -44,7 +44,6 @@ public:
TabWidget* tabWidget() const;
QString getIp() const;
QLabel* animationLoading(int index, bool addMovie);
int tabIndex() const;
bool hasRss() { return m_hasRss; }
@ -79,7 +78,6 @@ private slots:
void urlChanged(const QUrl &url);
void linkHovered(const QString &link, const QString &title, const QString &content);
void getFocus(const QUrl &urla);
void stopAnimation();
void setIp(const QHostInfo &info);
void checkRss();
void slotIconChanged();

View File

@ -284,8 +284,7 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT
locBar->setWebView(webView);
setTabText(index, title);
webView->animationLoading(index, true)->movie()->stop();
webView->animationLoading(index, false)->setPixmap(_iconForUrl(url).pixmap(16, 16));
setTabIcon(index, IconProvider::emptyWebIcon());
if (openFlags & Qz::NT_SelectedTab) {
setCurrentIndex(index);
@ -405,6 +404,59 @@ void TabWidget::tabMoved(int before, int after)
m_lastBackgroundTabIndex = -1;
}
void TabWidget::startTabAnimation(int index)
{
if (index == -1) {
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
if (!label) {
label = new QLabel();
m_tabBar->setTabButton(index, QTabBar::LeftSide, label);
}
if (label->movie()) {
label->movie()->start();
return;
}
QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), label);
movie->setSpeed(70);
movie->start();
label->setMovie(movie);
}
void TabWidget::stopTabAnimation(int index)
{
if (index == -1) {
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
if (label && label->movie()) {
label->movie()->stop();
}
}
void TabWidget::setTabIcon(int index, const QIcon &icon)
{
if (index == -1) {
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
if (!label) {
label = new QLabel();
label->resize(16, 16);
m_tabBar->setTabButton(index, QTabBar::LeftSide, label);
}
label->setPixmap(icon.pixmap(16, 16));
}
void TabWidget::setTabText(int index, const QString &text)
{
QString newtext = text;
@ -664,9 +716,9 @@ QByteArray TabWidget::saveState()
return data;
}
bool TabWidget::restoreState(QByteArray &state)
bool TabWidget::restoreState(const QByteArray &state)
{
QDataStream stream(&state, QIODevice::ReadOnly);
QDataStream stream(state);
if (stream.atEnd()) {
return false;
}

View File

@ -55,13 +55,19 @@ public:
explicit TabWidget(QupZilla* mainclass, QWidget* parent = 0);
~TabWidget();
void loadSettings();
QByteArray saveState();
bool restoreState(QByteArray &state);
bool restoreState(const QByteArray &state);
void savePinnedTabs();
void restorePinnedTabs();
void startTabAnimation(int index);
void stopTabAnimation(int index);
void setTabIcon(int index, const QIcon &icon);
void setTabText(int index, const QString &text);
void loadSettings();
inline TabBar* getTabBar() { return m_tabBar; }
inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }

View File

@ -224,7 +224,7 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab)
m_savedTab = tab;
int index = tabIndex();
m_view->animationLoading(index, false)->setPixmap(tab.icon.pixmap(16, 16));
m_view->tabWidget()->setTabIcon(tabIndex(), tab.icon);
m_view->tabWidget()->setTabText(index, tab.title);
m_locationBar.data()->showUrl(tab.url);
}