From 8e9293e47594892b03f7c09cf7b058563abadeec Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 23 Mar 2012 17:29:12 +0100 Subject: [PATCH] Added new page into Site Info: Databases. - shows all used web databases on the site --- src/defines.pri | 34 +++--- src/lib/3rdparty/qtsingleapplication.pri | 4 +- src/lib/3rdparty/squeezelabelv1.cpp | 1 + src/lib/3rdparty/squeezelabelv2.cpp | 49 +++++++++ src/lib/3rdparty/squeezelabelv2.h | 55 ++++------ src/lib/app/mainapplication.cpp | 4 +- src/lib/downloads/downloadmanager.cpp | 2 +- src/lib/downloads/downloadoptionsdialog.ui | 6 +- src/lib/lib.pro | 2 +- src/lib/navigation/locationbar.cpp | 2 +- src/lib/navigation/websearchbar.cpp | 2 +- src/lib/other/clearprivatedata.cpp | 54 ++++++++-- src/lib/other/clearprivatedata.h | 5 + src/lib/other/clearprivatedata.ui | 55 +++++++--- src/lib/popupwindow/popupwebview.cpp | 2 +- src/lib/preferences/preferences.cpp | 5 +- src/lib/webview/siteinfo.cpp | 48 ++++++++- src/lib/webview/siteinfo.h | 2 + src/lib/webview/siteinfo.ui | 117 +++++++++++++++++++-- src/lib/webview/tabbedwebview.cpp | 2 +- 20 files changed, 351 insertions(+), 100 deletions(-) diff --git a/src/defines.pri b/src/defines.pri index 8db160170..657cc4d00 100644 --- a/src/defines.pri +++ b/src/defines.pri @@ -6,21 +6,21 @@ UI_DIR = $$PWD/../build unix: VERSION = 1.1.8 # Please read BUILD information # -#DEFINES += NO_SYSTEM_DATAPATH -#DEFINES += USE_WEBGL -#DEFINES += KDE -#DEFINES += PORTABLE_BUILD +#DEFINES *= NO_SYSTEM_DATAPATH +#DEFINES *= USE_WEBGL +#DEFINES *= KDE +#DEFINES *= PORTABLE_BUILD win32 { - DEFINES += W7API + DEFINES *= W7API LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.lib } -DEFINES += QT_NO_URL_CAST_FROM_STRING +DEFINES *= QT_NO_URL_CAST_FROM_STRING ##It won't compile on windows with this define. Some bug in qtsingleapp / qvector template -!win32: !CONFIG(debug, debug|release): DEFINES += QT_NO_DEBUG_OUTPUT +!win32: !CONFIG(debug, debug|release): DEFINES *= QT_NO_DEBUG_OUTPUT -CONFIG(debug, debug|release): DEFINES += QUPZILLA_DEBUG_BUILD +CONFIG(debug, debug|release): DEFINES *= QUPZILLA_DEBUG_BUILD d_no_system_datapath = $$(NO_SYSTEM_DATAPATH) d_use_webgl = $$(USE_WEBGL) @@ -30,13 +30,13 @@ d_portable = $$(PORTABLE_BUILD) d_nonblock_dialogs = $$(NONBLOCK_JS_DIALOGS) d_use_qtwebkit_2_2 = $$(USE_QTWEBKIT_2_2) -equals(d_no_system_datapath, "true") { DEFINES += NO_SYSTEM_DATAPATH } -equals(d_use_webgl, "true") { DEFINES += USE_WEBGL } -equals(d_w7api, "true") { DEFINES += W7API } -equals(d_kde, "true") { DEFINES += KDE } -equals(d_portable, "true") { DEFINES += PORTABLE_BUILD } -equals(d_nonblock_dialogs, "true") { DEFINES += NONBLOCK_JS_DIALOGS } -equals(d_use_qtwebkit_2_2, "true") { DEFINES += USE_QTWEBKIT_2_2 } +equals(d_no_system_datapath, "true") { DEFINES *= NO_SYSTEM_DATAPATH } +equals(d_use_webgl, "true") { DEFINES *= USE_WEBGL } +equals(d_w7api, "true") { DEFINES *= W7API } +equals(d_kde, "true") { DEFINES *= KDE } +equals(d_portable, "true") { DEFINES *= PORTABLE_BUILD } +equals(d_nonblock_dialogs, "true") { DEFINES *= NONBLOCK_JS_DIALOGS } +equals(d_use_qtwebkit_2_2, "true") { DEFINES *= USE_QTWEBKIT_2_2 } !mac:unix { d_prefix = $$(QUPZILLA_PREFIX) @@ -56,11 +56,11 @@ equals(d_use_qtwebkit_2_2, "true") { DEFINES += USE_QTWEBKIT_2_2 } hicolor_folder = "$$d_prefix"share/icons/hicolor } - DEFINES += USE_DATADIR=\\\"""$$data_folder/"\\\"" + DEFINES *= USE_DATADIR=\\\"""$$data_folder/"\\\"" #Git revision rev = $$system(cd ../ && sh $$PWD/../scripts/getrevision.sh) - !equals(rev, ""): DEFINES += GIT_REVISION=\\\"""$$rev"\\\"" + !equals(rev, ""): DEFINES *= GIT_REVISION=\\\"""$$rev"\\\"" } isEmpty(QMAKE_LRELEASE) { diff --git a/src/lib/3rdparty/qtsingleapplication.pri b/src/lib/3rdparty/qtsingleapplication.pri index 4b720fd9e..4574effd4 100644 --- a/src/lib/3rdparty/qtsingleapplication.pri +++ b/src/lib/3rdparty/qtsingleapplication.pri @@ -10,6 +10,6 @@ qtsingleapplication-uselib:!qtsingleapplication-buildlib { } os2|win32 { - contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT - else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT + contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES *= QT_QTSINGLEAPPLICATION_EXPORT + else:qtsingleapplication-uselib:DEFINES *= QT_QTSINGLEAPPLICATION_IMPORT } diff --git a/src/lib/3rdparty/squeezelabelv1.cpp b/src/lib/3rdparty/squeezelabelv1.cpp index 8d2c2ef31..99dbf2914 100644 --- a/src/lib/3rdparty/squeezelabelv1.cpp +++ b/src/lib/3rdparty/squeezelabelv1.cpp @@ -15,5 +15,6 @@ void SqueezeLabelV1::paintEvent(QPaintEvent* event) setText(elided); } } + QLabel::paintEvent(event); } diff --git a/src/lib/3rdparty/squeezelabelv2.cpp b/src/lib/3rdparty/squeezelabelv2.cpp index e6c8a0f13..707a2d9fa 100644 --- a/src/lib/3rdparty/squeezelabelv2.cpp +++ b/src/lib/3rdparty/squeezelabelv2.cpp @@ -1,5 +1,27 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2010-2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ #include "squeezelabelv2.h" +#include +#include +#include +#include + SqueezeLabelV2::SqueezeLabelV2(QWidget* parent) : QLabel(parent) { @@ -19,6 +41,33 @@ void SqueezeLabelV2::setText(const QString &txt) QLabel::setText(elided); } +void SqueezeLabelV2::copy() +{ + if (selectedText().length() == text().length()) { + QApplication::clipboard()->setText(m_originalText); + } + else { + QApplication::clipboard()->setText(selectedText()); + } +} + +void SqueezeLabelV2::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu menu; + QAction* act = menu.addAction(tr("Copy"), this, SLOT(copy())); + act->setShortcut(QKeySequence("Ctrl+C")); + act->setEnabled(hasSelectedText()); + + menu.exec(event->globalPos()); +} + +void SqueezeLabelV2::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) { + copy(); + } +} + QString SqueezeLabelV2::originalText() { return m_originalText; diff --git a/src/lib/3rdparty/squeezelabelv2.h b/src/lib/3rdparty/squeezelabelv2.h index 0f178a529..8d37c3c12 100644 --- a/src/lib/3rdparty/squeezelabelv2.h +++ b/src/lib/3rdparty/squeezelabelv2.h @@ -1,42 +1,27 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2010-2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ #ifndef SQUEEZELABELV2_H #define SQUEEZELABELV2_H #include "qz_namespace.h" -/** -* Copyright (c) 2009, Benjamin C. Meyer -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Benjamin Meyer nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -*/ - #include -/* -A label that will squeeze the set text to fit within the size of the -widget. The text will be elided in the middle. -*/ class QT_QUPZILLA_EXPORT SqueezeLabelV2 : public QLabel { Q_OBJECT @@ -48,11 +33,15 @@ public: QString originalText(); void setText(const QString &txt); +private slots: + void copy(); + protected: + void contextMenuEvent(QContextMenuEvent *event); + void keyPressEvent(QKeyEvent *event); void resizeEvent(QResizeEvent* event); private: - QString m_SqueezedTextCache; QString m_originalText; }; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 84abbb79b..cadb5aedc 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -46,6 +46,7 @@ #include "settings.h" #include "locationbarsettings.h" #include "webviewsettings.h" +#include "clearprivatedata.h" #ifdef Q_WS_MAC #include @@ -612,8 +613,7 @@ void MainApplication::saveSettings() m_historymodel->clearHistory(); } if (deleteHtml5Storage) { - qz_removeDir(m_activeProfil + "Databases"); - qz_removeDir(m_activeProfil + "LocalStorage"); + ClearPrivateData::clearLocalStorage(); } m_searchEnginesManager->saveSettings(); diff --git a/src/lib/downloads/downloadmanager.cpp b/src/lib/downloads/downloadmanager.cpp index bff1f6f86..b5d718765 100644 --- a/src/lib/downloads/downloadmanager.cpp +++ b/src/lib/downloads/downloadmanager.cpp @@ -204,7 +204,7 @@ void DownloadManager::download(const QNetworkRequest &request, WebPage* page, bo handleUnsupportedContent(m_networkManager->get(req), page, fromPageDownload, suggestedFileName); } -void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, WebPage *page, bool fromPageDownload, const QString &suggestedFileName) +void DownloadManager::handleUnsupportedContent(QNetworkReply* reply, WebPage* page, bool fromPageDownload, const QString &suggestedFileName) { if (!page || reply->url().scheme() == "qupzilla") { return; diff --git a/src/lib/downloads/downloadoptionsdialog.ui b/src/lib/downloads/downloadoptionsdialog.ui index 8d7bfec11..3d94552fc 100644 --- a/src/lib/downloads/downloadoptionsdialog.ui +++ b/src/lib/downloads/downloadoptionsdialog.ui @@ -47,7 +47,7 @@ - + @@ -166,9 +166,9 @@ - SqueezeLabelV1 + SqueezeLabelV2 QLabel -
squeezelabelv1.h
+
squeezelabelv2.h
diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 178b3ede6..1472aa870 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -3,7 +3,7 @@ unix:QT += dbus TARGET = qupzilla TEMPLATE = lib -DEFINES += QUPZILLA_SHAREDLIBRARY +DEFINES *= QUPZILLA_SHAREDLIBRARY include(3rdparty/qtsingleapplication.pri) include(../defines.pri) diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 642c38b67..58eb8957f 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -320,7 +320,7 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event) m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); //Prevent choosing first option with double rightclick - QPoint pos = mapToGlobal(event->pos()); + QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); } diff --git a/src/lib/navigation/websearchbar.cpp b/src/lib/navigation/websearchbar.cpp index eca99038c..431b93a84 100644 --- a/src/lib/navigation/websearchbar.cpp +++ b/src/lib/navigation/websearchbar.cpp @@ -276,7 +276,7 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); //Prevent choosing first option with double rightclick - QPoint pos = mapToGlobal(event->pos()); + QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); } diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index 5c790a978..42df11c41 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -24,7 +24,9 @@ #include "clickablelabel.h" #include "ui_clearprivatedata.h" #include "iconprovider.h" +#include "globalfunctions.h" +#include #include #include #include @@ -50,6 +52,35 @@ void ClearPrivateData::historyClicked(bool state) ui->historyLength->setEnabled(state); } +void ClearPrivateData::clearLocalStorage() +{ + const QString &profile = mApp->getActiveProfilPath(); + + qz_removeDir(profile + "LocalStorage"); +} + +void ClearPrivateData::clearWebDatabases() +{ + const QString &profile = mApp->getActiveProfilPath(); + + QWebDatabase::removeAllDatabases(); + qz_removeDir(profile + "Databases"); +} + +void ClearPrivateData::clearCache() +{ + mApp->webSettings()->clearMemoryCaches(); + mApp->networkManager()->cache()->clear(); + + QFile::remove(mApp->getActiveProfilPath() + "ApplicationCache.db"); +} + +void ClearPrivateData::clearIcons() +{ + mApp->webSettings()->clearIconDatabase(); + mApp->iconProvider()->clearIconDatabase(); +} + void ClearPrivateData::clearFlash() { p_QupZilla->tabWidget()->addView(QUrl("http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html")); @@ -58,6 +89,7 @@ void ClearPrivateData::clearFlash() void ClearPrivateData::dialogAccepted() { QApplication::setOverrideCursor(Qt::WaitCursor); + if (ui->history->isChecked()) { QDateTime dateTime = QDateTime::currentDateTime(); qint64 nowMS = QDateTime::currentMSecsSinceEpoch(); @@ -83,18 +115,28 @@ void ClearPrivateData::dialogAccepted() query.exec("DELETE FROM history WHERE date > " + QString::number(date)); query.exec("VACUUM"); } + if (ui->cookies->isChecked()) { - QList cookies; - mApp->cookieJar()->setAllCookies(cookies); + mApp->cookieJar()->setAllCookies(QList()); } + if (ui->cache->isChecked()) { - mApp->webSettings()->clearMemoryCaches(); - mApp->networkManager()->cache()->clear(); + clearCache(); } + + if (ui->databases->isChecked()) { + clearWebDatabases(); + } + + if (ui->localStorage->isChecked()) { + clearLocalStorage(); + } + if (ui->icons->isChecked()) { - mApp->webSettings()->clearIconDatabase(); - mApp->iconProvider()->clearIconDatabase(); + clearIcons(); } + QApplication::restoreOverrideCursor(); + close(); } diff --git a/src/lib/other/clearprivatedata.h b/src/lib/other/clearprivatedata.h index 7e0e74f93..f7bc855de 100644 --- a/src/lib/other/clearprivatedata.h +++ b/src/lib/other/clearprivatedata.h @@ -34,6 +34,11 @@ class QT_QUPZILLA_EXPORT ClearPrivateData : public QDialog public: explicit ClearPrivateData(QupZilla* mainClass, QWidget* parent = 0); + static void clearLocalStorage(); + static void clearWebDatabases(); + static void clearCache(); + static void clearIcons(); + private slots: void historyClicked(bool state); void dialogAccepted(); diff --git a/src/lib/other/clearprivatedata.ui b/src/lib/other/clearprivatedata.ui index 67a9610f7..d2ad07cd9 100644 --- a/src/lib/other/clearprivatedata.ui +++ b/src/lib/other/clearprivatedata.ui @@ -7,7 +7,7 @@ 0 0 308 - 260 + 310 @@ -27,21 +27,11 @@ Clear history - true + false
- - - - Clear cookies - - - true - - - - + Clear cache @@ -51,14 +41,14 @@ - + Clear icons - + PointingHandCursor @@ -71,7 +61,7 @@ - + Qt::Horizontal @@ -106,6 +96,9 @@ + + false + Earlier Today @@ -141,6 +134,36 @@ + + + + Clear web databases + + + true + + + + + + + Clear local storage + + + true + + + + + + + Clear cookies + + + false + + + diff --git a/src/lib/popupwindow/popupwebview.cpp b/src/lib/popupwindow/popupwebview.cpp index 3e214bd27..6fbd41771 100644 --- a/src/lib/popupwindow/popupwebview.cpp +++ b/src/lib/popupwindow/popupwebview.cpp @@ -88,7 +88,7 @@ void PopupWebView::contextMenuEvent(QContextMenuEvent* event) if (!m_menu->isEmpty()) { //Prevent choosing first option with double rightclick - const QPoint &pos = mapToGlobal(event->pos()); + const QPoint &pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); return; diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 75ee952c7..ed4826782 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -41,6 +41,7 @@ #include "autofillmodel.h" #include "settings.h" #include "tabbedwebview.h" +#include "clearprivatedata.h" #include #include @@ -503,9 +504,7 @@ void Preferences::chooseUserStyleClicked() void Preferences::deleteHtml5storage() { - QString activeProfil = mApp->getActiveProfilPath(); - qz_removeDir(activeProfil + "Databases"); - qz_removeDir(activeProfil + "LocalStorage"); + ClearPrivateData::clearLocalStorage(); ui->deleteHtml5storage->setText(tr("Deleted")); ui->deleteHtml5storage->setEnabled(false); diff --git a/src/lib/webview/siteinfo.cpp b/src/lib/webview/siteinfo.cpp index 0c0eeefbf..facc7bea5 100644 --- a/src/lib/webview/siteinfo.cpp +++ b/src/lib/webview/siteinfo.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include QString SiteInfo::showCertInfo(const QString &string) { @@ -46,13 +48,15 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) : QDialog(parent) , ui(new Ui::SiteInfo) , m_certWidget(0) + , m_view(view) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); ui->listWidget->item(0)->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/preferences/document-properties.png"))); ui->listWidget->item(1)->setIcon(QIcon::fromTheme("applications-graphics", QIcon(":/icons/preferences/applications-graphics.png"))); - ui->listWidget->item(2)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png"))); + ui->listWidget->item(2)->setIcon(QIcon::fromTheme("text-x-sql", QIcon(":/icons/preferences/text-x-sql.png"))); + ui->listWidget->item(3)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png"))); ui->listWidget->item(0)->setSelected(true); WebPage* webPage = qobject_cast(view->page()); @@ -123,6 +127,24 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) ui->treeImages->addTopLevelItem(item); } + //DATABASES + const QList databases = frame->securityOrigin().databases(); + + int counter = 0; + foreach(const QWebDatabase & b, databases) { + QListWidgetItem* item = new QListWidgetItem(ui->databaseList); + item->setText(b.displayName()); + item->setData(Qt::UserRole + 10, counter); + + ++counter; + } + + if (counter == 0) { + QListWidgetItem* item = new QListWidgetItem(ui->databaseList); + item->setText(tr("No databases are used by this page.")); + item->setFlags(item->flags() & Qt::ItemIsSelectable); + } + //SECURITY if (cert.isValid()) { ui->securityLabel->setText(tr("Connection is Encrypted.")); @@ -140,6 +162,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) connect(ui->secDetailsButton, SIGNAL(clicked()), this, SLOT(securityDetailsClicked())); connect(ui->saveButton, SIGNAL(clicked(QAbstractButton*)), this, SLOT(downloadImage())); + connect(ui->databaseList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(databaseItemChanged(QListWidgetItem*))); connect(ui->treeImages, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showImagePreview(QTreeWidgetItem*))); connect(ui->treeImages, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(imagesCustomContextMenuRequested(const QPoint &))); @@ -161,6 +184,27 @@ void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p) menu.exec(QCursor::pos()); } +void SiteInfo::databaseItemChanged(QListWidgetItem* item) +{ + if (!item) { + return; + } + + int id = item->data(Qt::UserRole + 10).toInt(); + const QList &list = m_view->page()->mainFrame()->securityOrigin().databases(); + + if (id > list.count() - 1) { + qDebug("database is shit"); + return; + } + + const QWebDatabase &db = list.at(id); + + ui->databaseName->setText(QString("%1 (%2)").arg(db.displayName(), db.name())); + ui->databasePath->setText(db.fileName()); + ui->databaseSize->setText(DownloadItem::fileSizeToString(db.size())); +} + void SiteInfo::copyActionData() { if (QAction* action = qobject_cast(sender())) { @@ -237,7 +281,7 @@ void SiteInfo::showImagePreview(QTreeWidgetItem* item) void SiteInfo::securityDetailsClicked() { - ui->listWidget->setCurrentRow(2); + ui->listWidget->setCurrentRow(3); } SiteInfo::~SiteInfo() diff --git a/src/lib/webview/siteinfo.h b/src/lib/webview/siteinfo.h index ca2fb9adb..b8f2f775d 100644 --- a/src/lib/webview/siteinfo.h +++ b/src/lib/webview/siteinfo.h @@ -45,6 +45,7 @@ public: static QString showCertInfo(const QString &string); private slots: + void databaseItemChanged(QListWidgetItem* item); void showImagePreview(QTreeWidgetItem* item); void securityDetailsClicked(); @@ -55,6 +56,7 @@ private slots: private: Ui::SiteInfo* ui; CertificateInfoWidget* m_certWidget; + WebView* m_view; QPixmap m_activePixmap; QUrl m_baseUrl; diff --git a/src/lib/webview/siteinfo.ui b/src/lib/webview/siteinfo.ui index 0bf6eafff..883af90e3 100644 --- a/src/lib/webview/siteinfo.ui +++ b/src/lib/webview/siteinfo.ui @@ -49,6 +49,9 @@ true + + false + General @@ -59,6 +62,11 @@ Media + + + Databases + + Security @@ -82,6 +90,16 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + @@ -327,6 +345,95 @@ + + + + + + + 16777215 + 120 + + + + + + + + <b>Database details</b> + + + + + + + + + Name: + + + + + + + Path: + + + + + + + Size: + + + + + + + <database not selected> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + <database not selected> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + <database not selected> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + Qt::Vertical + + + + 20 + 124 + + + + + + @@ -365,16 +472,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index d1a9e4a5d..f80114442 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -280,7 +280,7 @@ void TabbedWebView::contextMenuEvent(QContextMenuEvent* event) if (!m_menu->isEmpty()) { //Prevent choosing first option with double rightclick - const QPoint &pos = mapToGlobal(event->pos()); + const QPoint &pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p);