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

Remove TextPropertyAutoEnabler, replace with basic QML functionality.

Wolthera van Hövell tot Westerfliera942a879313d
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
index dacae9535d..7637b56d8f 100644
--- a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
@@ -112,8 +112,3 @@ QString CssStylePresetEditDialog::wwsFontFamilyName(QString familyName)
}
return name.value();
}
-
-void CssStylePresetEditDialog::connectAutoEnabler(QObject *watched)
-{
-
-}
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.h b/plugins/dockers/textproperties/CssStylePresetEditDialog.h
index 483d46ae12..f6a3932945 100644
--- a/plugins/dockers/textproperties/CssStylePresetEditDialog.h
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.h
@@ -26,7 +26,6 @@ public Q_SLOTS:
void slotUpdateTextProperties();
QColor modalColorDialog(QColor oldColor);
QString wwsFontFamilyName(QString familyName);
- void connectAutoEnabler(QObject *watched);
private:
QQuickWidget *m_quickWidget {0};
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index 49b23de3bd..f7b7a7bd46 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -84,35 +84,6 @@ KIS_DECLARE_STATIC_INITIALIZER {
qmlRegisterType<TextPropertyConfigFilterModel>("org.krita.flake.text", 1, 0, "TextPropertyConfigFilterModel");
}
-
-/// This will call the 'autoEnable' function on any "watched" QObject.
-/// Within QML, this should be used with a MouseArea that holds the disabled QtQuickControl
-/// The autoEnable function on this MouseArea should enable the QtQuick control.
-/// This is because disabled QtQuickControls never receive mouse events.
-struct TextPropertyAutoEnabler : public QObject {
- Q_OBJECT
-public:
- TextPropertyAutoEnabler (QObject *watched, QObject *parent)
- : QObject(parent), m_watched(watched) {
- watched->installEventFilter(this);
- }
-
- bool eventFilter(QObject *watched, QEvent *event) override {
- if (watched != m_watched) return false;
-
- if (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::TabletPress ||
- event->type() == QEvent::TouchBegin) {
-
- QMetaObject::invokeMethod(m_watched, "autoEnable");
- }
-
- return false;
- }
-private:
- QObject *m_watched;
-};
-
struct TextPropertiesDock::Private
{
Private(QObject *parent = nullptr)
@@ -247,13 +218,6 @@ void TextPropertiesDock::unsetCanvas()
m_canvas = 0;
}
-void TextPropertiesDock::connectAutoEnabler(QObject *watched)
-{
- KIS_SAFE_ASSERT_RECOVER_RETURN(watched);
-
- new TextPropertyAutoEnabler(watched, watched);
-}
-
QColor TextPropertiesDock::modalColorDialog(QColor oldColor)
{
QColor c = QColorDialog::getColor(oldColor);
@@ -339,5 +303,3 @@ void TextPropertiesDock::editPreset(KoResourceSP resource)
KisResourceUserOperations::updateResourceWithUserInput(this, dialog->currentResource());
}
}
-
-#include "TextPropertiesDock.moc"
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.h b/plugins/dockers/textproperties/TextPropertiesDock.h
index 054c8ce059..716fbeed8f 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.h
+++ b/plugins/dockers/textproperties/TextPropertiesDock.h
@@ -32,7 +32,6 @@ public Q_SLOTS:
void slotCanvasTextPropertiesChanged();
void slotTextPropertiesChanged();
QString wwsFontFamilyName(QString familyName);
- void connectAutoEnabler(QObject *watched);
QColor modalColorDialog(QColor oldColor);
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qml
index 81680e193b..c7673748b2 100644
--- a/plugins/dockers/textproperties/qml/BaselineShift.qml
+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml
@@ -55,9 +55,6 @@ TextPropertyBase {
onEnableProperty: properties.baselineShiftState = KoSvgTextPropertiesModel.PropertySet;
- Component.onCompleted: {
- mainWindow.connectAutoEnabler(baselineShiftSpnArea);
- }
GridLayout {
columns: 3;
columnSpacing: columnSpacing;
@@ -107,15 +104,8 @@ TextPropertyBase {
MouseArea {
id: baselineShiftSpnArea;
- function autoEnable() {
- baselineShiftMode = 3;
- }
Layout.fillWidth: true;
Layout.fillHeight: true;
- PaletteControl {
- id: baselinePalette;
- colorGroup: baselineShiftSpn.enabled? SystemPalette.Active: SystemPalette.Disabled;
- }
Kis.DoubleSliderSpinBox {
id: baselineShiftSpn
width: parent.width;
@@ -125,6 +115,15 @@ TextPropertyBase {
onDValueChanged: if (enabled) baselineShiftUnitCmb.userValue = dValue;
palette: baselinePalette.palette;
blockUpdateSignalOnDrag: true;
+ PaletteControl {
+ id: baselinePalette;
+ }
+ }
+ onClicked: {
+ if (!baselineShiftSpn.enabled) {
+ baselineShiftMode = 3;
+ baselineShiftSpn.forceActiveFocus();
+ }
}
}
diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qml
index a7b038c7af..68e8a4775a 100644
--- a/plugins/dockers/textproperties/qml/FontStyle.qml
+++ b/plugins/dockers/textproperties/qml/FontStyle.qml
@@ -104,10 +104,6 @@ CollapsibleGroupProperty {
properties.fontWeightState = KoSvgTextPropertiesModel.PropertySet;
}
- Component.onCompleted: {
- mainWindow.connectAutoEnabler(fontSlantSpnArea);
- }
-
titleItem: RowLayout{
width: parent.width;
height: implicitHeight;
@@ -235,9 +231,7 @@ CollapsibleGroupProperty {
}
MouseArea {
id: fontSlantSpnArea;
- function autoEnable() {
- fontSlant = CssFontStyleModel.StyleOblique;
- }
+
Layout.fillWidth: true;
Layout.preferredHeight: fontSlantSpn.implicitHeight;
Kis.IntSliderSpinBox {
@@ -248,11 +242,19 @@ CollapsibleGroupProperty {
enabled: fontSlant == CssFontStyleModel.StyleOblique;
PaletteControl {
id: slantSpnPal;
- colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;
}
blockUpdateSignalOnDrag: true;
anchors.fill: parent;
palette: slantSpnPal.palette;
+
+ wheelEnabled: true;
+ }
+
+ onClicked: {
+ if (!fontSlantSpn.enabled) {
+ fontSlant = CssFontStyleModel.StyleOblique;
+ fontSlantSpn.forceActiveFocus();
+ }
}
}
diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qml
index b6181788a2..7b4d0c5b7d 100644
--- a/plugins/dockers/textproperties/qml/LineHeight.qml
+++ b/plugins/dockers/textproperties/qml/LineHeight.qml
@@ -76,7 +76,6 @@ TextPropertyBase {
onEnableProperty: properties.lineHeightState = KoSvgTextPropertiesModel.PropertySet;
Component.onCompleted: {
- mainWindow.connectAutoEnabler(lineHeightSpnArea);
converter.setDataUnitMap(unitMap);
converter.setDataValueAndUnit(0, 0);
}
@@ -116,9 +115,6 @@ TextPropertyBase {
Layout.columnSpan: 2;
MouseArea {
id: lineHeightSpnArea;
- function autoEnable() {
- lineHeightNormalCbx.checked = false;
- }
Layout.fillWidth: true;
Layout.fillHeight: true;
Kis.DoubleSliderSpinBox {
@@ -132,6 +128,12 @@ TextPropertyBase {
palette: lineHeightPalette.palette;
blockUpdateSignalOnDrag: true;
}
+ onClicked: {
+ if (!lineHeightSpn.enabled) {
+ lineHeightNormalCbx.checked = false;
+ lineHeightSpn.forceActiveFocus();
+ }
+ }
}
SqueezedComboBox {