From 197455a6044b66bdfdd479f07f4ad52649816998 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Jul 2012 17:30:52 +0200 Subject: Re-add && Re-view tab preview popup --- src/webwindow/webwindow.cpp | 52 +++++++++++++++++++++------------------------ src/webwindow/webwindow.h | 9 ++++++++ 2 files changed, 33 insertions(+), 28 deletions(-) (limited to 'src/webwindow') diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index 6d0d4d72..4b94414a 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -32,37 +32,14 @@ WebWindow::WebWindow(QWidget *parent) : QWidget(parent) + , _progress(0) , _view(new QWebView(this)) , _edit(new QLineEdit(this)) { WebPage *p = new WebPage(_view); _view->setPage(p); - // layout - QVBoxLayout *l = new QVBoxLayout; - l->addWidget(_edit); - l->addWidget(_view); - l->setContentsMargins(0, 0, 0, 0); - setLayout(l); - - setContentsMargins(0, 0, 0, 0); - - // line edit signals - connect(_edit, SIGNAL(returnPressed()), this, SLOT(checkLoadUrl())); - - // url signal - connect(_view, SIGNAL(urlChanged(QUrl)), this, SLOT(setUrlText(QUrl))); - - // things changed signals - connect(_view, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); - - // load signals - connect(_view, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); - connect(_view, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); - connect(_view, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); - - // page signals - connect(p, SIGNAL(pageCreated(WebPage *)), this, SIGNAL(pageCreated(WebPage *))); + init(); } @@ -74,6 +51,12 @@ WebWindow::WebWindow(WebPage *page, QWidget *parent) _view->setPage(page); page->setParent(_view); + init(); +} + + +void WebWindow::init() +{ // layout QVBoxLayout *l = new QVBoxLayout; l->addWidget(_edit); @@ -94,12 +77,12 @@ WebWindow::WebWindow(WebPage *page, QWidget *parent) // load signals connect(_view, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); - connect(_view, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); connect(_view, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); - // page signals - connect(page, SIGNAL(pageCreated(WebPage *)), this, SIGNAL(pageCreated(WebPage *))); + connect(_view, SIGNAL(loadProgress(int)), this, SLOT(checkLoadProgress(int))); + // page signals + connect(page(), SIGNAL(pageCreated(WebPage *)), this, SIGNAL(pageCreated(WebPage *))); } @@ -133,6 +116,13 @@ void WebWindow::setUrlText(const QUrl &u) } +void WebWindow::checkLoadProgress(int p) +{ + _progress = p; + emit loadProgress(p); +} + + QUrl WebWindow::url() const { return _view->url(); @@ -155,3 +145,9 @@ QPixmap WebWindow::tabPreview(int width, int height) { return WebSnap::renderPagePreview(*page(), width, height); } + + +bool WebWindow::isLoading() +{ + return _progress != 0 && _progress != 100; +} diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index 189f111f..fdcb0383 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -51,10 +51,17 @@ public: QPixmap tabPreview(int width, int height); + bool isLoading(); + +private: + void init(); + private Q_SLOTS: void checkLoadUrl(); void setUrlText(const QUrl &); + void checkLoadProgress(int); + Q_SIGNALS: void titleChanged(QString); @@ -65,6 +72,8 @@ Q_SIGNALS: void pageCreated(WebPage *); private: + int _progress; + QWebView *_view; QLineEdit *_edit; }; -- cgit v1.2.1