summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-12-15 16:15:38 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-12-15 16:15:38 +0100
commit387984c5373c31957dd3302a92b1052918c0f734 (patch)
tree9ff44376dc508d4a528b415ac27f25c9e43ebc32
parentSimpler web classes (but no more friends :) (diff)
parentcreate walletwidget only when necessary (diff)
downloadrekonq-387984c5373c31957dd3302a92b1052918c0f734.tar.xz
Merge commit 'refs/merge-requests/71' of git://gitorious.org/rekonq/mainline into m71
-rw-r--r--src/mainview.cpp45
-rw-r--r--src/mainview.h4
-rw-r--r--src/walletwidget.cpp12
-rw-r--r--src/walletwidget.h4
4 files changed, 39 insertions, 26 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 9b5c2595..cf1aa7fd 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -336,6 +336,7 @@ WebView *MainView::newWebView(bool focused, bool nearParent)
QVBoxLayout* l=new QVBoxLayout(w);
l->setMargin(0);
+ l->setSpacing(0);
QWidget* messageBar=new QWidget(w);
l->addWidget(messageBar);
@@ -349,32 +350,13 @@ WebView *MainView::newWebView(bool focused, bool nearParent)
l->addWidget(webView);
webView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
- // add kwallet bar
+ KWebWallet *wallet = webView->page()->wallet();
+ if(wallet)
{
- 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()));
-
- }
+ connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)),
+ this, SLOT(createWalletBar(const QString &, const QUrl &)));
}
-
+
// connecting webview with mainview
connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
@@ -404,6 +386,21 @@ WebView *MainView::newWebView(bool focused, bool nearParent)
}
+void MainView::createWalletBar(const QString &key, const QUrl &url)
+{
+ KWebWallet *wallet = currentWebView()->page()->wallet();
+ QWidget *messageBar=this->widget(currentIndex())->layout()->itemAt(0)->widget();
+
+ WalletWidget *walletBar = new WalletWidget(messageBar);
+ walletBar->onSaveFormData(key,url);
+ messageBar->layout()->addWidget(walletBar);
+
+ connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
+ wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
+ connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
+ wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
+}
+
void MainView::newTab()
{
WebView *w = newWebView();
diff --git a/src/mainview.h b/src/mainview.h
index af957da2..d16743b1 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -145,7 +145,9 @@ private slots:
void windowCloseRequested();
void postLaunch();
-
+
+ void createWalletBar(const QString &, const QUrl &);
+
protected:
virtual void resizeEvent(QResizeEvent *event);
diff --git a/src/walletwidget.cpp b/src/walletwidget.cpp
index 56188c95..156a3ba5 100644
--- a/src/walletwidget.cpp
+++ b/src/walletwidget.cpp
@@ -59,7 +59,6 @@ WalletWidget::WalletWidget(QWidget *parent)
// layout
QGridLayout *layout = new QGridLayout(this);
- layout->setMargin(0);
layout->addWidget(closeButton,0,0);
layout->addWidget(m_label,0,1);
layout->addWidget(rememberButton,0,2);
@@ -79,6 +78,7 @@ WalletWidget::~WalletWidget()
void WalletWidget::rememberData()
{
emit saveFormDataAccepted(m_key);
+ destroy();
}
@@ -92,6 +92,16 @@ void WalletWidget::neverRememberData()
void WalletWidget::notNowRememberData()
{
emit saveFormDataRejected (m_key);
+ destroy();
+}
+
+void WalletWidget::destroy()
+{
+ if (parentWidget() && parentWidget()->layout())
+ {
+ parentWidget()->layout()->removeWidget(this);
+ }
+ this->deleteLater();
}
diff --git a/src/walletwidget.h b/src/walletwidget.h
index 7b20ead5..3e5f6465 100644
--- a/src/walletwidget.h
+++ b/src/walletwidget.h
@@ -48,6 +48,8 @@ private slots:
void rememberData();
void neverRememberData();
void notNowRememberData();
+
+public slots:
void onSaveFormData(const QString &, const QUrl &);
signals:
@@ -55,6 +57,8 @@ signals:
void saveFormDataRejected(const QString &);
private:
+ void destroy();
+
QString m_key;
QUrl m_url;