diff --git a/resources/library/interactive/Geogebra.wgt/config.xml b/resources/library/interactive/Geogebra.wgt/config.xml new file mode 100644 index 00000000..64bb595c --- /dev/null +++ b/resources/library/interactive/Geogebra.wgt/config.xml @@ -0,0 +1,12 @@ + + + Geogebra + + diff --git a/resources/library/interactive/Geogebra.wgt/icon.png b/resources/library/interactive/Geogebra.wgt/icon.png new file mode 100644 index 00000000..2b5397e4 Binary files /dev/null and b/resources/library/interactive/Geogebra.wgt/icon.png differ diff --git a/resources/library/interactive/Geogebra.wgt/images/loading.gif b/resources/library/interactive/Geogebra.wgt/images/loading.gif new file mode 100644 index 00000000..5ccc287b Binary files /dev/null and b/resources/library/interactive/Geogebra.wgt/images/loading.gif differ diff --git a/resources/library/interactive/Geogebra.wgt/index.html b/resources/library/interactive/Geogebra.wgt/index.html new file mode 100644 index 00000000..9fe49048 --- /dev/null +++ b/resources/library/interactive/Geogebra.wgt/index.html @@ -0,0 +1,71 @@ + + + + +
+ + + diff --git a/src/domain/UBAbstractWidget.cpp b/src/domain/UBAbstractWidget.cpp index 6ff6116b..a5fafc18 100644 --- a/src/domain/UBAbstractWidget.cpp +++ b/src/domain/UBAbstractWidget.cpp @@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent) , mInitialLoadDone(false) , mLoadIsErronous(false) , mIsFreezable(true) - , mCanBeContent(true) - , mCanBeTool(true) + , mCanBeContent(0) + , mCanBeTool(0) , mIsFrozen(false) , mIsTakingSnapshot(false) { @@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent) setMouseTracking(true); } +bool UBAbstractWidget::canBeContent() +{ + // if we under MAC OS + #if defined(Q_OS_MAC) + return mCanBeContent & OSType::type_MAC; + #endif + + // if we under UNIX OS + #if defined(Q_OS_UNIX) + return mCanBeContent & OSType::type_UNIX; + #endif + + // if we under WINDOWS OS + #if defined(Q_OS_WIN) + return mCanBeContent & OSType::type_WIN; + #endif +} + +bool UBAbstractWidget::canBeTool() +{ + // if we under MAC OS + #if defined(Q_OS_MAC) + return mCanBeTool & OSType::type_MAC; + #endif + + // if we under UNIX OS + #if defined(Q_OS_UNIX) + return mCanBeTool & OSType::type_UNIX; + #endif + + // if we under WINDOWS OS + #if defined(Q_OS_WIN) + return mCanBeTool & OSType::type_WIN; + #endif +} UBAbstractWidget::~UBAbstractWidget() { // NOOP } +void UBAbstractWidget::loadMainHtml() +{ + QWebView::load(mMainHtmlUrl); +} bool UBAbstractWidget::event(QEvent *event) { diff --git a/src/domain/UBAbstractWidget.h b/src/domain/UBAbstractWidget.h index e96706e9..5c077d04 100644 --- a/src/domain/UBAbstractWidget.h +++ b/src/domain/UBAbstractWidget.h @@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0); virtual ~UBAbstractWidget(); + void loadMainHtml(); + QUrl mainHtml() { return mMainHtmlUrl; @@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView return mNominalSize; } - bool canBeContent() const - { - return mCanBeContent; - } - - bool canBeTool() const - { - return mCanBeTool; - } + bool canBeContent(); + bool canBeTool(); bool hasLoadedSuccessfully() const { @@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView bool mLoadIsErronous; bool mIsFreezable; - bool mCanBeContent; - bool mCanBeTool; + 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 paintEvent(QPaintEvent * event); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 0c36530b..0974105f 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1091,7 +1091,6 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true); graphicsWidget->setZValue(getNextObjectZIndex()); -// QGraphicsScene::addWidget(graphicsWidget->widgetWebView()); addItem(graphicsWidget); qreal ssf = 1 / UBApplication::boardController->systemScaleFactor(); @@ -1103,21 +1102,13 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co if (graphicsWidget->widgetWebView()->canBeContent()) { + graphicsWidget->widgetWebView()->loadMainHtml(); + graphicsWidget->setSelected(true); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); UBApplication::undoStack->push(uc); setDocumentUpdated(); - -// graphicsWidget->widgetWebView()->setParent(graphicsWidget->v)); -// QObject *zz1= graphicsWidget->widgetWebView()->parent(); -// QWidget *zz2= graphicsWidget->widgetWebView()->parentWidget(); -// -// QObject *zz3= graphicsWidget->parent(); -// QGraphicsWidget *zz4= graphicsWidget->parentWidget(); - -// graphicsWidget->widgetWebView()->loadUrl(); - } else { diff --git a/src/domain/UBW3CWidget.cpp b/src/domain/UBW3CWidget.cpp index b3fbf575..7a1af1e2 100644 --- a/src/domain/UBW3CWidget.cpp +++ b/src/domain/UBW3CWidget.cpp @@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent) QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower(); - mCanBeTool = roles == "" || roles.contains("tool"); - mCanBeContent = roles == "" || roles.contains("content"); + //------------------------------// + + if( roles == "" || roles.contains("tool") ) + { + mCanBeTool = UBAbstractWidget::OSType::type_ALL; + } + + if( roles.contains("twin") ) + { + mCanBeTool |= UBAbstractWidget::OSType::type_WIN; + } + + if( roles.contains("tmac") ) + { + mCanBeTool |= UBAbstractWidget::OSType::type_MAC; + } + + if( roles.contains("tunix") ) + { + mCanBeTool |= UBAbstractWidget::OSType::type_UNIX; + } + + //---------// + + if( roles == "" || roles.contains("content") ) + { + mCanBeContent = UBAbstractWidget::OSType::type_ALL; + } + + if( roles.contains("cwin") ) + { + mCanBeContent |= UBAbstractWidget::OSType::type_WIN; + } + + if( roles.contains("cmac") ) + { + mCanBeContent |= UBAbstractWidget::OSType::type_MAC; + } + + if( roles.contains("cunix") ) + { + mCanBeContent |= UBAbstractWidget::OSType::type_UNIX; + } + + //------------------------------// QDomNodeList contentDomList = widgetElement.elementsByTagName("content"); @@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent) connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared())); - QWebView::load(mMainHtmlUrl); - setFixedSize(QSize(width, height)); mNominalSize = QSize(width, height); @@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget() // NOOP } - void UBW3CWidget::javaScriptWindowObjectCleared() { UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0); diff --git a/src/gui/UBToolWidget.cpp b/src/gui/UBToolWidget.cpp index 59ff2af4..ea1bdee1 100644 --- a/src/gui/UBToolWidget.cpp +++ b/src/gui/UBToolWidget.cpp @@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent) , mShouldMoveWidget(false) { mToolWidget->setParent(this); + mToolWidget->loadMainHtml(); initialize();