From 67d6d380cd206d9a12437739e17dc4a1ff379dfc Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 8 Feb 2013 18:44:26 +0100 Subject: [PATCH] [AutoFill] Added password icon into locationbar to choose username. Closes #735 --- bin/themes/chrome/images/key.png | Bin 0 -> 713 bytes bin/themes/chrome/main.css | 6 ++ bin/themes/default/images/key.png | Bin 0 -> 713 bytes bin/themes/default/main.css | 5 ++ bin/themes/linux/images/key.png | Bin 0 -> 713 bytes bin/themes/linux/main.css | 6 ++ bin/themes/mac/images/key.png | Bin 0 -> 713 bytes bin/themes/mac/main.css | 6 ++ bin/themes/windows/images/key.png | Bin 0 -> 713 bytes bin/themes/windows/main.css | 5 ++ src/lib/autofill/autofill.cpp | 27 +++--- src/lib/autofill/autofill.h | 2 +- src/lib/autofill/autofillicon.cpp | 37 +++++++++ src/lib/autofill/autofillicon.h | 40 +++++++++ src/lib/autofill/autofillnotification.cpp | 2 +- src/lib/autofill/autofillnotification.h | 10 +-- src/lib/autofill/autofillnotification.ui | 4 +- src/lib/autofill/autofillwidget.cpp | 82 +++++++++++++++++++ src/lib/autofill/autofillwidget.h | 55 +++++++++++++ src/lib/autofill/autofillwidget.ui | 95 ++++++++++++++++++++++ src/lib/bookmarks/bookmarkicon.cpp | 6 +- src/lib/bookmarks/bookmarkicon.h | 6 +- src/lib/bookmarks/bookmarkswidget.cpp | 3 +- src/lib/bookmarks/bookmarkswidget.h | 6 +- src/lib/data/icons/other/background.png | Bin 546 -> 0 bytes src/lib/lib.pro | 5 ++ src/lib/navigation/locationbar.cpp | 48 ++++++++--- src/lib/navigation/locationbar.h | 7 +- src/lib/webview/webpage.cpp | 20 +++++ src/lib/webview/webpage.h | 7 +- src/lib/webview/webview.cpp | 3 - translations/empty.ts | 31 ++++++- 32 files changed, 465 insertions(+), 59 deletions(-) create mode 100644 bin/themes/chrome/images/key.png create mode 100644 bin/themes/default/images/key.png create mode 100644 bin/themes/linux/images/key.png create mode 100644 bin/themes/mac/images/key.png create mode 100644 bin/themes/windows/images/key.png create mode 100644 src/lib/autofill/autofillicon.cpp create mode 100644 src/lib/autofill/autofillicon.h create mode 100644 src/lib/autofill/autofillwidget.cpp create mode 100644 src/lib/autofill/autofillwidget.h create mode 100644 src/lib/autofill/autofillwidget.ui delete mode 100644 src/lib/data/icons/other/background.png diff --git a/bin/themes/chrome/images/key.png b/bin/themes/chrome/images/key.png new file mode 100644 index 0000000000000000000000000000000000000000..2151029e0adbab6678e541f1ab0a080809f0a44f GIT binary patch literal 713 zcmV;)0yh1LP)XV#?~IOCxKK)w2oo1A+@;VeaPbyut7zx0 zg*$g461>2|wLx!D3q#AcA=E~F2t5(Mz=a5YE2cDliyv6lsB_=B(md)>FZ;t`KJNU^ z{hxEsAdKOQPitDR^x+AtUl5B>+fnMfq6tJR9n=ks_l7~o(q*rU;&vfJ$s zjYi|GQmI6#R4UZzbdXxDmh7{$()Zf;j%C?ZHk-w*RtuBsa=FBTK;ZMg;OpUVxG|Yb za4MC;^?Dtr(`md|EJ%_ca=HA`d4Peq3UR|?wcK;LT(5e)9v_d#ak*T^$z&2wr&FBC zWH^9b@ZA-PfD}cE%x3d_o6Yt_r_*VqQmKUPvW#A@m$F}2q*N-=d_G6;j2evwXR%n^ zkmv~5ZwN#?oz5dz*pkkU$K$gomWue~O*Zo*5_7Uzke@xKr zcHhI0wASl2A`)B>k#~N-zYC?kMSqbnKzF=eZw2O@C!XV#?~IOCxKK)w2oo1A+@;VeaPbyut7zx0 zg*$g461>2|wLx!D3q#AcA=E~F2t5(Mz=a5YE2cDliyv6lsB_=B(md)>FZ;t`KJNU^ z{hxEsAdKOQPitDR^x+AtUl5B>+fnMfq6tJR9n=ks_l7~o(q*rU;&vfJ$s zjYi|GQmI6#R4UZzbdXxDmh7{$()Zf;j%C?ZHk-w*RtuBsa=FBTK;ZMg;OpUVxG|Yb za4MC;^?Dtr(`md|EJ%_ca=HA`d4Peq3UR|?wcK;LT(5e)9v_d#ak*T^$z&2wr&FBC zWH^9b@ZA-PfD}cE%x3d_o6Yt_r_*VqQmKUPvW#A@m$F}2q*N-=d_G6;j2evwXR%n^ zkmv~5ZwN#?oz5dz*pkkU$K$gomWue~O*Zo*5_7Uzke@xKr zcHhI0wASl2A`)B>k#~N-zYC?kMSqbnKzF=eZw2O@C!XV#?~IOCxKK)w2oo1A+@;VeaPbyut7zx0 zg*$g461>2|wLx!D3q#AcA=E~F2t5(Mz=a5YE2cDliyv6lsB_=B(md)>FZ;t`KJNU^ z{hxEsAdKOQPitDR^x+AtUl5B>+fnMfq6tJR9n=ks_l7~o(q*rU;&vfJ$s zjYi|GQmI6#R4UZzbdXxDmh7{$()Zf;j%C?ZHk-w*RtuBsa=FBTK;ZMg;OpUVxG|Yb za4MC;^?Dtr(`md|EJ%_ca=HA`d4Peq3UR|?wcK;LT(5e)9v_d#ak*T^$z&2wr&FBC zWH^9b@ZA-PfD}cE%x3d_o6Yt_r_*VqQmKUPvW#A@m$F}2q*N-=d_G6;j2evwXR%n^ zkmv~5ZwN#?oz5dz*pkkU$K$gomWue~O*Zo*5_7Uzke@xKr zcHhI0wASl2A`)B>k#~N-zYC?kMSqbnKzF=eZw2O@C!XV#?~IOCxKK)w2oo1A+@;VeaPbyut7zx0 zg*$g461>2|wLx!D3q#AcA=E~F2t5(Mz=a5YE2cDliyv6lsB_=B(md)>FZ;t`KJNU^ z{hxEsAdKOQPitDR^x+AtUl5B>+fnMfq6tJR9n=ks_l7~o(q*rU;&vfJ$s zjYi|GQmI6#R4UZzbdXxDmh7{$()Zf;j%C?ZHk-w*RtuBsa=FBTK;ZMg;OpUVxG|Yb za4MC;^?Dtr(`md|EJ%_ca=HA`d4Peq3UR|?wcK;LT(5e)9v_d#ak*T^$z&2wr&FBC zWH^9b@ZA-PfD}cE%x3d_o6Yt_r_*VqQmKUPvW#A@m$F}2q*N-=d_G6;j2evwXR%n^ zkmv~5ZwN#?oz5dz*pkkU$K$gomWue~O*Zo*5_7Uzke@xKr zcHhI0wASl2A`)B>k#~N-zYC?kMSqbnKzF=eZw2O@C!XV#?~IOCxKK)w2oo1A+@;VeaPbyut7zx0 zg*$g461>2|wLx!D3q#AcA=E~F2t5(Mz=a5YE2cDliyv6lsB_=B(md)>FZ;t`KJNU^ z{hxEsAdKOQPitDR^x+AtUl5B>+fnMfq6tJR9n=ks_l7~o(q*rU;&vfJ$s zjYi|GQmI6#R4UZzbdXxDmh7{$()Zf;j%C?ZHk-w*RtuBsa=FBTK;ZMg;OpUVxG|Yb za4MC;^?Dtr(`md|EJ%_ca=HA`d4Peq3UR|?wcK;LT(5e)9v_d#ak*T^$z&2wr&FBC zWH^9b@ZA-PfD}cE%x3d_o6Yt_r_*VqQmKUPvW#A@m$F}2q*N-=d_G6;j2evwXR%n^ zkmv~5ZwN#?oz5dz*pkkU$K$gomWue~O*Zo*5_7Uzke@xKr zcHhI0wASl2A`)B>k#~N-zYC?kMSqbnKzF=eZw2O@C!dbWriter()->executeQuery(query); } -void AutoFill::completePage(WebPage* page) +QList AutoFill::completePage(WebPage* page) { + QList list; + if (!page) { - return; + return list; } QUrl pageUrl = page->url(); if (!isStored(pageUrl)) { - return; + return list; } - const AutoFillData data = getFirstFormData(pageUrl); + list = getFormData(pageUrl); + + if (!list.isEmpty()) { + const AutoFillData data = getFirstFormData(pageUrl); - if (data.isValid()) { PageFormCompleter completer(page); completer.completePage(data.postData); } + + return list; } void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingData) diff --git a/src/lib/autofill/autofill.h b/src/lib/autofill/autofill.h index c4bbc0476..001aed4a1 100644 --- a/src/lib/autofill/autofill.h +++ b/src/lib/autofill/autofill.h @@ -65,7 +65,7 @@ public: void updateEntry(const PageFormData &formData, const AutoFillData &updateData); void post(const QNetworkRequest &request, const QByteArray &outgoingData); - void completePage(WebPage* frame); + QList completePage(WebPage* page); static QByteArray exportPasswords(); static bool importPasswords(const QByteArray &data); diff --git a/src/lib/autofill/autofillicon.cpp b/src/lib/autofill/autofillicon.cpp new file mode 100644 index 000000000..98c6cc96a --- /dev/null +++ b/src/lib/autofill/autofillicon.cpp @@ -0,0 +1,37 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 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 "autofillicon.h" + +AutoFillIcon::AutoFillIcon(QWidget* parent) + : ClickableLabel(parent) +{ + setObjectName("locationbar-autofillicon"); + setCursor(Qt::PointingHandCursor); + setToolTip(tr("Choose username to login")); + setFocusPolicy(Qt::ClickFocus); +} + +void AutoFillIcon::setFormData(const QList &data) +{ + m_data = data; +} + +QList AutoFillIcon::formData() const +{ + return m_data; +} diff --git a/src/lib/autofill/autofillicon.h b/src/lib/autofill/autofillicon.h new file mode 100644 index 000000000..a6ef8452c --- /dev/null +++ b/src/lib/autofill/autofillicon.h @@ -0,0 +1,40 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 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 AUTOFILLICON_H +#define AUTOFILLICON_H + +#include "qz_namespace.h" +#include "clickablelabel.h" +#include "autofill.h" + +struct AutoFillData; + +class QT_QUPZILLA_EXPORT AutoFillIcon : public ClickableLabel +{ +public: + explicit AutoFillIcon(QWidget* parent = 0); + + void setFormData(const QList &data); + QList formData() const; + +private: + QList m_data; + +}; + +#endif // AUTOFILLICON_H diff --git a/src/lib/autofill/autofillnotification.cpp b/src/lib/autofill/autofillnotification.cpp index 67640da7b..91e774e22 100644 --- a/src/lib/autofill/autofillnotification.cpp +++ b/src/lib/autofill/autofillnotification.cpp @@ -24,7 +24,7 @@ AutoFillNotification::AutoFillNotification(const QUrl &url, const PageFormData &formData, const AutoFillData &updateData) : AnimatedWidget(AnimatedWidget::Down, 300, 0) - , ui(new Ui::AutoFillWidget) + , ui(new Ui::AutoFillNotification) , m_url(url) , m_formData(formData) , m_updateData(updateData) diff --git a/src/lib/autofill/autofillnotification.h b/src/lib/autofill/autofillnotification.h index 0673626c9..32eb8b590 100644 --- a/src/lib/autofill/autofillnotification.h +++ b/src/lib/autofill/autofillnotification.h @@ -15,8 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#ifndef AUTOFILLWIDGET_H -#define AUTOFILLWIDGET_H +#ifndef AUTOFILLNOTIFICATION_H +#define AUTOFILLNOTIFICATION_H #include @@ -27,7 +27,7 @@ namespace Ui { -class AutoFillWidget; +class AutoFillNotification; } class AnimatedWidget; @@ -48,11 +48,11 @@ private slots: void never(); private: - Ui::AutoFillWidget* ui; + Ui::AutoFillNotification* ui; QUrl m_url; PageFormData m_formData; AutoFillData m_updateData; }; -#endif // AUTOFILLWIDGET_H +#endif // AUTOFILLNOTIFICATION_H diff --git a/src/lib/autofill/autofillnotification.ui b/src/lib/autofill/autofillnotification.ui index 97faed650..b1838f612 100644 --- a/src/lib/autofill/autofillnotification.ui +++ b/src/lib/autofill/autofillnotification.ui @@ -1,7 +1,7 @@ - AutoFillWidget - + AutoFillNotification + 0 diff --git a/src/lib/autofill/autofillwidget.cpp b/src/lib/autofill/autofillwidget.cpp new file mode 100644 index 000000000..8ef767e13 --- /dev/null +++ b/src/lib/autofill/autofillwidget.cpp @@ -0,0 +1,82 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 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 "autofillwidget.h" +#include "ui_autofillwidget.h" +#include "pageformcompleter.h" +#include "autofill.h" +#include "qztools.h" +#include "webview.h" +#include "webpage.h" + +#include + +AutoFillWidget::AutoFillWidget(WebView* view, QWidget* parent) + : LocationBarPopup(parent) + , ui(new Ui::AutoFillWidget) + , m_view(view) +{ + ui->setupUi(this); +} + +void AutoFillWidget::setFormData(const QList &data) +{ + m_data = data; + + for (int i = 0; i < data.count(); ++i) { + const AutoFillData d = data.at(i); + if (d.username.isEmpty()) { + continue; + } + + QPushButton* button = new QPushButton(this); + button->setText(tr("Login")); + button->setToolTip(d.username); + button->setProperty("data-index", i); + QLabel* label = new QLabel(this); + label->setText(tr("Login as %1").arg(d.username)); + + ui->gridLayout->addWidget(label, i, 0); + ui->gridLayout->addWidget(button, i, 1); + connect(button, SIGNAL(clicked()), this, SLOT(loginToPage())); + } +} + +void AutoFillWidget::loginToPage() +{ + QPushButton* button = qobject_cast(sender()); + if (!button || !m_view) { + return; + } + + bool ok; + int index = button->property("data-index").toInt(&ok); + + if (ok && QzTools::listContainsIndex(m_data, index)) { + const AutoFillData data = m_data.at(index); + + PageFormCompleter completer(m_view->page()); + completer.completePage(data.postData); + } + + close(); +} + +AutoFillWidget::~AutoFillWidget() +{ + delete ui; +} diff --git a/src/lib/autofill/autofillwidget.h b/src/lib/autofill/autofillwidget.h new file mode 100644 index 000000000..80d69e594 --- /dev/null +++ b/src/lib/autofill/autofillwidget.h @@ -0,0 +1,55 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 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 AUTOFILLWIDGET_H +#define AUTOFILLWIDGET_H + +#include +#include + +#include "qz_namespace.h" +#include "locationbarpopup.h" + +namespace Ui +{ +class AutoFillWidget; +} + +class WebView; +struct AutoFillData; + +class QT_QUPZILLA_EXPORT AutoFillWidget : public LocationBarPopup +{ + Q_OBJECT + +public: + explicit AutoFillWidget(WebView* view, QWidget* parent = 0); + ~AutoFillWidget(); + + void setFormData(const QList &data); + +private slots: + void loginToPage(); + +private: + Ui::AutoFillWidget* ui; + + WebView* m_view; + QList m_data; +}; + +#endif // AUTOFILLWIDGET_H diff --git a/src/lib/autofill/autofillwidget.ui b/src/lib/autofill/autofillwidget.ui new file mode 100644 index 000000000..b90b7bc32 --- /dev/null +++ b/src/lib/autofill/autofillwidget.ui @@ -0,0 +1,95 @@ + + + AutoFillWidget + + + + 0 + 0 + 211 + 54 + + + + Form + + + + 0 + + + + + QFrame::NoFrame + + + + 0 + + + + + 0 + + + + + + 0 + 0 + + + + + + + :/icons/other/keys.png + + + + + + + + 0 + 0 + + + + Choose username to login + + + + + + + + + 10 + + + 6 + + + 0 + + + + + + + + + + + Frame + QFrame +
frame.h
+ 1 +
+
+ + + + +
diff --git a/src/lib/bookmarks/bookmarkicon.cpp b/src/lib/bookmarks/bookmarkicon.cpp index ec8be1763..11db50edc 100644 --- a/src/lib/bookmarks/bookmarkicon.cpp +++ b/src/lib/bookmarks/bookmarkicon.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -17,7 +17,6 @@ * ============================================================ */ #include "bookmarkicon.h" #include "mainapplication.h" -#include "qupzilla.h" #include "tabbedwebview.h" #include "locationbar.h" #include "bookmarksmodel.h" @@ -27,9 +26,8 @@ #include #include -BookmarkIcon::BookmarkIcon(QupZilla* mainClass, QWidget* parent) +BookmarkIcon::BookmarkIcon(QWidget* parent) : ClickableLabel(parent) - , p_QupZilla(mainClass) , m_bookmarksModel(0) , m_speedDial(mApp->plugins()->speedDial()) { diff --git a/src/lib/bookmarks/bookmarkicon.h b/src/lib/bookmarks/bookmarkicon.h index b618ff8bc..bd5ad6aa5 100644 --- a/src/lib/bookmarks/bookmarkicon.h +++ b/src/lib/bookmarks/bookmarkicon.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -25,13 +25,12 @@ #include "qz_namespace.h" class SpeedDial; -class QupZilla; class QT_QUPZILLA_EXPORT BookmarkIcon : public ClickableLabel { Q_OBJECT public: - explicit BookmarkIcon(QupZilla* mainClass, QWidget* parent = 0); + explicit BookmarkIcon(QWidget* parent = 0); void checkBookmark(const QUrl &url, bool forceCheck = false); private slots: @@ -46,7 +45,6 @@ private: void setBookmarkSaved(); void setBookmarkDisabled(); - QupZilla* p_QupZilla; BookmarksModel* m_bookmarksModel; SpeedDial* m_speedDial; diff --git a/src/lib/bookmarks/bookmarkswidget.cpp b/src/lib/bookmarks/bookmarkswidget.cpp index daf411892..68d7b2d0b 100644 --- a/src/lib/bookmarks/bookmarkswidget.cpp +++ b/src/lib/bookmarks/bookmarkswidget.cpp @@ -33,10 +33,9 @@ #define HIDE_DELAY 270 -BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent) +BookmarksWidget::BookmarksWidget(WebView* view, QWidget* parent) : LocationBarPopup(parent) , ui(new Ui::BookmarksWidget) - , p_QupZilla(mainClass) , m_url(view->url()) , m_view(view) , m_bookmarksModel(mApp->bookmarksModel()) diff --git a/src/lib/bookmarks/bookmarkswidget.h b/src/lib/bookmarks/bookmarkswidget.h index 997a319b5..a103a1beb 100644 --- a/src/lib/bookmarks/bookmarkswidget.h +++ b/src/lib/bookmarks/bookmarkswidget.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -32,14 +32,13 @@ class BookmarksWidget; class WebView; class SpeedDial; class BookmarksModel; -class QupZilla; class BookmarksTree; class QT_QUPZILLA_EXPORT BookmarksWidget : public LocationBarPopup { Q_OBJECT public: - explicit BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent = 0); + explicit BookmarksWidget(WebView* view, QWidget* parent = 0); ~BookmarksWidget(); signals: @@ -56,7 +55,6 @@ private: void loadBookmark(); Ui::BookmarksWidget* ui; - QupZilla* p_QupZilla; QUrl m_url; int m_bookmarkId; diff --git a/src/lib/data/icons/other/background.png b/src/lib/data/icons/other/background.png deleted file mode 100644 index cce542d086ddea15d71ae6166d99c3a04e10c02a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 546 zcmeAS@N?(olHy`uVBq!ia0vp^?hFi!M>v>(tS5~Nx_}g8age(c!@6@aFM;eko-U3d z6}R4=HxxQ#z{BD&cOFA+#wBCt^Yd5yWUgQ4;Ug4fl@@w4{q(hGMZ4!Ov-G^=8Lr>0 z`oi@6y3&u9ZwnV@-_1Sw!YlXTKc`o(SKiw$Gx_fRQW?$UQ-;OrJN=$t|9tUlzw0QV fe+Yc7-ply?GP^m0+aEDtq%(NB`njxgN@xNA01&J} diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 89edca26a..7ac958b3a 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -210,6 +210,8 @@ SOURCES += \ autofill/pageformcompleter.cpp \ autofill/autofill.cpp \ network/schemehandlers/ftpschemehandler.cpp \ + autofill/autofillicon.cpp \ + autofill/autofillwidget.cpp HEADERS += \ webview/tabpreview.h \ @@ -374,6 +376,8 @@ HEADERS += \ autofill/pageformcompleter.h \ autofill/autofill.h \ network/schemehandlers/ftpschemehandler.h \ + autofill/autofillicon.h \ + autofill/autofillwidget.h FORMS += \ preferences/autofillmanager.ui \ @@ -422,6 +426,7 @@ FORMS += \ session/recoverywidget.ui \ tools/html5permissions/html5permissionsnotification.ui \ tools/html5permissions/html5permissionsdialog.ui \ + autofill/autofillwidget.ui RESOURCES += \ data/icons.qrc \ diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 368cb06fc..a2fcf5170 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -39,6 +39,8 @@ #include "iconprovider.h" #include "qzsettings.h" #include "colors.h" +#include "autofillicon.h" +#include "autofillwidget.h" #include #include @@ -60,20 +62,22 @@ LocationBar::LocationBar(QupZilla* mainClass) setObjectName("locationbar"); setDragEnabled(true); - m_bookmarkIcon = new BookmarkIcon(p_QupZilla); + m_bookmarkIcon = new BookmarkIcon(this); m_goIcon = new GoIcon(this); m_rssIcon = new RssIcon(this); m_rssIcon->setToolTip(tr("Add RSS from this page...")); m_siteIcon = new SiteIcon(this); + m_autofillIcon = new AutoFillIcon(this); DownIcon* down = new DownIcon(this); - ////RTL Support - ////if we don't add 'm_siteIcon' by following code, then we should use suitable padding-left value - //// but then, when typing RTL text the layout dynamically changed and within RTL layout direction - //// padding-left is equivalent to padding-right and vice versa, and because style sheet is - //// not changed dynamically this create padding problems. + // RTL Support + // if we don't add 'm_siteIcon' by following code, then we should use suitable padding-left value + // but then, when typing RTL text the layout dynamically changed and within RTL layout direction + // padding-left is equivalent to padding-right and vice versa, and because style sheet is + // not changed dynamically this create padding problems. addWidget(m_siteIcon, LineEdit::LeftSide); + addWidget(m_autofillIcon, LineEdit::RightSide); addWidget(m_goIcon, LineEdit::RightSide); addWidget(m_bookmarkIcon, LineEdit::RightSide); addWidget(m_rssIcon, LineEdit::RightSide); @@ -88,6 +92,7 @@ LocationBar::LocationBar(QupZilla* mainClass) connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter())); connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked())); connect(m_bookmarkIcon, SIGNAL(clicked(QPoint)), this, SLOT(bookmarkIconClicked())); + connect(m_autofillIcon, SIGNAL(clicked(QPoint)), this, SLOT(autofillIconClicked())); connect(down, SIGNAL(clicked(QPoint)), this, SLOT(showMostVisited())); connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText())); connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText())); @@ -97,6 +102,11 @@ LocationBar::LocationBar(QupZilla* mainClass) clearIcon(); updatePlaceHolderText(); + + // Hide icons by default + m_goIcon->hide(); + m_rssIcon->hide(); + m_autofillIcon->hide(); } void LocationBar::setWebView(TabbedWebView* view) @@ -244,10 +254,17 @@ void LocationBar::rssIconClicked() void LocationBar::bookmarkIconClicked() { - BookmarksWidget* bWidget = new BookmarksWidget(p_QupZilla, m_webView, this); + BookmarksWidget* bWidget = new BookmarksWidget(m_webView, this); bWidget->showAt(this); } +void LocationBar::autofillIconClicked() +{ + AutoFillWidget* widget = new AutoFillWidget(m_webView, this); + widget->setFormData(m_autofillIcon->formData()); + widget->showAt(this); +} + void LocationBar::showRSSIcon(bool state) { m_rssIcon->setVisible(state); @@ -534,14 +551,10 @@ void LocationBar::keyReleaseEvent(QKeyEvent* event) LineEdit::keyReleaseEvent(event); } -LocationBar::~LocationBar() -{ - delete m_bookmarkIcon; -} - void LocationBar::onLoadStarted() { m_progressVisible = true; + m_autofillIcon->hide(); } void LocationBar::onLoadProgress(int progress) @@ -557,6 +570,13 @@ void LocationBar::onLoadFinished() if (qzSettings->showLoadingProgress) { QTimer::singleShot(700, this, SLOT(hideProgress())); } + + WebPage* page = qobject_cast(m_webView->page()); + + if (page && page->hasMultipleUsernames()) { + m_autofillIcon->setFormData(page->autoFillData()); + m_autofillIcon->show(); + } } void LocationBar::loadSettings() @@ -732,3 +752,7 @@ void LocationBar::paintEvent(QPaintEvent* event) p.drawText(currentRect, currentText, opt); } + +LocationBar::~LocationBar() +{ +} diff --git a/src/lib/navigation/locationbar.h b/src/lib/navigation/locationbar.h index a27e44ac4..4324b5246 100644 --- a/src/lib/navigation/locationbar.h +++ b/src/lib/navigation/locationbar.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -28,11 +28,12 @@ class QupZilla; class LineEdit; class LocationCompleter; class ClickableLabel; -class BookmarkIcon; class TabbedWebView; +class BookmarkIcon; class SiteIcon; class GoIcon; class RssIcon; +class AutoFillIcon; class QT_QUPZILLA_EXPORT LocationBar : public LineEdit { @@ -66,6 +67,7 @@ private slots: void showSiteInfo(); void rssIconClicked(); void bookmarkIconClicked(); + void autofillIconClicked(); void urlEnter(); void clearIcon(); void showRSSIcon(bool state); @@ -111,6 +113,7 @@ private: GoIcon* m_goIcon; RssIcon* m_rssIcon; SiteIcon* m_siteIcon; + AutoFillIcon* m_autofillIcon; QupZilla* p_QupZilla; TabbedWebView* m_webView; diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 4dd7e9c3c..27cc70b96 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -229,6 +229,7 @@ void WebPage::finished() mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1); } + // File scheme watcher if (url().scheme() == QLatin1String("file")) { QFileInfo info(url().toLocalFile()); if (info.isFile()) { @@ -248,6 +249,10 @@ void WebPage::finished() m_fileWatcher->removePaths(m_fileWatcher->files()); } + // Autofill + m_autoFillData = mApp->autoFill()->completePage(this); + + // AdBlock cleanBlockedObjects(); } @@ -571,6 +576,21 @@ void WebPage::addAdBlockRule(const AdBlockRule* rule, const QUrl &url) } } +QList WebPage::adBlockedEntries() const +{ + return m_adBlockedEntries; +} + +bool WebPage::hasMultipleUsernames() const +{ + return m_autoFillData.count() > 1; +} + +QList WebPage::autoFillData() const +{ + return m_autoFillData; +} + void WebPage::cleanBlockedObjects() { AdBlockManager* manager = AdBlockManager::instance(); diff --git a/src/lib/webview/webpage.h b/src/lib/webview/webpage.h index bcf9cd8e0..31668c8df 100644 --- a/src/lib/webview/webpage.h +++ b/src/lib/webview/webpage.h @@ -22,6 +22,7 @@ #include #include "qz_namespace.h" +#include "autofill.h" class QWebSecurityOrigin; class QFileSystemWatcher; @@ -62,7 +63,10 @@ public: void javaScriptAlert(QWebFrame* originatingFrame, const QString &msg); void addAdBlockRule(const AdBlockRule* rule, const QUrl &url); - QList adBlockedEntries() { return m_adBlockedEntries; } + QList adBlockedEntries() const; + + bool hasMultipleUsernames() const; + QList autoFillData() const; void scheduleAdjustPage(); bool isRunningLoop(); @@ -133,6 +137,7 @@ private: QSslCertificate m_sslCert; QList m_rejectedSslCerts; QList m_adBlockedEntries; + QList m_autoFillData; QWebPage::NavigationType m_lastRequestType; QUrl m_lastRequestUrl; diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 455ae952e..a132ae67a 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -22,7 +22,6 @@ #include "qztools.h" #include "iconprovider.h" #include "history.h" -#include "autofill.h" #include "pluginproxy.h" #include "downloadmanager.h" #include "sourceviewer.h" @@ -381,8 +380,6 @@ void WebView::slotLoadFinished() mApp->history()->addHistoryEntry(this); } - mApp->autoFill()->completePage(page()); - m_isReloading = false; m_lastUrl = url(); } diff --git a/translations/empty.ts b/translations/empty.ts index 75188a258..717b6762c 100644 --- a/translations/empty.ts +++ b/translations/empty.ts @@ -247,6 +247,13 @@ + + AutoFillIcon + + Choose username to login + + + AutoFillManager @@ -368,9 +375,10 @@ Do you want QupZilla to update saved password %1? - - - AutoFillWidget + + Update + + Remember @@ -383,8 +391,23 @@ Not Now + + + AutoFillWidget - Update + Form + + + + Choose username to login + + + + Login + + + + Login as <b>%1</b>