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 <brook.cronin@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Aleksei German
2020-11-18 16:28:16 +01:00
parent f38d7910fe
commit 181fd57cc4
6 changed files with 89 additions and 33 deletions

View File

@@ -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,

View File

@@ -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()

View File

@@ -125,6 +125,8 @@ public:
static QIcon getIconFromIconFont(const QString &fontName, const QList<IconFontHelper> &parameters);
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);

View File

@@ -116,7 +116,8 @@ public:
pin,
plus,
redo,
rotation,
rotationFill,
rotationOutline,
search,
splitColumns,
splitRows,

View File

@@ -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));
}