First modifications to move from QWebView to QGraphicsWebView.

This is not functional.
preferencesAboutTextFull
Yimgo 13 years ago
parent 46809871fa
commit 371496178f
  1. 16
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 34
      src/adaptors/publishing/UBDocumentPublisher.cpp
  3. 120
      src/api/UBW3CWidgetAPI.cpp
  4. 12
      src/api/UBW3CWidgetAPI.h
  5. 17
      src/api/UBWidgetMessageAPI.cpp
  6. 4
      src/api/UBWidgetMessageAPI.h
  7. 4
      src/api/UBWidgetUniboardAPI.cpp
  8. 2
      src/api/UBWidgetUniboardAPI.h
  9. 14
      src/board/UBBoardController.cpp
  10. 2
      src/board/UBBoardView.cpp
  11. 6
      src/domain/UBGraphicsScene.cpp
  12. 2
      src/domain/UBGraphicsScene.h
  13. 182
      src/domain/UBGraphicsWebView.cpp
  14. 64
      src/domain/UBGraphicsWebView.h
  15. 961
      src/domain/UBGraphicsWidgetItem.cpp
  16. 174
      src/domain/UBGraphicsWidgetItem.h
  17. 8
      src/domain/UBGraphicsWidgetItemDelegate.cpp
  18. 2
      src/domain/domain.pri

@ -2484,7 +2484,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsW3CWidgetToSvg(UBGraphicsW3C
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidgetItem* item)
{
QUrl widgetRootUrl = item->widgetWebView()->widgetUrl();
QUrl widgetRootUrl = item->widgetUrl();
QString uuid = UBStringUtils::toCanonicalUuid(item->uuid());
QString widgetDirectoryPath = UBPersistenceManager::widgetDirectory;
if (widgetRootUrl.toString().startsWith("file://"))
@ -2513,13 +2513,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
graphicsItemToSvg(item);
if (item->widgetWebView()->isFrozen())
if (item->isFrozen())
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "frozen", xmlTrue);
}
QString snapshotPath = mDocumentPath + "/" + UBPersistenceManager::widgetDirectory + "/" + uuid + ".png";
item->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG");
item->takeSnapshot().save(snapshotPath, "PNG");
mXmlWriter.writeStartElement(nsXHtml, "iframe");
@ -2528,10 +2528,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height()));
QString startFileUrl;
if (item->widgetWebView()->mainHtmlFileName().startsWith("http://"))
startFileUrl = item->widgetWebView()->mainHtmlFileName();
if (item->mainHtmlFileName().startsWith("http://"))
startFileUrl = item->mainHtmlFileName();
else
startFileUrl = widgetRootUrl.toString() + "/" + item->widgetWebView()->mainHtmlFileName();
startFileUrl = widgetRootUrl.toString() + "/" + item->mainHtmlFileName();
mXmlWriter.writeAttribute("src", startFileUrl);
mXmlWriter.writeEndElement(); //iFrame
@ -2622,13 +2622,13 @@ UBGraphicsW3CWidgetItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsW3CWidge
QPixmap snapshot(pixPath);
if (!snapshot.isNull())
widgetItem->w3cWidget()->setSnapshot(snapshot);
widgetItem->setSnapshot(snapshot);
QStringRef frozen = mXmlReader.attributes().value(mNamespaceUri, "frozen");
if (!frozen.isNull() && frozen.toString() == xmlTrue && !snapshot.isNull())
{
widgetItem->w3cWidget()->freeze();
widgetItem->freeze();
}
graphicsItemFromSvg(widgetItem);

@ -281,12 +281,12 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
jsonFile.write(QString(" \"uuid\": \"%1\",\n").arg(UBStringUtils::toCanonicalUuid(widget->uuid())).toUtf8());
jsonFile.write(QString(" \"id\": \"%1\",\n").arg(widget->metadatas().id).toUtf8());
jsonFile.write(QString(" \"name\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().name).toUtf8());
jsonFile.write(QString(" \"description\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().description).toUtf8());
jsonFile.write(QString(" \"author\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().author).toUtf8());
jsonFile.write(QString(" \"authorEmail\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorEmail).toUtf8());
jsonFile.write(QString(" \"authorHref\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"version\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"name\": \"%1\",\n").arg(widget->metadatas().name).toUtf8());
jsonFile.write(QString(" \"description\": \"%1\",\n").arg(widget->metadatas().description).toUtf8());
jsonFile.write(QString(" \"author\": \"%1\",\n").arg(widget->metadatas().author).toUtf8());
jsonFile.write(QString(" \"authorEmail\": \"%1\",\n").arg(widget->metadatas().authorEmail).toUtf8());
jsonFile.write(QString(" \"authorHref\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"version\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"x\": %1,\n").arg(widget->sceneBoundingRect().x()).toUtf8());
jsonFile.write(QString(" \"y\": %1,\n").arg(widget->sceneBoundingRect().y()).toUtf8());
@ -298,7 +298,7 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
QString url = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt";
jsonFile.write(QString(" \"src\": \"%1\",\n").arg(url).toUtf8());
QString startFile = widget->w3cWidget()->mainHtmlFileName();
QString startFile = widget->mainHtmlFileName();
jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8());
QMap<QString, QString> preferences = widget->preferences();
@ -363,7 +363,7 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
QMap<QString, QString> preferences = widgetItem->preferences();
QMap<QString, QString> datastoreEntries = widgetItem->datastoreEntries();
QString startFileName = widgetItem->w3cWidget()->mainHtmlFileName();
QString startFileName = widgetItem->mainHtmlFileName();
if (!startFileName.startsWith("http://"))
{
@ -394,18 +394,18 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
lines << " <script type=\"text/javascript\">";
lines << " var widget = {};";
lines << " widget.id = '" + widgetItem->w3cWidget()->metadatas().id + "';";
lines << " widget.name = '" + widgetItem->w3cWidget()->metadatas().name + "';";
lines << " widget.description = '" + widgetItem->w3cWidget()->metadatas().description + "';";
lines << " widget.author = '" + widgetItem->w3cWidget()->metadatas().author + "';";
lines << " widget.authorEmail = '" + widgetItem->w3cWidget()->metadatas().authorEmail + "';";
lines << " widget.authorHref = '" + widgetItem->w3cWidget()->metadatas().authorHref + "';";
lines << " widget.version = '" + widgetItem->w3cWidget()->metadatas().version + "';";
lines << " widget.id = '" + widgetItem->metadatas().id + "';";
lines << " widget.name = '" + widgetItem->metadatas().name + "';";
lines << " widget.description = '" + widgetItem->metadatas().description + "';";
lines << " widget.author = '" + widgetItem->metadatas().author + "';";
lines << " widget.authorEmail = '" + widgetItem->metadatas().authorEmail + "';";
lines << " widget.authorHref = '" + widgetItem->metadatas().authorHref + "';";
lines << " widget.version = '" + widgetItem->metadatas().version + "';";
lines << " widget.uuid = '" + UBStringUtils::toCanonicalUuid(widgetItem->uuid()) + "';";
lines << " widget.width = " + QString("%1").arg(widgetItem->w3cWidget()->width()) + ";";
lines << " widget.height = " + QString("%1").arg(widgetItem->w3cWidget()->height()) + ";";
lines << " widget.width = " + QString("%1").arg(widgetItem->nominalSize().width()) + ";";
lines << " widget.height = " + QString("%1").arg(widgetItem->nominalSize().height()) + ";";
lines << " widget.openUrl = function(url) { window.open(url); }";
lines << " widget.preferences = new Array()";

@ -30,25 +30,14 @@
#include "core/memcheck.h"
UBW3CWidgetAPI::UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
: QObject(graphicsWidget)
UBW3CWidgetAPI::UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent)
: QObject(parent)
, mGraphicsW3CWidget(graphicsWidget)
, mW3CWidget(mGraphicsW3CWidget->w3cWidget())
{
mPreferencesAPI = new UBW3CWidgetPreferenceAPI(graphicsWidget);
mPreferencesAPI = new UBW3CWidgetPreferenceAPI(graphicsWidget, parent);
}
UBW3CWidgetAPI::UBW3CWidgetAPI(UBW3CWidget *widget)
: QObject(widget)
, mGraphicsW3CWidget(0)
, mW3CWidget(widget)
{
mPreferencesAPI = new UBW3CWidgetPreferenceAPI(widget);
}
UBW3CWidgetAPI::~UBW3CWidgetAPI()
{
// NOOP
@ -66,55 +55,55 @@ QString UBW3CWidgetAPI::uuid()
int UBW3CWidgetAPI::width()
{
return mW3CWidget->geometry().width();
return mGraphicsW3CWidget->nominalSize().width();
}
int UBW3CWidgetAPI::height()
{
return mW3CWidget->geometry().height();
return mGraphicsW3CWidget->nominalSize().height();
}
QString UBW3CWidgetAPI::id()
{
return mW3CWidget->metadatas().id;
return mGraphicsW3CWidget->metadatas().id;
}
QString UBW3CWidgetAPI::name()
{
return mW3CWidget->metadatas().name;
return mGraphicsW3CWidget->metadatas().name;
}
QString UBW3CWidgetAPI::description()
{
return mW3CWidget->metadatas().description;
return mGraphicsW3CWidget->metadatas().description;
}
QString UBW3CWidgetAPI::author()
{
return mW3CWidget->metadatas().author;
return mGraphicsW3CWidget->metadatas().author;
}
QString UBW3CWidgetAPI::authorEmail()
{
return mW3CWidget->metadatas().authorEmail;
return mGraphicsW3CWidget->metadatas().authorEmail;
}
QString UBW3CWidgetAPI::authorHref()
{
return mW3CWidget->metadatas().authorHref;
return mGraphicsW3CWidget->metadatas().authorHref;
}
QString UBW3CWidgetAPI::version()
{
return mW3CWidget->metadatas().version;
return mGraphicsW3CWidget->metadatas().version;
}
QObject* UBW3CWidgetAPI::preferences()
@ -129,24 +118,13 @@ void UBW3CWidgetAPI::openURL(const QString& url)
}
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
: UBW3CWebStorage(graphicsWidget)
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QOBject *parent)
: UBW3CWebStorage(parent)
, mGraphicsW3CWidget(graphicsWidget)
, mW3CWidget(graphicsWidget->w3cWidget())
{
// NOOP
}
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBW3CWidget *widget)
: UBW3CWebStorage(widget)
, mGraphicsW3CWidget(0)
, mW3CWidget(widget)
{
// NOOP
}
UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
{
// NOOP
@ -155,45 +133,30 @@ UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
QString UBW3CWidgetPreferenceAPI::key(int index)
{
QMap<QString, UBW3CWidget::PreferenceValue> w3CPrefs = mW3CWidget->preferences();
if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index);
else
return "";
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences();
if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index);
else
return "";
}
QString UBW3CWidgetPreferenceAPI::getItem(const QString& key)
{
if (mGraphicsW3CWidget)
{
QMap<QString, QString> docPref = mGraphicsW3CWidget->preferences();
if (docPref.contains(key))
return docPref.value(key);
}
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences();
if (w3cPrefs.contains(key))
{
UBW3CWidget::PreferenceValue pref = w3cPrefs.value(key);
return pref.value;
}
else
{
return "";
}
if (mGraphicsW3CWidget) {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPref = mGraphicsW3CWidget->preferences();
if (w3cPref.contains(key))
return w3cPref.value(key).value;
}
return "";
}
int UBW3CWidgetPreferenceAPI::length()
{
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences();
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget-->preferences();
return w3cPrefs.size();
}
@ -201,39 +164,26 @@ int UBW3CWidgetPreferenceAPI::length()
void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
{
if (mGraphicsW3CWidget)
{
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences();
if (mGraphicsW3CWidget) {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly)
mGraphicsW3CWidget->setPreference(key, value);
}
else
{
// No state for non graphics widget (aka tool widget)
}
if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly)
mGraphicsW3CWidget->setPreference(key, value);
}
}
void UBW3CWidgetPreferenceAPI::removeItem(const QString& key)
{
if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removePreference(key);
else
{
// No state for non graphics widget (aka tool widget)
}
if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removePreference(key);
}
void UBW3CWidgetPreferenceAPI::clear()
{
if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removeAllPreferences();
else
{
// No state for non graphics widget (aka tool widget)
}
if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removeAllPreferences();
}

@ -47,8 +47,7 @@ class UBW3CWidgetAPI : public QObject
public:
UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget);
UBW3CWidgetAPI(UBW3CWidget *widget);
UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent = 0);
virtual ~UBW3CWidgetAPI();
@ -72,7 +71,6 @@ class UBW3CWidgetAPI : public QObject
private:
UBGraphicsW3CWidgetItem* mGraphicsW3CWidget;
UBW3CWidget *mW3CWidget;
UBW3CWidgetPreferenceAPI* mPreferencesAPI;
@ -88,8 +86,8 @@ class UBW3CWebStorage : public QObject
public:
UBW3CWebStorage(QObject *parent = 0)
: QObject(parent){}
virtual ~UBW3CWebStorage(){}
: QObject(parent){/* NOOP */}
virtual ~UBW3CWebStorage(){/* NOOP */}
public slots:
@ -110,8 +108,7 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage
Q_OBJECT;
public:
UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget);
UBW3CWidgetPreferenceAPI(UBW3CWidget *widget);
UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QOBject *parent = 0);
virtual ~UBW3CWidgetPreferenceAPI();
@ -129,7 +126,6 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage
private:
UBGraphicsW3CWidgetItem* mGraphicsW3CWidget;
UBW3CWidget* mW3CWidget;
};

@ -17,16 +17,15 @@
#include "core/UBApplication.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsWidget.h"
#include "core/memcheck.h"
UBWidgetMessageAPI::UBWidgetMessageAPI(UBW3CWidget *widget)
: QObject(widget)
, mWebWidget(widget)
UBWidgetMessageAPI::UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent)
: QObject(parent)
, mGraphicsWidgetItem(graphicsWidgetItem)
{
connect(UBWidgetAPIMessageBroker::instance(), SIGNAL(newMessage(const QString&, const QString&))
, this, SLOT(onNewMessage(const QString&, const QString&)), Qt::QueuedConnection);
connect(UBWidgetAPIMessageBroker::instance(), SIGNAL(newMessage(const QString&, const QString&)), this, SLOT(onNewMessage(const QString&, const QString&)), Qt::QueuedConnection);
}
UBWidgetMessageAPI::~UBWidgetMessageAPI()
@ -45,9 +44,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString&
{
if (mSubscribedTopics.contains(pTopicName))
{
if (mWebWidget
&& mWebWidget->page()
&& mWebWidget->page()->mainFrame())
if (mGraphicsWidgetItem && mGraphicsWidgetItem->page() && mGraphicsWidgetItem->page()->mainFrame())
{
QString js;
@ -55,7 +52,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString&
js += "{widget.messages.onmessage('";
js += pMessage + "', '" + pTopicName + "')}";
mWebWidget->page()->
mGraphicsWidgetItem->page()->
mainFrame()->evaluateJavaScript(js);
}

@ -25,7 +25,7 @@ class UBWidgetMessageAPI : public QObject
Q_OBJECT;
public:
UBWidgetMessageAPI(UBW3CWidget *widget);
UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent = 0);
virtual ~UBWidgetMessageAPI();
public slots:
@ -49,7 +49,7 @@ class UBWidgetMessageAPI : public QObject
private:
QSet<QString> mSubscribedTopics;
UBW3CWidget *mWebWidget;
UBGraphicsWidgetItem *mGraphicsWidgetItem;
};

@ -736,9 +736,9 @@ void UBDocumentDatastoreAPI::removeItem(const QString& key)
{
mGraphicsW3CWidget->removeDatastoreEntry(key);
}
void
void UBDocumentDatastoreAPI::clear()
UBDocumentDatastoreAPI::clear()
{
mGraphicsW3CWidget->removeAllDatastoreEntries();
}

@ -57,7 +57,7 @@ class UBWidgetUniboardAPI : public QObject
*
* some potential values are
*
* en
* enlocale
* en-UK
* fr
* fr-CH

@ -1885,7 +1885,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath));
UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem);
if (tmpItem)
tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG");
tmpItem->takeSnapshot().save(snapshotPath, "PNG");
}
@ -2092,7 +2092,7 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
/*QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
graphicsWidget->setSelected(false);
@ -2105,13 +2105,13 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
toolWidget->show();*/
}
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{
int xIsOdd = toolWidget->width() % 2;
/*int xIsOdd = toolWidget->width() % 2;
int yIsOdd = toolWidget->height() % 2;
QPoint mainWindowCenter = toolWidget->mapTo(mMainWindow, QPoint(toolWidget->width(), toolWidget->height()) / 2);
@ -2141,7 +2141,7 @@ void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
mActiveScene->addGraphicsWidget(graphicsWidget, scenePos);
toolWidget->hide();
toolWidget->deleteLater();
toolWidget->deleteLater();*/
}
@ -2227,8 +2227,8 @@ void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze)
return;
if (freeze) {
item_casted->widgetWebView()->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii());
item_casted->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii());
} else
item_casted->widgetWebView()->loadMainHtml();
item_casted->loadMainHtml();
}
}

@ -1182,7 +1182,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
}
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent);
QApplication::sendEvent(graphicsWidget,&newEvent);
} else {
mOkOnWidget = false;
event->ignore();

@ -1422,9 +1422,9 @@ UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUr
return appleWidget;
}
UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos, int widgetType)
UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos)
{
UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0, widgetType);
UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0);
addGraphicsWidget(w3CWidget, pPos);
@ -1444,7 +1444,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
graphicsWidget->setPos(QPointF(pPos.x() - graphicsWidget->boundingRect().width() / 2,
pPos.y() - graphicsWidget->boundingRect().height() / 2));
if (graphicsWidget->widgetWebView()->canBeContent())
if (graphicsWidget->canBeContent())
{
// graphicsWidget->widgetWebView()->loadMainHtml();

@ -130,7 +130,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsWidgetItem* addWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsAppleWidgetItem* addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0),int widgetType = UBGraphicsItemType::W3CWidgetItemType);
UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
void addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));

@ -0,0 +1,182 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsWebView.h"
#include <QtGui>
#include <QtWebKit>
#include "UBGraphicsScene.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent) :
QGraphicsWebView(parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
}
UBGraphicsWebView::~UBGraphicsWebView()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemCursorHasChanged && scene())
{
unsetCursor();
}
if ((change == QGraphicsItem::ItemSelectedHasChanged)
&& scene())
{
if (isSelected())
{
scene()->setActiveWindow(this);
}
else
{
if(scene()->activeWindow() == this)
{
scene()->setActiveWindow(0);
}
}
}
QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWebView::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
{
//NOOP
}
else
{
// QT Proxy Widget is a bit lazy, we force the selection ...
setSelected(true);
}
QGraphicsWebView::mousePressEvent(event);
}
void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
{
// NOOP;
}
else
{
QGraphicsWebView::mouseMoveEvent(event);
}
}
void UBGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
}
void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if( mDelegate->weelEvent(event) )
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
{
delete mDelegate;
}
mDelegate = pDelegate;
}
void UBGraphicsWebView::resize(qreal w, qreal h)
{
UBGraphicsWebView::resize(QSizeF(w, h));
}
void UBGraphicsWebView::resize(const QSizeF & pSize)
{
if (pSize != size())
{
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWebView::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsScene* UBGraphicsWebView::scene()
{
return static_cast<UBGraphicsScene*>(QGraphicsItem::scene());
}
void UBGraphicsWebView::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -0,0 +1,64 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSWEBVIEW_H_
#define UBGRAPHICSWEBVIEW_H_
#include <QtGui>
#include <QtWebKit>
#include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBGraphicsItemDelegate;
class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{
public:
UBGraphicsWebView(QGraphicsItem* parent = 0);
virtual ~UBGraphicsWebView();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
};
#endif /* UBGRAPHICSWEBVIEW_H_ */

File diff suppressed because it is too large Load Diff

@ -20,7 +20,7 @@
#include "core/UB.h"
#include "UBGraphicsProxyWidget.h"
#include "UBGraphicsWebView.h"
#include "UBW3CWidget.h"
#include "UBAppleWidget.h"
@ -32,7 +32,7 @@ class UBW3CWidgetWebStorageAPI;
class UBGraphiscItem;
class UBGraphiscItemDelegate;
class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
class UBGraphicsWidgetItem : public UBGraphicsWebView
{
Q_OBJECT
@ -42,26 +42,25 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual UBGraphicsScene* scene();
UBAbstractWidget* widgetWebView();
virtual void initialize();
virtual UBItem* deepCopy() const = 0;
virtual void resize ( qreal w, qreal h );
virtual void resize ( const QSizeF & size );
/* preferences */
void setPreference(const QString& key, QString value);
QString preference(const QString& key) const;
QMap<QString, QString> preferences() const;
void removePreference(const QString& key);
void removeAllPreferences();
/* datastore */
void setDatastoreEntry(const QString& key, QString value);
QString datastoreEntry(const QString& key) const;
QMap<QString, QString> datastoreEntries() const;
void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate; }
virtual void remove();
@ -80,6 +79,73 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void clearSource();
virtual void setUuid(const QUuid &pUuid);
/* from UBAbstractWidget */
void loadMainHtml();
QUrl mainHtml()
{
return mMainHtmlUrl;
}
QUrl widgetUrl()
{
return mWidgetUrl;
}
QString mainHtmlFileName()
{
return mMainHtmlFileName;
}
bool hasEmbededObjects();
bool hasEmbededFlash();
void resize(qreal width, qreal height);
QSize nominalSize() const
{
return mNominalSize;
}
bool canBeContent();
bool canBeTool();
bool hasLoadedSuccessfully() const
{
return (mInitialLoadDone && !mLoadIsErronous);
}
bool freezable()
{
return mIsFreezable;
}
bool resizable()
{
return mIsResizable;
}
static QString iconFilePath(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
static int widgetType(const QUrl& pUrl);
bool isFrozen()
{
return mIsFrozen;
}
QPixmap snapshot(){
return mSnapshot;
}
void setSnapshot(const QPixmap& pix);
QPixmap takeSnapshot();
public slots:
void freeze();
void unFreeze();
/* end from */
protected:
@ -96,14 +162,44 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
UBAbstractWidget* mWebKitWidget;
QMap<QString, QString> mPreferences;
QMap<QString, QString> mDatastore;
/* from UBAbstractWidget*/
bool mMouseIsPressed;
bool mFirstReleaseAfterMove;
QUrl mMainHtmlUrl;
QString mMainHtmlFileName;
QUrl mWidgetUrl;
QSize mNominalSize;
bool mIsResizable;
bool mInitialLoadDone;
bool mLoadIsErronous;
bool mIsFreezable;
int mCanBeContent;
int mCanBeTool;
enum OSType
{
type_NONE = 0, // 0000
type_WIN = 1, // 0001
type_MAC = 2, // 0010
type_UNIX = 4, // 0100
type_ALL = 7, // 0111
};
virtual void injectInlineJavaScript();
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void dropEvent(QDropEvent *);
/* end from */
protected slots:
void geometryChangeRequested(const QRect& geom);
virtual void javaScriptWindowObjectCleared();
/* from UBAbstractWidget*/
void mainFrameLoadFinished(bool ok);
/* end from */
private:
QPointF mLastMousePos;
@ -111,6 +207,14 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
UBWidgetUniboardAPI* mUniboardAPI;
QUrl ownFolder;
QUrl SnapshotFile;
/* from UBAbstractWidget*/
static QStringList sInlineJavaScripts;
static bool sInlineJavaScriptLoaded;
bool mIsFrozen;
QPixmap mSnapshot;
bool mIsTakingSnapshot;
/* end from */
};
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
@ -119,7 +223,6 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
public:
UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
UBGraphicsAppleWidgetItem(UBAppleWidget *appleWidget, QGraphicsItem *parent = 0);
~UBGraphicsAppleWidgetItem();
enum { Type = UBGraphicsItemType::AppleWidgetItemType };
@ -139,8 +242,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
Q_OBJECT
public:
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0, int widgetType = UBGraphicsItemType::W3CWidgetItemType);
UBGraphicsW3CWidgetItem(UBW3CWidget *w3cWidget, QGraphicsItem *parent = 0, int widgetType = UBGraphicsItemType::W3CWidgetItemType);
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsW3CWidgetItem();
enum { Type = UBGraphicsItemType::W3CWidgetItemType };
@ -152,22 +254,64 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual UBItem* deepCopy() const;
UBW3CWidget::Metadata metadatas() const;
UBW3CWidget* w3cWidget() const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
virtual void setUuid(const QUuid &pUuid);
static QString createNPAPIWrapper(const QString& url,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createNPAPIWrapperInDir(const QString& url, const QDir& pDir,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir,
const QSize& sizeHint, const QString& pName);
static QString freezedWidgetPage();
static bool hasNPAPIWrapper(const QString& pMimeType);
class Metadata
{
public:
QString id;
QString name;
QString description;
QString author;
QString authorEmail;
QString authorHref;
QString version;
};
Metadata metadatas() const
{
return mMetadatas;
}
Metadata mMetadatas;
private slots:
virtual void javaScriptWindowObjectCleared();
private:
UBW3CWidget* mW3CWidget;
UBW3CWidgetAPI* mW3CWidgetAPI;
static bool sTemplateLoaded;
static QMap<QString, QString> sNPAPIWrapperTemplates;
static QString sNPAPIWrappperConfigTemplate;
static void loadNPAPIWrappersTemplates();
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
};

@ -55,7 +55,7 @@ void UBGraphicsWidgetItemDelegate::updateMenuActionState()
UBGraphicsItemDelegate::updateMenuActionState();
if (freezeAction)
freezeAction->setChecked(delegated()->widgetWebView()->isFrozen());
freezeAction->setChecked(delegated()->isFrozen());
}
void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu)
@ -71,7 +71,7 @@ void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu)
freezeAction->setCheckable(true);
if (delegated()->widgetWebView()->canBeTool())
if (delegated()->canBeTool())
{
setAsToolAction = mMenu->addAction(tr("Transform as Tool "), this, SLOT(pin()));
QIcon pinIcon;
@ -86,11 +86,11 @@ void UBGraphicsWidgetItemDelegate::freeze(bool frozen)
{
if(frozen)
{
delegated()->widgetWebView()->freeze();
delegated()->freeze();
}
else
{
delegated()->widgetWebView()->unFreeze();
delegated()->unFreeze();
}
}

@ -7,6 +7,7 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBDocumentUndoCommand.h \
src/domain/UBPageSizeUndoCommand.h \
src/domain/UBGraphicsProxyWidget.h \
src/domain/UBGraphicsWebView.h \
src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \
@ -40,6 +41,7 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBDocumentUndoCommand.cpp \
src/domain/UBPageSizeUndoCommand.cpp \
src/domain/UBGraphicsProxyWidget.cpp \
src/domain/UBGraphicsWebView.cpp \
src/domain/UBGraphicsSvgItem.cpp \
src/domain/UBGraphicsPolygonItem.cpp \
src/domain/UBItem.cpp \

Loading…
Cancel
Save