~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-viewer

« back to all changes in this revision

Viewing changes to src/app/qml/loView/LOViewGotoDialog.qml

  • Committer: Tarmac
  • Author(s): Stefano Verzegnassi
  • Date: 2015-10-10 12:21:13 UTC
  • mfrom: (172.1.5 reboot-lok-qsg-zoom)
  • Revision ID: tarmac-20151010122113-drtgshq9lhxx8noe
[loviewer] Implemented zoom:
* Added a manual zoom mode
* Added an automatic zoom mode (fit zoom to flickable width)
* Added a bottom panel with a zoom selector (which includes a TextField and an OptionSelector).

Approved by Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014-2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.3
 
18
import Ubuntu.Components 1.1
 
19
import Ubuntu.Components.Popups 1.0
 
20
 
 
21
// TODO: Use page breaks detection, when LibreOfficeKit will support it.
 
22
 
 
23
Dialog {
 
24
    id: goToPageDialog
 
25
    objectName: "LOViewGotoDialog"
 
26
 
 
27
    title: i18n.tr("Go to position")
 
28
    text: i18n.tr("Choose a position between 1% and 100%")
 
29
 
 
30
    TextField {
 
31
        id: goToPageTextField
 
32
        objectName:"goToPageTextField"
 
33
 
 
34
        width: parent.width
 
35
 
 
36
        hasClearButton: true
 
37
        inputMethodHints: Qt.ImhFormattedNumbersOnly
 
38
        validator: IntValidator{ bottom: 1; top: 100 }
 
39
 
 
40
        Keys.onReturnPressed: goToPage()
 
41
        Component.onCompleted: forceActiveFocus()
 
42
    }
 
43
 
 
44
    Button {
 
45
        objectName:"GOButton"
 
46
        text: i18n.tr("GO!")
 
47
        color: UbuntuColors.green
 
48
 
 
49
        enabled: goToPageTextField.acceptableInput
 
50
        onClicked: goToPage()
 
51
    }
 
52
 
 
53
    Button {
 
54
        text: i18n.tr("Cancel")
 
55
        onClicked: PopupUtils.close(goToPageDialog)
 
56
    }
 
57
 
 
58
    function goToPage() {
 
59
        var pos = loView.contentHeight * parseInt(goToPageTextField.text) / 100
 
60
 
 
61
        loView.contentY = Math.min(pos, (loView.contentHeight - loView.height))
 
62
        PopupUtils.close(goToPageDialog)
 
63
    }
 
64
}