Commit dc272ce3 authored by Claudio Valerio's avatar Claudio Valerio

fixed issue 1131 and 1161

parent 3607318f
This diff is collapsed.
...@@ -303,12 +303,10 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta ...@@ -303,12 +303,10 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
if (mCurrentStroke) if (mCurrentStroke && mCurrentStroke->polygons().empty()){
if (mCurrentStroke->polygons().empty()) delete mCurrentStroke;
{ mCurrentStroke = NULL;
delete mCurrentStroke; }
mCurrentStroke = NULL;
}
if (mZLayerController) if (mZLayerController)
delete mZLayerController; delete mZLayerController;
...@@ -437,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre ...@@ -437,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){ if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke; delete mCurrentStroke;
mCurrentStroke = NULL; mCurrentStroke = NULL;
} }
...@@ -800,7 +798,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) ...@@ -800,7 +798,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
} }
} }
else if (eraserPath.intersects(itemPainterPath)) else if (eraserPath.intersects(itemPainterPath))
{ {
QPainterPath newPath = itemPainterPath.subtracted(eraserPath); QPainterPath newPath = itemPainterPath.subtracted(eraserPath);
#pragma omp critical #pragma omp critical
...@@ -820,7 +818,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) ...@@ -820,7 +818,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
else else
{ {
UBGraphicsPolygonItem *pi = intersectedItems[i]; UBGraphicsPolygonItem *pi = intersectedItems[i];
for(int j = 0; j < intersectedPolygons[i].size(); j++) for(int j = 0; j < intersectedPolygons[i].size(); j++)
{ {
QPolygonF p = intersectedPolygons[i][j]; QPolygonF p = intersectedPolygons[i][j];
...@@ -2295,7 +2293,7 @@ void UBGraphicsScene::createPointer() ...@@ -2295,7 +2293,7 @@ void UBGraphicsScene::createPointer()
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {
if (tool == (int)UBStylusTool::Selector || if (tool == (int)UBStylusTool::Selector ||
tool == (int)UBStylusTool::Text || tool == (int)UBStylusTool::Text ||
tool == (int)UBStylusTool::Play) tool == (int)UBStylusTool::Play)
{ {
deselectAllItems(); deselectAllItems();
...@@ -2310,5 +2308,5 @@ void UBGraphicsScene::setToolCursor(int tool) ...@@ -2310,5 +2308,5 @@ void UBGraphicsScene::setToolCursor(int tool)
void UBGraphicsScene::initStroke() void UBGraphicsScene::initStroke()
{ {
mCurrentStroke = new UBGraphicsStroke(); mCurrentStroke = new UBGraphicsStroke();
} }
...@@ -48,7 +48,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem ...@@ -48,7 +48,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
: QGraphicsWebView(parent) : QGraphicsWebView(parent)
, mInitialLoadDone(false) , mInitialLoadDone(false)
, mIsFreezable(true) , mIsFreezable(true)
, mIsResizable(false) , mIsResizable(false)
, mLoadIsErronous(false) , mLoadIsErronous(false)
, mCanBeContent(0) , mCanBeContent(0)
, mCanBeTool(0) , mCanBeTool(0)
...@@ -56,7 +56,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem ...@@ -56,7 +56,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
, mIsFrozen(false) , mIsFrozen(false)
, mIsTakingSnapshot(false) , mIsTakingSnapshot(false)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mUniboardAPI(0) , mUniboardAPI(0)
{ {
setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
...@@ -119,7 +119,8 @@ void UBGraphicsWidgetItem::initialize() ...@@ -119,7 +119,8 @@ void UBGraphicsWidgetItem::initialize()
void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url) void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url)
{ {
UBApplication::webController->loadUrl(url); //UBApplication::webController->loadUrl(url);
load(url);
} }
void UBGraphicsWidgetItem::initialLayoutCompleted() void UBGraphicsWidgetItem::initialLayoutCompleted()
...@@ -147,24 +148,6 @@ QString UBGraphicsWidgetItem::mainHtmlFileName() ...@@ -147,24 +148,6 @@ QString UBGraphicsWidgetItem::mainHtmlFileName()
return mMainHtmlFileName; return mMainHtmlFileName;
} }
bool UBGraphicsWidgetItem::hasEmbededObjects()
{
if (page()->mainFrame()) {
QList<UBWebKitUtils::HtmlObject> htmlObjects = UBWebKitUtils::objectsInFrame(page()->mainFrame());
return htmlObjects.length() > 0;
}
return false;
}
bool UBGraphicsWidgetItem::hasEmbededFlash()
{
if (hasEmbededObjects())
return page()->mainFrame()->toHtml().contains("application/x-shockwave-flash");
else
return false;
}
bool UBGraphicsWidgetItem::canBeContent() bool UBGraphicsWidgetItem::canBeContent()
{ {
// if we under MAC OS // if we under MAC OS
...@@ -324,18 +307,18 @@ bool UBGraphicsWidgetItem::hasLoadedSuccessfully() const ...@@ -324,18 +307,18 @@ bool UBGraphicsWidgetItem::hasLoadedSuccessfully() const
return (mInitialLoadDone && !mLoadIsErronous); return (mInitialLoadDone && !mLoadIsErronous);
} }
bool UBGraphicsWidgetItem::freezable() bool UBGraphicsWidgetItem::freezable()
{ {
return mIsFreezable; return mIsFreezable;
} }
bool UBGraphicsWidgetItem::resizable() bool UBGraphicsWidgetItem::resizable()
{ {
return mIsResizable; return mIsResizable;
} }
bool UBGraphicsWidgetItem::isFrozen() bool UBGraphicsWidgetItem::isFrozen()
{ {
return mIsFrozen; return mIsFrozen;
} }
...@@ -351,7 +334,7 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot() ...@@ -351,7 +334,7 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot()
QPixmap pixmap(size().toSize()); QPixmap pixmap(size().toSize());
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
QPainter painter(&pixmap); QPainter painter(&pixmap);
QStyleOptionGraphicsItem options; QStyleOptionGraphicsItem options;
paint(&painter, &options); paint(&painter, &options);
...@@ -497,7 +480,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event) ...@@ -497,7 +480,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event)
event->accept(); event->accept();
return true; return true;
} }
} }
else if (event->type() == QEvent::ShortcutOverride) else if (event->type() == QEvent::ShortcutOverride)
event->accept(); event->accept();
...@@ -813,7 +796,7 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi ...@@ -813,7 +796,7 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
if (roles.contains("tmac")) if (roles.contains("tmac"))
mCanBeTool |= UBGraphicsWidgetItem::type_MAC; mCanBeTool |= UBGraphicsWidgetItem::type_MAC;
if (roles.contains("tunix")) if (roles.contains("tunix"))
mCanBeTool |= UBGraphicsWidgetItem::type_UNIX; mCanBeTool |= UBGraphicsWidgetItem::type_UNIX;
...@@ -886,9 +869,6 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi ...@@ -886,9 +869,6 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
/* is it a valid local file ? */ /* is it a valid local file ? */
QFile f(mMainHtmlUrl.toLocalFile()); QFile f(mMainHtmlUrl.toLocalFile());
qDebug() << mMainHtmlFileName;
qDebug() << mMainHtmlUrl.toLocalFile();
if(!f.exists()) if(!f.exists())
mMainHtmlUrl = QUrl(mMainHtmlFileName); mMainHtmlUrl = QUrl(mMainHtmlFileName);
...@@ -1108,11 +1088,11 @@ QString UBGraphicsW3CWidgetItem::freezedWidgetPage() ...@@ -1108,11 +1088,11 @@ QString UBGraphicsW3CWidgetItem::freezedWidgetPage()
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;
defaultcontent = ""; defaultcontent = "";
} }
else { else {
QByteArray arr = wrapperFile.readAll(); QByteArray arr = wrapperFile.readAll();
if (!arr.isEmpty()) if (!arr.isEmpty())
defaultcontent = QString(arr); defaultcontent = QString(arr);
else { else {
qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty"; qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty";
defaultcontent = QString(); defaultcontent = QString();
......
...@@ -62,14 +62,11 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -62,14 +62,11 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
QUrl widgetUrl(); QUrl widgetUrl();
QString mainHtmlFileName(); QString mainHtmlFileName();
bool hasEmbededObjects();
bool hasEmbededFlash();
bool canBeContent(); bool canBeContent();
bool canBeTool(); bool canBeTool();
QString preference(const QString& key) const; QString preference(const QString& key) const;
void setPreference(const QString& key, QString value); void setPreference(const QString& key, QString value);
QMap<QString, QString> preferences() const; QMap<QString, QString> preferences() const;
void removePreference(const QString& key); void removePreference(const QString& key);
void removeAllPreferences(); void removeAllPreferences();
...@@ -94,7 +91,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -94,7 +91,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
QSize nominalSize() const; QSize nominalSize() const;
bool hasLoadedSuccessfully() const; bool hasLoadedSuccessfully() const;
...@@ -110,7 +107,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -110,7 +107,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
static int widgetType(const QUrl& pUrl); static int widgetType(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl); static QString widgetName(const QUrl& pUrl);
static QString iconFilePath(const QUrl& pUrl); static QString iconFilePath(const QUrl& pUrl);
public slots: public slots:
...@@ -127,7 +124,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -127,7 +124,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
type_ALL = 7, // 0111 type_ALL = 7, // 0111
}; };
bool mFirstReleaseAfterMove; bool mFirstReleaseAfterMove;
bool mInitialLoadDone; bool mInitialLoadDone;
bool mIsFreezable; bool mIsFreezable;
bool mIsResizable; bool mIsResizable;
...@@ -137,7 +134,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -137,7 +134,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
int mCanBeTool; int mCanBeTool;
QSize mNominalSize; QSize mNominalSize;
QString mMainHtmlFileName; QString mMainHtmlFileName;
QUrl mMainHtmlUrl; QUrl mMainHtmlUrl;
QUrl mWidgetUrl; QUrl mWidgetUrl;
QMap<QString, QString> mDatastore; QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences; QMap<QString, QString> mPreferences;
...@@ -162,21 +159,21 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe ...@@ -162,21 +159,21 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
void mainFrameLoadFinished(bool ok); void mainFrameLoadFinished(bool ok);
private slots: private slots:
void onLinkClicked(const QUrl& url); void onLinkClicked(const QUrl& url);
void initialLayoutCompleted(); void initialLayoutCompleted();
private: private:
bool mIsFrozen; bool mIsFrozen;
bool mIsTakingSnapshot; bool mIsTakingSnapshot;
bool mShouldMoveWidget; bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI; UBWidgetUniboardAPI* mUniboardAPI;
QPixmap mSnapshot; QPixmap mSnapshot;
QPointF mLastMousePos; QPointF mLastMousePos;
QUrl ownFolder; QUrl ownFolder;
QUrl SnapshotFile; QUrl SnapshotFile;
static bool sInlineJavaScriptLoaded; static bool sInlineJavaScriptLoaded;
static QStringList sInlineJavaScripts; static QStringList sInlineJavaScripts;
}; };
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
...@@ -185,11 +182,11 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem ...@@ -185,11 +182,11 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
public: public:
UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0); UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsAppleWidgetItem(); ~UBGraphicsAppleWidgetItem();
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
}; };
class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
...@@ -205,7 +202,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem ...@@ -205,7 +202,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
{ {
/* NOOP */ /* NOOP */
} }
PreferenceValue(const QString& pValue, bool pReadonly) PreferenceValue(const QString& pValue, bool pReadonly)
{ {
...@@ -230,13 +227,13 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem ...@@ -230,13 +227,13 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
}; };
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0); UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsW3CWidgetItem(); ~UBGraphicsW3CWidgetItem();
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
QMap<QString, PreferenceValue> preferences(); QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const; Metadata metadatas() const;
static QString freezedWidgetFilePath(); static QString freezedWidgetFilePath();
static QString createNPAPIWrapper(const QString& url, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString()); static QString createNPAPIWrapper(const QString& url, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString());
...@@ -255,11 +252,11 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem ...@@ -255,11 +252,11 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale); static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
UBW3CWidgetAPI* mW3CWidgetAPI; UBW3CWidgetAPI* mW3CWidgetAPI;
QMap<QString, PreferenceValue> mPreferences; QMap<QString, PreferenceValue> mPreferences;
static bool sTemplateLoaded; static bool sTemplateLoaded;
static QString sNPAPIWrappperConfigTemplate; static QString sNPAPIWrappperConfigTemplate;
static QMap<QString, QString> sNPAPIWrapperTemplates; static QMap<QString, QString> sNPAPIWrapperTemplates;
}; };
#endif // UBGRAPHICSWIDGETITEM_H #endif // UBGRAPHICSWIDGETITEM_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment