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++

Improve look of the font family selector.

Wolthera van Hövell tot Westerflier6cb920d6c73e
diff --git a/libs/flake/resources/KoFontFamily.cpp b/libs/flake/resources/KoFontFamily.cpp
index 31d0c6ae6c..aac96ceef9 100644
--- a/libs/flake/resources/KoFontFamily.cpp
+++ b/libs/flake/resources/KoFontFamily.cpp
@@ -17,11 +17,12 @@ const QString LOCALIZED_TYPOGRAPHIC_STYLE = "localized_typographic_style";
const QString LOCALIZED_FONT_FAMILY = "localized_font_family";
const QString AXES = "axes";
const QString STYLES = "styles";
+const QString FONT_TYPE = "font_type";
const QString IS_VARIABLE = "is_variable";
const QString COLOR_BITMAP = "color_bitmap";
const QString COLOR_CLRV0 = "color_clrv0";
const QString COLOR_CLRV1 = "color_clrv1";
-const QString COLOR_SVG = "color_SVG";
+const QString COLOR_SVG = "color_svg";
const QString SAMPLE_STRING = "sample_string";
const QString SAMPLE_SVG = "sample_svg";
@@ -103,6 +104,7 @@ KoFontFamily::KoFontFamily(KoFontFamilyWWSRepresentation representation)
}
addMetaData(SAMPLE_STRING, samples);
+ addMetaData(FONT_TYPE, representation.type);
addMetaData(IS_VARIABLE, representation.isVariable);
addMetaData(COLOR_BITMAP, representation.colorBitMap);
addMetaData(COLOR_CLRV0, representation.colorClrV0);
diff --git a/libs/flake/text/KoFFWWSConverter.cpp b/libs/flake/text/KoFFWWSConverter.cpp
index 9d8d6f8c86..623178a280 100644
--- a/libs/flake/text/KoFFWWSConverter.cpp
+++ b/libs/flake/text/KoFFWWSConverter.cpp
@@ -110,6 +110,7 @@ struct FontFamilyNode {
wwsFamily.colorSVG = child.colorSVG;
wwsFamily.colorClrV0 = child.colorClrV0;
wwsFamily.colorClrV1 = child.colorClrV1;
+ wwsFamily.type = child.type;
return wwsFamily;
}
@@ -790,6 +791,7 @@ KoFontFamilyWWSRepresentation createRepresentation(KisForest<FontFamilyNode>::ch
representation.colorClrV0 = wws->colorClrV0;
representation.colorClrV1 = wws->colorClrV1;
representation.colorSVG = wws->colorSVG;
+ representation.type = wws->type;
for (auto subFamily = childBegin(wws); subFamily != childEnd(wws); subFamily++) {
KoSvgText::FontFamilyStyleInfo style;
diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
index dd9aa50c64..1b05d860b1 100644
--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
@@ -16,6 +16,9 @@ struct KoShapeQtQuickLabel::Private {
QString svgData;
int imagePadding = 5;
qreal imageScale = 1;
+ bool fullColor = false;
+
+ bool firstPaint = false;
};
KoShapeQtQuickLabel::KoShapeQtQuickLabel(QQuickItem *parent)
@@ -32,6 +35,10 @@ KoShapeQtQuickLabel::~KoShapeQtQuickLabel()
void KoShapeQtQuickLabel::paint(QPainter *painter)
{
if (!painter->isActive()) return;
+ if (!d->firstPaint) {
+ updateShapes();
+ d->firstPaint = true;
+ }
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->fillRect(0, 0, width(), height(), fillColor());
@@ -54,7 +61,10 @@ void KoShapeQtQuickLabel::paint(QPainter *painter)
painter->setPen(Qt::transparent);
Q_FOREACH(const KoShape *shape, d->shape->shapes()) {
+ painter->save();
+ painter->setTransform(shape->transformation() * painter->transform());
shape->paint(*painter);
+ painter->restore();
}
painter->restore();
@@ -68,6 +78,8 @@ QString KoShapeQtQuickLabel::svgData() const
void KoShapeQtQuickLabel::setSvgData(const QString &newSvgData)
{
+ qreal max = qMax(20.0*imageScale(), qMax(width()-(d->imagePadding*2), height()-(d->imagePadding*2)));
+ setImplicitHeight(max);
if (d->svgData == newSvgData)
return;
d->svgData = newSvgData;
@@ -75,8 +87,7 @@ void KoShapeQtQuickLabel::setSvgData(const QString &newSvgData)
QDomDocument doc = SvgParser::createDocumentFromSvg(d->svgData);
KoDocumentResourceManager resourceManager;
SvgParser p(&resourceManager);
- qreal max = qMax(60.0, qMax(width()-(d->imagePadding*2), height()-(d->imagePadding*2)));
- QRectF bb = QRectF( 0, 0, max, max);
+ QRectF bb = QRectF( 0, 0, 200, 200);
QSizeF sz = bb.size();
p.setResolution(bb, 72);
@@ -86,11 +97,7 @@ void KoShapeQtQuickLabel::setSvgData(const QString &newSvgData)
KoShapeGroupCommand cmd(d->shape, shapes, false);
cmd.redo();
- d->shape->setAbsolutePosition(QPointF(), KoFlake::TopLeft);
- qreal scale = bb.height() / sz.height();
-
- setImplicitHeight(bb.height());
emit svgDataChanged();
}
@@ -147,3 +154,26 @@ void KoShapeQtQuickLabel::setImageScale(qreal newImageScale)
d->imageScale = newImageScale;
emit imageScaleChanged();
}
+
+bool KoShapeQtQuickLabel::fullColor() const
+{
+ return d->fullColor;
+}
+
+void KoShapeQtQuickLabel::setFullColor(bool newFullColor)
+{
+ if (d->fullColor == newFullColor)
+ return;
+ d->fullColor = newFullColor;
+
+ emit fullColorChanged();
+}
+
+void KoShapeQtQuickLabel::updateShapes()
+{
+ if (d->shape) {
+ for (int i = 0; i < d->shape->shapes().size(); i++) {
+ d->shape->shapes().at(i)->setInheritBackground(!d->fullColor);
+ }
+ }
+}
diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.h b/plugins/dockers/textproperties/KoShapeQtQuickLabel.h
index 1d5dcdafa7..17446355ea 100644
--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.h
+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.h
@@ -21,6 +21,7 @@ class KoShapeQtQuickLabel: public QQuickPaintedItem
Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor NOTIFY foregroundColorChanged)
Q_PROPERTY(int imagePadding READ imagePadding WRITE setImagePadding NOTIFY imagePaddingChanged)
Q_PROPERTY(qreal imageScale READ imageScale WRITE setImageScale NOTIFY imageScaleChanged)
+ Q_PROPERTY(bool fullColor READ fullColor WRITE setFullColor NOTIFY fullColorChanged)
public:
KoShapeQtQuickLabel(QQuickItem *parent = nullptr);
~KoShapeQtQuickLabel();
@@ -43,6 +44,9 @@ public:
qreal imageScale() const;
void setImageScale(qreal newImageScale);
+ bool fullColor() const;
+ void setFullColor(bool newFullColor);
+
Q_SIGNALS:
void svgDataChanged();
@@ -54,6 +58,11 @@ Q_SIGNALS:
void imageScaleChanged();
+ void fullColorChanged();
+
+private Q_SLOTS:
+ void updateShapes();
+
private:
struct Private;
const QScopedPointer<Private> d;
diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qml
index 958c12f99e..7788013e4b 100644
--- a/plugins/dockers/textproperties/qml/FontFamily.qml
+++ b/plugins/dockers/textproperties/qml/FontFamily.qml
@@ -66,13 +66,20 @@ CollapsibleGroupProperty {
highlighted: mainFamilyCmb.highlightedIndex === model.index;
contentItem: KoShapeQtQuickLabel{
- Layout.fillWidth: true;
- height: fontResourceView.listWidth/8;
- svgData: model.metadata["sample_svg"]
+ id: fontFamilyDelegate;
+ property bool colorBitmap : model.metadata["color_bitmap"];
+ property bool colorCLRV0 : model.metadata["color_clrv0"];
+ property bool colorCLRV1 : model.metadata["color_clrv1"];
+ property bool colorSVG : model.metadata["color_svg"];
+ property bool isVariable : model.metadata["is_variable"];
+ property int type : model.metadata["font_type"];
+ Layout.fillWidth: true;
+ svgData: model.metadata["sample_svg"];
imageScale: 3;
imagePadding: nameLabel.height;
foregroundColor: sysPalette.text;
+ fullColor: colorBitmap || colorCLRV0 || colorCLRV1 || colorSVG;
Label {
id: nameLabel;
@@ -80,6 +87,53 @@ CollapsibleGroupProperty {
anchors.top: parent.top;
anchors.left: parent.left;
}
+
+ Row {
+ id: featureRow;
+ spacing: columnSpacing;
+ anchors.bottom: parent.bottom;
+ anchors.left: parent.left;
+ property int imgHeight: 12;
+ Image {
+ property int type: fontFamilyDelegate.type;
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ source: type === KoSvgText.BDFFontType? "qrc:///light_select-pixel.svg"
+ : type === KoSvgText.Type1FontType? "qrc:///light_transparency-enabled.svg"
+ : type === KoSvgText.OpenTypeFontType? "qrc:///light_select-shape.svg":"qrc:///light_system-help.svg";
+ }
+ Image {
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ visible: fontFamilyDelegate.isVariable;
+ source: "qrc:///light_zoom-horizontal.svg"
+ }
+
+ Image {
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ visible: fontFamilyDelegate.colorBitmap;
+ source: "qrc:///light_palette-library.svg"
+ }
+ Image {
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ visible: fontFamilyDelegate.colorCLRV0;
+ source: "qrc:///light_color-adjustment-mode-channels.svg"
+ }
+ Image {
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ visible: fontFamilyDelegate.colorCLRV1;
+ source: "qrc:///light_config-color-manage.svg"
+ }
+ Image {
+ width: parent.imgHeight;
+ height: parent.imgHeight;
+ visible: fontFamilyDelegate.colorSVG;
+ source: "qrc:///light_sort-by-hue.svg"
+ }
+ }
}
width: fontResourceView.listWidth;
background: Rectangle { color: highlighted? parent.palette.highlight:"transparent"; }