Commit 44d8a750 authored by Xuetian Weng's avatar Xuetian Weng

Resolve the input method issue by always force focus in search field.

Summary:
ActivityManager.qml doesn't have input method issue because the initial
focus is inside the text field. So here we try to apply the same logic.
Always force focus into the text field first, and handle the rest of key
event accordingly. So we don't need to use event.text to append or do
anything special, because event.text is not a input method compatible
way to handle input.

Test Plan:
Manually test arrow key navigation. Also test input method typing is enabled
when menu is opened.

Reviewers: hein, mart

Reviewed By: hein

Subscribers: ngraham, ihipop, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8770
parent 0e4484b6
......@@ -43,10 +43,13 @@ Item {
property QtObject globalFavorites: rootModelFavorites
state: "Normal"
focus: true
onFocusChanged: {
header.input.forceActiveFocus();
}
function switchToInitial() {
if(firstButton != null) {
if (firstButton != null) {
mainTabGroup.currentTab = firstButton.tab;
tabBar.currentTab = firstButton;
header.query = ""
......@@ -400,7 +403,7 @@ Item {
}
}
onCurrentTabChanged: root.forceActiveFocus();
onCurrentTabChanged: header.input.forceActiveFocus();
Connections {
target: plasmoid
......@@ -409,7 +412,7 @@ Item {
createButtons();
}
if (!expanded) {
switchToInitial()
switchToInitial();
}
}
}
......@@ -437,7 +440,7 @@ Item {
break;
}
case Qt.Key_Left: {
if (header.input.focus) {
if (header.input.focus && header.state == "query") {
break;
}
if (!currentView.deactivateCurrentIndex()) {
......@@ -451,7 +454,7 @@ Item {
break;
}
case Qt.Key_Right: {
if (header.input.focus) {
if (header.input.focus && header.state == "query") {
break;
}
currentView.activateCurrentIndex();
......@@ -473,7 +476,7 @@ Item {
if (header.state != "query") {
plasmoid.expanded = false;
} else {
switchToInitial();
header.query = "";
}
event.accepted = true;
break;
......@@ -483,28 +486,10 @@ Item {
event.accepted = true;
break;
}
default: { // forward key to searchView
//header.query += event.text will break if the key is backspace,
//since if the user continues to type, it will produce an invalid query,
//having backspace as the first character
if (event.key == Qt.Key_Backspace && header.query == "") {
return;
}
if (event.text != "" && !header.input.focus) {
root.currentView.listView.currentIndex = -1;
if (event.matches(StandardKey.Paste) ) {
header.input.paste();
} else if (! (event.key & Qt.Key_Escape)) {
//if special key, do nothing. Qt.Escape is 0x10000000 which happens to be a mask used for all special keys in Qt.
header.query = "";
header.query += event.text;
}
default:
if (!header.input.focus) {
header.input.forceActiveFocus();
event.accepted = true;
}
}
}
}
......@@ -541,6 +526,10 @@ Item {
target: mainTabGroup
currentTab: searchPage
}
PropertyChanges {
target: root
Keys.forwardTo: [root]
}
}
] // states
......
......@@ -177,7 +177,6 @@ Item {
}
if (text == "") {
root.state = root.previousState;
root.forceActiveFocus();
header.state = "info";
} else {
header.state = "query";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment