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 baa995bb5c5..f5e80745563 100644 Binary files a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf and b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf differ 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)); }