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

Close popup palette when clicking outside the palette with tablet

Dmitry Kazakovd4bc264cf83b
diff --git a/libs/ui/kis_popup_palette.cpp b/libs/ui/kis_popup_palette.cpp
index e43cd5c3ad..6c810fac9d 100644
--- a/libs/ui/kis_popup_palette.cpp
+++ b/libs/ui/kis_popup_palette.cpp
@@ -1141,11 +1141,21 @@ void KisPopupPalette::showEvent(QShowEvent *event)
void KisPopupPalette::tabletEvent(QTabletEvent *event)
{
- if (event->button() == Qt::RightButton && event->type() == QEvent::TabletPress) {
- m_tabletRightClickPressed = true;
- }
-
event->ignore();
+
+ if (this->windowHandle()) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ const QPointF localPos = event->localPos();
+#else
+ const QPointF localPos = event->position();
+#endif
+
+ if (event->type() == QEvent::TabletRelease && !QRectF(rect()).contains(localPos)) {
+ event->accept();
+ Q_EMIT finished();
+ return;
+ }
+ }
}
void KisPopupPalette::mouseReleaseEvent(QMouseEvent *event)
diff --git a/libs/ui/kis_popup_palette.h b/libs/ui/kis_popup_palette.h
index a59177d665..1c77a4adc6 100644
--- a/libs/ui/kis_popup_palette.h
+++ b/libs/ui/kis_popup_palette.h
@@ -125,7 +125,6 @@ private:
bool m_useDynamicSlotCount {true};
int m_hoveredColor {0};
int m_selectedColor {0};
- bool m_tabletRightClickPressed {false};
bool m_touchBeginReceived {false};
bool m_isOverFgBgColors {false};
bool m_snapRotation {false};