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

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