2021-05-24 04:01:26 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 CutefishOS Team.
|
|
|
|
*
|
|
|
|
* Author: revenmartin <revenmartin@gmail.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2021-04-05 00:21:39 -07:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-04-09 07:49:19 -07:00
|
|
|
import FishUI 1.0 as FishUI
|
2021-04-21 19:24:10 -07:00
|
|
|
import Cutefish.FileManager 1.0
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: _listItem
|
|
|
|
width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin
|
2021-04-04 08:38:01 -07:00
|
|
|
height: ListView.view.itemHeight
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
Accessible.name: fileName
|
|
|
|
Accessible.role: Accessible.Canvas
|
|
|
|
|
|
|
|
property Item iconArea: _image.visible ? _image : _icon
|
2021-04-01 01:05:15 -07:00
|
|
|
property Item labelArea: _label
|
|
|
|
property Item labelArea2: _label2
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
property int index: model.index
|
|
|
|
property bool hovered: ListView.view.hoveredItem === _listItem
|
|
|
|
property bool selected: model.selected
|
|
|
|
property bool blank: model.blank
|
|
|
|
|
2021-07-24 12:50:15 -07:00
|
|
|
property color hoveredColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 2.3)
|
|
|
|
: Qt.darker(FishUI.Theme.backgroundColor, 1.05)
|
2021-04-09 07:49:19 -07:00
|
|
|
property color selectedColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 1.2)
|
2021-07-24 12:50:15 -07:00
|
|
|
: Qt.darker(FishUI.Theme.backgroundColor, 1.15)
|
2021-03-29 01:51:34 -07:00
|
|
|
// onSelectedChanged: {
|
|
|
|
// if (selected && !blank) {
|
|
|
|
// _listItem.grabToImage(function(result) {
|
|
|
|
// folderModel.addItemDragImage(_listItem.index,
|
|
|
|
// _listItem.x,
|
|
|
|
// _listItem.y,
|
|
|
|
// _listItem.width, _listItem.height, result.image)
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: _background
|
|
|
|
anchors.fill: parent
|
2021-04-09 07:49:19 -07:00
|
|
|
radius: FishUI.Theme.smallRadius
|
|
|
|
color: selected ? FishUI.Theme.highlightColor : hovered ? hoveredColor : "transparent"
|
2021-03-29 01:51:34 -07:00
|
|
|
visible: selected || hovered
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: _mainLayout
|
|
|
|
anchors.fill: parent
|
2021-04-09 07:49:19 -07:00
|
|
|
anchors.leftMargin: FishUI.Units.smallSpacing
|
|
|
|
anchors.rightMargin: FishUI.Units.smallSpacing
|
|
|
|
spacing: FishUI.Units.largeSpacing
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: iconItem
|
|
|
|
Layout.fillHeight: true
|
|
|
|
width: parent.height * 0.8
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: _icon
|
|
|
|
anchors.centerIn: iconItem
|
|
|
|
width: iconItem.width
|
|
|
|
height: width
|
|
|
|
sourceSize.width: width
|
|
|
|
sourceSize.height: height
|
|
|
|
source: "image://icontheme/" + model.iconName
|
|
|
|
visible: !_image.visible
|
|
|
|
asynchronous: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: _image
|
|
|
|
width: parent.height * 0.8
|
|
|
|
height: width
|
|
|
|
anchors.centerIn: iconItem
|
|
|
|
sourceSize: Qt.size(_icon.width, _icon.height)
|
|
|
|
source: model.thumbnail ? model.thumbnail : ""
|
|
|
|
visible: _image.status === Image.Ready
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
asynchronous: true
|
|
|
|
smooth: false
|
2021-07-28 12:30:17 -07:00
|
|
|
cache: false
|
2021-04-05 00:21:39 -07:00
|
|
|
|
|
|
|
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: height * 0.1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-01 01:05:15 -07:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: _label
|
|
|
|
text: model.fileName
|
|
|
|
Layout.fillWidth: true
|
2021-04-09 07:49:19 -07:00
|
|
|
color: selected ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
|
2021-04-01 01:05:15 -07:00
|
|
|
elide: Qt.ElideMiddle
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: _label2
|
|
|
|
text: model.fileSize
|
2021-04-09 07:49:19 -07:00
|
|
|
color: selected ? FishUI.Theme.highlightedTextColor : FishUI.Theme.disabledTextColor
|
2021-04-01 01:05:15 -07:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
Label {
|
2021-04-01 01:05:15 -07:00
|
|
|
text: model.modified
|
2021-04-09 07:49:19 -07:00
|
|
|
color: selected ? FishUI.Theme.highlightedTextColor : FishUI.Theme.disabledTextColor
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|