forked from openkylin/ukui-menu
补充进入搜索框时,带入当前字母;解决重命名和按键焦点冲突问题
This commit is contained in:
parent
f37cf0ece0
commit
eb1b79fe43
|
@ -19,6 +19,7 @@ MouseArea {
|
|||
alpha: 0.55
|
||||
}
|
||||
}
|
||||
|
||||
StyleBackground {
|
||||
id: controlBase
|
||||
anchors.fill: parent
|
||||
|
@ -84,9 +85,9 @@ MouseArea {
|
|||
selectByMouse: true
|
||||
maximumLength: 14
|
||||
|
||||
onEditingFinished: {
|
||||
modelManager.getAppModel().renameFolder(id, text);
|
||||
function editStatusEnd() {
|
||||
control.editStatus = false;
|
||||
control.focus = true;
|
||||
}
|
||||
|
||||
function updateTextInputColor() {
|
||||
|
@ -94,12 +95,15 @@ MouseArea {
|
|||
selectionColor = themePalette.paletteColor(Palette.Highlight);
|
||||
}
|
||||
|
||||
onEditingFinished: {
|
||||
modelManager.getAppModel().renameFolder(id, text);
|
||||
textChange.editStatusEnd();
|
||||
}
|
||||
Component.onCompleted: {
|
||||
updateTextInputColor();
|
||||
themePalette.styleColorChanged.connect(updateTextInputColor);
|
||||
forceActiveFocus();
|
||||
}
|
||||
|
||||
Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor);
|
||||
}
|
||||
|
||||
|
@ -120,12 +124,10 @@ MouseArea {
|
|||
|
||||
onClicked: {
|
||||
textChange.text = name;
|
||||
control.editStatus = false;
|
||||
textChange.editStatusEnd();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loader {
|
||||
|
|
|
@ -27,9 +27,9 @@ Item {
|
|||
id: appListRoot
|
||||
property string title: ""
|
||||
property string idSelect: ""
|
||||
property bool folderEditStatus: false
|
||||
signal labelItemClicked()
|
||||
signal openFolderPageSignal(string folderId, string folderName);
|
||||
|
||||
signal openFolderPageSignal(string folderId, string folderName)
|
||||
function labelSelection(labelId) {
|
||||
appListView.view.positionViewAtIndex(appListView.model.getLabelIndex(labelId), ListView.Beginning)
|
||||
}
|
||||
|
@ -42,6 +42,16 @@ Item {
|
|||
id: appListView
|
||||
anchors.fill: parent
|
||||
|
||||
// 在listview区域,鼠标进出和移动事件都会清空原有的按键焦点
|
||||
// 鼠标不移动,原有的鼠标悬浮三态会保留
|
||||
onContainsMouseChanged: clearViewFocus()
|
||||
onPositionChanged: clearViewFocus()
|
||||
function clearViewFocus() {
|
||||
if(!folderEditStatus) {
|
||||
appListView.listFocus = false
|
||||
}
|
||||
}
|
||||
|
||||
model: modelManager.getAppModel()
|
||||
delegate: Component {
|
||||
Loader {
|
||||
|
@ -188,6 +198,7 @@ Item {
|
|||
appListView.model.renameText.disconnect(toEditText);
|
||||
}
|
||||
|
||||
onEditStatusChanged: folderEditStatus = editStatus;
|
||||
function toEditText(idOfIndex){
|
||||
if (id === idOfIndex) {
|
||||
editStatus = true;
|
||||
|
|
|
@ -32,7 +32,7 @@ MouseArea {
|
|||
property int itemHeight: 40
|
||||
hoverEnabled: true
|
||||
clip: true
|
||||
onContainsMouseChanged: listView.focus = false
|
||||
|
||||
AppControls2.StyleBackground {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
|
@ -57,6 +57,7 @@ MouseArea {
|
|||
highlightMoveDuration: 0
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
ScrollBar.vertical: listViewScrollBar
|
||||
|
||||
// 焦点切换后,listView按键导航重新开始
|
||||
onActiveFocusChanged: currentIndex = 0
|
||||
onCountChanged: currentIndex = 0
|
||||
|
|
|
@ -26,13 +26,13 @@ import org.ukui.menu.utils 1.0
|
|||
Item {
|
||||
id: appPageHeaderRoot
|
||||
property string title: ""
|
||||
required property Item focusToListView
|
||||
property Item focusToListView
|
||||
property Component content: null
|
||||
clip: true
|
||||
|
||||
function changeToSearch() {
|
||||
function changeToSearch(keyEvent) {
|
||||
if (appPageHeaderRoot.content === null) {
|
||||
loader.item.state = "search";
|
||||
loader.item.changeToSearchState(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,11 @@ Item {
|
|||
Item {
|
||||
id: root
|
||||
|
||||
function changeToSearchState(keyEvent) {
|
||||
state = "search";
|
||||
searchInputBar.text = keyEvent;
|
||||
}
|
||||
|
||||
state: "normal"
|
||||
states: [
|
||||
State {
|
||||
|
@ -128,7 +133,7 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
radius: 16
|
||||
keyDownTarget: focusToListView
|
||||
changeFocusTarget: focusToListView
|
||||
onTextChanged: {
|
||||
if (text === "") {
|
||||
pluginSelectMenu.model.reactivateProvider();
|
||||
|
|
|
@ -11,14 +11,14 @@ FocusScope {
|
|||
}
|
||||
function keyPressed(event) {
|
||||
// 任意字符键焦点切换到搜索(0-9 a-z)
|
||||
if ((0x2f < event.key && event.key < 0x3a )||(0x40 < event.key && event.key < 0x5b)) {
|
||||
if ((0x2f < event.key && event.key < 0x3a)||(0x40 < event.key && event.key < 0x5b)) {
|
||||
focus = true;
|
||||
appPage.header.changeToSearch();
|
||||
appPage.header.changeToSearch(event.text);
|
||||
// 任意方向键切换至搜索结果
|
||||
} else if ( 0x01000011 < event.key && event.key < 0x01000016) {
|
||||
} else if ((0x01000011 < event.key)&&(event.key < 0x01000016)) {
|
||||
focus = true;
|
||||
appPage.content.resetFocus();
|
||||
appPage.content.focus = true;
|
||||
appPage.content.resetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.ukui.menu.core 1.0
|
|||
import AppControls2 1.0 as AppControls2
|
||||
|
||||
AppControls2.StyleBackground {
|
||||
property Item keyDownTarget
|
||||
readonly property string text: textInput.text;
|
||||
property Item changeFocusTarget
|
||||
property alias text: textInput.text;
|
||||
|
||||
alpha: 0.04
|
||||
useStyleTransparent: false
|
||||
|
@ -98,8 +98,14 @@ AppControls2.StyleBackground {
|
|||
font.pointSize: defaultText.font.pointSize
|
||||
focus: parent.visible || mainWindow.isFullScreen
|
||||
|
||||
KeyNavigation.down: keyDownTarget
|
||||
onEditingFinished: KeyNavigation.down = keyDownTarget
|
||||
activeFocusOnTab: true
|
||||
function changeFocusToListView() {
|
||||
if (!mainWindow.isFullScreen) {
|
||||
changeFocusTarget.focus = true
|
||||
}
|
||||
}
|
||||
onEditingFinished: changeFocusToListView()
|
||||
Keys.onDownPressed: changeFocusToListView()
|
||||
|
||||
//字体选中跟随主题高亮
|
||||
property int textColor: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
|
||||
|
|
|
@ -99,6 +99,9 @@ Item {
|
|||
onLoaded: {
|
||||
item.send.connect(extensionListView.send);
|
||||
}
|
||||
Keys.onTabPressed: {
|
||||
extensionListView.focus = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,6 +173,7 @@ Item {
|
|||
height: ListView.view ? ListView.view.height : 0
|
||||
|
||||
activeFocusOnTab: true
|
||||
KeyNavigation.down: extensionLoader
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||
ListView.view.currentIndex = model.index;
|
||||
|
|
|
@ -53,6 +53,38 @@ UkuiMenuExtension {
|
|||
property int exchangedStartIndex: 0
|
||||
property int spacing: 4
|
||||
property int itemHeight: 104
|
||||
property int column: Math.floor(width / cellWidth)
|
||||
|
||||
// 按键导航处理(左右键可以循环)
|
||||
focus: true
|
||||
onActiveFocusChanged: currentIndex = 0
|
||||
onCountChanged: currentIndex = 0
|
||||
Keys.onRightPressed: {
|
||||
if(currentIndex === count - 1) {
|
||||
currentIndex = 0;
|
||||
return;
|
||||
}
|
||||
currentIndex++;
|
||||
}
|
||||
Keys.onLeftPressed: {
|
||||
if(currentIndex === 0) {
|
||||
currentIndex = count - 1;
|
||||
return;
|
||||
}
|
||||
currentIndex--;
|
||||
}
|
||||
Keys.onDownPressed: {
|
||||
if(currentIndex > count - 1 - column) {
|
||||
return;
|
||||
}
|
||||
currentIndex = currentIndex + column;
|
||||
}
|
||||
Keys.onUpPressed: {
|
||||
if(currentIndex < column) {
|
||||
return;
|
||||
}
|
||||
currentIndex = currentIndex - column;
|
||||
}
|
||||
|
||||
ScrollBar.vertical: AppControls2.ScrollBar {
|
||||
id: scrollBar
|
||||
|
@ -73,16 +105,26 @@ UkuiMenuExtension {
|
|||
onEntered: {
|
||||
visualModel.items.move(drag.source.visualIndex, icon.visualIndex)
|
||||
}
|
||||
|
||||
Binding { target: icon; property: "visualIndex"; value: visualIndex }
|
||||
|
||||
focus: true
|
||||
Keys.onReturnPressed: {
|
||||
var data = {"id": model.id};
|
||||
send(data);
|
||||
}
|
||||
states: State {
|
||||
when: delegateRoot.activeFocus
|
||||
PropertyChanges {
|
||||
target: icon
|
||||
alpha: 0.6
|
||||
}
|
||||
}
|
||||
AppControls2.StyleBackground {
|
||||
id: icon
|
||||
height: favoriteView.itemHeight; width: height
|
||||
property bool hold: false
|
||||
property int visualIndex: 0
|
||||
x: 0; y: 0
|
||||
|
||||
radius: 8
|
||||
useStyleTransparent: false
|
||||
scale: icon.hold ? 1.1 :1.0
|
||||
|
@ -91,7 +133,6 @@ UkuiMenuExtension {
|
|||
Behavior on scale {
|
||||
NumberAnimation { duration: 300; easing.type: Easing.InOutCubic }
|
||||
}
|
||||
|
||||
AppControls2.IconLabel {
|
||||
height: icon.height
|
||||
width: icon.width - 14
|
||||
|
|
Loading…
Reference in New Issue