Commit f48a791d authored by Camilo Higuita's avatar Camilo Higuita

use listview for viewer browsing close #30

parent 749a2a95
......@@ -9,5 +9,7 @@
<file>assets/album_bg_normal.png</file>
<file>assets/banner.png</file>
<file>assets/album.svg</file>
<file>assets/image-x-generic.svg</file>
</qresource>
<qresource prefix="/"/>
</RCC>
This diff is collapsed.
......@@ -52,5 +52,6 @@
<file>widgets/PicMenu.qml</file>
<file>widgets/views/Search/SearchView.qml</file>
<file>widgets/custom/SelectionBox/SelectionBox.qml</file>
<file>widgets/views/Viewer/ViewerDelegate.qml</file>
</qresource>
</RCC>
......@@ -85,7 +85,7 @@ ItemDelegate
fillMode: fit ? Image.PreserveAspectFit : Image.PreserveAspectCrop
source: (url && url.length>0)?
"file://"+encodeURIComponent(url) :
"qrc:/../assets/face.png"
"qrc:/img/assets/image-x-generic.svg"
asynchronous: true
Rectangle
......@@ -123,11 +123,11 @@ ItemDelegate
Layout.fillHeight: showLabel
Layout.fillWidth: true
Layout.maximumHeight: !showLabel ? 0 : parent.height * (isMobile? 0.5 : 0.3)
visible: showLabel
Label
{
text: title
visible: showLabel
width: parent.width
height: parent.height * 0.8
horizontalAlignment: Qt.AlignHCenter
......
......@@ -33,10 +33,10 @@ Item
width: parent.width* 0.9
height: parent.height * 0.9
anchors.centerIn: parent
currentIndex: currentPicIndex
orientation: ListView.Horizontal
clip: true
spacing: space.tiny
spacing: space.small
focus: true
interactive: true
......@@ -47,9 +47,9 @@ Item
{
id: delegate
picSize: rollPicSize
height: rollPicSize
width: rollPicSize
anchors.verticalCenter: parent.verticalCenter
picRadius: 0
showLabel: false
......
......@@ -15,7 +15,6 @@ PixPage
property bool currentPicFav: false
property var currentPic : ({})
property var picContext : []
property int currentPicIndex : 0
property bool tagBarVisible : pix.loadSettings("TAGBAR", "PIX", true) === "true" ? true : false
......@@ -98,7 +97,7 @@ PixPage
id: holder
message: "<h2>No Pic!</h2><p>Open an image from your collection</p>"
emoji: "qrc:/img/assets/face-hug.png"
visible: Object.keys(currentPic).length === 0
visible: viewer.list.count === 0
foregroundColor: viewerForegroundColor
}
......@@ -136,5 +135,5 @@ PixPage
anchors.bottom: parent.bottom
onPicClicked: VIEWER.view(index)
}
}
}
}
......@@ -4,11 +4,9 @@
function open(model, index)
{
pixViewer.currentPicIndex = index
pixViewer.picContext = model
pixViewer.roll.populate(pixViewer.picContext)
view(pixViewer.currentPicIndex)
pixViewer.roll.populate(model)
pixViewer.viewer.populate(model)
view(index)
if(currentView !== views.viewer)
currentView = views.viewer
......@@ -17,12 +15,15 @@ function open(model, index)
function view(index)
{
pixViewer.currentPic = pixViewer.picContext[index]
pixViewer.currentPicIndex = index
pixViewer.currentPic = pixViewer.viewer.list.model.get(pixViewer.currentPicIndex)
pixViewer.currentPicFav = pix.isFav(pixViewer.currentPic.url)
pixViewer.tagBar.tagsList.populate(Q.Query.picTags_.arg(pixViewer.currentPic.url))
root.title = pixViewer.currentPic.title
pixViewer.roll.position(index)
pixViewer.roll.position(pixViewer.currentPicIndex)
}
function fullscreen(state)
......@@ -32,9 +33,9 @@ function fullscreen(state)
function next()
{
if(pixViewer.picContext && pixViewer.picContext.length > 0)
if(pixViewer.viewer.list.count > 0)
{
if(pixViewer.currentPicIndex < pixViewer.picContext.length)
if(pixViewer.currentPicIndex < pixViewer.viewer.list.count)
pixViewer.currentPicIndex++
else
pixViewer.currentPicIndex = 0
......@@ -45,12 +46,12 @@ function next()
function previous()
{
if(pixViewer.picContext && pixViewer.picContext.length > 0)
if(pixViewer.viewer.list.count > 0)
{
if(pixViewer.currentPicIndex > 0)
pixViewer.currentPicIndex--
else
pixViewer.currentPicIndex = pixViewer.picContext.length-1
pixViewer.currentPicIndex = pixViewer.viewer.list.count-1
view(pixViewer.currentPicIndex)
}
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
import "../../"
import "Viewer.js" as VIEWER
Item
{
......@@ -13,79 +13,51 @@ Item
property real picHue : 0
property real picLightness : 0
property alias list : viewerList
clip: true
Image
ListView
{
id: pic
anchors.centerIn: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
id: viewerList
height: parent.height
width: parent.width
source: "file://"+currentPic.url
fillMode: Image.PreserveAspectFit
cache: true
asynchronous: true
MouseArea
orientation: ListView.Horizontal
currentIndex: currentPicIndex
clip: true
focus: true
interactive: true
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
snapMode: ListView.SnapOneItem
onMovementEnded:
{
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: galleryRoll.visible = !galleryRoll.visible
onPressAndHold: picMenu.show(currentPic.url)
onWheel: wheel.angleDelta.y > 0 ? zoomIn() : zoomOut()
onClicked: if(!isMobile && mouse.button === Qt.RightButton)
picMenu.show(currentPic.url)
var index = indexAt(contentX, contentY)
if(index !== currentPicIndex)
VIEWER.view(index)
}
// BrightnessContrast
// {
// anchors.fill: pic
// source: pic
// brightness: picBrightness
// contrast: picContrast
// }
// HueSaturation
// {
// anchors.fill: pic
// source: pic
// hue: picHue
// saturation: picSaturation
// lightness: picLightness
// }
}
function zoomIn()
{
pic.width = pic.width + 50
}
model : ListModel{}
function zoomOut()
{
pic.width = pic.width - 50
}
function fit()
{
pic.width = pic.sourceSize.width
}
delegate: ViewerDelegate
{
id: delegate
itemHeight: viewerList.height
itemWidth: viewerList.width
function fill()
{
pic.width = parent.width
}
}
function rotateLeft()
{
pic.rotation = pic.rotation - 90
}
function rotateRight()
function populate(pics)
{
pic.rotation = pic.rotation + 90
viewerList.model.clear()
if(pics.length > 0)
for(var i in pics)
{
console.log("Appending to viewer", pics[i].url)
viewerList.model.append(pics[i])
}
}
}
import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
ItemDelegate
{
property int itemWidth : parent.width
property int itemHeight : parent.height
height: itemHeight
width: itemWidth
background: Rectangle
{
color: "transparent"
}
Image
{
id: pic
anchors.centerIn: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
width: parent.width
height: parent.height
source: "file://"+url
fillMode: Image.PreserveAspectFit
cache: true
asynchronous: true
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: galleryRoll.visible = !galleryRoll.visible
onPressAndHold: picMenu.show(currentPic.url)
onWheel: wheel.angleDelta.y > 0 ? zoomIn() : zoomOut()
onClicked: if(!isMobile && mouse.button === Qt.RightButton)
picMenu.show(currentPic.url)
}
// BrightnessContrast
// {
// anchors.fill: pic
// source: pic
// brightness: picBrightness
// contrast: picContrast
// }
// HueSaturation
// {
// anchors.fill: pic
// source: pic
// hue: picHue
// saturation: picSaturation
// lightness: picLightness
// }
}
function zoomIn()
{
pic.width = pic.width + 50
}
function zoomOut()
{
pic.width = pic.width - 50
}
function fit()
{
pic.width = pic.sourceSize.width
}
function fill()
{
pic.width = parent.width
}
function rotateLeft()
{
pic.rotation = pic.rotation - 90
}
function rotateRight()
{
pic.rotation = pic.rotation + 90
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment