Fixed behavior of freezing wodgets.

Improved mechansm of determination status of widgets - loading or error, or all is ok. Messages doesn't hides widget content.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 3e3db465a7
commit cfd4f8d1c5
  1. 4
      src/board/UBBoardController.cpp
  2. 15
      src/domain/UBAbstractWidget.cpp
  3. 9
      src/domain/UBGraphicsItemUndoCommand.cpp
  4. 1
      src/domain/UBGraphicsScene.cpp
  5. 8
      src/domain/UBW3CWidget.cpp
  6. 2
      src/domain/UBW3CWidget.h

@ -2233,8 +2233,8 @@ void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze)
return; return;
if (freeze) { if (freeze) {
item_casted->widgetWebView()->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii()); item_casted->widgetWebView()->load(QUrl(item_casted->w3cWidget()->freezedWidgetFilePath()));
} else }else
item_casted->widgetWebView()->loadMainHtml(); item_casted->widgetWebView()->loadMainHtml();
} }
} }

@ -73,7 +73,7 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
connect(QWebView::page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(QWebView::page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(QWebView::page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SIGNAL(geometryChangeRequested(const QRect&))); connect(QWebView::page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SIGNAL(geometryChangeRequested(const QRect&)));
connect(QWebView::page(), SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool)));
setMouseTracking(true); setMouseTracking(true);
} }
@ -121,6 +121,7 @@ UBAbstractWidget::~UBAbstractWidget()
void UBAbstractWidget::loadMainHtml() void UBAbstractWidget::loadMainHtml()
{ {
mInitialLoadDone = false;
QWebView::load(mMainHtmlUrl); QWebView::load(mMainHtmlUrl);
} }
@ -400,21 +401,21 @@ void UBAbstractWidget::paintEvent(QPaintEvent * event)
QPainter p(this); QPainter p(this);
p.drawPixmap(0, 0, mSnapshot); p.drawPixmap(0, 0, mSnapshot);
} }
else if(mIsTakingSnapshot || (mInitialLoadDone && !mLoadIsErronous)) else
{ {
QWebView::paintEvent(event); QWebView::paintEvent(event);
} }
else if (!mInitialLoadDone || mLoadIsErronous)
{ {
QPainter p(this); QPainter p(this);
QString message = tr("Loading ..."); QString message = tr("Loading ...");
// this is the right way of doing but we receive two callback and the one return always that the // this is the right way of doing but we receive two callback and the one return always that the
// load as failed... to check // load as failed... to check
// if (mLoadIsErronous) if (mInitialLoadDone && mLoadIsErronous)
// message = tr("Cannot load content"); message = tr("Cannot load content");
// else else
// message = tr("Loading ..."); message = tr("Loading ...");
p.setFont(QFont("Arial", 12)); p.setFont(QFont("Arial", 12));

@ -54,13 +54,11 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QG
if (pRemovedItem) if (pRemovedItem)
{ {
mRemovedItems.insert(pRemovedItem); mRemovedItems.insert(pRemovedItem);
UBApplication::boardController->freezeW3CWidget(pRemovedItem, true);
} }
if (pAddedItem) if (pAddedItem)
{ {
mAddedItems.insert(pAddedItem); mAddedItems.insert(pAddedItem);
UBApplication::boardController->freezeW3CWidget(pAddedItem, false);
} }
mFirstRedo = true; mFirstRedo = true;
@ -82,9 +80,10 @@ void UBGraphicsItemUndoCommand::undo()
while (itAdded.hasNext()) while (itAdded.hasNext())
{ {
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
UBApplication::boardController->freezeW3CWidget(item, true);
item->setSelected(false); item->setSelected(false);
mScene->removeItem(item); mScene->removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true);
} }
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems);
@ -132,12 +131,12 @@ void UBGraphicsItemUndoCommand::redo()
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
if (item) if (item)
{ {
UBApplication::boardController->freezeW3CWidget(item, false);
if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType)) if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType))
mScene->setAsBackgroundObject(item); mScene->setAsBackgroundObject(item);
else else
mScene->addItem(item); mScene->addItem(item);
UBApplication::boardController->freezeW3CWidget(item, false);
} }
} }

@ -1717,6 +1717,7 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
{ {
setModified(true); setModified(true);
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true);
if (!mTools.contains(item)) if (!mTools.contains(item))
--mItemCount; --mItemCount;

@ -425,8 +425,7 @@ QString UBW3CWidget::freezedWidgetPage()
static QString defaultcontent; static QString defaultcontent;
if (defaultcontent.isNull()) { if (defaultcontent.isNull()) {
QString etcPath = UBPlatformUtils::applicationResourcesDirectory() + "/etc/"; QString freezedWidgetDefaultContentFilePath = freezedWidgetFilePath();
QString freezedWidgetDefaultContentFilePath = etcPath + "freezedWidgetWrapper.html";
QFile wrapperFile(freezedWidgetDefaultContentFilePath); QFile wrapperFile(freezedWidgetDefaultContentFilePath);
if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath; qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath;
@ -445,6 +444,11 @@ QString UBW3CWidget::freezedWidgetPage()
return defaultcontent; return defaultcontent;
} }
QString UBW3CWidget::freezedWidgetFilePath()
{
return UBPlatformUtils::applicationResourcesDirectory() + "/etc/" + "freezedWidgetWrapper.html";
}
void UBW3CWidget::loadNPAPIWrappersTemplates() void UBW3CWidget::loadNPAPIWrappersTemplates()
{ {
if (!sTemplateLoaded) if (!sTemplateLoaded)

@ -50,6 +50,8 @@ class UBW3CWidget : public UBAbstractWidget
static QString freezedWidgetPage(); static QString freezedWidgetPage();
static QString freezedWidgetFilePath();
static bool hasNPAPIWrapper(const QString& pMimeType); static bool hasNPAPIWrapper(const QString& pMimeType);
class PreferenceValue class PreferenceValue

Loading…
Cancel
Save