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 SAP buttons not responding to tablet events

Luna Lovecraftb34ee807d9e1
diff --git a/libs/ui/kis_selection_actions_panel_button.cpp b/libs/ui/kis_selection_actions_panel_button.cpp
index b0f44430a0..aa2dd1ec23 100644
--- a/libs/ui/kis_selection_actions_panel_button.cpp
+++ b/libs/ui/kis_selection_actions_panel_button.cpp
@@ -8,6 +8,7 @@
#include "kis_icon_utils.h"
#include <qapplication.h>
+#include <qevent.h>
#include <qpainter.h>
#include <qpainterpath.h>
@@ -59,3 +60,15 @@ void KisSelectionActionsPanelButton::paintEvent(QPaintEvent *e)
Q_UNUSED(e);
}
+// For whatever reason the children of the canvas don't interpret tabletPress/Release events as mouse press/release events
+// So we have to do this manually
+void KisSelectionActionsPanelButton::tabletEvent(QTabletEvent *e)
+{
+ if (e->type() == QEvent::TabletPress) {
+ QAbstractButton::mousePressEvent((QMouseEvent *)e);
+ e->accept();
+ } else if (e->type() == QEvent::TabletRelease) {
+ QAbstractButton::mouseReleaseEvent((QMouseEvent *)e);
+ e->accept();
+ }
+}
diff --git a/libs/ui/kis_selection_actions_panel_button.h b/libs/ui/kis_selection_actions_panel_button.h
index 604d2c92fa..5fb6816442 100644
--- a/libs/ui/kis_selection_actions_panel_button.h
+++ b/libs/ui/kis_selection_actions_panel_button.h
@@ -17,6 +17,7 @@ class KisSelectionActionsPanelButton : public QAbstractButton {
void draw(QPainter &painter);
protected:
void paintEvent(QPaintEvent *e) override;
+ void tabletEvent(QTabletEvent* e) override;
};