~verzegnassi-stefano/+junk/docviewer-tmp-001

« back to all changes in this revision

Viewing changes to PdfView.qml

  • Committer: Tarmac
  • Author(s): David Planella, Daniel Holbach, Fabio Colella, Stefano Verzegnassi, Arto Jalkanen
  • Date: 2014-10-29 07:39:08 UTC
  • mfrom: (31.1.22 add-plugin)
  • Revision ID: tarmac-20141029073908-8s6r18syexjo37ga
Adds the file plugin to the source tree.

Approved by Stefano Verzegnassi, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import QtQuick 2.3
2
 
import Ubuntu.Components 1.1
3
 
import org.docviewer.poppler 1.0
4
 
 
5
 
Flickable {
6
 
    id: flickable
7
 
    anchors.fill: parent
8
 
 
9
 
    contentHeight: columnPages.height + 10
10
 
    contentWidth: parent.width
11
 
 
12
 
    PinchArea {
13
 
        id: pinchy
14
 
        anchors.fill: columnPages
15
 
        enabled: true
16
 
        pinch.target: flickable
17
 
 
18
 
        property real lastWidth
19
 
        /*property real lastHeight
20
 
        property double p1toC_X
21
 
        property double p1toC_Y
22
 
        property double contentInitX
23
 
        property double contentInitY*/
24
 
 
25
 
        onPinchStarted: {
26
 
            lastWidth = flickable.width
27
 
 
28
 
            /*contentInitX = flickImg.contentX
29
 
            contentInitY = flickImg.contentY*/
30
 
 
31
 
        }
32
 
 
33
 
        onPinchUpdated: {
34
 
 
35
 
            var newWidth = 0;
36
 
 
37
 
            newWidth = lastWidth*pinch.scale;
38
 
 
39
 
            /*if (newWidth < image.startWidth)
40
 
                newWidth = image.startWidth;
41
 
            else if (newWidth > image.sourceSize.width)
42
 
                newWidth = image.sourceSize.width;*/
43
 
 
44
 
            flickable.contentWidth = newWidth;
45
 
 
46
 
            /*flickImg.contentX = contentInitX-(lastWidth-newWidth)/2
47
 
            flickImg.contentY = contentInitY-(lastHeight-image.height)/2*/
48
 
 
49
 
        }
50
 
 
51
 
        onPinchFinished: {
52
 
 
53
 
            columnPages.shouldReloadImg = true;
54
 
            console.log("FINISHED");
55
 
        }
56
 
    }
57
 
 
58
 
 
59
 
    Poppler {
60
 
        id: popplerProp
61
 
        path: file.path
62
 
    }
63
 
 
64
 
    Column {
65
 
        id: columnPages
66
 
 
67
 
        property bool shouldReloadImg : false
68
 
 
69
 
        width: parent.width - 10
70
 
        x: 5
71
 
        y: 5
72
 
        spacing: 10
73
 
 
74
 
        onWidthChanged: {
75
 
            if (!pinchy.pinch.active)
76
 
                shouldReloadImg=true
77
 
            else
78
 
                shouldReloadImg=false
79
 
        }
80
 
 
81
 
    }
82
 
 
83
 
    Component.onCompleted: {
84
 
 
85
 
        var i=0;
86
 
        for(i=1; i <= popplerProp.numPages; i++)
87
 
        {
88
 
            var component = Qt.createComponent("PdfPage.qml");
89
 
 
90
 
            if (component.status === Component.Error)
91
 
            {
92
 
                console.debug("Error creating component");
93
 
            }
94
 
            else
95
 
            {
96
 
                var page = component.createObject(columnPages);
97
 
 
98
 
                page.source = "image://poppler/page/"+i;
99
 
            }
100
 
        }
101
 
    }
102
 
}