Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix rebase issues, ensure that glyphs are drawn correctly on HiDPI screens.

Wolthera van Hövell tot Westerflier8bffd7a4da57
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
index d0dcbf9fa9..d22a8cc3df 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
@@ -5,7 +5,7 @@
*/
import QtQuick 2.15
import QtQuick.Controls 2.5
-import org.krita.sketch 1.0
+import org.krita.tools.text 1.0
SvgTextLabel {
id: glyphLabel;
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
index b43aaaf500..8f5edca549 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
@@ -155,6 +155,8 @@ Rectangle {
focus: true
padding: 2;
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
+
+ palette: TabBar.palette;
GridView {
anchors.fill: parent;
clip: true;
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
index c18d03e512..ba6473afff 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
@@ -42,6 +42,13 @@ GlyphPaletteDialog::GlyphPaletteDialog(QWidget *parent)
m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
+ /*
+ // Default to fusion style unless the user forces another style
+ if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
+ QQuickStyle::setStyle(QStringLiteral("Fusion"));
+ }
+ */
+
m_quickWidget->setPalette(this->palette());
m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_quickWidget->setSource(QUrl("qrc:/GlyphPalette.qml"));
diff --git a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp b/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
index 9b814a5306..afd6a22020 100644
--- a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
+++ b/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
@@ -9,6 +9,7 @@
#include <KoColorBackground.h>
#include <QPainter>
#include <QImage>
+#include <QQuickWindow>
struct Q_DECL_HIDDEN SvgTextLabel::Private {
KoSvgTextShape* shape{nullptr};
@@ -32,8 +33,13 @@ SvgTextLabel::~SvgTextLabel()
void SvgTextLabel::paint(QPainter *painter)
{
+ if (!painter->isActive()) return;
painter->save();
painter->fillRect(0, 0, width(), height(), fillColor());
+ if (d->shape->boundingRect().isEmpty()) {
+ painter->restore();
+ return;
+ }
QRectF bbox = d->shape->selectionBoxes(0, d->shape->posForIndex(d->shape->plainText().size())).boundingRect();
qreal boxHeight = bbox.isEmpty()? fontSize(): bbox.height();
@@ -44,8 +50,10 @@ void SvgTextLabel::paint(QPainter *painter)
painter->scale(scale, scale);
painter->translate(-bbox.center());
+ qreal pixelRatio = this->window()->effectiveDevicePixelRatio();
+ QRectF scaledBounds = QRectF(0, 0, this->boundingRect().width()*pixelRatio, this->boundingRect().height()*pixelRatio);
- painter->setClipRect(painter->transform().inverted().mapRect(this->boundingRect()));
+ painter->setClipRect(painter->transform().inverted().mapRect(scaledBounds));
painter->setPen(Qt::transparent);
d->shape->paint(*painter);