~mutse-young/ubuntu-docviewer-app/trunk

« back to all changes in this revision

Viewing changes to src/app/qml/PdfView.qml

  • Committer: Tarmac
  • Author(s): Stefano Verzegnassi
  • Date: 2014-11-28 23:08:00 UTC
  • mfrom: (36.3.8 content-hub-support)
  • Revision ID: tarmac-20141128230800-6t6nd9dhc0w157wo
Added a GoToPage dialog in pdfView. Fixes: https://bugs.launchpad.net/bugs/1390684.

Approved by Anthony Granger, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import "utils.js" as Utils
6
6
 
7
7
Page {
8
 
    id: pageMain
 
8
    id: pdfPage
9
9
    title: Utils.getNameOfFile(file.path);
10
10
 
11
11
    // Disable header auto-hide
12
12
    flickable: null
13
13
 
 
14
    property string currentPage: i18n.tr("Page %1 of %2").arg(pdfView.currentIndex + 1).arg(pdfView.count)
 
15
 
14
16
    // TODO: Restore zooming
15
17
    ListView {
16
18
        id: pdfView
 
19
 
17
20
        anchors {
18
21
            fill: parent
19
22
            leftMargin: units.gu(1)
30
33
        highlightFollowsCurrentItem: false
31
34
        keyNavigationWraps: false
32
35
 
33
 
        // TODO: Not a good way to have spacing
34
 
        header: Item {
35
 
            width: parent.width
36
 
            height: units.gu(2)
37
 
        }
38
 
 
39
 
        footer: Item {
40
 
            width: parent.width
41
 
            height: units.gu(2)
42
 
        }
 
36
        header: Item { width: parent.width; height: units.gu(2) }
 
37
        footer: Item { width: parent.width; height: units.gu(2) }
43
38
 
44
39
        model: Poppler {
45
40
            id: poppler
60
55
 
61
56
                var title = getDocumentInfo("Title")
62
57
                if (title !== "")
63
 
                    titleLabel.text = title
 
58
                    pdfPage.title = title
64
59
            }
65
60
        }
66
61
 
67
 
        delegate: PdfPage {}
 
62
        delegate: PdfViewDelegate {}
68
63
 
69
64
        onWidthChanged: {
70
65
            /* On resizing window, pages size changes but contentY is still the same.
84
79
            }
85
80
 
86
81
            if (i !== -1) {
87
 
                currentPageLabel.text = i18n.tr("Page %1 of %2").arg(i + 1).arg(pdfView.count)
 
82
                currentPage = i18n.tr("Page %1 of %2").arg(i + 1).arg(pdfView.count)
88
83
 
89
84
                if (!pdfView.flickingVertically) {
90
85
                    pdfView.currentIndex = i
103
98
    // *** HEADER ***
104
99
    state: "default"
105
100
    states: [
106
 
        PageHeadState {
 
101
        PdfViewDefaultHeader {
107
102
            name: "default"
108
 
            head: pageMain.head
109
 
 
110
 
            contents: Column {
111
 
                anchors.centerIn: parent
112
 
 
113
 
                Label {
114
 
                    id: titleLabel
115
 
                    text: Utils.getNameOfFile(file.path)
116
 
                    font.weight: Font.DemiBold
117
 
                    anchors.horizontalCenter: parent.horizontalCenter
118
 
                }
119
 
                Label {
120
 
                    id: currentPageLabel
121
 
                    text: i18n.tr("Page %1 of %2").arg(pdfView.currentIndex + 1).arg(pdfView.count)
122
 
                    fontSize: "small"
123
 
                    anchors.horizontalCenter: parent.horizontalCenter
124
 
                }
125
 
            }
126
 
 
127
 
            backAction: Action {
128
 
                iconName: "back"
129
 
                text: (pageStack.depth > 1) ? i18n.tr("Back") : i18n.tr("Close")
130
 
                onTriggered: {
131
 
                    if (pageStack.depth > 1) {
132
 
                        // Go back to Welcome page
133
 
                        pageStack.pop();
134
 
                    } else {
135
 
                        // File has been imported through Content Hub (or was not chosen through WelcomePage)
136
 
                        // Close the application and show our source app (e.g. ubuntu-filemanager-app if used to open a document)
137
 
                        Qt.quit()
138
 
                    }
139
 
                }
140
 
            }
141
 
 
142
 
            actions: [
143
 
                Action {
144
 
                    iconName: "search"
145
 
                   // onTriggered: pageMain.state = "search"
146
 
                    //Disable it until we provide search in Poppler plugin.
147
 
                    enabled: false
148
 
                },
149
 
 
150
 
                Action {
151
 
                    iconName: "browser-tabs"
152
 
                    text: "Go to page..."
153
 
                    enabled: false
154
 
                },
155
 
 
156
 
                Action {
157
 
                    objectName: "detailsAction"
158
 
                    text: i18n.tr("Details")
159
 
                    iconName: "info"
160
 
                    onTriggered: pageStack.push(Qt.resolvedUrl("DetailsPage.qml"))
161
 
                }
162
 
            ]
 
103
            targetPage: pdfPage
163
104
        }
164
 
 
165
 
       /* PageHeadState {
166
 
            id: headerState
167
 
            name: "search"
168
 
            head: pageMain.head
169
 
            actions: [
170
 
                Action {
171
 
                    iconName: "go-up"
172
 
                },
173
 
 
174
 
                Action {
175
 
                    iconName: "go-down"
176
 
                }
177
 
            ]
178
 
 
179
 
            backAction: Action {
180
 
                id: leaveSearchAction
181
 
                text: "back"
182
 
                iconName: "back"
183
 
                onTriggered: pageMain.state = "default"
184
 
            }
185
 
        }*/
186
105
    ]
 
106
 
 
107
    // *** DIALOGS ***
 
108
    property alias goToPageDialog: goToPageDialog
 
109
    Component { id: goToPageDialog; PdfViewGotoDialog { view: pdfView } }
187
110
}