diff --git a/src/adaptors/UBImportAdaptor.cpp b/src/adaptors/UBImportAdaptor.cpp index b09ba0ff..0770fa39 100644 --- a/src/adaptors/UBImportAdaptor.cpp +++ b/src/adaptors/UBImportAdaptor.cpp @@ -35,7 +35,7 @@ UBImportAdaptor::~UBImportAdaptor() UBDocumentProxy* UBImportAdaptor::importFile(const QFile& pFile, const QString& pGroup) { - QString documentName = QFileInfo(pFile.fileName()).baseName(); + QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); diff --git a/src/adaptors/UBSvgSubsetAdaptor.h b/src/adaptors/UBSvgSubsetAdaptor.h index 2335c3cf..d3dc75fa 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.h +++ b/src/adaptors/UBSvgSubsetAdaptor.h @@ -171,20 +171,15 @@ class UBSvgSubsetAdaptor int pointsCount = crashedPoints.size(); QString svgPoints; - static const int maxBufferLengthPerPoint = 30; - int maxBufferLength = maxBufferLengthPerPoint * pointsCount; - char *buffer = new char[maxBufferLength]; int length = 0; - + QString sBuf; for(int j = 0; j < pointsCount; j++) { - const QPointF & point = crashedPoints.at(j); - int n = sprintf(buffer + length, "%.2f,%.2f ", point.x(), point.y()); - length += n; + const QPointF & point = crashedPoints.at(j); + sBuf.sprintf("%.2f,%.2f ", point.x(), point.y()); + svgPoints.insert(length, sBuf); + length += sBuf.length(); } - - svgPoints = QString::fromAscii(buffer, length); - delete buffer; return svgPoints; } diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 0793d2a3..8eed4e4e 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -855,8 +855,8 @@ QString UBSettings::userFavoriteListFilePath() static QString filePath = ""; if(filePath.isEmpty()){ QString dirPath = userDataDirectory() + "/libraryPalette"; - filePath = dirPath + "/favorite.dat"; checkDirectory(dirPath); + filePath = dirPath + "/favorite.dat"; } return filePath; } @@ -865,7 +865,7 @@ QString UBSettings::userTrashDirPath() { static QString trashPath = ""; if(trashPath.isEmpty()){ - QString trashPath = userDataDirectory() + "/libraryPalette/trash"; + trashPath = userDataDirectory() + "/libraryPalette/trash"; checkDirectory(trashPath); } return trashPath; @@ -878,12 +878,10 @@ QString UBSettings::applicationShapeLibraryDirectory() QString configPath = value("Library/ShapeDirectory", QVariant(defaultRelativePath)).toString(); - if (configPath.startsWith(".")) - { + if (configPath.startsWith(".")) { return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); } - else - { + else { return configPath; } } @@ -914,12 +912,10 @@ QString UBSettings::applicationImageLibraryDirectory() QString configPath = value("Library/ImageDirectory", QVariant(defaultRelativePath)).toString(); - if (configPath.startsWith(".")) - { + if (configPath.startsWith(".")) { return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); } - else - { + else { return configPath; } } @@ -959,12 +955,10 @@ QString UBSettings::applicationInteractivesDirectory() QString configPath = value("Library/InteractivitiesDirectory", QVariant(defaultRelativePath)).toString(); - if (configPath.startsWith(".")) - { + if (configPath.startsWith(".")) { return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); } - else - { + else { return configPath; } } @@ -975,12 +969,10 @@ QString UBSettings::applicationApplicationsLibraryDirectory() QString configPath = value("Library/ApplicationsDirectory", QVariant(defaultRelativePath)).toString(); - if (configPath.startsWith(".")) - { + if (configPath.startsWith(".")) { return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); } - else - { + else { return configPath; } } @@ -1132,6 +1124,9 @@ QString UBSettings::replaceWildcard(QString& path) else if(result.startsWith("{Home}")) { result = result.replace("{Home}", QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); } + else if(result.startsWith("{Desktop}")) { + result = result.replace("{Desktop}", QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); + } if(result.contains("{UserLoginName}") && UBPlatformUtils::osUserLoginName().length() > 0) { result = result.replace("{UserLoginName}", UBPlatformUtils::osUserLoginName()); diff --git a/src/domain/UBGraphicsProxyWidget.cpp b/src/domain/UBGraphicsProxyWidget.cpp index 48242b99..5c811784 100644 --- a/src/domain/UBGraphicsProxyWidget.cpp +++ b/src/domain/UBGraphicsProxyWidget.cpp @@ -111,6 +111,16 @@ void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) } } +void UBGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event) +// NOOP +} +void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event) +// NOOP +} void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate) { diff --git a/src/domain/UBGraphicsProxyWidget.h b/src/domain/UBGraphicsProxyWidget.h index 6faecb06..ae1e9692 100644 --- a/src/domain/UBGraphicsProxyWidget.h +++ b/src/domain/UBGraphicsProxyWidget.h @@ -51,6 +51,8 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public 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); diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index aace8aa2..08ac72b1 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -78,6 +78,16 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) UBGraphicsProxyWidget::mouseReleaseEvent(event); } +void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + sendJSEnterEvent(); + UBGraphicsProxyWidget::hoverEnterEvent(event); +} +void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + sendJSLeaveEvent(); + UBGraphicsProxyWidget::hoverLeaveEvent(event); +} bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event) { @@ -247,6 +257,20 @@ void UBGraphicsWidgetItem::removeScript() mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}"); } } +void UBGraphicsWidgetItem::sendJSEnterEvent() +{ + if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame()) + { + mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onenter) { widget.onenter();}"); + } +} +void UBGraphicsWidgetItem::sendJSLeaveEvent() +{ + if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame()) + { + mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onleave) { widget.onleave();}"); + } +} void UBGraphicsWidgetItem::clearSource() { diff --git a/src/domain/UBGraphicsWidgetItem.h b/src/domain/UBGraphicsWidgetItem.h index 26cbb3dc..9eba8d80 100644 --- a/src/domain/UBGraphicsWidgetItem.h +++ b/src/domain/UBGraphicsWidgetItem.h @@ -66,6 +66,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget virtual void remove(); void removeScript(); + QString downloadUrl(const QString &fileUrl, const QString &extention); QString downloadWeb(const QString &fileUrl); void processDropEvent(QDropEvent *event); @@ -77,13 +78,20 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget virtual void clearSource(); + protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + virtual bool eventFilter(QObject *obj, QEvent *event); + virtual void sendJSEnterEvent(); + virtual void sendJSLeaveEvent(); + UBAbstractWidget* mWebKitWidget; QMap mPreferences;