From 13163fef304b9a7c70e1961703ec1826c9b42d52 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Mon, 20 Aug 2012 11:47:55 +0300 Subject: [PATCH 1/3] Frame size doesn't depends on zoom. --- src/domain/UBGraphicsItemDelegate.cpp | 7 +++++++ src/domain/UBGraphicsItemDelegate.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index f26d5ed1..962121a9 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -115,6 +115,7 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec , mToolBarUsed(useToolBar) { // NOOP + connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); } void UBGraphicsItemDelegate::init() @@ -535,6 +536,12 @@ void UBGraphicsItemDelegate::commitUndoStep() } } +void UBGraphicsItemDelegate::onZoomChanged() +{ + mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); + + positionHandles(); +} void UBGraphicsItemDelegate::buildButtons() { diff --git a/src/domain/UBGraphicsItemDelegate.h b/src/domain/UBGraphicsItemDelegate.h index c45fd8be..fc5c460c 100644 --- a/src/domain/UBGraphicsItemDelegate.h +++ b/src/domain/UBGraphicsItemDelegate.h @@ -259,6 +259,8 @@ class UBGraphicsItemDelegate : public QObject void increaseZlevelTop(); void increaseZlevelBottom(); + void onZoomChanged(); + protected: virtual void buildButtons(); virtual void decorateMenu(QMenu *menu); From 61626ecd285dcca42a57cd8ee572ad1cdab0b374 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Mon, 20 Aug 2012 13:22:40 +0300 Subject: [PATCH 2/3] Improved compatibility with Sankore 1.30 text format. Improved performance of loading text from old format. --- src/adaptors/UBSvgSubsetAdaptor.cpp | 6 ++++++ src/domain/UBGraphicsTextItemDelegate.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index e40e164d..370b3240 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -2769,6 +2769,12 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() } } + QTextCursor curCursor = textItem->textCursor(); + QTextCharFormat format; + + format.setFont(font); + curCursor.mergeCharFormat(format); + textItem->setTextCursor(curCursor); textItem->setFont(font); QStringRef fill = mXmlReader.attributes().value("color"); diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 3ab8f973..30ef6f3a 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -322,6 +322,12 @@ void UBGraphicsTextItemDelegate::positionHandles() void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode changeMode) { + if (scaleSize == changeMode) + { + if (1 == factor) + return; + } + else if (0 == factor) return; From 9a5cc5b8d2129f0f54846fdc65baec744f0797a4 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Mon, 20 Aug 2012 13:32:52 +0300 Subject: [PATCH 3/3] SANKORE-909 Write text : Select the text --- src/domain/UBGraphicsTextItemDelegate.cpp | 17 +++++++++++++++++ src/domain/UBGraphicsTextItemDelegate.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 3ab8f973..03efa958 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -403,3 +403,20 @@ void UBGraphicsTextItemDelegate::scaleTextSize(qreal multiplyer) { ChangeTextSize(multiplyer, scaleSize); } + +QVariant UBGraphicsTextItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (delegated()->isSelected()) + { + QTextCursor c = delegated()->textCursor(); + if (c.hasSelection()) + { + c.clearSelection(); + delegated()->setTextCursor(c); + } + } + } + return UBGraphicsItemDelegate::itemChange(change, value); +} \ No newline at end of file diff --git a/src/domain/UBGraphicsTextItemDelegate.h b/src/domain/UBGraphicsTextItemDelegate.h index b01df4e2..26b3ba9b 100644 --- a/src/domain/UBGraphicsTextItemDelegate.h +++ b/src/domain/UBGraphicsTextItemDelegate.h @@ -40,6 +40,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate virtual ~UBGraphicsTextItemDelegate(); bool isEditable(); void scaleTextSize(qreal multiplyer); + virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); + public slots: void contentsChanged();