From 5d59512ca2e4a36cf6c4f85537c8fa227c44c1dc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 30 Nov 2009 16:34:34 +0100 Subject: kde wallet integration. First bits --- src/mainview.cpp | 8 +++++ src/walletwidget.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/walletwidget.h | 53 +++++++++++++++++++++++++++++++++ src/webpage.cpp | 6 ++++ 4 files changed, 149 insertions(+) create mode 100644 src/walletwidget.cpp create mode 100644 src/walletwidget.h diff --git a/src/mainview.cpp b/src/mainview.cpp index f4598f22..d190507e 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -48,6 +48,7 @@ #include #include #include +#include // Qt Includes #include @@ -544,6 +545,13 @@ void MainView::webViewLoadFinished(bool ok) webViewIconChanged(); emit browserTabLoading(false); + // KWallet Integration + // TODO: Add check for sites exempt from automatic form filling... + if (webView->page()->wallet()) + { + webView->page()->wallet()->fillFormData(webView->page()->mainFrame()); + } + // don't display messages for background tabs if (index != currentIndex()) { diff --git a/src/walletwidget.cpp b/src/walletwidget.cpp new file mode 100644 index 00000000..8c68e187 --- /dev/null +++ b/src/walletwidget.cpp @@ -0,0 +1,82 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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 "walletwidget.h" +#include "walletwidget.moc" + +#include +#include +#include + + +WalletWidget::WalletWidget(QObject *parent) + : QWidget(parent) +{ + QLabel *label = new QLabel( i18n("Do you want rekonq to remember the password for %1 on %2?"), this); + QPushButton *rememberButton = new QPushButton( i18n("remember"), this); + QPushButton *neverHereButton = new QPushButton( i18n("never for this site"), this); + QPushButton *notNowButton = new QPushButton( i18n("not now"), this); + + connect(rememberButton, SIGNAL(clicked()), this, SLOT(rememberData())); + connect(neverHereButton, SIGNAL(clicked()), this, SLOT(neverRememberData())); + connect(notNowButton, SIGNAL(clicked()), this, SLOT(notNowRememberData())); + + // layout + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(label); + layout->addWidget(rememberButton); + layout->addWidget(neverHereButton); + layout->addWidget(notNowButton); + + setLayout(layout); +} + + +WalletWidget::~WalletWidget() +{ +} + + +void WalletWidget::rememberData() +{ + WebView *w = Application::instance()->mainWindow()->currentTab(); + w->page()->wallet()->saveFormData(w->page()->currentFrame()); + hide(); +} + + +void WalletWidget::neverRememberData() +{ + hide(); +} + + +void WalletWidget::notNowRememberData() +{ + hide(); +} + + diff --git a/src/walletwidget.h b/src/walletwidget.h new file mode 100644 index 00000000..e9e6ce87 --- /dev/null +++ b/src/walletwidget.h @@ -0,0 +1,53 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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 WALLET_WIDGET_H +#define WALLET_WIDGET_H + + +// Qt Includes +#include + +// Forward Declarations +class KMainWindow; + + +class WalletWidget : public QWidget +{ + Q_OBJECT + +public: + WalletWidget(QObject *parent); + ~WalletWidget(); + +private slots: + + void rememberData(); + void neverRememberData(); + void notNowRememberData(); +}; + +#endif // WALLET_WIDGET_H diff --git a/src/webpage.cpp b/src/webpage.cpp index 89579c88..42704ab3 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -80,6 +81,11 @@ WebPage::WebPage(QObject *parent) connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); + + // kwallet + KWebWallet *w = wallet(); + connect(w, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + w, SLOT(acceptSaveFormDataRequest(const QString &))); } -- cgit v1.2.1