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 the look and feel.

Wolthera van Hövell tot Westerflierb68e3f456569
diff --git a/libs/flake/text/KoFontGlyphModel.cpp b/libs/flake/text/KoFontGlyphModel.cpp
index 7f15168343..9682aaa3b9 100644
--- a/libs/flake/text/KoFontGlyphModel.cpp
+++ b/libs/flake/text/KoFontGlyphModel.cpp
@@ -89,7 +89,7 @@ struct KoFontGlyphModel::Private {
while(hb_set_next(unicodes.data(), &hbCodePointPoint)) {
QVector<GlyphInfo> glyphs = vsData.value(hbCodePointPoint);
GlyphInfo gci(hbCodePointPoint);
- gci.type = UnicodeVaritionSelector;
+ gci.type = UnicodeVariationSelector;
gci.baseString = QString::fromUcs4(&hbVSPoint, 1);
glyphs.append(gci);
vsData.insert(hbCodePointPoint, glyphs);
@@ -206,7 +206,7 @@ QVariant KoFontGlyphModel::data(const QModelIndex &index, int role) const
Private::CodePointInfo codePoint = d->codePoints.value(index.parent().row());
Private::GlyphInfo glyph = codePoint.glyphs.value(index.row());
//qDebug () << index.parent().row() << index.row() << codePoint.utfString << codePoint.ucs;
- if (glyph.type == UnicodeVaritionSelector) {
+ if (glyph.type == UnicodeVariationSelector) {
return QString(codePoint.utfString + glyph.baseString);
} else {
return codePoint.utfString;
@@ -219,7 +219,7 @@ QVariant KoFontGlyphModel::data(const QModelIndex &index, int role) const
QVector<Private::GlyphInfo> glyphList = d->codePoints.value(index.row()).glyphs;
glyphNames.append(QString("%1 glyph variants:").arg(glyphList.size()));
for(auto glyph = glyphList.begin(); glyph != glyphList.end(); glyph++) {
- if (glyph->type == UnicodeVaritionSelector) {
+ if (glyph->type == UnicodeVariationSelector) {
glyphNames.append("UVS:"+base+glyph->baseString);
} else if (glyph->type == OpenType) {
glyphNames.append("OTF:"+glyph->baseString+" "+QString::number(glyph->layoutIndex));
@@ -247,6 +247,34 @@ QVariant KoFontGlyphModel::data(const QModelIndex &index, int role) const
}
return features;
+ } else if (role == GlyphLabel) {
+ QString glyphId;
+ if (!index.parent().isValid()) {
+ Private::CodePointInfo codePoint = d->codePoints.value(index.row());
+ QByteArray ba;
+ ba.setNum(codePoint.ucs, 16);
+ QString hex = QString(ba);
+ glyphId = QString("U+%1").arg(hex, hex.size() > 4? 6: 4, '0');
+ } else {
+ Private::CodePointInfo codePoint = d->codePoints.value(index.parent().row());
+ Private::GlyphInfo glyph = codePoint.glyphs.value(index.row());
+ if (glyph.type == OpenType) {
+ glyphId = glyph.baseString;
+ } else if (glyph.type == UnicodeVariationSelector) {
+ QByteArray ba;
+ ba.setNum(glyph.baseString.toUcs4().first(), 16);
+ QString hex = QString(ba);
+ glyphId = QString("U+%1").arg(hex, hex.size() > 4? 6: 4, '0');
+ }
+ }
+ return glyphId;
+ } else if (role == ChildCount) {
+ int childCount = 0;
+ if (!index.parent().isValid()) {
+ Private::CodePointInfo codePoint = d->codePoints.value(index.row());
+ childCount = codePoint.childCount();
+ }
+ return childCount;
}
return QVariant();
}
@@ -340,5 +368,7 @@ QHash<int, QByteArray> KoFontGlyphModel::roleNames() const
{
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
roles[OpenTypeFeatures] = "openType";
+ roles[GlyphLabel] = "glyphLabel";
+ roles[ChildCount] = "childCount";
return roles;
}
diff --git a/libs/flake/text/KoFontGlyphModel.h b/libs/flake/text/KoFontGlyphModel.h
index d976341427..624595c894 100644
--- a/libs/flake/text/KoFontGlyphModel.h
+++ b/libs/flake/text/KoFontGlyphModel.h
@@ -24,7 +24,7 @@ class KRITAFLAKE_EXPORT KoFontGlyphModel: public QAbstractItemModel
public:
enum GlyphType {
Base,
- UnicodeVaritionSelector,
+ UnicodeVariationSelector,
OpenType
};
@@ -32,7 +32,9 @@ public:
~KoFontGlyphModel();
enum Roles {
- OpenTypeFeatures = Qt::UserRole + 1
+ OpenTypeFeatures = Qt::UserRole + 1,
+ GlyphLabel,
+ ChildCount
};
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index 356b2bef96..dbc93e884a 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -541,8 +541,9 @@ QPainterPath KoSvgTextShape::selectionBoxes(int pos, int anchor)
{
int start = qMin(pos, anchor);
int end = qMax(pos, anchor);
+ end = qMin(d->cursorPos.size()-1, end);
- if (start == end || start < 0 || end >= d->cursorPos.size()) {
+ if (start == end || start < 0) {
return QPainterPath();
}
diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cpp
index f14392fe2d..5cd394dca2 100644
--- a/plugins/tools/svgtexttool/SvgTextTool.cpp
+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp
@@ -105,6 +105,9 @@ SvgTextTool::~SvgTextTool()
if(m_editor) {
m_editor->close();
}
+ if(m_glyphPalette) {
+ m_glyphPalette->close();
+ }
delete m_defAlignment;
}
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
index 1731317984..d41c045ad5 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
@@ -52,7 +52,7 @@ Rectangle {
Component {
id: glyphDelegate;
SvgTextLabel {
- textColor: palette.windowText;
+ textColor: palette.text;
fillColor: palette.base;
fontFamilies: root.fontFamilies;
fontSize: root.fontSize;
@@ -61,6 +61,7 @@ Rectangle {
openTypeFeatures: model.openType;
text: model.display;
padding: height/8;
+ clip: true;
width: charMap.cellWidth;
height: charMap.cellHeight;
@@ -70,16 +71,46 @@ Rectangle {
anchors.fill: parent;
color: "transparent";
border.color: parent.currentItem? palette.highlight: palette.alternateBase;
+ border.width: parent.currentItem? 2: 1;
+ }
+ Rectangle {
+ anchors.top: parent.top;
+ anchors.left: parent.left;
+ color: palette.text;
+ opacity: 0.3;
+ layer.enabled: true
+ width: childrenRect.width;
+ height: childrenRect.height;
+ Text {
+ padding: 2;
+ text: model.glyphLabel;
+ color: palette.base;
+ font.pointSize: 9;
+ }
+ visible: glyphMouseArea.containsMouse;
}
+ Rectangle {
+ anchors.top: parent.top;
+ anchors.right: parent.right;
+ width: 8;
+ height: 8;
+ radius: 4;
+ color: palette.text;
+ opacity: 0.3;
+ visible: model.childCount > 1;
+ }
+
MouseArea {
anchors.fill: parent;
+ id: glyphMouseArea
onClicked: {
- //parent.currentIndex = index;
+ parent.GridView.view.currentIndex = index;
console.log(model.toolTip)
}
hoverEnabled: true;
ToolTip.text: model.toolTip;
ToolTip.visible: containsMouse;
+ ToolTip.delay: 1000;
}
}
}
@@ -99,11 +130,10 @@ Rectangle {
id: glyphAltModel
model: root.model
property alias rIndex: root.currentIndex;
+ property var defaultIndex: modelIndex(-1);
onRIndexChanged: {
- console.log("start");
- rootIndex = parentModelIndex()
+ rootIndex = defaultIndex;
rootIndex = modelIndex(root.currentIndex);
- console.log(rootIndex , root.currentIndex);
}
delegate: glyphDelegate;
diff --git a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp b/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
index 49d2a8336c..9b814a5306 100644
--- a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
+++ b/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp
@@ -34,11 +34,15 @@ void SvgTextLabel::paint(QPainter *painter)
{
painter->save();
painter->fillRect(0, 0, width(), height(), fillColor());
- qreal scale = (height()- d->padding*2) / fontSize();
+
+ QRectF bbox = d->shape->selectionBoxes(0, d->shape->posForIndex(d->shape->plainText().size())).boundingRect();
+ qreal boxHeight = bbox.isEmpty()? fontSize(): bbox.height();
+ bbox = bbox.isEmpty()? d->shape->boundingRect(): bbox;
+ qreal scale = (height()- d->padding*2) / boxHeight;
painter->translate(boundingRect().center());
painter->scale(scale, scale);
- painter->translate(-d->shape->boundingRect().center());
+ painter->translate(-bbox.center());
painter->setClipRect(painter->transform().inverted().mapRect(this->boundingRect()));