1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

QzTools: Add function to obtain url of QWebFrame

QWebFrame::url() may be empty, and in that case QWebFrame::baseUrl()
should be used

The issue with empty frame url caused AutoFill to not complete
such frames.

Closes #1465
This commit is contained in:
David Rosca 2014-09-29 16:03:22 +02:00
parent 011c5d4038
commit dc29f6bde5
8 changed files with 27 additions and 14 deletions

View File

@ -1,3 +1,8 @@
Version 1.8.1
* not yet released
* fixed: autofill not working for some frames
* fixed: building on Mac
Version 1.8.0 Version 1.8.0
* released 25 September 2014 * released 25 September 2014
* added support for window.beforeunload event * added support for window.beforeunload event

View File

@ -1187,7 +1187,7 @@ void BrowserWindow::printPage(QWebFrame* frame)
connect(dialog, SIGNAL(paintRequested(QPrinter*)), weView(), SLOT(print(QPrinter*))); connect(dialog, SIGNAL(paintRequested(QPrinter*)), weView(), SLOT(print(QPrinter*)));
} }
else { else {
dialog->printer()->setDocName(QzTools::getFileNameFromUrl(frame->url())); dialog->printer()->setDocName(QzTools::getFileNameFromUrl(QzTools::frameUrl(frame)));
connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*))); connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*)));
} }

View File

@ -26,6 +26,7 @@
#include "pageformcompleter.h" #include "pageformcompleter.h"
#include "settings.h" #include "settings.h"
#include "passwordmanager.h" #include "passwordmanager.h"
#include "qztools.h"
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QXmlStreamReader> #include <QXmlStreamReader>
@ -178,12 +179,12 @@ QVector<PasswordEntry> AutoFill::completeFrame(QWebFrame* frame)
return list; return list;
} }
QUrl pageUrl = frame->url(); const QUrl frameUrl = QzTools::frameUrl(frame);
if (!isStored(pageUrl)) { if (!isStored(frameUrl)) {
return list; return list;
} }
list = getFormData(pageUrl); list = getFormData(frameUrl);
if (!list.isEmpty()) { if (!list.isEmpty()) {
const PasswordEntry entry = list.first(); const PasswordEntry entry = list.first();
@ -221,9 +222,8 @@ void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingDa
return; return;
} }
const QUrl siteUrl = webPage->url(); const QUrl frameUrl = QzTools::frameUrl(frame);
if (!isStoringEnabled(frameUrl)) {
if (!isStoringEnabled(siteUrl)) {
return; return;
} }
@ -236,8 +236,8 @@ void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingDa
PasswordEntry updateData; PasswordEntry updateData;
if (isStored(siteUrl)) { if (isStored(frameUrl)) {
const QVector<PasswordEntry> &list = getFormData(siteUrl); const QVector<PasswordEntry> &list = getFormData(frameUrl);
foreach (const PasswordEntry &data, list) { foreach (const PasswordEntry &data, list) {
if (data.username == formData.username) { if (data.username == formData.username) {
@ -257,7 +257,7 @@ void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingDa
} }
} }
AutoFillNotification* aWidget = new AutoFillNotification(siteUrl, formData, updateData); AutoFillNotification* aWidget = new AutoFillNotification(frameUrl, formData, updateData);
webView->addNotification(aWidget); webView->addNotification(aWidget);
} }

View File

@ -38,7 +38,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
, m_selectedHtml(selectedHtml) , m_selectedHtml(selectedHtml)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("Source of ") + frame->url().toString()); setWindowTitle(tr("Source of ") + QzTools::frameUrl(frame).toString());
m_layout = new QBoxLayout(QBoxLayout::TopToBottom, this); m_layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
m_sourceEdit = new PlainEditWithLines(this); m_sourceEdit = new PlainEditWithLines(this);
m_sourceEdit->setObjectName("sourceviewer-textedit"); m_sourceEdit->setObjectName("sourceviewer-textedit");
@ -46,7 +46,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
m_sourceEdit->setUndoRedoEnabled(false); m_sourceEdit->setUndoRedoEnabled(false);
m_statusBar = new QStatusBar(this); m_statusBar = new QStatusBar(this);
m_statusBar->showMessage(frame->url().toString()); m_statusBar->showMessage(QzTools::frameUrl(frame).toString());
QMenuBar* menuBar = new QMenuBar(this); QMenuBar* menuBar = new QMenuBar(this);
m_layout->addWidget(m_sourceEdit); m_layout->addWidget(m_sourceEdit);

View File

@ -382,7 +382,7 @@ QList<QWebFrame*> SpeedDial::cleanFrames()
for (int i = 0; i < m_webFrames.count(); i++) { for (int i = 0; i < m_webFrames.count(); i++) {
QWebFrame* frame = m_webFrames.at(i).data(); QWebFrame* frame = m_webFrames.at(i).data();
if (!frame || frame->url().toString() != QLatin1String("qupzilla:speeddial")) { if (!frame || QzTools::frameUrl(frame).toString() != QLatin1String("qupzilla:speeddial")) {
m_webFrames.removeAt(i); m_webFrames.removeAt(i);
i--; i--;
continue; continue;

View File

@ -39,6 +39,7 @@
#include <QSysInfo> #include <QSysInfo>
#include <QProcess> #include <QProcess>
#include <QMessageBox> #include <QMessageBox>
#include <QWebFrame>
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
@ -215,6 +216,11 @@ QString QzTools::escapeSqlString(QString urlString)
return urlString; return urlString;
} }
QUrl QzTools::frameUrl(QWebFrame* frame)
{
return frame->url().isEmpty() ? frame->baseUrl() : frame->url();
}
QString QzTools::ensureUniqueFilename(const QString &name, const QString &appendFormat) QString QzTools::ensureUniqueFilename(const QString &name, const QString &appendFormat)
{ {
if (!QFile::exists(name)) { if (!QFile::exists(name)) {

View File

@ -24,6 +24,7 @@
class QSslCertificate; class QSslCertificate;
class QFontMetrics; class QFontMetrics;
class QWebFrame;
class QPixmap; class QPixmap;
class QIcon; class QIcon;
class QWidget; class QWidget;
@ -48,6 +49,7 @@ public:
static QString urlEncodeQueryString(const QUrl &url); static QString urlEncodeQueryString(const QUrl &url);
static QString fromPunycode(const QString &str); static QString fromPunycode(const QString &str);
static QString escapeSqlString(QString urlString); static QString escapeSqlString(QString urlString);
static QUrl frameUrl(QWebFrame* frame);
static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)")); static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
static QString getFileNameFromUrl(const QUrl &url); static QString getFileNameFromUrl(const QUrl &url);

View File

@ -201,7 +201,7 @@ void GM_Manager::frameLoadStart()
return; return;
} }
const QUrl url = frame->url().isEmpty() ? frame->baseUrl() : frame->url(); const QUrl url = QzTools::frameUrl(frame);
const QString urlScheme = url.scheme(); const QString urlScheme = url.scheme();
const QString urlString = url.toEncoded(); const QString urlString = url.toEncoded();