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++
Make sliders not show selection handles on Android
Carsten Hartenfels2716a1fc5dcb
diff --git a/libs/widgetutils/kis_slider_spin_box_p.h b/libs/widgetutils/kis_slider_spin_box_p.hindex 0cd46fa2d4..791ce83e41 100644--- a/libs/widgetutils/kis_slider_spin_box_p.h+++ b/libs/widgetutils/kis_slider_spin_box_p.h@@ -16,6 +16,7 @@#include <QStyleOptionSpinBox>#include <QPainter>#include <QEvent>+#include <QInputMethodQueryEvent>#include <QApplication>#include <QMouseEvent>#include <QTimer>@@ -576,6 +577,20 @@ public:return true;}+ bool blockInputMethodQuery(QInputMethodQueryEvent *e)+ {+ // On Android, pressing on a text input shows text selection handles,+ // see QAndroidInputContext::updateSelectionHandles. We don't want that+ // if a slider is not in edit mode, so we respond with "not enabled".+ if (e->queries().testFlag(Qt::ImEnabled) && !isEditModeActive()) {+ e->setValue(Qt::ImEnabled, false);+ e->accept();+ return true;+ } else {+ return false;+ }+ }+// Generic "style aware" helper function to draw a rectvoid paintSliderRect(QPainter &painter, const QRectF &rect, const QBrush &brush){@@ -877,6 +892,7 @@ public:case QEvent::MouseButtonPress : return qMousePressEvent(static_cast<QMouseEvent*>(e));case QEvent::KeyPress : return qKeyPressEvent(static_cast<QKeyEvent*>(e));case QEvent::ContextMenu : return qContextMenuEvent(static_cast<QContextMenuEvent*>(e));+ case QEvent::InputMethodQuery: return blockInputMethodQuery(static_cast<QInputMethodQueryEvent *>(e));default: break;}} else if (o == m_lineEdit) {@@ -894,6 +910,7 @@ public:case QEvent::MouseButtonRelease: return widgetRangeToggleMouseReleaseEvent(static_cast<QMouseEvent*>(e));case QEvent::Enter: return widgetRangeToggleEnterEvent(e);case QEvent::Leave: return widgetRangeToggleLeaveEvent(e);+ case QEvent::InputMethodQuery: return blockInputMethodQuery(static_cast<QInputMethodQueryEvent *>(e));default: break;}}