Sankore 1189 - loading message

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 6d66258441
commit e36a58a201
  1. 26
      src/domain/UBGraphicsWidgetItem.cpp
  2. 1
      src/domain/UBGraphicsWidgetItem.h

@ -113,6 +113,7 @@ void UBGraphicsWidgetItem::initialize()
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SLOT(geometryChangeRequested(const QRect&))); connect(page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SLOT(geometryChangeRequested(const QRect&)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool)));
connect(page()->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayoutCompleted()));
connect(page(), SIGNAL(linkClicked(const QUrl&)), this, SLOT(onLinkClicked(const QUrl&))); connect(page(), SIGNAL(linkClicked(const QUrl&)), this, SLOT(onLinkClicked(const QUrl&)));
} }
@ -121,6 +122,11 @@ void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url)
UBApplication::webController->loadUrl(url); UBApplication::webController->loadUrl(url);
} }
void UBGraphicsWidgetItem::initialLayoutCompleted()
{
mInitialLoadDone = true;
}
QUrl UBGraphicsWidgetItem::mainHtml() QUrl UBGraphicsWidgetItem::mainHtml()
{ {
return mMainHtmlUrl; return mMainHtmlUrl;
@ -564,19 +570,16 @@ void UBGraphicsWidgetItem::injectInlineJavaScript()
void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
if (scene() && scene()->renderingContext() != UBGraphicsScene::Screen) if (scene() && scene()->renderingContext() != UBGraphicsScene::Screen) {
{
painter->drawPixmap(0, 0, snapshot()); painter->drawPixmap(0, 0, snapshot());
} }
else else {
{ QGraphicsWebView::paint(painter, option, widget);
if (!mInitialLoadDone || mLoadIsErronous) }
{
if (!mInitialLoadDone) {
QString message; QString message;
if (mInitialLoadDone && mLoadIsErronous)
message = tr("Cannot load content");
else
message = tr("Loading ..."); message = tr("Loading ...");
painter->setFont(QFont("Arial", 12)); painter->setFont(QFont("Arial", 12));
@ -594,10 +597,6 @@ void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsI
painter->setPen(Qt::white); painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message); painter->drawText(rect(), Qt::AlignCenter, message);
} }
else
QGraphicsWebView::paint(painter, option, widget);
}
} }
void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom) void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom)
@ -618,7 +617,6 @@ void UBGraphicsWidgetItem::javaScriptWindowObjectCleared()
void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok) void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
{ {
mInitialLoadDone = true;
mLoadIsErronous = !ok; mLoadIsErronous = !ok;
update(boundingRect()); update(boundingRect());
takeSnapshot(); takeSnapshot();

@ -163,6 +163,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
private slots: private slots:
void onLinkClicked(const QUrl& url); void onLinkClicked(const QUrl& url);
void initialLayoutCompleted();
private: private:
bool mIsFrozen; bool mIsFrozen;

Loading…
Cancel
Save