1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Showing loading animation (spinner) in popup windows.

This commit is contained in:
nowrep 2012-06-27 18:29:00 +02:00
parent dfb82fb3cc
commit 4743549851
9 changed files with 55 additions and 20 deletions

View File

@ -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 {

View File

@ -21,6 +21,9 @@
#include "globalfunctions.h"
#include "iconprovider.h"
#include <QMovie>
#include <QLabel>
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());
}

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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()
{
}

View File

@ -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);

View File

@ -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();

View File

@ -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);