fix(qml): 添加全屏界面按下数字或字母跳转到搜索

This commit is contained in:
youdiansaodongxi 2024-07-09 16:36:17 +08:00 committed by iaom
parent e512704320
commit 6be045f9b4
4 changed files with 15 additions and 1 deletions

View File

@ -96,7 +96,7 @@ ListView {
text.text: model.name text.text: model.name
icon.source: model.icon icon.source: model.icon
isRecentInstalled: model.recentInstall isRecentInstalled: model.recentInstall === undefined ? false : model.recentInstall
onClicked: (event) => { onClicked: (event) => {
if (event.button === Qt.LeftButton) { if (event.button === Qt.LeftButton) {

View File

@ -27,6 +27,14 @@ FocusScope {
} }
} }
function keyPressed(event) {
if ((0x2f < event.key && event.key < 0x3a)||(0x40 < event.key && event.key < 0x5b)) {
focus = true;
searchInputBar.text = event.text;
searchInputBar.textInputFocus();
}
}
Item { Item {
anchors.fill: parent anchors.fill: parent

View File

@ -63,8 +63,10 @@ Item {
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
if (mainWindow.isFullScreen) { if (mainWindow.isFullScreen) {
root.currentSearchText = searchInputBar.text;
mainWindow.exitFullScreen(); mainWindow.exitFullScreen();
} else { } else {
root.currentSearchText = appPage.search.searchInputBar.text;
mainWindow.isFullScreen = true; mainWindow.isFullScreen = true;
} }
} }

View File

@ -175,6 +175,10 @@ Item {
active = mainWindow.isFullScreen ? true : false; active = mainWindow.isFullScreen ? true : false;
opacity = mainWindow.isFullScreen ? 1 : 0; opacity = mainWindow.isFullScreen ? 1 : 0;
} }
Keys.onPressed: {
item.keyPressed(event);
}
} }
Component { Component {