← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-app-init into lp:ubuntu-docviewer-app/reboot

 

Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-app-init into lp:ubuntu-docviewer-app/reboot.

Commit message:
* Refactored cpp init
* Moved command line parser to QML

Requested reviews:
  Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)

For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/reboot-app-init/+merge/274806

* Refactored cpp init
* Moved command line parser to QML

NOT READY YET: Need to check if .click and .deb packages are correctly built.
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-app-init into lp:ubuntu-docviewer-app/reboot.
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot	2015-10-11 11:32:00 +0000
+++ po/com.ubuntu.docviewer.pot	2015-10-18 17:16:22 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-10-11 13:31+0200\n"
+"POT-Creation-Date: 2015-10-12 21:00+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"
@@ -18,13 +18,36 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
-#: ../src/app/docviewer-application.cpp:162
-#: /tmp/build-reboot-qsg-impress-support-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
+#: ../src/app/docviewer-application.cpp:103
+#: /tmp/build-reboot-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
 msgid "Document Viewer"
 msgstr ""
 
+#: ../src/app/qml/common/CommandLineProxy.qml:47
+msgid "Some of the provided arguments is not valid."
+msgstr ""
+
+#: ../src/app/qml/common/CommandLineProxy.qml:56
+msgid "Opens ubuntu-docviewer-app displaying the selected file"
+msgstr ""
+
+#: ../src/app/qml/common/CommandLineProxy.qml:63
+msgid "Run fullscreen"
+msgstr ""
+
+#: ../src/app/qml/common/CommandLineProxy.qml:69
+msgid "Open ubuntu-docviewer-app in pick mode. Use it for tests only."
+msgstr ""
+
+#: ../src/app/qml/common/CommandLineProxy.qml:75
+msgid ""
+"Load the list of documents from the given folder, instead of default ~/"
+"Documents.\n"
+"The path must exist prior to running ubuntu-docviewer-app"
+msgstr ""
+
 #: ../src/app/qml/common/DetailsPage.qml:27
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:114
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:106
 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:97
 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:83
 msgid "Details"
@@ -63,7 +86,7 @@
 #: ../src/app/qml/common/RejectedImportDialog.qml:38
 #: ../src/app/qml/documentPage/DocumentPageSelectionModeHeader.qml:32
 #: ../src/app/qml/documentPage/SortSettingsDialog.qml:53
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:78
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:70
 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:61
 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:61
 msgid "Close"
@@ -254,7 +277,7 @@
 msgstr ""
 
 #: ../src/app/qml/documentPage/DocumentPageSearchHeader.qml:27
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:78
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:70
 #: ../src/app/qml/loView/LOViewPage.qml:191
 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:61
 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:61
@@ -306,50 +329,50 @@
 msgid "Reverse order"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:55
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:47
 #: ../src/app/qml/textView/TextView.qml:42
 msgid "Loading..."
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:59
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:51
 msgid "LibreOffice text document"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:61
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:53
 msgid "LibreOffice spread sheet"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:63
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:55
 msgid "LibreOffice presentation"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:65
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:57
 msgid "LibreOffice Draw document"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:67
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:59
 msgid "Unknown LibreOffice document"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:69
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:61
 msgid "Unknown type document"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:94
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:86
 msgid "Show zoom controls"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:101
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:93
 msgid "Go to position..."
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:108
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:100
 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:91
 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:77
 msgid "Disable night mode"
 msgstr ""
 
-#: ../src/app/qml/loView/LOViewDefaultHeader.qml:108
+#: ../src/app/qml/loView/LOViewDefaultHeader.qml:100
 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:91
 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:77
 msgid "Enable night mode"
@@ -443,11 +466,11 @@
 #.
 #. where "2" is given by the argument "%1"
 #.
-#: ../src/plugin/file-qml-plugin/docviewerutils.cpp:101
+#: ../src/plugin/file-qml-plugin/docviewerutils.cpp:111
 #, qt-format
 msgid "copy %1"
 msgstr ""
 
-#: /tmp/build-reboot-qsg-impress-support-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
+#: /tmp/build-reboot-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
 msgid "documents;viewer;pdf;reader;"
 msgstr ""

=== modified file 'src/app/CMakeLists.txt'
--- src/app/CMakeLists.txt	2015-09-19 14:54:11 +0000
+++ src/app/CMakeLists.txt	2015-10-18 17:16:22 +0000
@@ -6,11 +6,12 @@
   -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_LOCALEDIR}\"
 )
 
+include_directories(
+    ${CMAKE_CURRENT_BINARY_DIR}
+)
+
 set(docviewer_SRCS
     main.cpp
-    command-line-parser.cpp
-    docviewer-application.cpp
-    urlhandler.cpp
     ${QML_SRCS}
 )
 

=== removed file 'src/app/command-line-parser.cpp'
--- src/app/command-line-parser.cpp	2015-09-02 08:32:02 +0000
+++ src/app/command-line-parser.cpp	1970-01-01 00:00:00 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2013 Canonical, Ltd.
- *
- * Authors:
- *  Nicolas d'Offay <nicolas.doffay@xxxxxxxxxxxxx>
- *
- * 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
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "command-line-parser.h"
-
-#include "urlhandler.h"
-
-#include <QDebug>
-#include <QDir>
-#include <QStandardPaths>
-#include <QTextStream>
-#include <QUrl>
-
-CommandLineParser::CommandLineParser()
-    : m_pickMode(false),
-      m_isFullscreen(false),
-      m_testability(false),
-      m_documentFile(""),
-      m_documentsDir("")
-{
-    m_urlHandler = new UrlHandler();
-}
-
-/*!
- * @brief CommandLineParser::processArguments parsers our input commandline args and sets attributes accordingly.
- * @param QStringList of commandline args to parse and set attributes.
- * @return false if invalid parameter is input or -h/--help is called.
- */
-bool CommandLineParser::processArguments(const QStringList& args)
-{
-    bool valid_args = true;
-
-    for (int i = 1; i < args.count(); ++i)
-    {
-        if (args[i] == "--help" || args[i] == "-h") {
-            usage();
-            return false;
-        }
-        else if (args[i] == "--fullscreen") {
-            m_isFullscreen = true;
-        }
-        else if (args[i] == "--pick-mode") {
-            m_pickMode = true;
-        }
-        else if (args[i] == "--testability") {
-            m_testability = true;
-        }
-        else if (args[i].contains("--documents-dir")) {
-            // Extract the given path
-            QString dirPath = args[i].split("--documents-dir=").last();
-
-            if (!dirPath.isEmpty()) {
-                QDir di(dirPath);
-
-                if (di.exists())
-                    m_documentsDir = di.absolutePath();
-                else {
-                    QTextStream(stderr) << m_documentsDir << ": Not found" << endl;
-                    valid_args = false;
-                }
-
-                i++;
-            }
-            else {
-                QTextStream(stderr) << "Missing PATH argument for --documents-dir'" << endl;
-                usage();
-                valid_args = false;
-            }
-        }
-        else {
-            if (args[i].startsWith("--desktop_file_hint")) {
-                // ignore this command line switch, hybris uses it to get application info
-            }
-            else if (!args.at(i).isEmpty()) {
-                QFileInfo fi(args.at(i));
-
-                if (fi.exists()) {
-                    m_documentFile = fi.absoluteFilePath();
-                }
-                else if (m_urlHandler->processUri(args.at(i))) {
-                    m_documentFile = m_urlHandler->documentFile();
-                }
-            }
-            else {
-                valid_args = !invalidArg(args[i]);
-            }
-        }
-    }
-
-    return valid_args;
-}
-
-/*!
- * @brief CommandLineParser::usage() prints out our form factors.
- */
-void CommandLineParser::usage()
-{
-    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;
-    out << "  --documents-dir=PATH\n\t\tLoad the list of documents from the given folder, instead of default ~/Documents.\nThe path must exist prior to running ubuntu-docviewer-app" << endl;
-}
-
-/*!
- * @brief CommandLineParser::invalidArg() if an invalid argument is contained in our QStringList.
- * @return returns true.
- */
-bool CommandLineParser::invalidArg(QString arg)
-{
-    QTextStream(stderr) << "Invalid argument '" << arg << "'" << endl;
-    usage();
-
-    return true;
-}

=== removed file 'src/app/command-line-parser.h'
--- src/app/command-line-parser.h	2015-04-29 15:23:32 +0000
+++ src/app/command-line-parser.h	1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 Canonical, Ltd.
- *
- * Authors:
- *  Nicolas d'Offay <nicolas.doffay@xxxxxxxxxxxxx>
- *
- * 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
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef COMMANDLINEPARSER_H
-#define COMMANDLINEPARSER_H
-
-#include <QHash>
-#include <QSize>
-#include <QString>
-
-class UrlHandler;
-
-/*!
- * @brief The CommandLineParser is used to parse our commandline inputs and set
- * parameters accordingly.
- */
-class CommandLineParser
-{
-public:
-    CommandLineParser();
-
-    bool processArguments(const QStringList& args);
-
-    bool isFullscreen() const { return m_isFullscreen; }
-    const QString &documentsDir() const { return m_documentsDir; }
-    bool pickModeEnabled() const { return m_pickMode; }
-    bool testability() const { return m_testability; }
-    const QString &documentFile() const { return m_documentFile; }
-
-private:
-    bool invalidArg(QString arg);
-    void usage();
-
-    UrlHandler *m_urlHandler;
-
-    bool m_isFullscreen;
-    bool m_pickMode;
-    bool m_testability;
-    QString m_documentFile;
-    QString m_documentsDir;
-};
-
-#endif // COMMANDLINEPARSER_H

=== added file 'src/app/config.h'
--- src/app/config.h	1970-01-01 00:00:00 +0000
+++ src/app/config.h	2015-10-18 17:16:22 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 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
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QString>
+
+inline bool isClick() {
+    static bool click = (QCoreApplication::applicationDirPath().contains("click.ubuntu.com"));
+    return click;
+}
+
+inline bool isRunningInstalled()
+{
+    static bool installed = (QCoreApplication::applicationDirPath().startsWith("/usr"));
+    return installed;
+}
+
+inline QString docviewerDirectory()
+{
+    if (isClick()) {
+        return QString(".");
+    } else if (isRunningInstalled()) {
+        return QString("@DATA_DIR@");
+    } else {
+        return QString("@CMAKE_CURRENT_SOURCE_DIR@");
+    }
+}
+#endif // __CONFIG_H__

=== removed file 'src/app/docviewer-application.cpp'
--- src/app/docviewer-application.cpp	2015-09-11 14:48:57 +0000
+++ src/app/docviewer-application.cpp	1970-01-01 00:00:00 +0000
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2012 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- * Charles Lindsay <chaz@xxxxxxxxx>
- */
-
-#include "docviewer-application.h"
-#include "command-line-parser.h"
-#include "urlhandler.h"
-
-#include <QQuickItem>
-#include <QStandardPaths>
-#include <QQuickView>
-#include <QtQml/QtQml>
-#include <QString>
-#include <QUrl>
-#include <QtGui/QGuiApplication>
-
-/*!
- * \brief DocViewerApplication::DocViewerApplication
- * \param argc
- * \param argv
- */
-DocViewerApplication::DocViewerApplication(int& argc, char** argv)
-    : QApplication(argc, argv),
-      m_view(new QQuickView()),
-      m_documentFile(""),
-      m_documentLoaded(false)
-{
-   //
-}
-
-bool DocViewerApplication::init()
-{
-    m_cmdLineParser = new CommandLineParser();
-
-    if (!m_cmdLineParser->processArguments(arguments()))
-        return false;
-
-    if (qgetenv("QT_LOAD_TESTABILITY") == "1" || m_cmdLineParser->testability()) {
-        QLibrary testLib(QLatin1String("qttestability"));
-        if (testLib.load()) {
-            typedef void (*TasInitialize)(void);
-            TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
-            if (initFunction) {
-                initFunction();
-            } else {
-                qCritical("Library qttestability resolve failed!");
-            }
-        } else {
-            qCritical("Library qttestability load failed!");
-        }
-    }
-
-    m_urlHandler = new UrlHandler();
-
-    registerQML();
-
-    // FIXME: Broken after removal of it.
-    /*if (m_cmdLineParser->pickModeEnabled())
-        setDefaultUiMode(DocViewerApplication::PickContentMode);
-*/
-    return true;
-}
-
-/*!
- * \brief DocViewerApplication::~DocViewerApplication
- */
-DocViewerApplication::~DocViewerApplication()
-{
-    delete m_view;
-    delete m_cmdLineParser;
-}
-
-/*!
- * \brief DocViewerApplication::exec
- * \return
- */
-int DocViewerApplication::exec()
-{
-    createView();
-
-    return QApplication::exec();
-}
-
-/*!
- * \brief DocViewerApplication::registerQML
- */
-void DocViewerApplication::registerQML()
-{
-    // 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
-    importPathList.prepend(QCoreApplication::applicationDirPath() + "/../plugin/");
-    m_view->engine()->setImportPathList(importPathList);
-}
-
-/*!
- * \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
- */
-const QString& DocViewerApplication::getDocumentFile() const
-{
-    return m_documentFile;
-}
-
-/*!
- * \brief DocViewerApplication::getDocumentsDir
- * Returns the documents dir passed as a parameter
- */
-const QString& DocViewerApplication::getDocumentsDir() const
-{
-    return m_cmdLineParser->documentsDir();
-}
-
-
-/*!
- * \brief DocViewerApplication::createView
- * Create the master QDeclarativeView that all the pages will operate within
- */
-void DocViewerApplication::createView()
-{
-    m_view->setTitle(tr("Document Viewer"));
-
-    // Set ourselves up to expose functionality to run external commands from QML...
-    m_view->engine()->rootContext()->setContextProperty("DOC_VIEWER", this);
-
-    QObject::connect(m_view->engine(), SIGNAL(quit()), this, SLOT(quit()));
-
-    QString qmlfile;
-    const QString filePath = QLatin1String("qml/ubuntu-docviewer-app.qml");
-    QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
-    paths.prepend(QDir::currentPath());
-    paths.prepend(QCoreApplication::applicationDirPath());
-    Q_FOREACH (const QString &path, paths) {
-        QString myPath = path + QLatin1Char('/') + filePath;
-
-        if (QFile::exists(myPath)) {
-            qmlfile = myPath;
-            break;
-        } else {
-            myPath.replace(QCoreApplication::applicationName(), "ubuntu-docviewer-app");
-
-            if (QFile::exists(myPath)) {
-                qmlfile = myPath;
-                break;
-            }
-        }
-    }
-    // sanity check
-    if (qmlfile.isEmpty()) {
-        qFatal("File: %s does not exist at any of the standard paths!", qPrintable(filePath));
-    }
-
-    m_view->setSource(QUrl::fromLocalFile(qmlfile));
-    setDocumentFile(m_cmdLineParser->documentFile());
-
-    m_view->setResizeMode(QQuickView::SizeRootObjectToView);
-
-    //run fullscreen if specified at command line
-    if (m_cmdLineParser->isFullscreen()) {
-        setFullScreen(true);
-        m_view->showFullScreen();
-    } else {
-        m_view->show();
-    }
-}
-
-/*!
- * \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()) {
-        if (m_documentFile != documentFile) {
-            m_documentFile = "file://" + documentFile;
-            Q_EMIT documentFileChanged();;
-        }
-    }
-}
-
-void DocViewerApplication::parseUri(const QString &arg)
-{
-    if (m_urlHandler->processUri(arg)) {
-        setDocumentFile(m_urlHandler->documentFile());
-    }
-}
-
-void DocViewerApplication::releaseResources()
-{
-    if (m_view) {
-        m_view->releaseResources();
-    }
-}

=== removed file 'src/app/docviewer-application.h'
--- src/app/docviewer-application.h	2015-09-11 14:48:57 +0000
+++ src/app/docviewer-application.h	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- * Charles Lindsay <chaz@xxxxxxxxx>
- */
-
-#ifndef DOCVIEWERAPPLICATION_H
-#define DOCVIEWERAPPLICATION_H
-
-#include <QApplication>
-#include <QElapsedTimer>
-#include <QFileInfo>
-#include <QTimer>
-
-class CommandLineParser;
-class UrlHandler;
-class ContentCommunicator;
-
-class QQuickView;
-
-/*!
- * \brief The DocViewerApplication class
- */
-class DocViewerApplication : public QApplication
-{
-    Q_OBJECT
-    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)
-    Q_PROPERTY(QString documentsDir READ getDocumentsDir CONSTANT)
-
-public:
-    explicit DocViewerApplication(int& argc, char** argv);
-    virtual ~DocViewerApplication();
-
-    bool init();
-    int exec();
-
-    bool isDesktopMode() const;
-    bool isFullScreen() const;
-    const QString &getDocumentFile() const;
-    const QString &getDocumentsDir() const;
-
-    Q_INVOKABLE void parseUri(const QString &arg);
-    Q_INVOKABLE void releaseResources();
-
-signals:
-    void fullScreenChanged();
-    void documentFileChanged();
-
-private slots:
-    void setFullScreen(bool fullScreen);
-    void setDocumentFile(const QString &documentFile);
-
-private:
-    void registerQML();
-    void createView();
-
-    QQuickView *m_view;
-    CommandLineParser* m_cmdLineParser;
-    UrlHandler *m_urlHandler;
-
-    QString m_documentFile;
-    bool m_documentLoaded;
-};
-
-#endif // DOCVIEWERAPPLICATION_H

=== modified file 'src/app/main.cpp'
--- src/app/main.cpp	2015-09-14 18:59:09 +0000
+++ src/app/main.cpp	2015-10-18 17:16:22 +0000
@@ -1,37 +1,74 @@
 /*
- * Copyright: 2015 Canonical Ltd.
- *
- * This file is part of docviewer
- *
- * docviewer is free software: you can redistribute it and/or modify
+ * 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation; version 3.
  *
- * reminders is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 // Uncomment if you need to use QML analyzer
 // #define QT_QML_DEBUG
 // #include <QtQuick>
 
-#include "docviewer-application.h"
+#include <QGuiApplication>
+#include <QQuickView>
+#include <QLibrary>
+#include <QtQml>
+
 #include <QDebug>
 
+#include "config.h"
+
+void loadTestability() {
+    QLibrary testLib(QLatin1String("qttestability"));
+
+    if (testLib.load()) {
+        typedef void (*TasInitialize)(void);
+        TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
+
+        if (initFunction) {
+            initFunction();
+        } else {
+            qCritical("Library qttestability resolve failed!");
+        }
+    } else {
+        qCritical("Library qttestability load failed!");
+    }
+}
+
 int main(int argc, char *argv[])
 {
+    QGuiApplication app(argc, argv);
+    QQuickView view;
+
     QCoreApplication::setApplicationName("com.ubuntu.docviewer");
     QCoreApplication::setOrganizationDomain("com.ubuntu.docviewer");
 
-    DocViewerApplication app(argc, argv);
-    if (!app.init())
-        return 0;
-
-    app.exec();
+    view.rootContext()->setContextProperty("window", &view);
+    QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+
+    if (qgetenv("QT_LOAD_TESTABILITY") == "1")
+       loadTestability();
+
+    if (!isRunningInstalled())
+        view.engine()->addImportPath(QCoreApplication::applicationDirPath() + "/../plugin/");
+
+    view.setSource(QUrl::fromLocalFile(docviewerDirectory() + "/qml/ubuntu-docviewer-app.qml"));
+    view.setResizeMode(QQuickView::SizeRootObjectToView);
+
+    // UITK/QML command line arguments are parsed before view's window becomes visible.
+    if (view.windowState() == Qt::WindowFullScreen)
+        view.showFullScreen();
+    else
+        view.show();
+
+    return app.exec();
 }

=== added file 'src/app/qml/common/CommandLineProxy.qml'
--- src/app/qml/common/CommandLineProxy.qml	1970-01-01 00:00:00 +0000
+++ src/app/qml/common/CommandLineProxy.qml	2015-10-18 17:16:22 +0000
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2015 Stefano Verzegnassi
+ *
+ * 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
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+
+Item {
+    id: rootItem
+
+    property string documentFile: ""
+    property string documentsDir: ""
+    property bool fullscreen: false
+    property bool pickMode: false
+
+    Component.onCompleted: {
+        var docFile = args.defaultArgument.at(0)
+        if (docFile)
+            rootItem.documentFile = docFile
+
+        var docsDir = args.values.documentsDir
+        if (docsDir)
+            rootItem.documentsDir = docsDir
+
+        var fullscreen = args.values.fullscreen
+        if (fullscreen)
+            rootItem.fullscreen = fullscreen
+
+        var pickMode =  args.values.pickMode
+        if (pickMode)
+            rootItem.pickMode = pickMode
+
+        // Error catching
+        // This does not include any argument which is not expected: they are
+        // just skipped.
+        if (args.error) {
+            var errorString = i18n.tr("Some of the provided arguments is not valid.")
+            args.quitWithError(errorString)
+        }
+    }
+
+    Arguments {
+        id: args
+
+        defaultArgument {
+            help: i18n.tr("Opens ubuntu-docviewer-app displaying the selected file")
+            valueNames: ["file_path"]
+            required: false
+        }
+
+        Argument {
+            name: "fullscreen"
+            help: i18n.tr("Run fullscreen")
+            required: false
+        }
+
+        Argument {
+            name: "pickMode"
+            help: i18n.tr("Open ubuntu-docviewer-app in pick mode. Use it for tests only.")
+            required: false
+        }
+
+        Argument {
+            name: "documentsDir"
+            help: i18n.tr("Load the list of documents from the given folder, instead of default ~/Documents.\nThe path must exist prior to running ubuntu-docviewer-app")
+            valueNames: ["PATH"]
+            required: false
+        }
+    }
+}

=== modified file 'src/app/qml/pdfView/PdfView.qml'
--- src/app/qml/pdfView/PdfView.qml	2015-04-15 14:47:28 +0000
+++ src/app/qml/pdfView/PdfView.qml	2015-10-18 17:16:22 +0000
@@ -58,7 +58,7 @@
 
         model: poppler
         delegate: PdfViewDelegate {
-            Component.onDestruction: DOC_VIEWER.releaseResources()
+            Component.onDestruction: window.releaseResources()
         }
 
         // FIXME: On zooming, keep the same content position.
@@ -78,7 +78,7 @@
                 // This is a bit expensive, so it's safer to put it here.
                 // It won't be called on desktop (where PinchArea is not used),
                 // but it's not a problem at the moment (our target is phone).
-                DOC_VIEWER.releaseResources();
+                window.releaseResources();
             }
 
             MouseArea {

=== modified file 'src/app/qml/ubuntu-docviewer-app.qml'
--- src/app/qml/ubuntu-docviewer-app.qml	2015-10-05 20:53:25 +0000
+++ src/app/qml/ubuntu-docviewer-app.qml	2015-10-18 17:16:22 +0000
@@ -28,13 +28,13 @@
     id: mainView
     objectName: "mainView"
 
-    // TODO: Connect with arguments
-    property bool pickMode: false
+    property bool pickMode: commandLineProxy.pickMode
+    property bool fullscreen: commandLineProxy.fullscreen
     readonly property bool isLandscape: Screen.orientation == Qt.LandscapeOrientation ||
                                         Screen.orientation == Qt.InvertedLandscapeOrientation
 
     applicationName: "com.ubuntu.docviewer"
-    useDeprecatedToolbar: false   
+    useDeprecatedToolbar: false
     automaticOrientation: true
 
     width: units.gu(150)
@@ -67,12 +67,8 @@
                         mainView, { parent: mainView });
     }
 
-    function setFullScreen(fullScreen) {
-        DOC_VIEWER.fullScreen = fullScreen;
-    }
-
     function toggleFullScreen() {
-        DOC_VIEWER.fullScreen = !DOC_VIEWER.fullScreen;
+        mainView.fullscreen = !mainView.fullscreen
     }
 
     function setHeaderVisibility(visible, toggleFullscreen) {
@@ -81,41 +77,43 @@
 
         // If device orientation is landscape and screen width is limited,
         // force hiding Unity 8 indicators panel.
-        if (!DOC_VIEWER.desktopMode && mainView.isLandscape &&
+        if (!DocumentViewer.desktopMode && mainView.isLandscape &&
                 mainView.width < units.gu(51)) {
-            setFullScreen(true);
+            mainView.fullscreen = true;
             return;
         }
 
-        if (!DOC_VIEWER.desktopMode && toggleFullscreen)
-            setFullScreen(!visible);
+        if (!DocumentViewer.desktopMode && toggleFullscreen)
+            mainView.fullscreen = !visible;
     }
 
     function toggleHeaderVisibility() {
         setHeaderVisibility(!header.visible);
     }
 
-    function setPickMode(pickMode) {
-        mainView.pickMode = pickMode
-    }
-
     function switchToBrowseMode() {
-        setPickMode(false)
+        mainView.pickMode = false
     }
 
     function switchToPickMode() {
-        setPickMode(true)
+        mainView.pickMode = true
     }
 
-
     // On screen rotation, force updating of header/U8 indicators panel visibility
     onIsLandscapeChanged: setHeaderVisibility(true);
 
+    onFullscreenChanged: {
+        if (mainView.fullscreen)
+            window.visibility = Window.FullScreen
+        else
+            window.visibility = Window.Windowed
+    }
+
     Component.onCompleted: {
         pageStack.push(Qt.resolvedUrl("documentPage/DocumentPage.qml"));
 
         // Open the document, if one has been specified.
-        openDocument(DOC_VIEWER.documentFile);
+        openDocument(commandLineProxy.documentFile);
     }
 
     File {
@@ -142,7 +140,7 @@
             id: docModel
 
             // Used for autopilot tests! If customDir is empty, this property is not used.
-            customDir: DOC_VIEWER.documentsDir
+            customDir: commandLineProxy.documentsDir
         }
 
         sort.property: {
@@ -183,6 +181,11 @@
         property bool reverseOrder: false
     }
 
+    // CommandLine parser
+    CommandLineProxy {
+        id: commandLineProxy
+    }
+
     // Content Hub support
     property alias contentHubProxy: contentHubLoader.item
     Loader {
@@ -195,19 +198,7 @@
     // Uri Handler support
     Connections {
         target: UriHandler
-        onOpened: {
-            for (var i = 0; i < uris.length; ++i) {
-                DOC_VIEWER.parseUri(uris[i])
-            }
-        }
-    }
-
-    Connections {
-        target: DOC_VIEWER
-
-        onDocumentFileChanged: {
-            openDocument(DOC_VIEWER.documentFile);
-        }
+        onOpened: openDocument(uris[0])
     }
 
     onPickModeChanged: {

=== removed file 'src/app/urlhandler.cpp'
--- src/app/urlhandler.cpp	2015-02-13 15:30:01 +0000
+++ src/app/urlhandler.cpp	1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2014 Canonical, Ltd.
- *
- * Authors:
- *  Arthur Mello <arthur.mello@xxxxxxxxxxxxx>
- *
- * 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
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "urlhandler.h"
-
-#include <QUrl>
-#include <QStringList>
-#include <QFileInfo>
-#include <QDir>
-#include <QDebug>
-
-UrlHandler::UrlHandler()
-    : m_documentFile("")
-{
-    m_validSchemes << "document";
-}
-
-/*!
- * @brief UrlHandler::processUri parsers our input uri and sets attributes accordingly.
- * @param QString uri to parse and set attributes.
- * @return false if invalid parameter is input.
- */
-bool UrlHandler::processUri(const QString& arg)
-{
-    QUrl uri(arg);
-
-    if (!m_validSchemes.contains(uri.scheme())) {
-        return false;
-    }
-
-    if (uri.scheme() == "document") {
-        uri.setScheme("file");
-    }
-
-    if (uri.isRelative()) {
-        uri = QUrl::fromLocalFile(QDir::current().absoluteFilePath(arg));
-    }
-
-    // Check if it's a local file
-    if (uri.isValid() && uri.isLocalFile()) {
-        QFileInfo info(uri.toLocalFile());
-        if (info.exists() && info.isFile()) {
-            m_documentFile = info.absoluteFilePath();
-            return true;
-        } else {
-            qWarning() << "File not found:" << uri << info.exists() << info.isFile();
-        }
-    } else {
-        qWarning() << "Invalid uri:" << uri;
-    }
-
-    return false;
-}

=== removed file 'src/app/urlhandler.h'
--- src/app/urlhandler.h	2015-02-13 15:30:01 +0000
+++ src/app/urlhandler.h	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2014 Canonical, Ltd.
- *
- * Authors:
- *  Arthur Mello <arthur.mello@xxxxxxxxxxxxx>
- *
- * 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
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef URLHANDLER_H
-#define URLHANDLER_H
-
-#include <QString>
-#include <QList>
-
-/*!
- * @brief The UrlHandler is used to parse calls of docviewer from the url schema.
- */
-class UrlHandler
-{
-public:
-    UrlHandler();
-
-    bool processUri(const QString &arg);
-    const QString &documentFile() { return m_documentFile; }
-
-private:
-    QList<QString> m_validSchemes;
-    QString m_documentFile;
-};
-
-#endif // URLHANDLER_H

=== modified file 'src/plugin/file-qml-plugin/docviewerutils.cpp'
--- src/plugin/file-qml-plugin/docviewerutils.cpp	2015-09-21 11:31:20 +0000
+++ src/plugin/file-qml-plugin/docviewerutils.cpp	2015-10-18 17:16:22 +0000
@@ -22,6 +22,16 @@
 #include <QStandardPaths>
 #include <QDirIterator>
 #include <QDateTime>
+#include <QtGui/QGuiApplication>
+
+bool DocviewerUtils::desktopMode() 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"));
+}
 
 bool DocviewerUtils::exists(const QString &path)
 {

=== modified file 'src/plugin/file-qml-plugin/docviewerutils.h'
--- src/plugin/file-qml-plugin/docviewerutils.h	2015-09-21 11:15:29 +0000
+++ src/plugin/file-qml-plugin/docviewerutils.h	2015-10-18 17:16:22 +0000
@@ -23,8 +23,11 @@
 class DocviewerUtils : public QObject
 {
     Q_OBJECT
+    Q_PROPERTY(bool desktopMode READ desktopMode CONSTANT)
 
 public:
+    bool desktopMode() const;
+
     Q_INVOKABLE static bool exists(const QString &path);
     Q_INVOKABLE static bool copy(const QString &source, const QString &destination);