From 181fd57cc4f79991de60928330b30b115a77c0e8 Mon Sep 17 00:00:00 2001 From: Aleksei German Date: Wed, 18 Nov 2020 16:28:16 +0100 Subject: [PATCH] QmlDesigner: Fix for rotation cursor - Added new icons to icon font - Uses new drawing method for rotation cursor Task: QDS-3131 Change-Id: Ifa8dda2630794694dd262396ca314a9b4e6675ad Reviewed-by: Brook Cronin Reviewed-by: Thomas Hartmann --- .../imports/StudioTheme/InternalConstants.qml | 57 +++++++++--------- .../imports/StudioTheme/icons.ttf | Bin 16112 -> 16092 bytes src/libs/utils/stylehelper.cpp | 52 ++++++++++++++++ src/libs/utils/stylehelper.h | 2 + .../components/componentcore/theme.h | 3 +- .../formeditor/rotationcontroller.cpp | 8 +-- 6 files changed, 89 insertions(+), 33 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml index 28f39d89f31..09aedf94008 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml @@ -107,34 +107,35 @@ QtObject { readonly property string pin: "\u0064" readonly property string plus: "\u0065" readonly property string redo: "\u0066" - readonly property string rotation: "\u0067" - readonly property string search: "\u0068" - readonly property string splitColumns: "\u0069" - readonly property string splitRows: "\u006A" - readonly property string startNode: "\u006B" - readonly property string testIcon: "\u006C" - readonly property string textAlignBottom: "\u006D" - readonly property string textAlignCenter: "\u006E" - readonly property string textAlignLeft: "\u006F" - readonly property string textAlignMiddle: "\u0070" - readonly property string textAlignRight: "\u0071" - readonly property string textAlignTop: "\u0072" - readonly property string textBulletList: "\u0073" - readonly property string textFullJustification: "\u0074" - readonly property string textNumberedList: "\u0075" - readonly property string tickIcon: "\u0076" - readonly property string triState: "\u0077" - readonly property string undo: "\u0078" - readonly property string unpin: "\u0079" - readonly property string upDownIcon: "\u007A" - readonly property string upDownSquare2: "\u007B" - readonly property string visibilityOff: "\u007C" - readonly property string visibilityOn: "\u007D" - readonly property string wildcard: "\u007E" - readonly property string zoomAll: "\u007F" - readonly property string zoomIn: "\u0080" - readonly property string zoomOut: "\u0081" - readonly property string zoomSelection: "\u0082" + readonly property string rotationFill: "\u0067" + readonly property string rotationOutline: "\u0068" + readonly property string search: "\u0069" + readonly property string splitColumns: "\u006A" + readonly property string splitRows: "\u006B" + readonly property string startNode: "\u006C" + readonly property string testIcon: "\u006D" + readonly property string textAlignBottom: "\u006E" + readonly property string textAlignCenter: "\u006F" + readonly property string textAlignLeft: "\u0070" + readonly property string textAlignMiddle: "\u0071" + readonly property string textAlignRight: "\u0072" + readonly property string textAlignTop: "\u0073" + readonly property string textBulletList: "\u0074" + readonly property string textFullJustification: "\u0075" + readonly property string textNumberedList: "\u0076" + readonly property string tickIcon: "\u0077" + readonly property string triState: "\u0078" + readonly property string undo: "\u0079" + readonly property string unpin: "\u007A" + readonly property string upDownIcon: "\u007B" + readonly property string upDownSquare2: "\u007C" + readonly property string visibilityOff: "\u007D" + readonly property string visibilityOn: "\u007E" + readonly property string wildcard: "\u007F" + readonly property string zoomAll: "\u0080" + readonly property string zoomIn: "\u0081" + readonly property string zoomOut: "\u0082" + readonly property string zoomSelection: "\u0083" readonly property font iconFont: Qt.font({ "family": controlIcons.name, diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf index baa995bb5c53ea7799f84cbec5c7e332d32bd56e..f5e80745563d26364d520b9d50c90f287f3cd3f5 100644 GIT binary patch delta 4181 zcmexRd#BcffsuiMftR6yftew|%`L=t@?@?W1_rwW3=9l1{=xc2k?pC{3=E7B3=9kj z$+?LITW+@U7GG`?N10zWPm7M(KMEf-+0SpYxR~Q%=&gCXn6fkUH zSj51+fGEvzTlc-U0feAr6Z zp0S&-x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UGgAd!b6;gaCU#MFb{T6k6NMil8aCPr z3Od$WBBH8x+KQrTnnntO6rX2jNl~5G+EKe zn8h}|mveHsks%AH{F~fuq@u#izy~c%L0Yx2YrSfu4$=DGNFJh9(O5(cR1za=R>H11 z(pVm%x!PD-8)WZa$FRxZvUc6%({^@{@{RAmBlC4;9&qbXkU^Y5i@|L2K4VE+W+ORt zj~Ll8f=YHiMiDWl+kQPq?Rt9bj`sL9gNo`68QnSmZt5_q$AEn*XrjsQ*PCwp*D-X; zy2)W6Yd3qC>}F&(WH6h|W@g7_Xr^musB2_kWH9->S-|9ZW{Vk9Cp(#++RSHhjfIn^ mD8D4JBr`v6Gpp?uMn%T|{~4ITNt1zr;pV4*JRqkdckcmOpZ|UU diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 4b317116c42..e89183d5981 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -623,6 +623,58 @@ QIcon StyleHelper::getIconFromIconFont(const QString &fontName, const QString &i return getIconFromIconFont(fontName, iconSymbol, fontSize, iconSize, penColor); } +QIcon StyleHelper::getCursorFromIconFont(const QString &fontName, const QString &cursorFill, const QString &cursorOutline, + int fontSize, int iconSize) +{ + QFontDatabase a; + + QTC_ASSERT(a.hasFamily(fontName), {}); + + const QColor outlineColor = Qt::black; + const QColor fillColor = Qt::white; + + if (a.hasFamily(fontName)) { + + QIcon icon; + QSize size(iconSize, iconSize); + + const int maxDpr = qRound(qApp->devicePixelRatio()); + for (int dpr = 1; dpr <= maxDpr; dpr++) { + QPixmap pixmap(size * dpr); + pixmap.setDevicePixelRatio(dpr); + pixmap.fill(Qt::transparent); + + QFont font(fontName); + font.setPixelSize(fontSize); + + QPainter painter(&pixmap); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setRenderHint(QPainter::TextAntialiasing, true); + painter.setRenderHint(QPainter::LosslessImageRendering, true); + painter.setRenderHint(QPainter::SmoothPixmapTransform, true); + + painter.setFont(font); + painter.setPen(outlineColor); + painter.drawText(QRectF(QPointF(0.0, 0.0), size), + Qt::AlignCenter, cursorOutline); + + painter.setPen(fillColor); + painter.drawText(QRectF(QPointF(0.0, 0.0), size), + Qt::AlignCenter, cursorFill); + + painter.restore(); + + icon.addPixmap(pixmap); + } + + return icon; + } + + return {}; +} + + QString StyleHelper::dpiSpecificImageFile(const QString &fileName) { // See QIcon::addFile() diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index a1a24a8d5b5..a6549f431a3 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -125,6 +125,8 @@ public: static QIcon getIconFromIconFont(const QString &fontName, const QList ¶meters); static QIcon getIconFromIconFont(const QString &fontName, const QString &iconSymbol, int fontSize, int iconSize, QColor color); static QIcon getIconFromIconFont(const QString &fontName, const QString &iconSymbol, int fontSize, int iconSize); + static QIcon getCursorFromIconFont(const QString &fontname, const QString &cursorFill, const QString &cursorOutline, + int fontSize, int iconSize); static QString dpiSpecificImageFile(const QString &fileName); static QString imageFileWithResolution(const QString &fileName, int dpr); diff --git a/src/plugins/qmldesigner/components/componentcore/theme.h b/src/plugins/qmldesigner/components/componentcore/theme.h index 659162d8005..4db7db24835 100644 --- a/src/plugins/qmldesigner/components/componentcore/theme.h +++ b/src/plugins/qmldesigner/components/componentcore/theme.h @@ -116,7 +116,8 @@ public: pin, plus, redo, - rotation, + rotationFill, + rotationOutline, search, splitColumns, splitRows, diff --git a/src/plugins/qmldesigner/components/formeditor/rotationcontroller.cpp b/src/plugins/qmldesigner/components/formeditor/rotationcontroller.cpp index a1869a5bd94..b0db31ba58f 100644 --- a/src/plugins/qmldesigner/components/formeditor/rotationcontroller.cpp +++ b/src/plugins/qmldesigner/components/formeditor/rotationcontroller.cpp @@ -203,11 +203,11 @@ QCursor RotationController::getRotationCursor() const const QString fontName = "qtds_propertyIconFont.ttf"; const int cursorSize = 32; //32 is cursor recommended size - QIcon rotationIcon = Utils::StyleHelper::getIconFromIconFont( + QIcon rotationIcon = Utils::StyleHelper::getCursorFromIconFont( fontName, - Theme::getIconUnicode(Theme::rotation), - cursorSize, cursorSize, - Qt::white); + Theme::getIconUnicode(Theme::rotationFill), + Theme::getIconUnicode(Theme::rotationOutline), + cursorSize, cursorSize); return QCursor(rotationIcon.pixmap(cursorSize, cursorSize)); }