← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/minor-code-styling into lp:ubuntu-docviewer-app

 

Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/minor-code-styling into lp:ubuntu-docviewer-app.

Commit message:
Minor code style changes

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)

For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/minor-code-styling/+merge/288557

Minor code style changes
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/minor-code-styling into lp:ubuntu-docviewer-app.
=== modified file 'src/app/qml/common/HorizontalDivider.qml'
--- src/app/qml/common/HorizontalDivider.qml	2015-10-27 20:19:05 +0000
+++ src/app/qml/common/HorizontalDivider.qml	2016-03-09 18:21:13 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Canonical, Ltd.
+ * Copyright (C) 2015, 2016 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
@@ -20,9 +20,9 @@
 Rectangle {
     height: units.dp(2)
     gradient: Gradient {
-        GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0.1)  }
-        GradientStop { position: 0.49; color:  Qt.rgba(0, 0, 0, 0.1)  }
-        GradientStop { position: 0.5; color: Qt.rgba(1, 1, 1, 0.4) }
-        GradientStop { position: 1.0; color:  Qt.rgba(1, 1, 1, 0.4)  }
+        GradientStop { position: 0.0;  color: Qt.rgba(0, 0, 0, 0.1) }
+        GradientStop { position: 0.49; color: Qt.rgba(0, 0, 0, 0.1) }
+        GradientStop { position: 0.5;  color: Qt.rgba(1, 1, 1, 0.4) }
+        GradientStop { position: 1.0;  color: Qt.rgba(1, 1, 1, 0.4) }
     }
 }

=== modified file 'src/app/qml/common/ScalingMouseArea.qml'
--- src/app/qml/common/ScalingMouseArea.qml	2016-01-19 17:42:01 +0000
+++ src/app/qml/common/ScalingMouseArea.qml	2016-03-09 18:21:13 +0000
@@ -23,29 +23,26 @@
 
         scaleInfo.fromZoom = zoomValue
 
-        if (zoomValue <= thresholdZoom) {
+        if (zoomValue <= thresholdZoom)
             scaleInfo.toZoom = maximumZoom
-        } else {
+        else
             scaleInfo.toZoom = minimumZoom
-        }
 
         scaleInfo.tempContentX = tpt.x * scaleInfo.effectiveZoom - (flick.width * 0.5)
         scaleInfo.tempContentY = tpt.y * scaleInfo.effectiveZoom - (flick.height * 0.5)
 
         scaleInfo.finalContentX = Math.max(0, Math.min(pt.x * scaleInfo.effectiveZoom - (flick.width * 0.5),
-                                                            (flick.contentWidth * scaleInfo.effectiveZoom) - flick.width))
+                                                       (flick.contentWidth * scaleInfo.effectiveZoom) - flick.width))
 
         scaleInfo.finalContentY = Math.max(0, Math.min(pt.y * scaleInfo.effectiveZoom - (flick.height * 0.5),
-                                                            (flick.contentHeight * scaleInfo.effectiveZoom) - flick.height))
+                                                       (flick.contentHeight * scaleInfo.effectiveZoom) - flick.height))
 
-        if (zoomValue <= thresholdZoom) {
+        if (zoomValue <= thresholdZoom)
             zoomInAnimation.start()
-        } else {
+        else
             zoomOutAnimation.start()
-        }
     }
 
-
     QtObject {
         id: scaleInfo
 
@@ -62,7 +59,6 @@
 
     SequentialAnimation {
         id: zoomInAnimation
-
         ScriptAction { script: targetFlickable.interactive = false; }
 
         // Fake zooming
@@ -73,14 +69,12 @@
                 duration: mouseArea.zoomDuration
                 to: scaleInfo.effectiveZoom
             }
-
             NumberAnimation {
                 target: targetFlickable
                 property: "contentX"
                 duration: mouseArea.zoomDuration
                 to: scaleInfo.tempContentX
             }
-
             NumberAnimation {
                 target: targetFlickable
                 property: "contentY"
@@ -90,13 +84,10 @@
         }
 
         ScriptAction { script: targetFlickable.contentItem.scale = 1; }
-
         ScriptAction { script: totalScale = scaleInfo.toZoom; }
         ScriptAction { script: targetFlickable.contentX = scaleInfo.finalContentX; }
         ScriptAction { script: targetFlickable.contentY = scaleInfo.finalContentY; }
-
         ScriptAction { script: targetFlickable.returnToBounds(); }
-
         ScriptAction { script: targetFlickable.interactive = true; }
     }
 
@@ -104,13 +95,10 @@
         id: zoomOutAnimation
 
         ScriptAction { script: targetFlickable.interactive = false; }
-
         ScriptAction { script: totalScale = scaleInfo.toZoom; }
         ScriptAction { script: targetFlickable.contentX = scaleInfo.finalContentX; }
         ScriptAction { script: targetFlickable.contentY = scaleInfo.finalContentY; }
-
         ScriptAction { script: targetFlickable.returnToBounds(); }
-
         ScriptAction { script: targetFlickable.interactive = true; }
     }
 }

=== modified file 'src/app/qml/common/ScalingPinchArea.qml'
--- src/app/qml/common/ScalingPinchArea.qml	2016-01-19 17:42:01 +0000
+++ src/app/qml/common/ScalingPinchArea.qml	2016-03-09 18:21:13 +0000
@@ -10,25 +10,6 @@
     property real maximumZoom: 4.0
     property alias zoomValue: zoomHelper.scale
 
-    pinch {
-        target: Item { id: zoomHelper }
-        minimumScale: pinchArea.minimumZoom
-        maximumScale: pinchArea.maximumZoom
-    }
-
-    onPinchStarted: {
-        targetFlickable.interactive = false
-    }
-
-    onPinchUpdated: {
-        pinchUpdatedHandler(pinch)
-    }
-
-    onPinchFinished: {
-        targetFlickable.interactive = true
-        pinchFinishedHandler()
-    }
-
     function pinchUpdatedHandler(pinch) {
         if (zoomHelper.scale < pinchArea.maximumZoom &&
                 zoomHelper.scale > pinchArea.minimumZoom) {
@@ -56,4 +37,23 @@
         // Return to the legal bounds
         targetFlickable.returnToBounds()
     }
+
+    pinch {
+        target: Item { id: zoomHelper }
+        minimumScale: pinchArea.minimumZoom
+        maximumScale: pinchArea.maximumZoom
+    }
+
+    onPinchStarted: {
+        targetFlickable.interactive = false
+    }
+
+    onPinchUpdated: {
+        pinchUpdatedHandler(pinch)
+    }
+
+    onPinchFinished: {
+        targetFlickable.interactive = true
+        pinchFinishedHandler()
+    }
 }

=== modified file 'src/app/qml/ubuntu-docviewer-app.qml'
--- src/app/qml/ubuntu-docviewer-app.qml	2016-02-29 09:14:19 +0000
+++ src/app/qml/ubuntu-docviewer-app.qml	2016-03-09 18:21:13 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2015 Canonical, Ltd.
+ * Copyright (C) 2013-2016 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
@@ -30,6 +30,8 @@
     objectName: "mainView"
 
     property bool pickMode: commandLineProxy.pickMode
+    property alias contentHubProxy: contentHubLoader.item
+    property bool nightModeEnabled: false
 
     // If device orientation is landscape and screen width is limited,
     // force hiding Unity 8 indicators panel.
@@ -45,12 +47,6 @@
     readonly property bool isLandscape: Screen.orientation == Qt.LandscapeOrientation ||
                                         Screen.orientation == Qt.InvertedLandscapeOrientation
 
-    applicationName: "com.ubuntu.docviewer"
-    automaticOrientation: true
-
-    width: units.gu(150)
-    height: units.gu(75)
-
     function openDocument(path)  {
         if (path !== "") {
             console.log("Path of the document:", path)
@@ -91,6 +87,17 @@
                         mainView, { parent: mainView, text: message });
     }
 
+    applicationName: "com.ubuntu.docviewer"
+    automaticOrientation: true
+
+    width: units.gu(150)
+    height: units.gu(75)
+
+    layer.effect: NightModeShader {}
+    layer.enabled: nightModeEnabled &&
+                   (pageStack.depth > 1) &&
+                   !pageStack.currentPage.isPresentationMode
+
     onFullscreenChanged: {
         if (mainView.fullscreen)
             window.visibility = Window.FullScreen
@@ -98,6 +105,15 @@
             window.visibility = Window.Windowed
     }
 
+    onPickModeChanged: {
+        if (mainView.pickMode) {
+            // If a document is loaded, pop() its page.
+            while (pageStack.depth > 1) {
+                pageStack.pop()
+            }
+        }
+    }
+
     Component.onCompleted: {
         pageStack.push(Qt.resolvedUrl("documentPage/DocumentPage.qml"));
 
@@ -161,11 +177,12 @@
         filter.property: "name"
     }
 
-    PageStack { id: pageStack }
+    PageStack {
+        id: pageStack
+    }
 
     Settings {
         id: sortSettings
-
         property int sortMode: 0    // 0 = by date, 1 = by name, 2 = by size
         property bool reverseOrder: false
     }
@@ -176,10 +193,8 @@
     }
 
     // Content Hub support
-    property alias contentHubProxy: contentHubLoader.item
     Loader {
         id: contentHubLoader
-
         asynchronous: true
         source: Qt.resolvedUrl("common/ContentHubProxy.qml")
     }
@@ -190,21 +205,9 @@
         onOpened: openDocument(uris[0])
     }
 
-    onPickModeChanged: {
-        if (mainView.pickMode) {
-            // If a document is loaded, pop() its page.
-            while (pageStack.depth > 1) {
-                pageStack.pop()
-            }
-        }
-    }
-
+    // Screen saver controller
     ScreenSaver {
         // Turn off screen saver during a full-screen presentation when the app is focused.
         screenSaverEnabled: !(Qt.application.active && pageStack.currentPage.isPresentationMode)
     }
-
-    property bool nightModeEnabled: false
-    layer.effect: NightModeShader {}
-    layer.enabled: nightModeEnabled && (pageStack.depth > 1) && !pageStack.currentPage.isPresentationMode
 }


Follow ups