feat(qml):实现搜索框默认激活功能、右键菜单和拖拽失焦时功能
This commit is contained in:
parent
e41f971254
commit
37a1773519
|
@ -80,7 +80,10 @@ AppListView {
|
|||
return;
|
||||
}
|
||||
}
|
||||
onPressed: grabImage();
|
||||
onPressed: {
|
||||
normalUI.focus = false;
|
||||
grabImage();
|
||||
}
|
||||
}
|
||||
|
||||
function grabImage() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.ukui.menu.utils 1.0
|
|||
Item {
|
||||
property Item focusToPageContent
|
||||
property bool inputStatus: false
|
||||
property alias searchInputBar: searchInputBar
|
||||
|
||||
SearchInputBar {
|
||||
id: searchInputBar
|
||||
|
@ -32,9 +33,9 @@ Item {
|
|||
}
|
||||
|
||||
function changeToSearch(keyEvent) {
|
||||
if (header.content === null) {
|
||||
// if (header.content === null) {
|
||||
searchInputBar.text = keyEvent;
|
||||
searchInputBar.textInputFocus();
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,9 +99,12 @@ ListView {
|
|||
}
|
||||
|
||||
drag.target: appItem
|
||||
onPressed: grabToImage(function(result) {
|
||||
onPressed: {
|
||||
fullScreenUI.focus = false;
|
||||
grabToImage(function(result) {
|
||||
Drag.imageSource = result.url
|
||||
})
|
||||
}
|
||||
Drag.supportedActions: Qt.CopyAction
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.active: appItem.drag.active
|
||||
|
|
|
@ -9,7 +9,23 @@ import AppControls2 1.0 as AppControls2
|
|||
import org.ukui.quick.items 1.0 as UkuiItems
|
||||
import org.ukui.quick.platform 1.0 as Platform
|
||||
|
||||
FocusScope {
|
||||
id: fullScreenUI
|
||||
|
||||
Component.onCompleted: {
|
||||
forceFocus();
|
||||
mainWindow.visibleChanged.connect(forceFocus);
|
||||
}
|
||||
Component.onDestruction: {
|
||||
mainWindow.visibleChanged.disconnect(forceFocus);
|
||||
}
|
||||
|
||||
function forceFocus() {
|
||||
fullScreenUI.focus = true;
|
||||
}
|
||||
|
||||
UkuiItems.StyleBackground {
|
||||
anchors.fill: parent
|
||||
paletteRole: Platform.Theme.Dark
|
||||
|
||||
MouseArea {
|
||||
|
@ -20,7 +36,6 @@ UkuiItems.StyleBackground {
|
|||
} else {
|
||||
if (mainContainer.visible) {
|
||||
//执行全屏退出操作
|
||||
forceActiveFocus();
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
folderLoader.isFolderOpened = false;
|
||||
|
@ -246,3 +261,6 @@ UkuiItems.StyleBackground {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,16 @@ import org.ukui.quick.items 1.0 as UkuiItems
|
|||
FocusScope {
|
||||
id: normalUI
|
||||
|
||||
function focusToFalse() {
|
||||
focus = false;
|
||||
Component.onCompleted: {
|
||||
forceFocus();
|
||||
mainWindow.visibleChanged.connect(forceFocus);
|
||||
}
|
||||
Component.onDestruction: {
|
||||
mainWindow.visibleChanged.disconnect(forceFocus);
|
||||
}
|
||||
|
||||
function forceFocus() {
|
||||
normalUI.focus = true;
|
||||
}
|
||||
function keyPressed(event) {
|
||||
// 任意字符键焦点切换到搜索(0-9 a-z)
|
||||
|
@ -23,17 +31,6 @@ FocusScope {
|
|||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: mainWindow.visibleChanged.connect(focusToFalse)
|
||||
Component.onDestruction: mainWindow.visibleChanged.disconnect(focusToFalse)
|
||||
|
||||
// 点击空白处失去焦点
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
normalUI.focusToFalse();
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
|
|
@ -31,13 +31,6 @@ UkuiItems.StyleBackground {
|
|||
radius: childrenRect.width / 2
|
||||
alpha: 0.06
|
||||
|
||||
|
||||
function resetFocus() {
|
||||
if(!mainWindow.isFullScreen) {
|
||||
normalUI.focusToFalse();
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: pluginSortButtonRoot
|
||||
property int currentId: 0
|
||||
|
@ -67,7 +60,6 @@ UkuiItems.StyleBackground {
|
|||
background.alpha: parent.currentId === 0 ? 0.7 : 0
|
||||
|
||||
onClicked: {
|
||||
resetFocus();
|
||||
pluginSortButtonRoot.model.changeProvider(0);
|
||||
}
|
||||
Keys.onPressed: {
|
||||
|
@ -95,7 +87,6 @@ UkuiItems.StyleBackground {
|
|||
background.alpha: parent.currentId === 1 ? 0.7 : 0
|
||||
|
||||
onClicked: {
|
||||
resetFocus();
|
||||
pluginSortButtonRoot.model.changeProvider(1);
|
||||
}
|
||||
Keys.onPressed: {
|
||||
|
|
|
@ -34,7 +34,6 @@ UkuiItems.StyleBackground {
|
|||
border.width: 1
|
||||
borderAlpha: textInput.activeFocus ? 1 : 0.1
|
||||
borderColor: textInput.activeFocus ? Platform.Theme.Highlight : Platform.Theme.Base
|
||||
|
||||
Component.onCompleted: mainWindow.visibleChanged.connect(clear)
|
||||
Component.onDestruction: mainWindow.visibleChanged.disconnect(clear)
|
||||
function textInputFocus() {
|
||||
|
@ -46,8 +45,8 @@ UkuiItems.StyleBackground {
|
|||
Item {
|
||||
id: defaultSearch
|
||||
width: searchIcon.width + defaultText.contentWidth; height: parent.height
|
||||
anchors.horizontalCenter: mainWindow.isFullScreen ? parent.horizontalCenter : undefined
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
|
||||
Item {
|
||||
id: searchIcon
|
||||
|
@ -75,19 +74,6 @@ UkuiItems.StyleBackground {
|
|||
verticalAlignment: TextInput.AlignVCenter
|
||||
alpha: 0.25
|
||||
}
|
||||
|
||||
states: State {
|
||||
when: !mainWindow.isFullScreen || textInput.text !== "" || textInput.activeFocus
|
||||
AnchorChanges {
|
||||
target: defaultSearch
|
||||
anchors.left: parent.left
|
||||
anchors.horizontalCenter: undefined
|
||||
}
|
||||
}
|
||||
|
||||
transitions: Transition {
|
||||
AnchorAnimation { duration: 300; easing.type: Easing.InOutCubic }
|
||||
}
|
||||
}
|
||||
|
||||
TextInput {
|
||||
|
@ -99,29 +85,21 @@ UkuiItems.StyleBackground {
|
|||
selectByMouse: true
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
font.pointSize: defaultText.font.pointSize
|
||||
focus: parent.visible || mainWindow.isFullScreen
|
||||
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
|
||||
function changeFocusToListView() {
|
||||
if (!mainWindow.isFullScreen) {
|
||||
normalUI.focus = true;
|
||||
changeFocusTarget.focus = true;
|
||||
appPage.content.resetFocus();
|
||||
} else {
|
||||
if (text !== "") {
|
||||
fullScreenContent.viewFocusEnable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Keys.onDownPressed: changeFocusToListView()
|
||||
Keys.onReturnPressed: changeFocusToListView()
|
||||
|
||||
//字体选中跟随主题高亮
|
||||
property bool isFullScreen: mainWindow.isFullScreen
|
||||
onIsFullScreenChanged: updateTextInputColor()
|
||||
|
||||
function updateTextInputColor() {
|
||||
color = isFullScreen ? Platform.Theme.highlightedText() : Platform.Theme.text();
|
||||
color = Platform.Theme.text();
|
||||
selectionColor = Platform.Theme.highlight();
|
||||
}
|
||||
|
||||
|
@ -138,18 +116,16 @@ UkuiItems.StyleBackground {
|
|||
anchors.right: parent.right
|
||||
anchors.rightMargin: (parent.height - height) / 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 18; height: width
|
||||
visible: textInput.activeFocus
|
||||
width: 32; height: width
|
||||
background.radius: width / 2
|
||||
visible: textInput.length !== 0
|
||||
activeFocusOnTab: false
|
||||
|
||||
background.radius: width/2
|
||||
background.border.width: 1
|
||||
icon.source: "edit-clear-symbolic"
|
||||
icon.mode: UkuiItems.Icon.AutoHighlight
|
||||
|
||||
onClicked: {
|
||||
textInput.clear();
|
||||
textInput.focus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,6 @@ Item {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
normalUI.focusToFalse();
|
||||
widgetList.currentIndex = model.index;
|
||||
EventTrack.sendClickEvent("switch_plugin", "Sidebar", {"plugin": model.name});
|
||||
}
|
||||
|
|
|
@ -90,10 +90,21 @@ UkuiItems.StyleBackground {
|
|||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
|
||||
onClicked: {
|
||||
if (mainWindow.isFullScreen) {
|
||||
fullScreenUI.focus =false;
|
||||
} else {
|
||||
normalUI.focus = false;
|
||||
}
|
||||
|
||||
itemLoader.item.itemClicked(mouse.button);
|
||||
}
|
||||
onPressAndHold: {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (mainWindow.isFullScreen) {
|
||||
fullScreenUI.focus =false;
|
||||
} else {
|
||||
normalUI.focus = false;
|
||||
}
|
||||
drag.target = itemLoader;
|
||||
iconItem.hold = true;
|
||||
favoriteView.exchangedStartIndex = itemLoader.visualIndex;
|
||||
|
|
|
@ -35,6 +35,7 @@ UkuiMenuExtension {
|
|||
|
||||
onClicked: {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
normalUI.focus = false;
|
||||
menu.open();
|
||||
} else {
|
||||
if (mainWindow.editMode) {
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.ukui.quick.platform 1.0 as Platform
|
|||
Item {
|
||||
id: root
|
||||
clip: true
|
||||
|
||||
property int animationDuration: menuSetting.get("animationDuration")
|
||||
property double transparency: mainWindow.transparency
|
||||
property bool onComlpeted: false
|
||||
|
@ -224,6 +223,7 @@ Item {
|
|||
Loader {
|
||||
id: normalScreenLoader
|
||||
focus: !mainWindow.isFullScreen
|
||||
active: false
|
||||
height: normalScreenGeometry.normalGeometry.height; width: normalScreenGeometry.normalGeometry.width
|
||||
sourceComponent: normalComponent
|
||||
NumberAnimation { id: normalShow; target: normalScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
||||
|
@ -240,6 +240,7 @@ Item {
|
|||
Loader {
|
||||
id: fullScreenLoader
|
||||
anchors.fill: parent
|
||||
focus: mainWindow.isFullScreen
|
||||
sourceComponent: fullSceenComponent
|
||||
NumberAnimation { id: fullShow; target: fullScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
||||
NumberAnimation { id: fullHide; target: fullScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
||||
|
|
Loading…
Reference in New Issue