75 lines
2.4 KiB
QML
75 lines
2.4 KiB
QML
|
/*
|
||
|
* 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.12
|
||
|
import QtQuick.Controls 2.12
|
||
|
import org.ukui.quick.items 1.0 as UkuiItems
|
||
|
import org.ukui.quick.platform 1.0 as Platform
|
||
|
|
||
|
UkuiItems.StyleBackground {
|
||
|
id: root
|
||
|
property alias count: actionsRepeater.count
|
||
|
property alias actions: actionsRepeater.model
|
||
|
property alias spacing: mainLayout.spacing
|
||
|
property int maring: 2
|
||
|
|
||
|
width: count > 0 ? (childrenRect.width + maring*2) : 0
|
||
|
|
||
|
useStyleTransparency: false
|
||
|
paletteRole: Platform.Theme.Text
|
||
|
radius: height/2
|
||
|
alpha: 0.06
|
||
|
|
||
|
Row {
|
||
|
id: mainLayout
|
||
|
width: childrenRect.width
|
||
|
height: parent.height - maring*2
|
||
|
x: root.maring; y: root.maring
|
||
|
spacing: 2
|
||
|
|
||
|
Repeater {
|
||
|
id: actionsRepeater
|
||
|
delegate: Component {
|
||
|
UkuiItems.Button {
|
||
|
width: height
|
||
|
height: parent.height
|
||
|
|
||
|
ToolTip.delay: 500
|
||
|
ToolTip.text: modelData.toolTip
|
||
|
ToolTip.visible: modelData.toolTip !== "" && containsMouse
|
||
|
|
||
|
background.radius: width / 2
|
||
|
background.alpha: modelData.checked ? 0.75 : containsMouse ? 0.4 : 0
|
||
|
icon.source: modelData.icon
|
||
|
icon.mode: UkuiItems.Icon.AutoHighlight
|
||
|
|
||
|
onClicked: {
|
||
|
// 执行action
|
||
|
modelData.trigger();
|
||
|
}
|
||
|
Keys.onPressed: {
|
||
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||
|
pluginSortButtonRoot.model.changeProvider(0);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|