filemanager/qml/FolderGridItem.qml

108 lines
3.5 KiB
QML
Raw Normal View History

2021-03-29 01:51:34 -07:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0
import Cutefish.FileManager 1.0
import MeuiKit 1.0 as Meui
Item {
id: control
width: GridView.view.cellWidth
height: GridView.view.cellHeight
property Item iconArea: _image.visible ? _image : _icon
property Item textArea: _label
property int index: model.index
property bool hovered: GridView.view.hoveredItem === control
property bool selected: model.selected
property bool blank: model.blank
property var fileName: model.fileName
property color hoveredColor: Meui.Theme.darkMode ? Qt.lighter(Meui.Theme.backgroundColor, 1.1)
: Qt.darker(Meui.Theme.backgroundColor, 1.05)
2021-03-29 01:51:34 -07:00
ColumnLayout {
anchors.fill: parent
anchors.margins: Meui.Units.largeSpacing
spacing: Meui.Units.smallSpacing
Item {
id: _iconItem
2021-03-29 07:53:21 -07:00
Layout.preferredHeight: parent.height * 0.6
2021-03-29 01:51:34 -07:00
Layout.fillWidth: true
Image {
id: _icon
anchors.centerIn: parent
width: parent.height
height: width
sourceSize: Qt.size(width, height)
source: "image://icontheme/" + model.iconName
visible: !_image.visible
}
Image {
id: _image
anchors.centerIn: parent
height: parent.height
width: parent.width
2021-03-29 01:51:34 -07:00
2021-03-29 07:53:21 -07:00
fillMode: Image.PreserveAspectFit
2021-03-29 01:51:34 -07:00
visible: status === Image.Ready
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
sourceSize.width: width
sourceSize.height: height
source: model.thumbnail ? model.thumbnail : ""
asynchronous: true
cache: true
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: _image.width
height: _image.height
Rectangle {
anchors.centerIn: parent
width: Math.min(parent.width, _image.paintedWidth)
height: Math.min(parent.height, _image.paintedHeight)
radius: Meui.Theme.smallRadius
}
}
}
}
}
Item {
id: _labelItem
2021-03-29 01:51:34 -07:00
Layout.fillHeight: true
Layout.preferredHeight: Math.min(_label.implicitHeight, height)
2021-03-29 07:53:21 -07:00
Layout.fillWidth: true
2021-03-29 01:51:34 -07:00
Rectangle {
width: _label.paintedWidth + Meui.Units.smallSpacing * 2
height: _label.paintedHeight
x: (_labelItem.width - width + Meui.Units.smallSpacing) / 2
color: selected ? Meui.Theme.highlightColor : hovered ? hoveredColor : "transparent"
2021-03-29 01:51:34 -07:00
radius: Meui.Theme.smallRadius
}
Label {
id: _label
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignTop
2021-03-29 07:53:21 -07:00
anchors.fill: parent
anchors.margins: 0
2021-03-29 01:51:34 -07:00
elide: Qt.ElideRight
wrapMode: Text.Wrap
text: model.fileName
2021-03-29 07:53:21 -07:00
color: selected ? Meui.Theme.highlightedTextColor : Meui.Theme.textColor
2021-03-29 01:51:34 -07:00
}
}
}
}