summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2009-12-13 16:39:26 +0100
committermegabigbug <megabigbug@arrakis.(none)>2009-12-13 16:39:26 +0100
commitc0d7804c239a15451a7ca61e902c1e80c5c22378 (patch)
tree9b8e658b4aa6b8470bd6dc3c3a414931c0dd61b1 /src
parentMerge commit 'refs/merge-requests/64' of git://gitorious.org/rekonq/mainline (diff)
downloadrekonq-c0d7804c239a15451a7ca61e902c1e80c5c22378.tar.xz
walletwidget on top of the webview (not over)
add close button add icons
Diffstat (limited to 'src')
-rw-r--r--src/mainview.cpp51
-rw-r--r--src/walletwidget.cpp40
-rw-r--r--src/webview.cpp46
-rw-r--r--src/webview.h5
4 files changed, 79 insertions, 63 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 4437936d..d2105dcd 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -59,7 +59,7 @@
#include <QtGui/QLabel>
#include <QtGui/QMovie>
#include <QtGui/QWidget>
-
+#include <QtGui/QVBoxLayout>
MainView::MainView(MainWindow *parent)
: KTabWidget(parent)
@@ -182,8 +182,8 @@ WebView *MainView::currentWebView() const
int MainView::webViewIndex(WebView *webView) const
-{
- return indexOf(webView);
+{
+ return indexOf(webView->parentWidget());
}
@@ -252,9 +252,7 @@ void MainView::reloadTab(int index)
if (index < 0 || index >= count())
return;
- QWidget *widget = this->widget(index);
- if (WebView *tab = qobject_cast<WebView*>(widget))
- tab->reload();
+ webView(index)->reload();
}
@@ -314,10 +312,13 @@ void MainView::currentChanged(int index)
WebView *MainView::webView(int index) const
{
- QWidget *widget = this->widget(index);
- if (WebView *webView = qobject_cast<WebView*>(widget))
+ if (this->widget(index) && this->widget(index)->layout() && this->widget(index)->layout()->itemAt(1)) //TODO: find why it crashes when closetab without that.
{
- return webView;
+ QWidget *widget = this->widget(index)->layout()->itemAt(1)->widget();
+ if (WebView *webView = qobject_cast<WebView*>(widget))
+ {
+ return webView;
+ }
}
kDebug() << "WebView with index " << index << "not found. Returning NULL." ;
@@ -327,8 +328,20 @@ WebView *MainView::webView(int index) const
WebView *MainView::newWebView(bool focused, bool nearParent)
{
- WebView *webView = new WebView; // should be deleted on tab close?
-
+ QWidget* w=new QWidget;
+ QVBoxLayout* l=new QVBoxLayout(w);
+ l->setMargin(0);
+ QWidget* messageBar=new QWidget; // should be deleted on tab close?
+ QVBoxLayout* l2=new QVBoxLayout(messageBar);
+ l->addWidget(messageBar);
+
+ messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
+ messageBar->hide();
+
+ WebView *webView = new WebView(w,messageBar); // should be deleted on tab close?
+ l->addWidget(webView);
+ webView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
+
// connecting webview with mainview
connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
@@ -339,17 +352,17 @@ WebView *MainView::newWebView(bool focused, bool nearParent)
// connecting webPage signals with mainview
connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
-
+
if (nearParent)
- insertTab(currentIndex() + 1, webView, i18n("(Untitled)"));
+ insertTab(currentIndex() + 1, w, i18n("(Untitled)"));
else
- addTab(webView, i18n("(Untitled)"));
+ addTab(w, i18n("(Untitled)"));
updateTabBar();
if (focused)
{
- setCurrentWidget(webView);
+ setCurrentWidget(w);
}
emit tabsChanged();
@@ -384,11 +397,7 @@ void MainView::reloadAllTabs()
{
for (int i = 0; i < count(); ++i)
{
- QWidget *tabWidget = widget(i);
- if (WebView *tab = qobject_cast<WebView*>(tabWidget))
- {
- tab->reload();
- }
+ webView(i)->reload();
}
}
@@ -493,7 +502,7 @@ void MainView::closeTab(int index)
}
}
- QWidget *webView = widget(index);
+ QWidget *webView = this->webView(index);
removeTab(index);
updateTabBar(); // UI operation: do it ASAP!!
webView->deleteLater(); // webView is scheduled for deletion.
diff --git a/src/walletwidget.cpp b/src/walletwidget.cpp
index efb5af12..8aff4b8e 100644
--- a/src/walletwidget.cpp
+++ b/src/walletwidget.cpp
@@ -30,8 +30,10 @@
// KDE Includes
#include <klocalizedstring.h>
+#include <KIcon>
// Qt Includes
+#include <QToolButton>
#include <QPushButton>
#include <QHBoxLayout>
@@ -40,25 +42,32 @@ WalletWidget::WalletWidget(QWidget *parent)
: QWidget(parent)
, m_label( new QLabel(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);
+ m_label->setWordWrap(true);
+ QToolButton *closeButton = new QToolButton(this);
+ closeButton->setAutoRaise(true);
+ closeButton->setIcon(KIcon("dialog-close"));
+
+ QPushButton *rememberButton = new QPushButton(KIcon("document-save"), i18n("remember"), this);
+ QPushButton *neverHereButton = new QPushButton(KIcon("process-stop"), i18n("never for this site"), this);
+ QPushButton *notNowButton = new QPushButton(KIcon("dialog-cancel"), i18n("not now"), this);
+
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(notNowRememberData()));
connect(rememberButton, SIGNAL(clicked()), this, SLOT(rememberData()));
connect(neverHereButton, SIGNAL(clicked()), this, SLOT(neverRememberData()));
connect(notNowButton, SIGNAL(clicked()), this, SLOT(notNowRememberData()));
// layout
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_label);
- layout->addWidget(rememberButton);
- layout->addWidget(neverHereButton);
- layout->addWidget(notNowButton);
+ QGridLayout *layout = new QGridLayout(this);
+ layout->setMargin(0);
+ layout->addWidget(closeButton,0,0);
+ layout->addWidget(m_label,0,1);
+ layout->addWidget(rememberButton,0,2);
+ layout->addWidget(neverHereButton,0,3);
+ layout->addWidget(notNowButton,0,4);
+ layout->setColumnStretch(1,100);
setLayout(layout);
-
- // we start off hidden
- hide();
}
@@ -69,7 +78,6 @@ WalletWidget::~WalletWidget()
void WalletWidget::rememberData()
{
- hide();
emit saveFormDataAccepted(m_key);
}
@@ -83,7 +91,6 @@ void WalletWidget::neverRememberData()
void WalletWidget::notNowRememberData()
{
- hide();
emit saveFormDataRejected (m_key);
}
@@ -96,11 +103,4 @@ void WalletWidget::onSaveFormData(const QString &key, const QUrl &url)
);
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/webview.cpp b/src/webview.cpp
index fede781e..574af35a 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -55,15 +55,14 @@
#include <QClipboard>
#include <QKeyEvent>
#include <QAction>
+#include <QLayout>
-
-WebView::WebView(QWidget* parent)
+WebView::WebView(QWidget* parent, QWidget* messageWidget)
: KWebView(parent, false)
, m_page( new WebPage(this) )
- , m_walletBar( new WalletWidget(this) )
, m_progress(0)
, m_mousePos(QPoint(0,0))
-
+ , m_messageWidget(messageWidget)
{
setPage(m_page);
@@ -77,17 +76,32 @@ WebView::WebView(QWidget* parent)
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 &)));
- // kwallet
- KWebWallet *w = m_page->wallet();
- if(w)
+ if (messageWidget)
{
- 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 &)));
+
+ WalletWidget *walletBar= new WalletWidget(messageWidget);
+ messageWidget->layout()->addWidget(walletBar);
+ // kwallet
+ KWebWallet *w = m_page->wallet();
+ if(w)
+ {
+ connect (w, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)),
+ walletBar, SLOT(onSaveFormData(const QString &, const QUrl &)));
+ connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
+ w, SLOT(acceptSaveFormDataRequest(const QString &)));
+ connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
+ w, SLOT(rejectSaveFormDataRequest(const QString &)));
+
+ connect (w, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)),
+ messageWidget, SLOT(show()));
+ connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
+ messageWidget, SLOT(hide()));
+ connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
+ messageWidget, SLOT(hide()));
+
+ }
}
+
}
@@ -449,9 +463,3 @@ void WebView::loadInNewTab(const KUrl &url)
{
Application::instance()->loadUrl(url, Rekonq::NewCurrentTab);
}
-
-
-QWidget *WebView::walletBar()
-{
- return m_walletBar;
-}
diff --git a/src/webview.h b/src/webview.h
index 39cc51da..18ea66ad 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -45,7 +45,7 @@ class WebView : public KWebView
Q_OBJECT
public:
- explicit WebView(QWidget *parent = 0);
+ explicit WebView(QWidget *parent = 0, QWidget *messageWidget = 0);
~WebView();
WebPage *page();
@@ -53,7 +53,6 @@ public:
QString lastStatusBarText() const;
int progress();
QPoint mousePos();
- QWidget *walletBar();
protected:
void contextMenuEvent(QContextMenuEvent *event);
@@ -77,7 +76,7 @@ private slots:
private:
WebPage *m_page;
- WalletWidget *m_walletBar;
+ QWidget *m_messageWidget;
int m_progress;
QString m_statusBarText;
QPoint m_mousePos;