ukui-menu/qml/extensions/RecentFileExtension.qml

84 lines
2.5 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.0
import org.ukui.menu.extension 1.0
import AppControls2 1.0 as AppControls2
UkuiMenuExtension {
Component.onCompleted: {
recentFileView.model = extensionData.recentFilesModel
extensionData.recentFilesModel.updateData()
}
ListView {
id: recentFileView
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
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
}
}
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)
}
}
}
}
}