最近文件添加滑动条和文字超出折叠

This commit is contained in:
gjq 2023-02-14 10:09:55 +08:00 committed by hewenfei
parent 015186df71
commit 86a8b6387d
1 changed files with 67 additions and 40 deletions

View File

@ -17,6 +17,7 @@
*/
import QtQuick 2.0
import QtQuick.Controls 2.5
import org.ukui.menu.extension 1.0
import AppControls2 1.0 as AppControls2
@ -26,56 +27,82 @@ UkuiMenuExtension {
extensionData.recentFilesModel.updateData()
}
ListView {
id: recentFileView
Item {
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 6
spacing: 4
delegate: AppControls2.StyleBackground {
width: parent.width
height: 40
useStyleTransparent: false
alpha: itemArea.pressed ? 1 : itemArea.hovered ? 0.4 : 0
MouseArea {
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: {
Row {
anchors.fill: parent
anchors.leftMargin: 4
spacing: 12
Image {
width: 32
height: 32
anchors.verticalCenter: parent.verticalCenter
source: model.icon
if (containsMouse) {
scrollBar.visible = true
}
AppControls2.StyleText {
width: parent.width - x
height: 20
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
text: model.name
else {
scrollBar.visible = false
}
}
MouseArea {
id: itemArea
property bool hovered
ListView {
id: recentFileView
anchors.fill: parent
hoverEnabled: true
onEntered: {
hovered = true
anchors.leftMargin: 12
spacing: 4
ScrollBar.vertical: AppControls2.ScrollBar {
id: scrollBar
visible: false
width: 14
height: recentFileView.height
}
onExited: {
hovered = false
}
onClicked: {
var data = {
"url": model.uri
delegate: AppControls2.StyleBackground {
width: parent.width - 18
height: 40
useStyleTransparent: false
alpha: itemArea.pressed ? 1 : itemArea.hovered ? 0.65 : 0
radius: 8
Row {
anchors.fill: parent
anchors.leftMargin: 4
spacing: 12
Image {
width: 32
height: 32
anchors.verticalCenter: parent.verticalCenter
source: model.icon
}
AppControls2.StyleText {
width: parent.width - x
height: 20
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
text: model.name
elide: Text.ElideRight
}
}
MouseArea {
id: itemArea
property bool hovered
anchors.fill: parent
hoverEnabled: true
onEntered: {
hovered = true
}
onExited: {
hovered = false
}
onClicked: {
var data = {
"url": model.uri
}
send(data)
}
}
send(data)
}
}
}