You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
6 months ago
|
/******************************************************************
|
||
|
Copyright © Deng Zhimao Co., Ltd. 1990-2030. All rights reserved.
|
||
|
* @projectName photoview
|
||
|
* @brief PhotoListView.qml
|
||
|
* @author Deng Zhimao
|
||
|
* @email 1252699831@qq.com
|
||
|
* @date 2020-07-16
|
||
|
*******************************************************************/
|
||
|
import QtQuick 2.9
|
||
|
import QtQuick.Window 2.2
|
||
|
|
||
|
Item {
|
||
|
// function photoInit(){
|
||
|
// myPhoto.add(WINenv ? qsTr("C:/Users/Administrator/Desktop/img") : qsTr("/home/root/img"))
|
||
|
// }
|
||
|
// Component.onCompleted:{
|
||
|
// photoInit()
|
||
|
// }
|
||
|
|
||
|
// PhotoListView
|
||
|
GridView {
|
||
|
id: photoList
|
||
|
visible: true
|
||
|
anchors.top: parent.top
|
||
|
anchors.left: parent.left
|
||
|
anchors.right: parent.right
|
||
|
anchors.bottom: parent.bottom
|
||
|
focus: true
|
||
|
interactive: true
|
||
|
cellWidth: photoList.width / 4
|
||
|
cellHeight: photoList.width / 4
|
||
|
clip: true
|
||
|
z: 1
|
||
|
model: myPhoto
|
||
|
delegate: Rectangle {
|
||
|
id: itembg
|
||
|
width: photoList.cellWidth
|
||
|
height: photoList.cellWidth
|
||
|
color: "transparent"
|
||
|
Image {
|
||
|
id: photo
|
||
|
source: path
|
||
|
anchors.centerIn: parent
|
||
|
width: parent.height - 10
|
||
|
height: parent.height - 20
|
||
|
smooth: true
|
||
|
fillMode: Image.PreserveAspectFit
|
||
|
anchors.verticalCenter: parent.verticalCenter
|
||
|
}
|
||
|
Text {
|
||
|
id: photoName
|
||
|
width: parent.width
|
||
|
anchors.top: photo.bottom
|
||
|
anchors.horizontalCenter: photo.horizontalCenter
|
||
|
verticalAlignment: Text.AlignVCenter
|
||
|
horizontalAlignment: Text.AlignHCenter
|
||
|
anchors.left: parent.left
|
||
|
text: title
|
||
|
elide: Text.ElideRight
|
||
|
color: parent.ListView.isCurrentItem ? "#27def9" : "white"
|
||
|
font.bold: parent.ListView.isCurrentItem
|
||
|
}
|
||
|
MouseArea {
|
||
|
id:mouserArea
|
||
|
anchors.fill: parent
|
||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||
|
onClicked: {
|
||
|
myPhoto.currentIndex = index
|
||
|
photoSwipeView.currentIndex = 1
|
||
|
currtenPhotoPath = myPhoto.getcurrentPath()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|