mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
feat(album_contents): add ScrollView
This commit is contained in:
+106
-101
@@ -55,9 +55,8 @@ Item {
|
|||||||
albumContentsModel.clear()
|
albumContentsModel.clear()
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
console.log("item",item)
|
|
||||||
albumContentsModel.append({
|
albumContentsModel.append({
|
||||||
fileName : "wtf",
|
fileName : item,
|
||||||
filePath : item,
|
filePath : item,
|
||||||
thumbVersion : 0,
|
thumbVersion : 0,
|
||||||
selected : false
|
selected : false
|
||||||
@@ -84,120 +83,126 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GridView {
|
ScrollView {
|
||||||
id: gallery
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
interactive: true
|
Item {
|
||||||
clip: true
|
width: parent.width
|
||||||
cellWidth: 250
|
height: parent.height
|
||||||
cellHeight: 250
|
|
||||||
acceptedButtons : Qt.NoButton
|
|
||||||
model: albumContentsModel
|
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
GridView {
|
||||||
width: 250
|
id: gallery
|
||||||
height: 250
|
|
||||||
highlighted: selected
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onDoubleClicked: {
|
cellWidth: 250
|
||||||
const comp = Qt.createComponent("PreviewWindow.qml")
|
cellHeight: 250
|
||||||
|
model: albumContentsModel
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
width: 250
|
||||||
|
height: 250
|
||||||
|
highlighted: selected
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onDoubleClicked: {
|
||||||
|
const comp = Qt.createComponent("PreviewWindow.qml")
|
||||||
|
|
||||||
|
if (comp.status === Component.Ready) {
|
||||||
|
const win = comp.createObject(null,{
|
||||||
|
filePath,
|
||||||
|
udid : root.udid
|
||||||
|
})
|
||||||
|
if (win !== null) {
|
||||||
|
win.show()
|
||||||
|
} else {
|
||||||
|
console.error("createObject failed:", comp.errorString())
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (comp.status === Component.Error) {
|
||||||
|
console.error("Component failed to load:", comp.errorString())
|
||||||
|
}
|
||||||
|
|
||||||
if (comp.status === Component.Ready) {
|
|
||||||
const win = comp.createObject(null,{
|
|
||||||
filePath,
|
|
||||||
udid : root.udid
|
|
||||||
})
|
|
||||||
if (win !== null) {
|
|
||||||
win.show()
|
|
||||||
} else {
|
|
||||||
console.error("createObject failed:", comp.errorString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (comp.status === Component.Error) {
|
|
||||||
console.error("Component failed to load:", comp.errorString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
Rectangle {
|
||||||
}
|
anchors.fill: parent
|
||||||
|
color: selected ? "#4FC3F7" : "transparent"
|
||||||
|
opacity : 0.3
|
||||||
|
z : 1
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Image {
|
||||||
anchors.fill: parent
|
cache: false
|
||||||
color: selected ? "#4FC3F7" : "transparent"
|
anchors.fill: parent
|
||||||
opacity : 0.3
|
//FIXME:use encodeuricomp
|
||||||
z : 1
|
source: "image://thumb/" + filePath + "?udid=" + root.udid + "&index=" + index + "&v=" + thumbVersion
|
||||||
}
|
fillMode: Image.PreserveAspectFit
|
||||||
|
}
|
||||||
|
|
||||||
Image {
|
Text {
|
||||||
cache: false
|
anchors.bottom: parent.bottom
|
||||||
anchors.fill: parent
|
anchors.left: parent.left
|
||||||
//FIXME:use encodeuricomp
|
anchors.right: parent.right
|
||||||
source: "image://thumb/" + filePath + "?udid=" + root.udid + "&index=" + index + "&v=" + thumbVersion
|
text: fileName
|
||||||
fillMode: Image.PreserveAspectFit
|
font.pixelSize: 10
|
||||||
}
|
color: "white"
|
||||||
|
elide: Text.ElideMiddle
|
||||||
Text {
|
}
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
text: fileName
|
|
||||||
font.pixelSize: 10
|
|
||||||
color: "white"
|
|
||||||
elide: Text.ElideMiddle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//rubber band
|
|
||||||
Item {
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: selectionRect
|
|
||||||
color: "transparent"
|
|
||||||
border.color: "blue"
|
|
||||||
border.width: 1
|
|
||||||
visible: false
|
|
||||||
|
|
||||||
opacity: 0.3
|
|
||||||
Rectangle { anchors.fill: parent; color: "blue"; opacity: 0.2 }
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
property point startPos
|
|
||||||
|
|
||||||
propagateComposedEvents: true
|
|
||||||
|
|
||||||
onPressed: (mouse) => {
|
|
||||||
// mouse.accepted = false
|
|
||||||
startPos = Qt.point(mouse.x, mouse.y)
|
|
||||||
selectionRect.x = startPos.x
|
|
||||||
selectionRect.y = startPos.y
|
|
||||||
selectionRect.width = 0
|
|
||||||
selectionRect.height = 0
|
|
||||||
selectionRect.visible = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChanged: {
|
}
|
||||||
selectionRect.x = Math.min(mouse.x, startPos.x)
|
//rubber band
|
||||||
selectionRect.y = Math.min(mouse.y, startPos.y)
|
Item {
|
||||||
selectionRect.width = Math.abs(mouse.x - startPos.x)
|
anchors.fill: parent
|
||||||
selectionRect.height = Math.abs(mouse.y - startPos.y)
|
|
||||||
|
Rectangle {
|
||||||
|
id: selectionRect
|
||||||
|
color: "transparent"
|
||||||
|
border.color: "blue"
|
||||||
|
border.width: 1
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
opacity: 0.3
|
||||||
|
Rectangle { anchors.fill: parent; color: "blue"; opacity: 0.2 }
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
MouseArea {
|
||||||
selectionRect.visible = false
|
id: mouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
property point startPos
|
||||||
|
|
||||||
|
propagateComposedEvents: true
|
||||||
|
|
||||||
const append = mouse.modifiers & Qt.ControlModifier
|
onPressed: (mouse) => {
|
||||||
|
// mouse.accepted = false
|
||||||
|
startPos = Qt.point(mouse.x, mouse.y)
|
||||||
|
selectionRect.x = startPos.x
|
||||||
|
selectionRect.y = startPos.y
|
||||||
|
selectionRect.width = 0
|
||||||
|
selectionRect.height = 0
|
||||||
|
selectionRect.visible = true
|
||||||
|
}
|
||||||
|
|
||||||
selectItemsInRect({
|
onPositionChanged: {
|
||||||
x: selectionRect.x,
|
selectionRect.x = Math.min(mouse.x, startPos.x)
|
||||||
y: selectionRect.y,
|
selectionRect.y = Math.min(mouse.y, startPos.y)
|
||||||
width: selectionRect.width,
|
selectionRect.width = Math.abs(mouse.x - startPos.x)
|
||||||
height: selectionRect.height
|
selectionRect.height = Math.abs(mouse.y - startPos.y)
|
||||||
}, append)
|
}
|
||||||
|
|
||||||
|
onReleased: {
|
||||||
|
selectionRect.visible = false
|
||||||
|
|
||||||
|
const append = mouse.modifiers & Qt.ControlModifier
|
||||||
|
|
||||||
|
selectItemsInRect({
|
||||||
|
x: selectionRect.x,
|
||||||
|
y: selectionRect.y,
|
||||||
|
width: selectionRect.width,
|
||||||
|
height: selectionRect.height
|
||||||
|
}, append)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user