~verzegnassi-stefano/+junk/pdf-viewer

« back to all changes in this revision

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

  • Committer: Stefano Verzegnassi
  • Date: 2016-04-25 11:16:08 UTC
  • Revision ID: stefano92.100@gmail.com-20160425111608-p2rmgrprzvrr2hva
Fixed wrong appId. Fixed content-hub support as destination.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import Ubuntu.Components.Popups 1.3
20
20
import DocumentViewer 1.0
21
21
import QtQuick.Window 2.0
22
 
import Qt.labs.settings 1.0
23
22
import QtSystemInfo 5.0
24
23
import Ubuntu.Content 1.3
25
24
 
35
34
    property bool fullscreen: (!desktopMode && isLandscape && narrowWindow) ||
36
35
                              pageStack.currentPage.hasOwnProperty("isPresentationMode")
37
36
 
 
37
    property bool nightModeEnabled: false
 
38
    property alias contentStore: contentStore
 
39
 
38
40
    readonly property bool desktopMode: DocumentViewer.desktopMode
39
41
 
40
42
    readonly property bool narrowWindow: width < units.gu(51)
43
45
    readonly property bool isLandscape: Screen.orientation == Qt.LandscapeOrientation ||
44
46
                                        Screen.orientation == Qt.InvertedLandscapeOrientation
45
47
 
46
 
    applicationName: "sverzegnassi.pdfviewer"
47
 
    automaticOrientation: true
48
 
 
49
 
    width: units.gu(150)
50
 
    height: units.gu(75)
51
 
 
52
48
    function openDocument(path)  {
53
49
        if (path !== "") {
54
50
            console.log("Path of the document:", path)
80
76
                        mainView, { parent: mainView, text: message });
81
77
    }
82
78
 
83
 
    onFullscreenChanged: {
84
 
        if (mainView.fullscreen)
85
 
            window.visibility = Window.FullScreen
86
 
        else
87
 
            window.visibility = Window.Windowed
88
 
    }
 
79
    applicationName: "pdfviewer.sverzegnassi"
 
80
    automaticOrientation: true
 
81
 
 
82
    width: units.gu(150)
 
83
    height: units.gu(75)
 
84
 
 
85
    layer.effect: NightModeShader {}
 
86
    layer.enabled: nightModeEnabled && (pageStack.depth > 1) && !pageStack.currentPage.isPresentationMode
89
87
 
90
88
    Component.onCompleted: {
91
89
        QuickUtils.mouseAttached = true;
93
91
        pageStack.push(Qt.resolvedUrl("documentPage/DocumentPage.qml"));
94
92
    }
95
93
 
 
94
    onFullscreenChanged: {
 
95
        window.visibility = mainView.fullscreen ? Window.FullScreen : Window.Windowed
 
96
    }
 
97
 
96
98
    File {
97
99
        id: file
98
100
        objectName: "file"
104
106
        }
105
107
    }
106
108
 
107
 
    PageStack { id: pageStack }
108
 
 
109
 
    Settings {
110
 
        id: sortSettings
111
 
 
112
 
        property int sortMode: 0    // 0 = by date, 1 = by name, 2 = by size
113
 
        property bool reverseOrder: false
 
109
    PageStack {
 
110
        id: pageStack
114
111
    }
115
112
 
116
 
    property alias contentStore: contentStore
117
113
    ContentStore {
118
114
        id: contentStore
119
115
        scope: ContentScope.App
124
120
        screenSaverEnabled: !(Qt.application.active && pageStack.currentPage.isPresentationMode)
125
121
    }
126
122
 
127
 
    property bool nightModeEnabled: false
128
 
    layer.effect: NightModeShader {}
129
 
    layer.enabled: nightModeEnabled && (pageStack.depth > 1) && !pageStack.currentPage.isPresentationMode
 
123
    Connections {
 
124
        target: ContentHub
 
125
 
 
126
        onImportRequested: {
 
127
            if (transfer.state === ContentTransfer.Charged) {
 
128
                mainView.openDocument(transfer.items[0].url.toString().replace("file://", ""))
 
129
                console.log("[CONTENT-HUB] Content imported (from external call)!")
 
130
            }
 
131
        }
 
132
    }
130
133
}