Set busy cursor when doing page loading in browser.

This commit is contained in:
Krzesimir Nowak 2013-08-07 14:57:22 +02:00
parent a875b46a80
commit 87cb2a7114
2 changed files with 25 additions and 2 deletions

View file

@ -11,6 +11,7 @@
* for more details. * for more details.
*/ */
#include <QApplication>
#include <QDebug> #include <QDebug>
#include <QNetworkCookie> #include <QNetworkCookie>
#include <QWebFrame> #include <QWebFrame>
@ -29,8 +30,12 @@ void ShibbolethWebView::setup(const QUrl& url, ShibbolethCookieJar* jar)
QWebPage* page = new QWebPage(this); QWebPage* page = new QWebPage(this);
jar->setParent(this); jar->setParent(this);
connect (jar, SIGNAL (newCookiesForUrl (QList<QNetworkCookie>, QUrl)), connect(jar, SIGNAL (newCookiesForUrl (QList<QNetworkCookie>, QUrl)),
this, SLOT (onNewCookiesForUrl (QList<QNetworkCookie>, QUrl))); this, SLOT (onNewCookiesForUrl (QList<QNetworkCookie>, QUrl)));
connect(page, SIGNAL(loadStarted()),
this, SLOT(slotLoadStarted()));
connect(page, SIGNAL(loadFinished(bool)),
this, SLOT(slotLoadFinished()));
nm->setCookieJar(jar); nm->setCookieJar(jar);
page->setNetworkAccessManager(nm); page->setNetworkAccessManager(nm);
@ -44,6 +49,11 @@ ShibbolethWebView::ShibbolethWebView(const QUrl& url, QWidget* parent)
setup(url, new ShibbolethCookieJar(this)); setup(url, new ShibbolethCookieJar(this));
} }
ShibbolethWebView::~ShibbolethWebView()
{
slotLoadFinished();
}
ShibbolethWebView::ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent) ShibbolethWebView::ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent)
: QWebView(parent) : QWebView(parent)
{ {
@ -81,4 +91,14 @@ void ShibbolethWebView::hideEvent(QHideEvent* event)
QWebView::hideEvent(event); QWebView::hideEvent(event);
} }
void ShibbolethWebView::slotLoadStarted()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
void ShibbolethWebView::slotLoadFinished()
{
QApplication::restoreOverrideCursor();
}
} // ns Mirall } // ns Mirall

View file

@ -32,6 +32,7 @@ class ShibbolethWebView : public QWebView
public: public:
ShibbolethWebView(const QUrl& url, QWidget* parent = 0); ShibbolethWebView(const QUrl& url, QWidget* parent = 0);
ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent = 0); ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent = 0);
~ShibbolethWebView();
protected: protected:
void hideEvent(QHideEvent* event); void hideEvent(QHideEvent* event);
@ -43,6 +44,8 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void onNewCookiesForUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url); void onNewCookiesForUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url);
void slotLoadStarted();
void slotLoadFinished();
private: private:
void setup(const QUrl& url, ShibbolethCookieJar* jar); void setup(const QUrl& url, ShibbolethCookieJar* jar);