Merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support into lp:ubuntu-docviewer-app/trunk

Proposed by Stefano Verzegnassi
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 117
Merged at revision: 118
Proposed branch: lp:~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support
Merge into: lp:ubuntu-docviewer-app/trunk
Prerequisite: lp:~verzegnassi-stefano/ubuntu-docviewer-app/pdf-toc-improvements
Diff against target: 268 lines (+86/-9)
8 files modified
po/com.ubuntu.docviewer.pot (+3/-3)
src/app/command-line-parser.cpp (+5/-0)
src/app/command-line-parser.h (+2/-0)
src/app/docviewer-application.cpp (+47/-1)
src/app/docviewer-application.h (+6/-0)
src/app/qml/pdfView/PdfContentsPage.qml (+1/-2)
src/app/qml/pdfView/PdfView.qml (+3/-3)
src/app/qml/ubuntu-docviewer-app.qml (+19/-0)
To merge this branch: bzr merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Stefano Verzegnassi Pending
Review via email: mp+255856@code.launchpad.net

Commit message

Open a document in fullscreen mode on devices

Description of the change

Open a document in fullscreen mode on devices
Code added here comes from lp:gallery-app

This MP depends on lp:~verzegnassi-stefano/ubuntu-docviewer-app/pdf-toc-improvements, since that branch introduces some fix for the invisible header in PdfContentsPage.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.docviewer.pot'
2--- po/com.ubuntu.docviewer.pot 2015-04-10 15:53:49 +0000
3+++ po/com.ubuntu.docviewer.pot 2015-04-10 15:53:49 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-04-08 16:15+0200\n"
9+"POT-Creation-Date: 2015-04-10 17:46+0200\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13@@ -189,7 +189,7 @@
14 msgstr ""
15
16 #: ../src/app/qml/documentPage/DocumentPage.qml:25
17-#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
18+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
19 msgid "Document Viewer"
20 msgstr ""
21
22@@ -268,6 +268,6 @@
23 msgid "Loading..."
24 msgstr ""
25
26-#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
27+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
28 msgid "documents;viewer;pdf;reader;"
29 msgstr ""
30
31=== modified file 'src/app/command-line-parser.cpp'
32--- src/app/command-line-parser.cpp 2015-02-13 15:30:01 +0000
33+++ src/app/command-line-parser.cpp 2015-04-10 15:53:49 +0000
34@@ -31,6 +31,7 @@
35 CommandLineParser::CommandLineParser()
36 : m_pickMode(false),
37 m_testability(false),
38+ m_isFullscreen(false),
39 m_documentFile("")
40 {
41 m_urlHandler = new UrlHandler();
42@@ -51,6 +52,9 @@
43 usage();
44 return false;
45 }
46+ else if (args[i] == "--fullscreen") {
47+ m_isFullscreen = true;
48+ }
49 else if (args[i] == "--pick-mode") {
50 m_pickMode = true;
51 }
52@@ -88,6 +92,7 @@
53 QTextStream out(stdout);
54 out << "Usage: ubuntu-docviewer-app [options] [file_path]" << endl;
55 out << "Options:" << endl;
56+ out << " --fullscreen\trun fullscreen" << endl;
57 out << " --pick-mode\t\tEnable mode to pick photos" << endl;
58 out << " file_path\t\tOpens ubuntu-docviewer-app displaying the selected file" << endl;
59 }
60
61=== modified file 'src/app/command-line-parser.h'
62--- src/app/command-line-parser.h 2015-02-13 15:30:01 +0000
63+++ src/app/command-line-parser.h 2015-04-10 15:53:49 +0000
64@@ -38,6 +38,7 @@
65
66 bool processArguments(const QStringList& args);
67
68+ bool isFullscreen() const { return m_isFullscreen; }
69 bool pickModeEnabled() const { return m_pickMode; }
70 bool testability() const { return m_testability; }
71 const QString &documentFile() const { return m_documentFile; }
72@@ -48,6 +49,7 @@
73
74 UrlHandler *m_urlHandler;
75
76+ bool m_isFullscreen;
77 bool m_pickMode;
78 bool m_testability;
79 QString m_documentFile;
80
81=== modified file 'src/app/docviewer-application.cpp'
82--- src/app/docviewer-application.cpp 2015-03-03 15:41:11 +0000
83+++ src/app/docviewer-application.cpp 2015-04-10 15:53:49 +0000
84@@ -113,6 +113,7 @@
85 {
86 // Set up import paths
87 QStringList importPathList = m_view->engine()->importPathList();
88+
89 // Prepend the location of the plugin in the build dir,
90 // so that Qt Creator finds it there, thus overriding the one installed
91 // in the sistem if there is one
92@@ -123,6 +124,29 @@
93 }
94
95 /*!
96+ * \brief DocViewerApplication::isDesktopMode
97+ * Returns true if the DESKTOP_MODE env var is set
98+ */
99+bool DocViewerApplication::isDesktopMode() const
100+{
101+
102+ // Assume that platformName (QtUbuntu) with ubuntu
103+ // in name means it's running on device
104+ // TODO: replace this check with SDK call for formfactor
105+ QString platform = QGuiApplication::platformName();
106+ return !((platform == "ubuntu") || (platform == "ubuntumirclient"));
107+}
108+
109+/*!
110+ * \brief DocViewerApplication::isFullScreen
111+ * Returns true if window is on FullScreen mode
112+ */
113+bool DocViewerApplication::isFullScreen() const
114+{
115+ return m_view->windowState() == Qt::WindowFullScreen;
116+}
117+
118+/*!
119 * \brief DocViewerApplication::getDocumentFile
120 * Returns the document file passed as a parameter
121 */
122@@ -175,7 +199,14 @@
123 setDocumentFile(m_cmdLineParser->documentFile());
124
125 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
126- m_view->show();
127+
128+ //run fullscreen if specified at command line
129+ if (m_cmdLineParser->isFullscreen()) {
130+ setFullScreen(true);
131+ m_view->showFullScreen();
132+ } else {
133+ m_view->show();
134+ }
135 }
136
137 /*!
138@@ -229,6 +260,21 @@
139 Q_EMIT browseModeRequested();
140 }
141
142+/*!
143+ * \brief DocViewerApplication::setFullScreen
144+ * Change window state to fullScreen or no state
145+ */
146+void DocViewerApplication::setFullScreen(bool fullScreen)
147+{
148+ if(fullScreen) {
149+ m_view->setWindowState(Qt::WindowFullScreen);
150+ } else {
151+ m_view->setWindowState(Qt::WindowNoState);
152+ }
153+
154+ Q_EMIT fullScreenChanged();
155+}
156+
157 void DocViewerApplication::setDocumentFile(const QString &documentFile)
158 {
159 if(!documentFile.isEmpty()) {
160
161=== modified file 'src/app/docviewer-application.h'
162--- src/app/docviewer-application.h 2015-02-13 15:30:01 +0000
163+++ src/app/docviewer-application.h 2015-04-10 15:53:49 +0000
164@@ -38,6 +38,8 @@
165 {
166 Q_OBJECT
167 Q_PROPERTY(bool pickModeEnabled READ pickModeEnabled NOTIFY pickModeEnabledChanged)
168+ Q_PROPERTY(bool desktopMode READ isDesktopMode CONSTANT)
169+ Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
170 Q_PROPERTY(QString documentFile READ getDocumentFile WRITE setDocumentFile NOTIFY documentFileChanged)
171
172 public:
173@@ -56,6 +58,8 @@
174 UiMode defaultUiMode() const;
175 void setUiMode(UiMode mode);
176 bool pickModeEnabled() const;
177+ bool isDesktopMode() const;
178+ bool isFullScreen() const;
179 const QString &getDocumentFile() const;
180
181 Q_INVOKABLE void returnPickedContent(QList<QString> paths);
182@@ -65,12 +69,14 @@
183
184 signals:
185 void pickModeEnabledChanged();
186+ void fullScreenChanged();
187 void documentFileChanged();
188 void browseModeRequested();
189
190 private slots:
191 void switchToPickMode();
192 void switchToBrowseMode();
193+ void setFullScreen(bool fullScreen);
194 void setDocumentFile(const QString &documentFile);
195
196 private:
197
198=== modified file 'src/app/qml/pdfView/PdfContentsPage.qml'
199--- src/app/qml/pdfView/PdfContentsPage.qml 2015-04-10 15:53:49 +0000
200+++ src/app/qml/pdfView/PdfContentsPage.qml 2015-04-10 15:53:49 +0000
201@@ -36,8 +36,7 @@
202
203 onActiveChanged: {
204 // If the header was hidden in the PdfPage, make it visible.
205- if (!pdfPage.header.visible)
206- pdfPage.header.visible = true;
207+ mainView.setHeaderVisibility(true);
208
209 // Find out the current page position in the ToC index
210 var i=0
211
212=== modified file 'src/app/qml/pdfView/PdfView.qml'
213--- src/app/qml/pdfView/PdfView.qml 2015-04-07 14:14:52 +0000
214+++ src/app/qml/pdfView/PdfView.qml 2015-04-10 15:53:49 +0000
215@@ -1,5 +1,5 @@
216 /*
217- * Copyright (C) 2013-2014 Canonical, Ltd.
218+ * Copyright (C) 2013-2015 Canonical, Ltd.
219 *
220 * This program is free software; you can redistribute it and/or modify
221 * it under the terms of the GNU General Public License as published by
222@@ -85,7 +85,7 @@
223 objectName: "mouseArea"
224
225 anchors.fill: parent
226- onClicked: pdfPage.header.visible = !pdfPage.header.visible
227+ onClicked: mainView.toggleHeaderVisibility()
228 }
229 }
230
231@@ -109,7 +109,7 @@
232 pdfPage.title = title;
233
234 // Hide header when the document is ready
235- pdfPage.header.visible = false;
236+ mainView.setHeaderVisibility(false);
237 }
238 }
239
240
241=== modified file 'src/app/qml/ubuntu-docviewer-app.qml'
242--- src/app/qml/ubuntu-docviewer-app.qml 2015-03-26 13:58:31 +0000
243+++ src/app/qml/ubuntu-docviewer-app.qml 2015-04-10 15:53:49 +0000
244@@ -54,6 +54,25 @@
245 PopupUtils.open(Qt.resolvedUrl("common/UnknownTypeDialog.qml"), mainView, { parent: mainView });
246 }
247
248+ function setFullScreen(fullScreen) {
249+ DOC_VIEWER.fullScreen = fullScreen;
250+ }
251+
252+ function toggleFullScreen() {
253+ DOC_VIEWER.fullScreen = !APP.fullScreen;
254+ }
255+
256+ function setHeaderVisibility(visible, toggleFullscreen) {
257+ toggleFullscreen = typeof toggleFullscreen !== 'undefined' ? toggleFullscreen : true
258+ header.visible = visible;
259+ if (!DOC_VIEWER.desktopMode && toggleFullscreen)
260+ setFullScreen(!visible);
261+ }
262+
263+ function toggleHeaderVisibility() {
264+ setHeaderVisibility(!header.visible);
265+ }
266+
267 Component.onCompleted: {
268 pageStack.push(Qt.resolvedUrl("documentPage/DocumentPage.qml"));
269

Subscribers

People subscribed via source and target branches