aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-03-02 17:20:53 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-03-03 12:38:21 +0100
commit95be4f1e3945f88adc9d55fa06371665254a1127 (patch)
tree3739dba70ca65db8afd8efebd23cc572e712dc97
parent4e8b3dd45ae4cc66a1b77cce901f80406b2a0f69 (diff)
Refactor desktop-detection logic to become an explicit propertyv5.15.0-beta2
The __isRootPanel internal property was used to detect whether the keyboard is running in as a stand-alone, toplevel window in the desktop. The value of the property depended on the location of the keyboard panel within the QQuickItem hierarchy, which is fragile. Instead, declare an explicit property desktopPanel that is set to true by the desktop integration when the panel has been created. Change-Id: Idb9e90e01e9b1c643e84287716e0b964256b115e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/import/plugins.qmltypes16
-rw-r--r--src/virtualkeyboard/content/InputPanel.qml11
-rw-r--r--src/virtualkeyboard/platforminputcontext.cpp2
-rw-r--r--src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp6
4 files changed, 16 insertions, 19 deletions
diff --git a/src/import/plugins.qmltypes b/src/import/plugins.qmltypes
index b0f8537..71e29c5 100644
--- a/src/import/plugins.qmltypes
+++ b/src/import/plugins.qmltypes
@@ -1371,7 +1371,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1388,7 +1388,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1405,7 +1405,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1422,7 +1422,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1439,7 +1439,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1456,7 +1456,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1473,7 +1473,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
@@ -1490,7 +1490,7 @@ Module {
isComposite: true
defaultProperty: "data"
Property { name: "externalLanguageSwitchEnabled"; type: "bool" }
- Property { name: "__isRootItem"; type: "bool"; isReadonly: true }
+ Property { name: "desktopPanel"; type: "bool" }
Property { name: "active"; type: "bool" }
Property { name: "keyboard"; type: "Keyboard_QMLTYPE_22"; isReadonly: true; isPointer: true }
Signal {
diff --git a/src/virtualkeyboard/content/InputPanel.qml b/src/virtualkeyboard/content/InputPanel.qml
index ea3ab23..f511eab 100644
--- a/src/virtualkeyboard/content/InputPanel.qml
+++ b/src/virtualkeyboard/content/InputPanel.qml
@@ -114,16 +114,13 @@ Item {
property alias keyboard: keyboard
/*! \internal */
- readonly property bool __isRootItem: inputPanel.parent != null && inputPanel.parent.parent == null
-
- /*! \internal */
- property bool __reparented: false
+ property bool desktopPanel: false
SelectionControl {
objectName: "selectionControl"
x: -parent.x
y: -parent.y
- enabled: active && !keyboard.fullScreenMode && (!__isRootItem || __reparented)
+ enabled: active && !keyboard.fullScreenMode && !desktopPanel
}
implicitHeight: keyboard.height
@@ -143,8 +140,8 @@ Item {
target: InputContext.priv
property: "keyboardRectangle"
value: mapToItem(null,
- __isRootItem ? keyboard.x : x,
- (__isRootItem ? keyboard.y : y) + keyboard.wordCandidateView.currentYOffset - (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0),
+ desktopPanel ? keyboard.x : x,
+ (desktopPanel ? keyboard.y : y) + keyboard.wordCandidateView.currentYOffset - (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0),
keyboard.width,
keyboard.height - keyboard.wordCandidateView.currentYOffset + (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0))
when: !InputContext.animating
diff --git a/src/virtualkeyboard/platforminputcontext.cpp b/src/virtualkeyboard/platforminputcontext.cpp
index d57a63e..eef2657 100644
--- a/src/virtualkeyboard/platforminputcontext.cpp
+++ b/src/virtualkeyboard/platforminputcontext.cpp
@@ -104,6 +104,8 @@ void PlatformInputContext::update(Qt::InputMethodQueries queries)
if (m_inputContext) {
m_selectionControl = new DesktopInputSelectionControl(this, m_inputContext);
m_selectionControl->createHandles();
+ if (QObject *inputPanel = m_inputContext->priv()->inputPanel)
+ inputPanel->setProperty("desktopPanel", true);
}
}
#endif
diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
index 2c94535..a7c0aad 100644
--- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
+++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
@@ -273,15 +273,13 @@ void QVirtualKeyboardInputContextPrivate::onInputItemChanged()
if (QObject *item = inputItem()) {
if (QQuickItem *vkbPanel = qobject_cast<QQuickItem*>(inputPanel)) {
if (QQuickItem *quickItem = qobject_cast<QQuickItem*>(item)) {
- const QVariant isRootItem = vkbPanel->property("__isRootItem");
+ const QVariant isDesktopPanel = vkbPanel->property("desktopPanel");
/*
For integrated keyboards, make sure it's a sibling to the overlay. The
high z-order will make sure it gets events also during a modal session.
*/
- if (isRootItem.isValid() && !isRootItem.toBool()) {
+ if (isDesktopPanel.isValid() && !isDesktopPanel.toBool())
vkbPanel->setParentItem(quickItem->window()->contentItem());
- vkbPanel->setProperty("__reparented", true);
- }
}
}
} else {