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 13 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;
if (freeze) {
item_casted->widgetWebView()->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii());
} else
item_casted->widgetWebView()->load(QUrl(item_casted->w3cWidget()->freezedWidgetFilePath()));
}else
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(), 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);
}
@ -121,6 +121,7 @@ UBAbstractWidget::~UBAbstractWidget()
void UBAbstractWidget::loadMainHtml()
{
mInitialLoadDone = false;
QWebView::load(mMainHtmlUrl);
}
@ -400,21 +401,21 @@ void UBAbstractWidget::paintEvent(QPaintEvent * event)
QPainter p(this);
p.drawPixmap(0, 0, mSnapshot);
}
else if(mIsTakingSnapshot || (mInitialLoadDone && !mLoadIsErronous))
else
{
QWebView::paintEvent(event);
}
else
if (!mInitialLoadDone || mLoadIsErronous)
{
QPainter p(this);
QString message = tr("Loading ...");
// this is the right way of doing but we receive two callback and the one return always that the
// load as failed... to check
// if (mLoadIsErronous)
// message = tr("Cannot load content");
// else
// message = tr("Loading ...");
if (mInitialLoadDone && mLoadIsErronous)
message = tr("Cannot load content");
else
message = tr("Loading ...");
p.setFont(QFont("Arial", 12));

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

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

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

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

Loading…
Cancel
Save