diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 24b7a94d1..ee6e2431b 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -1329,7 +1329,7 @@ void QupZilla::updateLoadingActions() m_actionReload->setEnabled(!isLoading); if (isLoading) { - m_progressBar->setValue(view->loadProgress()); + m_progressBar->setValue(view->loadingProgress()); m_navigationBar->showStopButton(); } else { diff --git a/src/lib/popupwindow/popuplocationbar.cpp b/src/lib/popupwindow/popuplocationbar.cpp index 07bacd30e..7e3566120 100644 --- a/src/lib/popupwindow/popuplocationbar.cpp +++ b/src/lib/popupwindow/popuplocationbar.cpp @@ -21,6 +21,9 @@ #include "globalfunctions.h" #include "iconprovider.h" +#include +#include + class QT_QUPZILLA_EXPORT PopupSiteIcon : public QWidget { public: @@ -37,7 +40,6 @@ private: QPainter p(this); m_icon.paint(&p, rect()); } - }; PopupLocationBar::PopupLocationBar(QWidget* parent) @@ -48,8 +50,13 @@ PopupLocationBar::PopupLocationBar(QWidget* parent) m_siteIcon->setIcon(qIconProvider->emptyWebIcon()); m_siteIcon->setFixedSize(20, 26); + m_loadingAnimation = new QLabel(this); + QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), m_loadingAnimation); + m_loadingAnimation->setMovie(movie); + addWidget(m_siteIcon, LineEdit::LeftSide); - setWidgetSpacing(0); + addWidget(m_loadingAnimation, LineEdit::RightSide); + setWidgetSpacing(1); setFixedHeight(26); setReadOnly(true); @@ -60,6 +67,22 @@ void PopupLocationBar::setView(PopupWebView* view) m_view = view; } +void PopupLocationBar::startLoading() +{ + m_loadingAnimation->show(); + m_loadingAnimation->movie()->start(); + + updateTextMargins(); +} + +void PopupLocationBar::stopLoading() +{ + m_loadingAnimation->hide(); + m_loadingAnimation->movie()->stop(); + + updateTextMargins(); +} + void PopupLocationBar::showUrl(const QUrl &url) { setText(qz_urlEncodeQueryString(url)); @@ -68,5 +91,5 @@ void PopupLocationBar::showUrl(const QUrl &url) void PopupLocationBar::showIcon() { - m_siteIcon->setIcon(QIcon(m_view->icon().pixmap(16, 16))); + m_siteIcon->setIcon(m_view->icon()); } diff --git a/src/lib/popupwindow/popuplocationbar.h b/src/lib/popupwindow/popuplocationbar.h index 9c4a59aad..bd7fd7365 100644 --- a/src/lib/popupwindow/popuplocationbar.h +++ b/src/lib/popupwindow/popuplocationbar.h @@ -22,6 +22,7 @@ #include "lineedit.h" class QUrl; +class QLabel; class PopupSiteIcon; class PopupWebView; @@ -38,6 +39,9 @@ public: void setView(PopupWebView* view); + void startLoading(); + void stopLoading(); + signals: public slots: @@ -47,7 +51,7 @@ public slots: private: PopupWebView* m_view; PopupSiteIcon* m_siteIcon; - + QLabel* m_loadingAnimation; }; #endif // POPUPLOCATIONBAR_H diff --git a/src/lib/popupwindow/popupwebpage.cpp b/src/lib/popupwindow/popupwebpage.cpp index 2ca06297f..2ff9a2b56 100644 --- a/src/lib/popupwindow/popupwebpage.cpp +++ b/src/lib/popupwindow/popupwebpage.cpp @@ -109,6 +109,10 @@ void PopupWebPage::checkBehaviour() popup->setToolBarVisibility(m_toolBarVisible); popup->show(); + if (m_isLoading) { + view->fakeLoadingProgress(m_progress); + } + p_QupZilla->addDeleteOnCloseWidget(popup); disconnect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect))); @@ -124,8 +128,9 @@ void PopupWebPage::checkBehaviour() int index = p_QupZilla->tabWidget()->addView(QUrl(), Qz::NT_CleanSelectedTab); TabbedWebView* view = p_QupZilla->weView(index); view->setWebPage(this); + if (m_isLoading) { - view->fakePageLoading(m_progress); + view->fakeLoadingProgress(m_progress); } } } diff --git a/src/lib/popupwindow/popupwindow.cpp b/src/lib/popupwindow/popupwindow.cpp index 0aae20f9d..9b859b752 100644 --- a/src/lib/popupwindow/popupwindow.cpp +++ b/src/lib/popupwindow/popupwindow.cpp @@ -119,6 +119,8 @@ void PopupWindow::loadStarted() { m_progressBar->setValue(0); m_progressBar->show(); + + m_locationBar->startLoading(); } void PopupWindow::loadProgress(int value) @@ -130,6 +132,8 @@ void PopupWindow::loadProgress(int value) void PopupWindow::loadFinished() { m_progressBar->hide(); + + m_locationBar->stopLoading(); } void PopupWindow::closeEvent(QCloseEvent* event) diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index 9a188070a..f1858cb82 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -48,7 +48,7 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab) , m_rssChecked(false) { connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); - connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadingProgress(int))); + connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished())); connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); @@ -127,7 +127,7 @@ void TabbedWebView::urlChanged(const QUrl &url) } } -void TabbedWebView::loadingProgress(int prog) +void TabbedWebView::loadProgress(int prog) { if (prog > 60) { checkRss(); @@ -320,13 +320,6 @@ void TabbedWebView::disconnectObjects() WebView::disconnectObjects(); } -void TabbedWebView::fakePageLoading(int progress) -{ - WebView::slotLoadStarted(); - slotLoadStarted(); - loadingProgress(progress); -} - TabbedWebView::~TabbedWebView() { } diff --git a/src/lib/webview/tabbedwebview.h b/src/lib/webview/tabbedwebview.h index 4e06b0010..bd3a996c7 100644 --- a/src/lib/webview/tabbedwebview.h +++ b/src/lib/webview/tabbedwebview.h @@ -50,8 +50,6 @@ public: QWidget* overlayForJsAlert(); void disconnectObjects(); - void fakePageLoading(int progress); - signals: void wantsCloseTab(int); void ipChanged(QString); @@ -65,7 +63,7 @@ public slots: void showIcon(); void slotLoadStarted(); - void loadingProgress(int prog); + void loadProgress(int prog); void closeView(); void openUrlInNewTab(const QUrl &urla, Qz::NewTabPositionFlag position); diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index bff61595f..baa9a7c81 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -168,11 +168,17 @@ bool WebView::isLoading() const return m_isLoading; } -int WebView::loadProgress() const +int WebView::loadingProgress() const { return m_progress; } +void WebView::fakeLoadingProgress(int progress) +{ + emit loadStarted(); + emit loadProgress(progress); +} + bool WebView::isUrlValid(const QUrl &url) { const QString &urlScheme = url.scheme(); diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index f196854cc..6f42595ff 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -43,7 +43,9 @@ public: bool loadingError() const; bool isLoading() const; - int loadProgress() const; + + int loadingProgress() const; + void fakeLoadingProgress(int progress); void addNotification(QWidget* notif); bool eventFilter(QObject* obj, QEvent* event);