From c12d48542d1c153020e45d90efde078a220067ea Mon Sep 17 00:00:00 2001 From: Bernhard Beschow Date: Sun, 13 Dec 2009 23:31:22 +0100 Subject: clean up creation of WebView: * remove pointer to messageBar in WebView, don't even hand messageBar over to WebView constructor * add WalletWidget to messageBar outside of WebView constructor * hide the walletBar, but not the whole messageBar --- src/mainview.cpp | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index b5f47679..9b5c2595 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -36,6 +36,7 @@ // Local Includes #include "tabbar.h" #include "urlbar.h" +#include "walletwidget.h" #include "sessionmanager.h" // KDE Includes @@ -48,6 +49,7 @@ #include #include #include +#include // Qt Includes #include @@ -330,25 +332,49 @@ WebView *MainView::webView(int index) const WebView *MainView::newWebView(bool focused, bool nearParent) { - QWidget* w = new QWidget; - QVBoxLayout* l = new QVBoxLayout; + QWidget* w=new QWidget(this); + + QVBoxLayout* l=new QVBoxLayout(w); l->setMargin(0); - - // this messageBar with its relative layout is useful to embed widget, - // like the wallet bar and so on - QWidget* messageBar = new QWidget; // should be deleted on tab close? // yes! - QVBoxLayout* l2 = new QVBoxLayout; - messageBar->setLayout(l2); - messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - messageBar->hide(); - + + QWidget* messageBar=new QWidget(w); l->addWidget(messageBar); - - WebView *webView = new WebView(w, messageBar); // should be deleted on tab close? + messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + + QVBoxLayout* l2 = new QVBoxLayout(messageBar); + l2->setMargin(0); + l2->setSpacing(0); + + WebView *webView = new WebView(w); l->addWidget(webView); webView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - w->setLayout(l); - + + // add kwallet bar + { + WalletWidget *walletBar = new WalletWidget(messageBar); + messageBar->layout()->addWidget(walletBar); + walletBar->hide(); + + KWebWallet *wallet = webView->page()->wallet(); + if(wallet) + { + connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + walletBar, SLOT(onSaveFormData(const QString &, const QUrl &))); + connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)), + wallet, SLOT(acceptSaveFormDataRequest(const QString &))); + connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)), + wallet, SLOT(rejectSaveFormDataRequest(const QString &))); + + connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + walletBar, SLOT(show())); + connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)), + walletBar, SLOT(hide())); + connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)), + walletBar, SLOT(hide())); + + } + } + // connecting webview with mainview connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool))); -- cgit v1.2.1