From 5b063a1f845c930d472a63610fa3e04d723c4c0f Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 19 Jul 2012 16:53:13 +0300 Subject: [PATCH 1/3] Pixmaps with size less than 100px doesn't crashes sankore on mouse click. --- src/domain/UBGraphicsPixmapItem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/domain/UBGraphicsPixmapItem.cpp b/src/domain/UBGraphicsPixmapItem.cpp index 60ce4b2b..2df5c6fc 100644 --- a/src/domain/UBGraphicsPixmapItem.cpp +++ b/src/domain/UBGraphicsPixmapItem.cpp @@ -65,8 +65,9 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) QMimeData* pMime = new QMimeData(); pMime->setImageData(pixmap().toImage()); mDelegate->setMimeData(pMime); - int k = pixmap().width() / 100; - QSize newSize(pixmap().width() / k, pixmap().height() / k); + qreal k = (qreal)pixmap().width() / 100.0; + + QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k)); mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); From a0db7c4a9fc2c677d5cc0cb5cb140a7aee0b7daa Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 19 Jul 2012 16:36:26 +0200 Subject: [PATCH 2/3] fixed issue 777 --- release.win7.vc9.bat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release.win7.vc9.bat b/release.win7.vc9.bat index ef987d89..af1f549b 100644 --- a/release.win7.vc9.bat +++ b/release.win7.vc9.bat @@ -59,6 +59,10 @@ REM echo %LAST_TAG_VERSION% nmake release-install +set CUSTOMIZATIONS=build\win32\release\product\customizations +mkdir %CUSTOMIZATIONS% +xcopy /s resources\customizations %CUSTOMIZATIONS% + set I18n=build\win32\release\product\i18n mkdir %I18n% xcopy /s resources\i18n\*.qm %I18n% From 75ddbf8065e788b962dc8d141871ac99b050e992 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 19 Jul 2012 20:15:36 +0300 Subject: [PATCH 3/3] Undo-redo stack used for background objects. --- src/board/UBBoardController.cpp | 13 +++++++++++++ src/domain/UBGraphicsItemUndoCommand.cpp | 22 ++++++++++++++++++---- src/domain/UBGraphicsScene.cpp | 5 +++++ src/domain/UBGraphicsScene.h | 1 + 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 03597682..7739ae1c 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -855,6 +855,10 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) { + QGraphicsItem *oldBackgroundObject = NULL; + if (isBackground) + oldBackgroundObject = mActiveScene->backgroundObject(); + QString mimeType = pContentTypeHeader; // In some cases "image/jpeg;charset=" is returned by the drag-n-drop. That is @@ -1193,6 +1197,15 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader)); qWarning() << "ignoring mime type" << pContentTypeHeader ; } + + if (isBackground && oldBackgroundObject != mActiveScene->backgroundObject()) + { + if (mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented + UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, oldBackgroundObject, mActiveScene->backgroundObject()); + UBApplication::undoStack->push(uc); + } + + } } diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index 6c7420a0..eada4e0d 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -91,8 +91,15 @@ void UBGraphicsItemUndoCommand::undo() while (itRemoved.hasNext()) { QGraphicsItem* item = itRemoved.next(); - mScene->addItem(item); - UBApplication::boardController->freezeW3CWidget(item, false); + if (item) + { + if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType)) + mScene->setAsBackgroundObject(item); + else + mScene->addItem(item); + + UBApplication::boardController->freezeW3CWidget(item, false); + } } // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint @@ -123,8 +130,15 @@ void UBGraphicsItemUndoCommand::redo() while (itAdded.hasNext()) { QGraphicsItem* item = itAdded.next(); - mScene->addItem(item); - UBApplication::boardController->freezeW3CWidget(item, false); + if (item) + { + if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType)) + mScene->setAsBackgroundObject(item); + else + mScene->addItem(item); + + UBApplication::boardController->freezeW3CWidget(item, false); + } } // force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 39606b0b..90f0a6b2 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1292,6 +1292,11 @@ void UBGraphicsScene::clearBackground() { if(mBackgroundObject){ removeItem(mBackgroundObject); + + if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, mBackgroundObject, NULL); + UBApplication::undoStack->push(uc); + } mBackgroundObject = 0; } update(sceneRect()); diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index fb1b4c3b..b8cdb7b7 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -102,6 +102,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem // tmp stub for divide addings scene objects from undo mechanism implementation void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} + bool isURStackIsEnabled(){ return enableUndoRedoStack;} UBGraphicsScene(UBDocumentProxy *parent); virtual ~UBGraphicsScene();