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 some small issues in the glyph palette.

Wolthera van Hövell tot Westerflierfaade9cf4445
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
index 87dd4ec19e..7059186d78 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml
@@ -21,8 +21,8 @@ SvgTextLabel {
property bool currentItem: GridView.isCurrentItem;
- signal glyphClicked(int index, int posX, int posY);
- signal glyphDoubleClicked(int index, int posX, int posY);
+ signal glyphClicked(int index, QtObject mouse);
+ signal glyphDoubleClicked(int index, QtObject mouse);
Rectangle {
anchors.fill: parent;
@@ -34,7 +34,7 @@ SvgTextLabel {
anchors.top: parent.top;
anchors.left: parent.left;
color: sysPalette.text;
- opacity: 0.3;
+ opacity: 0.6;
layer.enabled: true
width: childrenRect.width;
height: childrenRect.height;
@@ -60,13 +60,13 @@ SvgTextLabel {
MouseArea {
anchors.fill: parent;
id: glyphMouseArea
- onClicked: {
+ onClicked: (mouse)=>{
parent.GridView.view.currentIndex = index;
- glyphClicked(index, mouseX, mouseY);
+ glyphClicked(index, mouse);
}
- onDoubleClicked: {
+ onDoubleClicked: (mouse)=>{
parent.GridView.view.currentIndex = index;
- glyphDoubleClicked(index, mouseX, mouseY);
+ glyphDoubleClicked(index, mouse);
}
hoverEnabled: true;
ToolTip.text: model.toolTip;
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
index a5b0d7053d..d75a40f2fe 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml
@@ -139,8 +139,10 @@ Rectangle {
fontSize: root.fontSize;
fontStyle: root.fontStyle;
fontWeight: root.fontWeight;
- onGlyphDoubleClicked: (index, posX, posY)=> {mainWindow.slotInsertRichText(index)};
- onGlyphClicked: (index, posX, posY)=> {
+ onGlyphDoubleClicked: (index, mouse)=> {
+ mainWindow.slotInsertRichText(index)
+ };
+ onGlyphClicked: (index, mouse)=> {
if (model.childCount > 1){
var entryPos = mapToItem(root, 0+width, 0);
mainWindow.slotShowPopupPalette(index, entryPos.x, entryPos.y, width, height)
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml
index 7b35671ffc..9073234be5 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml
@@ -44,12 +44,12 @@ Rectangle {
fontSize: root.fontSize;
fontStyle: root.fontStyle;
fontWeight: root.fontWeight;
- onGlyphClicked: (index, posX, posY)=> {
+ onGlyphClicked: (index, mouse)=> {
if (!root.replace) {
mainWindow.slotInsertRichText(root.parentIndex, index, root.replace)
}
};
- onGlyphDoubleClicked: (index, posX, posY)=> {mainWindow.slotInsertRichText(root.parentIndex, index, root.replace)};
+ onGlyphDoubleClicked: (index, mouse)=> {mainWindow.slotInsertRichText(root.parentIndex, index, root.replace)};
}
}
focus: true;
diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
index 3279530773..44ba490b48 100644
--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp
@@ -75,11 +75,12 @@ GlyphPaletteDialog::~GlyphPaletteDialog()
void GlyphPaletteDialog::setGlyphModelFromProperties(const QPair<KoSvgTextProperties, KoSvgTextProperties> &properties, const QString &text)
{
- if (m_lastUsedProperties.property(KoSvgTextProperties::FontFamiliesId) == properties.second.property(KoSvgTextProperties::FontFamiliesId)
- && m_lastUsedProperties.property(KoSvgTextProperties::FontWeightId) == properties.second.property(KoSvgTextProperties::FontWeightId)
- && m_lastUsedProperties.property(KoSvgTextProperties::FontStyleId) == properties.second.property(KoSvgTextProperties::FontStyleId)
- && m_lastUsedProperties.property(KoSvgTextProperties::FontStretchId) == properties.second.property(KoSvgTextProperties::FontStretchId)) {
+ if (m_lastUsedProperties.property(KoSvgTextProperties::FontFamiliesId) == properties.first.property(KoSvgTextProperties::FontFamiliesId)
+ && m_lastUsedProperties.property(KoSvgTextProperties::FontWeightId) == properties.first.property(KoSvgTextProperties::FontWeightId)
+ && m_lastUsedProperties.property(KoSvgTextProperties::FontStyleId) == properties.first.property(KoSvgTextProperties::FontStyleId)
+ && m_lastUsedProperties.property(KoSvgTextProperties::FontStretchId) == properties.first.property(KoSvgTextProperties::FontStretchId)) {
if (m_model && m_model->rowCount() > 0) {
+ if (text.isEmpty()) return;
QModelIndex idx = m_model->indexForString(text);
if (idx.isValid() && m_quickWidget->rootObject()) {
m_quickWidget->rootObject()->setProperty("currentIndex", QVariant::fromValue(idx.row()));
@@ -136,26 +137,32 @@ void GlyphPaletteDialog::slotInsertRichText(const int charRow, const int glyphRo
{
if (m_quickWidget->rootObject()) {
QModelIndex idx = replace? m_model->index(charRow, 0): m_charMapModel->index(charRow, 0);
- QString text;
+ QString text = idx.isValid()? m_model->data(idx, Qt::DisplayRole).toString(): QString();
KoSvgTextProperties props = m_lastUsedProperties;
QStringList otf;
- if (replace) {
- idx = m_model->index(glyphRow, 0, idx);
- text = m_model->data(idx, Qt::DisplayRole).toString();
- otf.append(m_model->data(idx, KoFontGlyphModel::OpenTypeFeatures).value<QStringList>());
- } else {
- idx = m_charMapModel->index(glyphRow, 0, idx);
- text = m_charMapModel->data(idx, Qt::DisplayRole).toString();
- otf.append(m_charMapModel->data(idx, KoFontGlyphModel::OpenTypeFeatures).value<QStringList>());
- }
- KoSvgTextShape *richText = new KoSvgTextShape();
- if (!otf.isEmpty()) {
- props.setProperty(KoSvgTextProperties::FontFeatureSettingsId, otf);
+
+ if (glyphRow > -1) {
+ if (replace) {
+ idx = m_model->index(glyphRow, 0, idx);
+ text = m_model->data(idx, Qt::DisplayRole).toString();
+ otf.append(m_model->data(idx, KoFontGlyphModel::OpenTypeFeatures).value<QStringList>());
+ } else {
+ idx = m_charMapModel->index(glyphRow, 0, idx);
+ text = m_charMapModel->data(idx, Qt::DisplayRole).toString();
+ otf.append(m_charMapModel->data(idx, KoFontGlyphModel::OpenTypeFeatures).value<QStringList>());
+ }
}
- richText->setPropertiesAtPos(-1, props);
- richText->insertText(0, text);
- emit signalInsertRichText(richText, replace);
+ if (!text.isEmpty()) {
+ KoSvgTextShape *richText = new KoSvgTextShape();
+ if (!otf.isEmpty()) {
+ props.setProperty(KoSvgTextProperties::FontFeatureSettingsId, otf);
+ }
+
+ richText->setPropertiesAtPos(-1, props);
+ richText->insertText(0, text);
+ emit signalInsertRichText(richText, replace);
+ }
if (m_altPopup->isVisible()) {
slotHidePopupPalette();
}