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
UBGraphicsScene::~UBGraphicsScene()
{
if (mCurrentStroke)
if (mCurrentStroke->polygons().empty())
{
delete mCurrentStroke;
mCurrentStroke = NULL;
}
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
if (mZLayerController)
delete mZLayerController;
......@@ -437,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
}
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
delete mCurrentStroke;
mCurrentStroke = NULL;
}
......@@ -800,7 +798,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
}
else if (eraserPath.intersects(itemPainterPath))
{
{
QPainterPath newPath = itemPainterPath.subtracted(eraserPath);
#pragma omp critical
......@@ -820,7 +818,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
else
{
UBGraphicsPolygonItem *pi = intersectedItems[i];
for(int j = 0; j < intersectedPolygons[i].size(); j++)
{
QPolygonF p = intersectedPolygons[i][j];
......@@ -2295,7 +2293,7 @@ void UBGraphicsScene::createPointer()
void UBGraphicsScene::setToolCursor(int tool)
{
if (tool == (int)UBStylusTool::Selector ||
tool == (int)UBStylusTool::Text ||
tool == (int)UBStylusTool::Text ||
tool == (int)UBStylusTool::Play)
{
deselectAllItems();
......@@ -2310,5 +2308,5 @@ void UBGraphicsScene::setToolCursor(int tool)
void UBGraphicsScene::initStroke()
{
mCurrentStroke = new UBGraphicsStroke();
mCurrentStroke = new UBGraphicsStroke();
}
......@@ -48,7 +48,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
: QGraphicsWebView(parent)
, mInitialLoadDone(false)
, mIsFreezable(true)
, mIsResizable(false)
, mIsResizable(false)
, mLoadIsErronous(false)
, mCanBeContent(0)
, mCanBeTool(0)
......@@ -56,7 +56,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
, mIsFrozen(false)
, mIsTakingSnapshot(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
......@@ -119,7 +119,8 @@ void UBGraphicsWidgetItem::initialize()
void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url)
{
UBApplication::webController->loadUrl(url);
//UBApplication::webController->loadUrl(url);
load(url);
}
void UBGraphicsWidgetItem::initialLayoutCompleted()
......@@ -147,24 +148,6 @@ QString UBGraphicsWidgetItem::mainHtmlFileName()
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()
{
// if we under MAC OS
......@@ -324,18 +307,18 @@ bool UBGraphicsWidgetItem::hasLoadedSuccessfully() const
return (mInitialLoadDone && !mLoadIsErronous);
}
bool UBGraphicsWidgetItem::freezable()
{
bool UBGraphicsWidgetItem::freezable()
{
return mIsFreezable;
}
bool UBGraphicsWidgetItem::resizable()
{
{
return mIsResizable;
}
}
bool UBGraphicsWidgetItem::isFrozen()
{
{
return mIsFrozen;
}
......@@ -351,7 +334,7 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot()
QPixmap pixmap(size().toSize());
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QStyleOptionGraphicsItem options;
paint(&painter, &options);
......@@ -497,7 +480,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event)
event->accept();
return true;
}
}
}
else if (event->type() == QEvent::ShortcutOverride)
event->accept();
......@@ -813,7 +796,7 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
if (roles.contains("tmac"))
mCanBeTool |= UBGraphicsWidgetItem::type_MAC;
if (roles.contains("tunix"))
mCanBeTool |= UBGraphicsWidgetItem::type_UNIX;
......@@ -886,9 +869,6 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
/* is it a valid local file ? */
QFile f(mMainHtmlUrl.toLocalFile());
qDebug() << mMainHtmlFileName;
qDebug() << mMainHtmlUrl.toLocalFile();
if(!f.exists())
mMainHtmlUrl = QUrl(mMainHtmlFileName);
......@@ -1108,11 +1088,11 @@ QString UBGraphicsW3CWidgetItem::freezedWidgetPage()
if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath;
defaultcontent = "";
}
}
else {
QByteArray arr = wrapperFile.readAll();
if (!arr.isEmpty())
defaultcontent = QString(arr);
defaultcontent = QString(arr);
else {
qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty";
defaultcontent = QString();
......
......@@ -62,14 +62,11 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
QUrl widgetUrl();
QString mainHtmlFileName();
bool hasEmbededObjects();
bool hasEmbededFlash();
bool canBeContent();
bool canBeTool();
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;
void removePreference(const QString& key);
void removeAllPreferences();
......@@ -94,7 +91,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual void setUuid(const QUuid &pUuid);
QSize nominalSize() const;
QSize nominalSize() const;
bool hasLoadedSuccessfully() const;
......@@ -110,7 +107,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual UBGraphicsScene* scene();
static int widgetType(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
static QString iconFilePath(const QUrl& pUrl);
public slots:
......@@ -127,7 +124,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
type_ALL = 7, // 0111
};
bool mFirstReleaseAfterMove;
bool mFirstReleaseAfterMove;
bool mInitialLoadDone;
bool mIsFreezable;
bool mIsResizable;
......@@ -137,7 +134,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
int mCanBeTool;
QSize mNominalSize;
QString mMainHtmlFileName;
QUrl mMainHtmlUrl;
QUrl mMainHtmlUrl;
QUrl mWidgetUrl;
QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences;
......@@ -162,21 +159,21 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
void mainFrameLoadFinished(bool ok);
private slots:
void onLinkClicked(const QUrl& url);
void onLinkClicked(const QUrl& url);
void initialLayoutCompleted();
private:
bool mIsFrozen;
bool mIsTakingSnapshot;
bool mShouldMoveWidget;
bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI;
QPixmap mSnapshot;
QPointF mLastMousePos;
QUrl ownFolder;
QUrl SnapshotFile;
QUrl SnapshotFile;
static bool sInlineJavaScriptLoaded;
static QStringList sInlineJavaScripts;
static QStringList sInlineJavaScripts;
};
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
......@@ -185,11 +182,11 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
public:
UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsAppleWidgetItem();
~UBGraphicsAppleWidgetItem();
virtual void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const;
virtual UBItem* deepCopy() const;
};
class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
......@@ -205,7 +202,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
{
/* NOOP */
}
PreferenceValue(const QString& pValue, bool pReadonly)
{
......@@ -230,13 +227,13 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
};
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsW3CWidgetItem();
~UBGraphicsW3CWidgetItem();
virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const;
Metadata metadatas() const;
static QString freezedWidgetFilePath();
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
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
UBW3CWidgetAPI* mW3CWidgetAPI;
QMap<QString, PreferenceValue> mPreferences;
QMap<QString, PreferenceValue> mPreferences;
static bool sTemplateLoaded;
static QString sNPAPIWrappperConfigTemplate;
static QMap<QString, QString> sNPAPIWrapperTemplates;
static QMap<QString, QString> sNPAPIWrapperTemplates;
};
#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