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