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

[android] Don't pan window up when using text tool

Carsten Hartenfelse5a465deddae
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afedf23911..6daa1e5cbe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -825,6 +825,15 @@ int main(int argc, char *argv[]) {}
KRITA_QT_HAS_QSCROLLER_FILTER
)
+CHECK_CXX_SOURCE_COMPILES("
+#include <QCoreApplication>
+int main(int argc, char *argv[]) {
+return Qt::ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING;
+}
+"
+KRITA_QT_HAS_ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING
+)
+
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
diff --git a/config-qt-patches-present.h.cmake b/config-qt-patches-present.h.cmake
index b78d609da0..d447b4f2d3 100644
--- a/config-qt-patches-present.h.cmake
+++ b/config-qt-patches-present.h.cmake
@@ -5,3 +5,4 @@
#cmakedefine01 KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
#cmakedefine01 KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
#cmakedefine01 KRITA_QT_HAS_QSCROLLER_FILTER
+#cmakedefine01 KRITA_QT_HAS_ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING
diff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cpp
index 323b8be1a4..cdb1c17c54 100644
--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp
+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp
@@ -43,6 +43,10 @@
#include <QBuffer>
#include <QWidget>
+#ifdef Q_OS_ANDROID
+#include <config-qt-patches-present.h>
+#endif
+
struct IMEDecorationInfo {
int start = -1; ///< The startPos from the attribute.
@@ -1038,7 +1042,18 @@ QVariant SvgTextCursor::inputMethodQuery(Qt::InputMethodQuery query) const
return Qt::ImhMultiLine;
break;
// case Qt::ImPreferredLanguage: // requires access to properties.
- // case Qt::ImPlatformData: // this is only for iOS at time of writing.
+#if defined(Q_OS_ANDROID) && KRITA_QT_HAS_ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING
+ case Qt::ImPlatformData:
+ // Platform-specific data. Qt normally only uses this on iOS, but we
+ // have a patch that allows us to control the keyboard pan behavior.
+ // Normally it pans the application window up if the text area would end
+ // up underneath the keyboard, but that's silly for the on-canvas text
+ // input because the location can be changed by panning the canvas. And
+ // if you do that while the keyboard is up, you end up with the whole
+ // window panned up for no reason until you dismiss and re-show it, so
+ // better to just do nothing in the first place and let the user pan.
+ return Qt::ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING;
+#endif
case Qt::ImEnterKeyType:
if (d->shape) {
return Qt::EnterKeyDefault; // because input method hint is always multiline, this will show a return key.