完善排序菜单UI显示和动画
This commit is contained in:
parent
c77c00b4c9
commit
ed7966461c
|
@ -8,15 +8,16 @@ MouseArea {
|
||||||
|
|
||||||
StyleBackground {
|
StyleBackground {
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
paletteRole: Palette.Text
|
paletteRole: mainWindow.isFullScreen ? Palette.Light : Palette.Text
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: height / 2
|
radius: height / 2
|
||||||
alpha: buttonMouseArea.containsPress ? 0.17 : buttonMouseArea.containsMouse ? 0.12 : 0.06
|
alpha: buttonMouseArea.containsPress ? 0.20 : buttonMouseArea.containsMouse ? 0.16 : 0.10
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeIcon {
|
ThemeIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: 16; height: width
|
width: 16; height: width
|
||||||
source: buttonIcon
|
source: buttonIcon
|
||||||
|
highLight: mainWindow.isFullScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
@ -10,15 +28,15 @@ RowLayout {
|
||||||
id: pluginSelectMenuRoot
|
id: pluginSelectMenuRoot
|
||||||
property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
AppControls2.RoundButton {
|
AppControls2.RoundButton {
|
||||||
id: pluginSelectButton
|
id: pluginSelectButton
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: height
|
Layout.maximumWidth: height
|
||||||
|
|
||||||
buttonIcon: "image://appicon/ukui-selected"
|
buttonIcon: "image://appicon/ukui-selected"
|
||||||
onClicked: {
|
onClicked: pluginSelectMenuRoot.model.autoSwitchProvider();
|
||||||
pluginSelectMenuRoot.model.autoSwitchProvider();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -29,21 +47,69 @@ RowLayout {
|
||||||
Layout.maximumHeight: 16
|
Layout.maximumHeight: 16
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
sortMenu.popup();
|
if(sortMenuSelector.state === "sortMenuClose") {
|
||||||
|
sortMenuSelector.state = "sortMenuOpen"
|
||||||
|
} else {
|
||||||
|
sortMenuSelector.state = "sortMenuClose"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
ThemeIcon {
|
||||||
id: sortMenuSelector
|
id: sortMenuSelector
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: "image://appicon/ukui-down.symbolic"
|
source: "image://appicon/ukui-up-symbolic"
|
||||||
|
opacity: 0.5
|
||||||
|
highLight: mainWindow.isFullScreen
|
||||||
|
state: "sortMenuClose"
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "sortMenuOpen"
|
||||||
|
PropertyChanges { target: sortMenuSelector; rotation: 0 }
|
||||||
|
PropertyChanges { target: sortMenu; visible: true }
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "sortMenuClose"
|
||||||
|
PropertyChanges { target: sortMenuSelector; rotation: 180 }
|
||||||
|
PropertyChanges { target: sortMenu; visible: false }
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
to: "sortMenuOpen"
|
||||||
|
RotationAnimation { duration: 300; direction: RotationAnimation.Counterclockwise}
|
||||||
|
},
|
||||||
|
Transition {
|
||||||
|
to: "sortMenuClose"
|
||||||
|
RotationAnimation { duration: 300; direction: RotationAnimation.Clockwise }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: sortMenu
|
id: sortMenu
|
||||||
width: 128
|
width: 128; height: 120
|
||||||
height: 120
|
|
||||||
padding: 8
|
padding: 8
|
||||||
clip: true
|
clip: true
|
||||||
|
opacity: visible
|
||||||
|
x: parent.width - width
|
||||||
|
|
||||||
|
enter: Transition {
|
||||||
|
ParallelAnimation {
|
||||||
|
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
|
||||||
|
NumberAnimation { property: "y"; from: pluginSelectButton.height - 20; to: pluginSelectButton.height }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
exit: Transition {
|
||||||
|
ParallelAnimation {
|
||||||
|
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
|
||||||
|
NumberAnimation { property: "y"; from: pluginSelectButton.height; to: pluginSelectButton.height - 20 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClosed: sortMenuSelector.state = "sortMenuClose"
|
||||||
|
|
||||||
// TODO 添加边框阴影
|
// TODO 添加边框阴影
|
||||||
background: AppControls2.StyleBackground {
|
background: AppControls2.StyleBackground {
|
||||||
|
@ -60,9 +126,10 @@ RowLayout {
|
||||||
width: ListView.view ? ListView.view.width : 0
|
width: ListView.view ? ListView.view.width : 0
|
||||||
height: 32
|
height: 32
|
||||||
radius: 4
|
radius: 4
|
||||||
alpha: (model.isChecked || mouseArea.isHoverd) ? 0.2 : 1
|
alpha: mouseArea.containsMouse ? 0.2 : 1
|
||||||
paletteRole: (model.isChecked || mouseArea.isHoverd) ? Palette.Text : Palette.Window
|
paletteRole: mouseArea.containsMouse ? Palette.Text : Palette.Window
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
|
opacity: sortMenu.opacity
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -87,19 +154,12 @@ RowLayout {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
property bool isHoverd: false
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (model.isChecked) {
|
if (model.isChecked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
appPageHeaderUtils.activateProvider(model.id);
|
appPageHeaderUtils.activateProvider(model.id);
|
||||||
}
|
}
|
||||||
onEntered: {
|
|
||||||
isHoverd = true;
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
isHoverd = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,14 +176,6 @@ RowLayout {
|
||||||
function updateProviderIcon() {
|
function updateProviderIcon() {
|
||||||
pluginSelectButton.buttonIcon = pluginSelectMenuRoot.model.currentProviderIcon();
|
pluginSelectButton.buttonIcon = pluginSelectMenuRoot.model.currentProviderIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
|
||||||
sortMenuSelector.source = "image://appicon/ukui-up.symbolic";
|
|
||||||
}
|
|
||||||
|
|
||||||
onClosed: {
|
|
||||||
sortMenuSelector.source = "image://appicon/ukui-down.symbolic";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue