diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-12-06 23:36:15 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-12-06 23:36:15 +0100 |
commit | eaa82c1922c7cc133458c65ecbe8eb2ab6adc03d (patch) | |
tree | b8954514b5d8bd0205bc0b8798de2bef2c7e751e /src | |
parent | kde wallet integration. (diff) | |
download | rekonq-eaa82c1922c7cc133458c65ecbe8eb2ab6adc03d.tar.xz |
KWebWallet integration
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/mainwindow.cpp | 4 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/networkaccessmanager.cpp | 10 | ||||
-rw-r--r-- | src/walletwidget.cpp | 42 | ||||
-rw-r--r-- | src/walletwidget.h | 19 | ||||
-rw-r--r-- | src/webpage.cpp | 5 | ||||
-rw-r--r-- | src/webview.cpp | 40 | ||||
-rw-r--r-- | src/webview.h | 7 |
9 files changed, 89 insertions, 41 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcdacd68..7f95a1d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ SET( rekonq_KDEINIT_SRCS clicktoflash.cpp networkaccessmanager.cpp webinspectordock.cpp + walletwidget.cpp #---------------------------------------- history/autosaver.cpp history/historymanager.cpp diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 583825af..6186ebea 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -97,8 +97,8 @@ MainWindow::MainWindow() : KMainWindow() - , m_view(new MainView(this)) - , m_findBar(new FindBar(this)) + , m_view( new MainView(this) ) + , m_findBar( new FindBar(this) ) , m_sidePanel(0) , m_bookmarksPanel(0) , m_webInspectorDock(0) diff --git a/src/mainwindow.h b/src/mainwindow.h index f141c5a2..f07a46da 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -73,7 +73,7 @@ public: virtual KActionCollection *actionCollection () const; bool newTabPage(const KUrl &url = KUrl("about:home")); - + private: void setupActions(); void setupTools(); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index a2c1fdee..1f8b8281 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -31,7 +31,7 @@ // Local Includes #include "application.h" #include "adblockmanager.h" - +#include <KDebug> NetworkAccessManager::NetworkAccessManager(QObject *parent) : AccessManager(parent) @@ -41,6 +41,14 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData) { + if (op == PostOperation && outgoingData) + { + QByteArray outgoingDataByteArray = outgoingData->peek(1024 * 1024); + kDebug() << "*************************************************************************"; + kDebug() << outgoingDataByteArray; + kDebug() << "*************************************************************************"; + } + QNetworkRequest request(req); request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); diff --git a/src/walletwidget.cpp b/src/walletwidget.cpp index 8c68e187..efb5af12 100644 --- a/src/walletwidget.cpp +++ b/src/walletwidget.cpp @@ -24,18 +24,22 @@ * ============================================================ */ +// Self Includes #include "walletwidget.h" #include "walletwidget.moc" -#include <QLabel> +// KDE Includes +#include <klocalizedstring.h> + +// Qt Includes #include <QPushButton> -#include <QVBoxLayout> +#include <QHBoxLayout> -WalletWidget::WalletWidget(QObject *parent) +WalletWidget::WalletWidget(QWidget *parent) : QWidget(parent) + , m_label( new QLabel(this) ) { - 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); @@ -45,13 +49,16 @@ WalletWidget::WalletWidget(QObject *parent) connect(notNowButton, SIGNAL(clicked()), this, SLOT(notNowRememberData())); // layout - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); + QHBoxLayout *layout = new QHBoxLayout; + layout->addWidget(m_label); layout->addWidget(rememberButton); layout->addWidget(neverHereButton); layout->addWidget(notNowButton); setLayout(layout); + + // we start off hidden + hide(); } @@ -62,21 +69,38 @@ WalletWidget::~WalletWidget() void WalletWidget::rememberData() { - WebView *w = Application::instance()->mainWindow()->currentTab(); - w->page()->wallet()->saveFormData(w->page()->currentFrame()); hide(); + emit saveFormDataAccepted(m_key); } void WalletWidget::neverRememberData() { - hide(); + // TODO: store site url (to remember never bother about) + notNowRememberData(); } void WalletWidget::notNowRememberData() { hide(); + emit saveFormDataRejected (m_key); } +void WalletWidget::onSaveFormData(const QString &key, const QUrl &url) +{ + m_label->setText( i18n("Do you want rekonq to remember the password for %1 on %2?") + .arg(key) + .arg(url.host()) + ); + m_key = key; + m_url = url; + + // TODO: check if url is stored somewhere to not remember pass.. + if(true) + show(); + else + notNowRememberData(); + +} diff --git a/src/walletwidget.h b/src/walletwidget.h index e9e6ce87..7b20ead5 100644 --- a/src/walletwidget.h +++ b/src/walletwidget.h @@ -30,9 +30,9 @@ // Qt Includes #include <QWidget> - -// Forward Declarations -class KMainWindow; +#include <QString> +#include <QUrl> +#include <QLabel> class WalletWidget : public QWidget @@ -40,7 +40,7 @@ class WalletWidget : public QWidget Q_OBJECT public: - WalletWidget(QObject *parent); + WalletWidget(QWidget *parent); ~WalletWidget(); private slots: @@ -48,6 +48,17 @@ private slots: void rememberData(); void neverRememberData(); void notNowRememberData(); + void onSaveFormData(const QString &, const QUrl &); + +signals: + void saveFormDataAccepted(const QString &); + void saveFormDataRejected(const QString &); + +private: + QString m_key; + QUrl m_url; + + QLabel *m_label; }; #endif // WALLET_WIDGET_H diff --git a/src/webpage.cpp b/src/webpage.cpp index 42704ab3..92318b36 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -81,11 +81,6 @@ 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 &))); } diff --git a/src/webview.cpp b/src/webview.cpp index c25b8903..78c4caf8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -38,6 +38,7 @@ #include "mainview.h" #include "webpage.h" #include "bookmarksmanager.h" +#include "walletwidget.h" // KDE Includes #include <KService> @@ -45,6 +46,7 @@ #include <KStandardShortcut> #include <KMenu> #include <KActionMenu> +#include <kwebwallet.h> // Qt Includes #include <QContextMenuEvent> @@ -56,22 +58,36 @@ WebView::WebView(QWidget* parent) - : KWebView(parent, false) - , m_page(new WebPage(this)) - , m_progress(0) - , m_mousePos(QPoint(0,0)) + : KWebView(parent, false) + , m_page( new WebPage(this) ) + , m_walletBar( new WalletWidget(this) ) + , m_progress(0) + , m_mousePos(QPoint(0,0)) { setPage(m_page); - connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); + connect(m_page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) ); - connect(this, SIGNAL(linkShiftClicked(const KUrl &)), this, SLOT(downloadRequest(const KUrl &))); - connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &r))); + // download system + connect(this, SIGNAL(linkShiftClicked(const KUrl &)), m_page, SLOT(downloadUrl(const KUrl &))); + connect(m_page, SIGNAL(downloadRequested(const QNetworkRequest &)), m_page, SLOT(downloadRequest(const QNetworkRequest &r))); + + // kwallet + KWebWallet *w = m_page->wallet(); + if(w) + { + connect (w, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + m_walletBar, SLOT(onSaveFormData(const QString &, const QUrl &))); + connect(m_walletBar, SIGNAL(saveFormDataAccepted(const QString &)), + w, SLOT(acceptSaveFormDataRequest(const QString &))); + connect(m_walletBar, SIGNAL(saveFormDataRejected(const QString &)), + w, SLOT(rejectSaveFormDataRequest(const QString &))); + } } @@ -433,15 +449,9 @@ void WebView::loadInNewTab(const KUrl &url) { Application::instance()->loadUrl(url, Rekonq::NewCurrentTab); } - - -void WebView::downloadRequest(const KUrl &url) -{ - m_page->downloadRequest(QNetworkRequest(url)); -} -void WebView::downloadRequest(const QNetworkRequest &request) +QWidget *WebView::walletBar() { - m_page->downloadRequest(request); + return m_walletBar; } diff --git a/src/webview.h b/src/webview.h index 4fa87978..39cc51da 100644 --- a/src/webview.h +++ b/src/webview.h @@ -37,6 +37,7 @@ // Forward Declarations class WebPage; +class WalletWidget; class WebView : public KWebView @@ -52,6 +53,7 @@ public: QString lastStatusBarText() const; int progress(); QPoint mousePos(); + QWidget *walletBar(); protected: void contextMenuEvent(QContextMenuEvent *event); @@ -73,14 +75,11 @@ private slots: void loadInNewTab(const KUrl &url); - void downloadRequest(const KUrl &url); - void downloadRequest(const QNetworkRequest &request); - private: WebPage *m_page; + WalletWidget *m_walletBar; int m_progress; QString m_statusBarText; - QPoint m_mousePos; }; |