ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #01444
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support into lp:ubuntu-docviewer-app
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support into lp:ubuntu-docviewer-app with lp:~verzegnassi-stefano/ubuntu-docviewer-app/pdf-toc-improvements as a prerequisite.
Commit message:
Open a document in fullscreen mode on devices
Requested reviews:
Stefano Verzegnassi (verzegnassi-stefano)
Related bugs:
Bug #1428718 in Ubuntu Document Viewer App: "opening a document should be fullscreen "
https://bugs.launchpad.net/ubuntu-docviewer-app/+bug/1428718
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/fullscreen-support/+merge/255856
Open a document in fullscreen mode on devices
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.
--
Your team Ubuntu Document Viewer Developers is subscribed to branch lp:ubuntu-docviewer-app.
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot 2015-04-10 15:53:49 +0000
+++ po/com.ubuntu.docviewer.pot 2015-04-10 15:53:49 +0000
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-04-08 16:15+0200\n"
+"POT-Creation-Date: 2015-04-10 17:46+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -189,7 +189,7 @@
msgstr ""
#: ../src/app/qml/documentPage/DocumentPage.qml:25
-#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
+#: /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
msgid "Document Viewer"
msgstr ""
@@ -268,6 +268,6 @@
msgid "Loading..."
msgstr ""
-#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
+#: /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
msgid "documents;viewer;pdf;reader;"
msgstr ""
=== modified file 'src/app/command-line-parser.cpp'
--- src/app/command-line-parser.cpp 2015-02-13 15:30:01 +0000
+++ src/app/command-line-parser.cpp 2015-04-10 15:53:49 +0000
@@ -31,6 +31,7 @@
CommandLineParser::CommandLineParser()
: m_pickMode(false),
m_testability(false),
+ m_isFullscreen(false),
m_documentFile("")
{
m_urlHandler = new UrlHandler();
@@ -51,6 +52,9 @@
usage();
return false;
}
+ else if (args[i] == "--fullscreen") {
+ m_isFullscreen = true;
+ }
else if (args[i] == "--pick-mode") {
m_pickMode = true;
}
@@ -88,6 +92,7 @@
QTextStream out(stdout);
out << "Usage: ubuntu-docviewer-app [options] [file_path]" << endl;
out << "Options:" << endl;
+ out << " --fullscreen\trun fullscreen" << endl;
out << " --pick-mode\t\tEnable mode to pick photos" << endl;
out << " file_path\t\tOpens ubuntu-docviewer-app displaying the selected file" << endl;
}
=== modified file 'src/app/command-line-parser.h'
--- src/app/command-line-parser.h 2015-02-13 15:30:01 +0000
+++ src/app/command-line-parser.h 2015-04-10 15:53:49 +0000
@@ -38,6 +38,7 @@
bool processArguments(const QStringList& args);
+ bool isFullscreen() const { return m_isFullscreen; }
bool pickModeEnabled() const { return m_pickMode; }
bool testability() const { return m_testability; }
const QString &documentFile() const { return m_documentFile; }
@@ -48,6 +49,7 @@
UrlHandler *m_urlHandler;
+ bool m_isFullscreen;
bool m_pickMode;
bool m_testability;
QString m_documentFile;
=== modified file 'src/app/docviewer-application.cpp'
--- src/app/docviewer-application.cpp 2015-03-03 15:41:11 +0000
+++ src/app/docviewer-application.cpp 2015-04-10 15:53:49 +0000
@@ -113,6 +113,7 @@
{
// Set up import paths
QStringList importPathList = m_view->engine()->importPathList();
+
// Prepend the location of the plugin in the build dir,
// so that Qt Creator finds it there, thus overriding the one installed
// in the sistem if there is one
@@ -123,6 +124,29 @@
}
/*!
+ * \brief DocViewerApplication::isDesktopMode
+ * Returns true if the DESKTOP_MODE env var is set
+ */
+bool DocViewerApplication::isDesktopMode() const
+{
+
+ // Assume that platformName (QtUbuntu) with ubuntu
+ // in name means it's running on device
+ // TODO: replace this check with SDK call for formfactor
+ QString platform = QGuiApplication::platformName();
+ return !((platform == "ubuntu") || (platform == "ubuntumirclient"));
+}
+
+/*!
+ * \brief DocViewerApplication::isFullScreen
+ * Returns true if window is on FullScreen mode
+ */
+bool DocViewerApplication::isFullScreen() const
+{
+ return m_view->windowState() == Qt::WindowFullScreen;
+}
+
+/*!
* \brief DocViewerApplication::getDocumentFile
* Returns the document file passed as a parameter
*/
@@ -175,7 +199,14 @@
setDocumentFile(m_cmdLineParser->documentFile());
m_view->setResizeMode(QQuickView::SizeRootObjectToView);
- m_view->show();
+
+ //run fullscreen if specified at command line
+ if (m_cmdLineParser->isFullscreen()) {
+ setFullScreen(true);
+ m_view->showFullScreen();
+ } else {
+ m_view->show();
+ }
}
/*!
@@ -229,6 +260,21 @@
Q_EMIT browseModeRequested();
}
+/*!
+ * \brief DocViewerApplication::setFullScreen
+ * Change window state to fullScreen or no state
+ */
+void DocViewerApplication::setFullScreen(bool fullScreen)
+{
+ if(fullScreen) {
+ m_view->setWindowState(Qt::WindowFullScreen);
+ } else {
+ m_view->setWindowState(Qt::WindowNoState);
+ }
+
+ Q_EMIT fullScreenChanged();
+}
+
void DocViewerApplication::setDocumentFile(const QString &documentFile)
{
if(!documentFile.isEmpty()) {
=== modified file 'src/app/docviewer-application.h'
--- src/app/docviewer-application.h 2015-02-13 15:30:01 +0000
+++ src/app/docviewer-application.h 2015-04-10 15:53:49 +0000
@@ -38,6 +38,8 @@
{
Q_OBJECT
Q_PROPERTY(bool pickModeEnabled READ pickModeEnabled NOTIFY pickModeEnabledChanged)
+ Q_PROPERTY(bool desktopMode READ isDesktopMode CONSTANT)
+ Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
Q_PROPERTY(QString documentFile READ getDocumentFile WRITE setDocumentFile NOTIFY documentFileChanged)
public:
@@ -56,6 +58,8 @@
UiMode defaultUiMode() const;
void setUiMode(UiMode mode);
bool pickModeEnabled() const;
+ bool isDesktopMode() const;
+ bool isFullScreen() const;
const QString &getDocumentFile() const;
Q_INVOKABLE void returnPickedContent(QList<QString> paths);
@@ -65,12 +69,14 @@
signals:
void pickModeEnabledChanged();
+ void fullScreenChanged();
void documentFileChanged();
void browseModeRequested();
private slots:
void switchToPickMode();
void switchToBrowseMode();
+ void setFullScreen(bool fullScreen);
void setDocumentFile(const QString &documentFile);
private:
=== modified file 'src/app/qml/pdfView/PdfContentsPage.qml'
--- src/app/qml/pdfView/PdfContentsPage.qml 2015-04-10 15:53:49 +0000
+++ src/app/qml/pdfView/PdfContentsPage.qml 2015-04-10 15:53:49 +0000
@@ -36,8 +36,7 @@
onActiveChanged: {
// If the header was hidden in the PdfPage, make it visible.
- if (!pdfPage.header.visible)
- pdfPage.header.visible = true;
+ mainView.setHeaderVisibility(true);
// Find out the current page position in the ToC index
var i=0
=== modified file 'src/app/qml/pdfView/PdfView.qml'
--- src/app/qml/pdfView/PdfView.qml 2015-04-07 14:14:52 +0000
+++ src/app/qml/pdfView/PdfView.qml 2015-04-10 15:53:49 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2014 Canonical, Ltd.
+ * Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -85,7 +85,7 @@
objectName: "mouseArea"
anchors.fill: parent
- onClicked: pdfPage.header.visible = !pdfPage.header.visible
+ onClicked: mainView.toggleHeaderVisibility()
}
}
@@ -109,7 +109,7 @@
pdfPage.title = title;
// Hide header when the document is ready
- pdfPage.header.visible = false;
+ mainView.setHeaderVisibility(false);
}
}
=== modified file 'src/app/qml/ubuntu-docviewer-app.qml'
--- src/app/qml/ubuntu-docviewer-app.qml 2015-03-26 13:58:31 +0000
+++ src/app/qml/ubuntu-docviewer-app.qml 2015-04-10 15:53:49 +0000
@@ -54,6 +54,25 @@
PopupUtils.open(Qt.resolvedUrl("common/UnknownTypeDialog.qml"), mainView, { parent: mainView });
}
+ function setFullScreen(fullScreen) {
+ DOC_VIEWER.fullScreen = fullScreen;
+ }
+
+ function toggleFullScreen() {
+ DOC_VIEWER.fullScreen = !APP.fullScreen;
+ }
+
+ function setHeaderVisibility(visible, toggleFullscreen) {
+ toggleFullscreen = typeof toggleFullscreen !== 'undefined' ? toggleFullscreen : true
+ header.visible = visible;
+ if (!DOC_VIEWER.desktopMode && toggleFullscreen)
+ setFullScreen(!visible);
+ }
+
+ function toggleHeaderVisibility() {
+ setHeaderVisibility(!header.visible);
+ }
+
Component.onCompleted: {
pageStack.push(Qt.resolvedUrl("documentPage/DocumentPage.qml"));
References