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

Don't require restart for touch painting change

Carsten Hartenfelse59aece268f9
diff --git a/libs/global/kis_config_notifier.cpp b/libs/global/kis_config_notifier.cpp
index 34cfcf6428..db4da28f99 100644
--- a/libs/global/kis_config_notifier.cpp
+++ b/libs/global/kis_config_notifier.cpp
@@ -55,6 +55,11 @@ void KisConfigNotifier::notifyColorHistoryModeChanged()
Q_EMIT colorHistoryModeChanged();
}
+void KisConfigNotifier::notifyTouchPaintingChanged()
+{
+ Q_EMIT touchPaintingChanged();
+}
+
void KisConfigNotifier::notifyColorThemeChanged(const QString &filename)
{
Q_EMIT signalColorThemeChanged(filename);
diff --git a/libs/global/kis_config_notifier.h b/libs/global/kis_config_notifier.h
index 79da4dcb9b..b6f9eb4b53 100644
--- a/libs/global/kis_config_notifier.h
+++ b/libs/global/kis_config_notifier.h
@@ -36,6 +36,7 @@ public:
void notifyDropFramesModeChanged();
void notifyPixelGridModeChanged();
void notifyColorHistoryModeChanged();
+ void notifyTouchPaintingChanged();
void notifyColorThemeChanged(const QString &filename);
@@ -47,6 +48,7 @@ Q_SIGNALS:
void dropFramesModeChanged();
void pixelGridModeChanged();
void colorHistoryModeChanged();
+ void touchPaintingChanged();
void signalColorThemeChanged(const QString &filename);
private:
KisConfigNotifier(const KisConfigNotifier&);
diff --git a/libs/ui/input/kis_input_manager_p.cpp b/libs/ui/input/kis_input_manager_p.cpp
index 0541862765..e56461d070 100644
--- a/libs/ui/input/kis_input_manager_p.cpp
+++ b/libs/ui/input/kis_input_manager_p.cpp
@@ -557,11 +557,11 @@ void KisInputManager::Private::addTouchShortcut(KisAbstractInputAction* action,
#ifndef Q_OS_MACOS
case KisShortcutConfiguration::OneFingerTap:
case KisShortcutConfiguration::OneFingerDrag:
- // Allow single finger panning if touch drawing is disabled
- if (KisConfig(true).disableTouchOnCanvas()) {
- shortcut->setMinimumTouchPoints(1);
- shortcut->setMaximumTouchPoints(1);
- }
+ // Touch painting takes precedence over one-finger touch shortcuts, so
+ // disable this type of shortcut when touch painting is active.
+ shortcut->setDisableOnTouchPainting(true);
+ shortcut->setMinimumTouchPoints(1);
+ shortcut->setMaximumTouchPoints(1);
break;
case KisShortcutConfiguration::TwoFingerTap:
case KisShortcutConfiguration::TwoFingerDrag:
diff --git a/libs/ui/input/kis_touch_shortcut.cpp b/libs/ui/input/kis_touch_shortcut.cpp
index bdd909776c..1dc2861a9e 100644
--- a/libs/ui/input/kis_touch_shortcut.cpp
+++ b/libs/ui/input/kis_touch_shortcut.cpp
@@ -8,6 +8,7 @@
#include "kis_touch_shortcut.h"
#include "kis_abstract_input_action.h"
+#include "kis_config.h"
#include <QTouchEvent>
@@ -18,11 +19,13 @@ public:
: minTouchPoints(0)
, maxTouchPoints(0)
, type(type)
+ , disableOnTouchPainting(false)
{ }
int minTouchPoints;
int maxTouchPoints;
GestureAction type;
+ bool disableOnTouchPainting;
};
KisTouchShortcut::KisTouchShortcut(KisAbstractInputAction* action, int index, GestureAction type)
@@ -52,6 +55,11 @@ void KisTouchShortcut::setMaximumTouchPoints(int max)
d->maxTouchPoints = max;
}
+void KisTouchShortcut::setDisableOnTouchPainting(bool disableOnTouchPainting)
+{
+ d->disableOnTouchPainting = disableOnTouchPainting;
+}
+
bool KisTouchShortcut::matchTapType(QTouchEvent *event)
{
return matchTouchPoint(event)
@@ -72,5 +80,6 @@ bool KisTouchShortcut::matchDragType(QTouchEvent *event)
bool KisTouchShortcut::matchTouchPoint(QTouchEvent *event)
{
- return event->touchPoints().count() >= d->minTouchPoints && event->touchPoints().count() <= d->maxTouchPoints;
+ return (!d->disableOnTouchPainting || KisConfig(true).disableTouchOnCanvas())
+ && event->touchPoints().count() >= d->minTouchPoints && event->touchPoints().count() <= d->maxTouchPoints;
}
diff --git a/libs/ui/input/kis_touch_shortcut.h b/libs/ui/input/kis_touch_shortcut.h
index 4962afa05c..1e989dbfcb 100644
--- a/libs/ui/input/kis_touch_shortcut.h
+++ b/libs/ui/input/kis_touch_shortcut.h
@@ -30,6 +30,7 @@ class KisTouchShortcut : public KisAbstractShortcut
void setMinimumTouchPoints( int min );
void setMaximumTouchPoints( int max );
+ void setDisableOnTouchPainting(bool disableOnTouchPainting);
bool matchTapType(QTouchEvent *event);
bool matchDragType(QTouchEvent *event);
diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc
index 482d9dba2f..5d7433c105 100644
--- a/libs/ui/kis_config.cc
+++ b/libs/ui/kis_config.cc
@@ -141,6 +141,7 @@ bool KisConfig::disableTouchOnCanvas(bool defaultValue) const
void KisConfig::setDisableTouchOnCanvas(bool value) const
{
m_cfg.writeEntry("disableTouchOnCanvas", value);
+ KisConfigNotifier::instance()->notifyTouchPaintingChanged();
}
bool KisConfig::useProjections(bool defaultValue) const
diff --git a/libs/ui/tool/kis_tool_freehand.cc b/libs/ui/tool/kis_tool_freehand.cc
index 265f4d6f15..e23dc37ee0 100644
--- a/libs/ui/tool/kis_tool_freehand.cc
+++ b/libs/ui/tool/kis_tool_freehand.cc
@@ -39,6 +39,7 @@
// Krita/ui
#include "kis_abstract_perspective_grid.h"
#include "kis_config.h"
+#include "kis_config_notifier.h"
#include "kis_image_config.h"
#include "canvas/kis_canvas2.h"
#include "kis_cursor.h"
@@ -59,7 +60,9 @@ KisToolFreehand::KisToolFreehand(KoCanvasBase * canvas, const QCursor & cursor,
{
setSupportOutline(true);
- setMaskSyntheticEvents(KisConfig(true).disableTouchOnCanvas()); // Disallow mouse events from finger presses unless enabled
+ updateMaskSyntheticEventsFromTouch();
+ connect(KisConfigNotifier::instance(), SIGNAL(touchPaintingChanged()),
+ SLOT(updateMaskSyntheticEventsFromTouch()));
m_infoBuilder = new KisToolFreehandPaintingInformationBuilder(this);
m_helper = new KisToolFreehandHelper(m_infoBuilder, canvas->resourceManager(), transactionText,
@@ -470,6 +473,11 @@ qreal KisToolFreehand::calculatePerspective(const QPointF &documentPoint)
return perspective;
}
+void KisToolFreehand::updateMaskSyntheticEventsFromTouch()
+{
+ setMaskSyntheticEvents(KisConfig(true).disableTouchOnCanvas());
+}
+
void KisToolFreehand::explicitUpdateOutline()
{
requestUpdateOutline(m_outlineDocPoint, 0);
diff --git a/libs/ui/tool/kis_tool_freehand.h b/libs/ui/tool/kis_tool_freehand.h
index a08a728b78..a67909bc00 100644
--- a/libs/ui/tool/kis_tool_freehand.h
+++ b/libs/ui/tool/kis_tool_freehand.h
@@ -101,6 +101,9 @@ private:
*/
qreal calculatePerspective(const QPointF &documentPoint);
+private Q_SLOTS:
+ void updateMaskSyntheticEventsFromTouch();
+
protected:
friend class KisViewManager;
friend class KisView;