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++
Move SvgTextLabel and DoubleSpinBox to a shared QML module
Halla Rempt66270712d148
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 78dc9b05e8..c18f4b4e4e 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -406,7 +406,7 @@ if (BUILD_WITH_QT6)find_package(ECM 6.0 REQUIRED CONFIG)else()set(QT_MAJOR_VERSION 5)- find_package(ECM 5.90 REQUIRED CONFIG)+ find_package(ECM 5.91 REQUIRED CONFIG)endif()# KDE Frameworks@@ -426,6 +426,7 @@ include(ECMGenerateHeaders)include(GenerateExportHeader)include(ECMMarkAsTest)include(ECMInstallIcons)+include(ECMQmlModule)include(CMakePackageConfigHelpers)include(WriteBasicConfigVersionFile)@@ -1473,6 +1474,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}add_subdirectory(sdk/tests)add_subdirectory(libs)+add_subdirectory(qmlmodules)add_subdirectory(plugins)if (BUILD_TESTING)add_subdirectory(benchmarks)diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qmlindex 748f8a783f..393e0a8c24 100644--- a/plugins/dockers/textproperties/qml/BaselineShift.qml+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@label", "Baseline-Shift")diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qmlindex b996373789..99fe5a798d 100644--- a/plugins/dockers/textproperties/qml/FontSize.qml+++ b/plugins/dockers/textproperties/qml/FontSize.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@label:spinbox", "Font Size");diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex abb7c3db82..7a8fb52b15 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0CollapsibleGroupProperty {propertyName: i18nc("@label", "Font Style");diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qmlindex 9f095a5ffc..5fe334ae13 100644--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@label:spinbox", "Letter Spacing");diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qmlindex 89894ec755..9342354b58 100644--- a/plugins/dockers/textproperties/qml/LineHeight.qml+++ b/plugins/dockers/textproperties/qml/LineHeight.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@label", "Line Height");diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qmlindex 56d2fd2162..1abbaa2247 100644--- a/plugins/dockers/textproperties/qml/TabSize.qml+++ b/plugins/dockers/textproperties/qml/TabSize.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@title:group", "Tab Size");diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qmlindex c8362aab2a..2f84f72bc8 100644--- a/plugins/dockers/textproperties/qml/TextIndent.qml+++ b/plugins/dockers/textproperties/qml/TextIndent.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0CollapsibleGroupProperty {propertyName: i18nc("@title:group", "Text Indent");diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qmlindex 3406c825ce..c2c81c01e3 100644--- a/plugins/dockers/textproperties/qml/WordSpacing.qml+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.qml 1.0TextPropertyBase {propertyName: i18nc("@title:group", "Word Spacing");diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrcindex 652269dc1d..d48cbeea0c 100644--- a/plugins/dockers/textproperties/textproperties.qrc+++ b/plugins/dockers/textproperties/textproperties.qrc@@ -32,7 +32,6 @@<file alias="RevertPropertyButton.qml">qml/RevertPropertyButton.qml</file><file alias="TextPropertyBaseList.qml">qml/TextPropertyBaseList.qml</file><file alias="UnitComboBox.qml">qml/UnitComboBox.qml</file>- <file alias="DoubleSpinBox.qml">qml/DoubleSpinBox.qml</file><file alias="FontResourceDropdown.qml">qml/FontResourceDropdown.qml</file><file alias="light_edit-undo-tristate.svg">icons/light_edit-undo-tristate.svg</file><file alias="font-color-type-clr-bitmap.svg">icons/font-color-type-clr-bitmap.svg</file>diff --git a/plugins/tools/svgtexttool/CMakeLists.txt b/plugins/tools/svgtexttool/CMakeLists.txtindex f1399a8a18..c6618883a6 100644--- a/plugins/tools/svgtexttool/CMakeLists.txt+++ b/plugins/tools/svgtexttool/CMakeLists.txt@@ -26,7 +26,6 @@ set (SvgTextTool_SRCSglyphpalette/GlyphPaletteDialog.cppglyphpalette/GlyphPaletteProxyModel.cpp- glyphpalette/SvgTextLabel.cppglyphpalette/GlyphPaletteAltPopup.cpp)@@ -58,6 +57,7 @@ target_link_libraries(krita_tool_svgtext_staticQt${QT_MAJOR_VERSION}::QuickControls2Qt${QT_MAJOR_VERSION}::QmlKF${KF_MAJOR}::I18n)+target_link_libraries(krita_tool_svgtext PRIVATE krita_tool_svgtext_static)install(TARGETS krita_tool_svgtext DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})diff --git a/plugins/tools/svgtexttool/Plugin.cpp b/plugins/tools/svgtexttool/Plugin.cppindex 627bed20ed..d67a7d7704 100644--- a/plugins/tools/svgtexttool/Plugin.cpp+++ b/plugins/tools/svgtexttool/Plugin.cpp@@ -8,19 +8,20 @@#include <kpluginfactory.h>+#include <QQmlEngine>+#include <KoShapeRegistry.h>#include <KoToolRegistry.h>#include <KisStaticInitializer.h>#include "SvgTextToolFactory.h"-#include "glyphpalette/SvgTextLabel.h"#include "glyphpalette/GlyphPaletteProxyModel.h"K_PLUGIN_FACTORY_WITH_JSON(PluginFactory, "krita_tool_svgtext.json", registerPlugin<Plugin>();)KIS_DECLARE_STATIC_INITIALIZER {- qmlRegisterType<SvgTextLabel>("org.krita.tools.text", 1, 0, "SvgTextLabel");+ //qmlRegisterType<SvgTextLabel>("org.krita.tools.text", 1, 0, "SvgTextLabel");qmlRegisterType<GlyphPaletteProxyModel>("org.krita.tools.text", 1, 0, "GlyphPaletteProxyModel");}Plugin::Plugin(QObject *parent, const QVariantList &)diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qmlindex 7059186d78..75acd93503 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml@@ -6,6 +6,7 @@import QtQuick 2.15import QtQuick.Controls 2.5import org.krita.tools.text 1.0+import org.krita.qml 1.0SvgTextLabel {id: glyphLabel;diff --git a/qmlmodules/CMakeLists.txt b/qmlmodules/CMakeLists.txtnew file mode 100644index 0000000000..6bb1046cdd--- /dev/null+++ b/qmlmodules/CMakeLists.txt@@ -0,0 +1,5 @@+#add_subdirectory(types)+#add_subdirectory(utilities)+#add_subdirectory(resources)+#add_subdirectory(widgets)+add_subdirectory(libqml)diff --git a/qmlmodules/libqml/CMakeLists.txt b/qmlmodules/libqml/CMakeLists.txtnew file mode 100644index 0000000000..2043955c7a--- /dev/null+++ b/qmlmodules/libqml/CMakeLists.txt@@ -0,0 +1,27 @@+ecm_add_qml_module(kritaqml+ URI org.krita.qml+ VERSION 1.0+ SHARED+ GENERATE_PLUGIN_SOURCE+)++target_sources(kritaqml+ PUBLIC+ SvgTextLabel.cpp+)++target_link_libraries(kritaqml+ PUBLIC+ kritaui+ PRIVATE+ Qt::Quick+)++ecm_target_qml_sources(kritaqml SOURCES+ qml/DoubleSpinBox.qml+)++ecm_finalize_qml_module(kritaqml DESTINATION ${KDE_INSTALL_QMLDIR})++install(TARGETS kritaqml ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})+diff --git a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpp b/qmlmodules/libqml/SvgTextLabel.cppsimilarity index 100%rename from plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.cpprename to qmlmodules/libqml/SvgTextLabel.cppdiff --git a/plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.h b/qmlmodules/libqml/SvgTextLabel.hsimilarity index 100%rename from plugins/tools/svgtexttool/glyphpalette/SvgTextLabel.hrename to qmlmodules/libqml/SvgTextLabel.hdiff --git a/qmlmodules/libqml/qml/DoubleSpinBox.qml b/qmlmodules/libqml/qml/DoubleSpinBox.qmlnew file mode 100644index 0000000000..c1708a9660--- /dev/null+++ b/qmlmodules/libqml/qml/DoubleSpinBox.qml@@ -0,0 +1,30 @@+/*+ * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import QtQuick.Controls 2.15+++// Simple double spinbox based on Qt example implementation, should proly be switched to spinbox slider at some point.+SpinBox {+ editable: true;+ wheelEnabled: true;++ property int decimals: 2;+ property int multiplier: Math.pow(10, decimals);++ validator: DoubleValidator {+ bottom: Math.min(from, to)+ top: Math.max(from, to)+ }++ textFromValue: function(value, locale) {+ return Number(value / multiplier).toLocaleString(locale, 'f', decimals)+ }++ valueFromText: function(text, locale) {+ return Number.fromLocaleString(locale, text) * multiplier;+ }+}