fix(AppPage): change the searchbar ui
This commit is contained in:
parent
44a453cbd9
commit
26b436d98a
|
@ -21,6 +21,7 @@ import QtQuick.Layouts 1.12
|
||||||
import org.ukui.menu.core 1.0
|
import org.ukui.menu.core 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
property alias search: appPageSearch
|
||||||
property alias header: appPageHeader
|
property alias header: appPageHeader
|
||||||
property alias content: appPageContent
|
property alias content: appPageContent
|
||||||
|
|
||||||
|
@ -29,13 +30,21 @@ Item {
|
||||||
anchors.topMargin: 12
|
anchors.topMargin: 12
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
AppPageHeader {
|
AppPageSearch {
|
||||||
id: appPageHeader
|
id: appPageSearch
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 40
|
||||||
focusToPageContent: appPageContent
|
focusToPageContent: appPageContent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppPageHeader {
|
||||||
|
id: appPageHeader
|
||||||
|
visible: !appPageSearch.inputStatus
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: 48
|
||||||
|
focusToPageContent: appPageContent
|
||||||
|
}
|
||||||
|
|
||||||
AppPageContent {
|
AppPageContent {
|
||||||
id: appPageContent
|
id: appPageContent
|
||||||
appPageHeader: appPageHeader
|
appPageHeader: appPageHeader
|
||||||
|
|
|
@ -50,78 +50,6 @@ Item {
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
function changeToSearchState(keyEvent) {
|
|
||||||
state = "search";
|
|
||||||
searchInputBar.text = keyEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
state: "normal"
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "normal"
|
|
||||||
PropertyChanges { target: searchBar; scale: 0.9; y: -pluginSelectionBar.height }
|
|
||||||
PropertyChanges { target: pluginSelectionBar; scale: 1.0; y: 0 }
|
|
||||||
StateChangeScript { script: pluginSelectMenu.model.reactivateProvider() }
|
|
||||||
},
|
|
||||||
State {
|
|
||||||
name: "search"
|
|
||||||
PropertyChanges { target: searchBar; scale: 1.0; y: 0 }
|
|
||||||
PropertyChanges { target: pluginSelectionBar; scale: 0.9; y: pluginSelectionBar.height }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
onStateChanged: {
|
|
||||||
if (isLiteMode) {
|
|
||||||
if (state === "search") {
|
|
||||||
setPluginSelectionVisible(false);
|
|
||||||
setSearchBarVisible(true);
|
|
||||||
} else {
|
|
||||||
setPluginSelectionVisible(true);
|
|
||||||
setSearchBarVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setPluginSelectionVisible(vis) {
|
|
||||||
pluginSelectionBar.visible = vis;
|
|
||||||
pluginSelectMenu.visible = vis;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSearchBarVisible(vis) {
|
|
||||||
searchBar.visible = vis;
|
|
||||||
if (vis) {
|
|
||||||
searchInputBar.providerId = "search";
|
|
||||||
searchInputBar.textInputFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
transitions:[
|
|
||||||
Transition {
|
|
||||||
to: "normal"
|
|
||||||
enabled: !isLiteMode
|
|
||||||
SequentialAnimation {
|
|
||||||
ScriptAction {
|
|
||||||
script: { setPluginSelectionVisible(true); }
|
|
||||||
}
|
|
||||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
|
||||||
ScriptAction { script: { setSearchBarVisible(false); } }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Transition {
|
|
||||||
to: "search"
|
|
||||||
enabled: !isLiteMode
|
|
||||||
SequentialAnimation {
|
|
||||||
ScriptAction {
|
|
||||||
script: { setSearchBarVisible(true); }
|
|
||||||
}
|
|
||||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
|
||||||
ScriptAction {
|
|
||||||
script: { setPluginSelectionVisible(false); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: searchBar
|
id: searchBar
|
||||||
width: parent.width; height: 30
|
width: parent.width; height: 30
|
||||||
|
@ -197,41 +125,6 @@ Item {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: searchListView
|
|
||||||
Layout.preferredWidth: childrenRect.width
|
|
||||||
Layout.preferredHeight: 32
|
|
||||||
Layout.minimumWidth: 32
|
|
||||||
Layout.maximumWidth: 68
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
spacing: 4
|
|
||||||
orientation: ListView.Horizontal
|
|
||||||
interactive: false
|
|
||||||
activeFocusOnTab: true
|
|
||||||
|
|
||||||
model: appPageHeaderUtils.model(PluginGroup.Button)
|
|
||||||
delegate: AppControls2.RoundButton {
|
|
||||||
width: height
|
|
||||||
height: ListView.view ? ListView.view.height : 0
|
|
||||||
buttonIcon: model.icon
|
|
||||||
ToolTip.text: qsTr("Search App")
|
|
||||||
ToolTip.delay: 500
|
|
||||||
ToolTip.visible: containsMouse
|
|
||||||
onClicked: {
|
|
||||||
root.state = "search";
|
|
||||||
// 后续添加需求,可以用model数据设置
|
|
||||||
// searchInputBar.providerId = model.id;
|
|
||||||
}
|
|
||||||
Keys.onPressed: {
|
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
|
||||||
root.state = "search";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginSelectMenu {
|
PluginSelectMenu {
|
||||||
id: pluginSelectMenu
|
id: pluginSelectMenu
|
||||||
Layout.preferredWidth: childrenRect.width
|
Layout.preferredWidth: childrenRect.width
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.5
|
||||||
|
import org.ukui.menu.core 1.0
|
||||||
|
import AppControls2 1.0 as AppControls2
|
||||||
|
import org.ukui.menu.utils 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property Item focusToPageContent
|
||||||
|
property bool inputStatus: false
|
||||||
|
id: appPageSearchBar
|
||||||
|
SearchInputBar {
|
||||||
|
id: searchInputBar
|
||||||
|
property string providerId: "search"
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 16
|
||||||
|
anchors.rightMargin: 16
|
||||||
|
radius: 6 //change theme
|
||||||
|
changeFocusTarget: focusToPageContent
|
||||||
|
visible: true
|
||||||
|
onTextChanged: {
|
||||||
|
if (text === "") {
|
||||||
|
appPageHeaderUtils.model(PluginGroup.SortMenuItem).reactivateProvider();
|
||||||
|
inputStatus = false;
|
||||||
|
} else {
|
||||||
|
appPageHeaderUtils.activateProvider(providerId);
|
||||||
|
appPageHeaderUtils.startSearch(text);
|
||||||
|
inputStatus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function changeToSearch(keyEvent) {
|
||||||
|
if (header.content === null) {
|
||||||
|
searchInputBar.text = keyEvent;
|
||||||
|
searchInputBar.textInputFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ Item {
|
||||||
id: searchInputBar
|
id: searchInputBar
|
||||||
width: 372; height: 36
|
width: 372; height: 36
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
radius: height / 2
|
radius: 4 //change theme
|
||||||
visible: opacity
|
visible: opacity
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
|
|
@ -13,7 +13,7 @@ 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(event.text);
|
appPage.search.changeToSearch(event.text);
|
||||||
// 任意方向键切换至应用列表
|
// 任意方向键切换至应用列表
|
||||||
} else if ((0x01000011 < event.key)&&(event.key < 0x01000016)) {
|
} else if ((0x01000011 < event.key)&&(event.key < 0x01000016)) {
|
||||||
focus = true;
|
focus = true;
|
||||||
|
|
|
@ -21,17 +21,18 @@ import QtQuick.Controls 2.5
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import org.ukui.menu.core 1.0
|
import org.ukui.menu.core 1.0
|
||||||
import AppControls2 1.0 as AppControls2
|
import AppControls2 1.0 as AppControls2
|
||||||
|
import org.ukui.quick.items 1.0 as UkuiItems
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
UkuiItems.StyleBackground {
|
||||||
property Item changeFocusTarget
|
property Item changeFocusTarget
|
||||||
property alias text: textInput.text;
|
property alias text: textInput.text;
|
||||||
|
|
||||||
alpha: 0.04
|
alpha: 0.04
|
||||||
useStyleTransparent: false
|
useStyleTransparency: false
|
||||||
paletteRole: Palette.Text
|
paletteRole: UkuiItems.Theme.Text
|
||||||
border.width: 1
|
border.width: 1
|
||||||
borderAlpha: textInput.activeFocus ? 1 : 0.1
|
borderAlpha: textInput.activeFocus ? 1 : 0.1
|
||||||
borderColor: textInput.activeFocus ? Palette.Highlight : Palette.Base
|
borderColor: textInput.activeFocus ? UkuiItems.Theme.Highlight : UkuiItems.Theme.Base
|
||||||
|
|
||||||
Component.onCompleted: mainWindow.visibleChanged.connect(clear)
|
Component.onCompleted: mainWindow.visibleChanged.connect(clear)
|
||||||
Component.onDestruction: mainWindow.visibleChanged.disconnect(clear)
|
Component.onDestruction: mainWindow.visibleChanged.disconnect(clear)
|
||||||
|
@ -57,20 +58,20 @@ AppControls2.StyleBackground {
|
||||||
ThemeIcon {
|
ThemeIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: parent.height / 2; height: width
|
width: parent.height / 2; height: width
|
||||||
source: "image://appicon/search-symbolic"
|
source: "search-symbolic"
|
||||||
highLight: mainWindow.isFullScreen
|
highLight: mainWindow.isFullScreen
|
||||||
autoHighLight: !mainWindow.isFullScreen
|
autoHighLight: !mainWindow.isFullScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AppControls2.StyleText {
|
UkuiItems.StyleText {
|
||||||
id: defaultText
|
id: defaultText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: searchIcon.right
|
anchors.left: searchIcon.right
|
||||||
text: qsTr("Search App")
|
text: qsTr("Search App")
|
||||||
visible: textInput.contentWidth === 0
|
visible: textInput.contentWidth === 0
|
||||||
paletteRole: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
|
paletteRole: mainWindow.isFullScreen ? UkuiItems.Theme.HighlightedText : UkuiItems.Theme.Text
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
alpha: 0.25
|
alpha: 0.25
|
||||||
}
|
}
|
||||||
|
@ -135,10 +136,10 @@ AppControls2.StyleBackground {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: (parent.height - height) / 2
|
anchors.rightMargin: (parent.height - height) / 2
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: mainWindow.isFullScreen && textInput.activeFocus
|
visible: textInput.activeFocus
|
||||||
buttonIcon: "image://appicon/edit-clear-symbolic"
|
buttonIcon: "image://appicon/edit-clear-symbolic"
|
||||||
highlight: true
|
highlight: mainWindow.isFullScreen
|
||||||
autoHighLight: false
|
autoHighLight: !mainWindow.isFullScreen
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
textInput.clear();
|
textInput.clear();
|
||||||
|
|
|
@ -32,5 +32,6 @@
|
||||||
<file>AppUI/PluginSelectMenu.qml</file>
|
<file>AppUI/PluginSelectMenu.qml</file>
|
||||||
<file>AppUI/EditText.qml</file>
|
<file>AppUI/EditText.qml</file>
|
||||||
<file>AppUI/FullScreenFolder.qml</file>
|
<file>AppUI/FullScreenFolder.qml</file>
|
||||||
|
<file>AppUI/AppPageSearch.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in New Issue