From d64b60a884452202d8d7dd5e4a13fcdcedbb6265 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Jul 2009 00:22:14 +0200 Subject: Simplifying a bit web load progress process structure --- src/mainview.cpp | 12 +++++------- src/mainview.h | 2 +- src/mainwindow.cpp | 8 ++++---- src/mainwindow.h | 2 +- src/webview.cpp | 26 -------------------------- src/webview.h | 6 +----- 6 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index bc33c1c0..2382210b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -305,20 +305,15 @@ void MainView::slotCurrentChanged(int index) this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), - this, SIGNAL(loadProgress(int))); } connect(webView->page(), SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - connect(webView, SIGNAL(loadProgress(int)), - this, SIGNAL(loadProgress(int))); emit setCurrentTitle(webView->title()); m_urlBars->setCurrentIndex(index); - emit loadProgress(webView->progress()); emit showStatusBarMessage(webView->lastStatusBarText()); // set focus to the current webview @@ -531,6 +526,8 @@ void MainView::webViewLoadStarted() } } + emit browserLoading(true); + if (index != currentIndex()) return; @@ -552,13 +549,14 @@ void MainView::webViewLoadFinished(bool ok) } webViewIconChanged(); - + emit browserLoading(false); + // don't display messages for background tabs if (index != currentIndex()) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done"), Rekonq::Success); else diff --git a/src/mainview.h b/src/mainview.h index 0324d4ed..49000434 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -91,7 +91,7 @@ signals: void setCurrentTitle(const QString &url); void showStatusBarMessage(const QString &message, Rekonq::Notify status = Rekonq::Info); void linkHovered(const QString &link); - void loadProgress(int progress); + void browserLoading(bool); void printRequested(QWebFrame *frame); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a862ee95..2f74bd8a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -168,7 +168,7 @@ void MainWindow::postLaunch() // --------- connect signals and slots connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); - connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); + connect(m_view, SIGNAL(browserLoading(bool)), this, SLOT(slotBrowserLoading(bool))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); // update toolbar actions signals @@ -252,7 +252,7 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); // stop reload Action - m_stopReloadAction = new KAction(KIcon("view-refresh"), i18n("Reload"), this); + m_stopReloadAction = new KAction(KIcon("process-stop"), i18n("&Stop"), this); actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction); m_stopReloadAction->setShortcutConfigurable(false); @@ -770,11 +770,11 @@ WebView *MainWindow::currentTab() const } -void MainWindow::slotLoadProgress(int progress) +void MainWindow::slotBrowserLoading(bool v) { QAction *stop = actionCollection()->action("stop"); QAction *reload = actionCollection()->action("view_redisplay"); - if (progress < 100 && progress > 0) + if (v) { disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); m_stopReloadAction->setIcon(KIcon("process-stop")); diff --git a/src/mainwindow.h b/src/mainwindow.h index 85d272e7..2cf880b8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -95,7 +95,7 @@ protected: private slots: void postLaunch(); void slotUpdateConfiguration(); - void slotLoadProgress(int); + void slotBrowserLoading(bool); void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); void slotOpenLocation(); diff --git a/src/webview.cpp b/src/webview.cpp index fec96edc..654efc29 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -65,13 +65,10 @@ WebView::WebView(QWidget* parent) : QWebView(parent) , m_page(new WebPage(this)) - , m_progress(0) { setPage(m_page); connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); - connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); - connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); } @@ -98,18 +95,6 @@ QString WebView::lastStatusBarText() const } -int WebView::progress() const -{ - return m_progress; -} - - -void WebView::setProgress(int progress) -{ - m_progress = progress; -} - - void WebView::setStatusBarText(const QString &string) { m_statusBarText = string; @@ -286,17 +271,6 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } -void WebView::loadFinished() -{ - if (m_progress != 100) - { - kWarning() << "Received finished signal while progress is still:" << progress() - << "Url:" << url(); - } - m_progress = 0; -} - - void WebView::keyPressEvent(QKeyEvent *event) { if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) diff --git a/src/webview.h b/src/webview.h index 08d597db..9630162a 100644 --- a/src/webview.h +++ b/src/webview.h @@ -43,7 +43,6 @@ public: WebPage *page(); KUrl url() const; QString lastStatusBarText() const; - int progress() const; signals: // switching tabs @@ -61,15 +60,12 @@ protected: void wheelEvent(QWheelEvent *event); private slots: - void setProgress(int progress); - void loadFinished(); void setStatusBarText(const QString &string); void slotSearch(); private: WebPage *m_page; - - int m_progress; + QString m_statusBarText; }; -- cgit v1.2.1