ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #09763
[Merge] lp:~fboucault/ubuntu-calculator-app/startup_time into lp:ubuntu-calculator-app
Florian Boucault has proposed merging lp:~fboucault/ubuntu-calculator-app/startup_time into lp:ubuntu-calculator-app.
Commit message:
Improved startup time (2.9s saved on krillin):
- Load Icons and Images asynchronously.
- Prevent multiple resize of keyboard due to window size bug.
- Make sure the keyboard model is built only once.
- Faster KeyboardButton using a MouseArea instead of AbstractButton
- Asynchronous loading of: individual keyboard keys, screenDelegateComponent.
- Asynchronous compilation of FavouritePage.
- Asynchronous import of math.js.
- Use new ListItem API instead of ListItemWithActions: faster to instantiate and less code to maintain.
- Saving resources by making formula.js a library.
Requested reviews:
Ubuntu Calculator Developers (ubuntu-calculator-dev)
Related bugs:
Bug #1520554 in Ubuntu Calculator App: "Startup of calculator should be optimized"
https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1520554
For more details, see:
https://code.launchpad.net/~fboucault/ubuntu-calculator-app/startup_time/+merge/302403
Improved startup time (2.9s saved on krillin):
- Load Icons and Images asynchronously.
- Prevent multiple resize of keyboard due to window size bug.
- Make sure the keyboard model is built only once.
- Faster KeyboardButton using a MouseArea instead of AbstractButton
- Asynchronous loading of: individual keyboard keys, screenDelegateComponent.
- Asynchronous compilation of FavouritePage.
- Asynchronous import of math.js.
- Use new ListItem API instead of ListItemWithActions: faster to instantiate and less code to maintain.
- Saving resources by making formula.js a library.
--
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~fboucault/ubuntu-calculator-app/startup_time into lp:ubuntu-calculator-app.
=== added file 'app/engine/MathJs.qml'
--- app/engine/MathJs.qml 1970-01-01 00:00:00 +0000
+++ app/engine/MathJs.qml 2016-08-09 12:38:05 +0000
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014-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; 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 QtQml 2.0
+import "math.js" as MathJs
+
+QtObject {
+ property var mathJs: MathJs.mathJs;
+}
=== modified file 'app/engine/formula.js'
--- app/engine/formula.js 2015-11-19 21:55:04 +0000
+++ app/engine/formula.js 2016-08-09 12:38:05 +0000
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+.pragma library
+
/**
* Function which will delete last element in the formula
* It could be literal, operator, const (eg. "pi") or function (eg. "sin(" )
@@ -165,7 +167,7 @@
* @param string engineFormulaToConvert: the string where we have to replace chars
* @return a string based on param with changes in chars
*/
-function returnFormulaToDisplay(engineFormulaToConvert) {
+function returnFormulaToDisplay(engineFormulaToConvert, i18n, decimalPoint) {
// The deletion of " is necessary for MathJs.format function - it returns a
// string surrounded by ", and they're useless, so we remove them
var engineToVisualMap = {
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml 2016-01-18 23:40:25 +0000
+++ app/ubuntu-calculator-app.qml 2016-08-09 12:38:05 +0000
@@ -16,13 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
+import QtQuick.Window 2.2
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes.Ambiance 1.3
import "ui"
import "upstreamcomponents"
import "engine"
-import "engine/math.js" as MathJs
import "engine/formula.js" as Formula
import Qt.labs.settings 1.0
@@ -39,7 +39,13 @@
height: units.gu(60);
// This is our engine
- property var mathJs: MathJs.mathJs;
+ property var mathJs: mathJsLoader.item ? mathJsLoader.item.mathJs : null;
+ Loader {
+ id: mathJsLoader
+ source: "engine/MathJs.qml"
+ asynchronous: true
+ active: keyboardLoader.active
+ }
// Long form of formula, which are saved in the storage/history
property string longFormula: "";
@@ -264,18 +270,11 @@
PageWithBottomEdge {
id: calculatorPage
- title: i18n.tr("Calculator")
anchors.fill: parent
visible: false
bottomEdgeTitle: i18n.tr("Favorite")
-
- bottomEdgePageComponent: FavouritePage {
- anchors.fill: parent
-
- title: i18n.tr("Favorite")
- }
-
+ bottomEdgePageSource: "ui/FavouritePage.qml"
bottomEdgeEnabled: textInputField.visible
state: visualModel.isInSelectionMode ? "selection" : "default"
@@ -365,7 +364,7 @@
property var model: itemModel
visible: model.dbId !== -1
- selectionMode: visualModel.isInSelectionMode
+ selectMode: visualModel.isInSelectionMode
selected: visualModel.isSelected(visualDelegate)
property var removalAnimation
@@ -376,15 +375,11 @@
// parent is the loader component
property var visualDelegate: parent ? parent : null
- onSwippingChanged: {
- visualModel.updateSwipeState(screenDelegate);
- }
-
- onSwipeStateChanged: {
- visualModel.updateSwipeState(screenDelegate);
- }
-
- onItemClicked: {
+ onSwipedChanged: {
+ visualModel.updateSwipeState(screenDelegate);
+ }
+
+ onClicked: {
if (visualModel.isInSelectionMode) {
if (!visualModel.selectItem(visualDelegate)) {
visualModel.deselectItem(visualDelegate);
@@ -392,65 +387,71 @@
}
}
- onItemPressAndHold: {
+ onPressAndHold: {
visualModel.startSelection();
visualModel.selectItem(visualDelegate);
}
- rightSideActions: [
- Action {
- id: screenDelegateCopyAction
- iconName: "edit-copy"
- text: i18n.tr("Copy")
- onTriggered: {
- var mimeData = Clipboard.newData();
- mimeData.text = model.formula + "=" + model.result;
- Clipboard.push(mimeData);
- }
- },
- Action {
- id: screenDelegateEditAction
- iconName: "edit"
- text: i18n.tr("Edit")
- onTriggered: {
- longFormula = model.formula;
- shortFormula = model.result;
- displayedInputText = model.formula;
- isLastCalculate = false;
- previousVisual = "";
- scrollableView.scrollToBottom();
- }
- },
- Action {
- id: screenDelegateFavouriteAction
- iconName: (mainView.editedCalculationIndex == model.index || model.isFavourite) ? "starred" : "non-starred"
-
- text: i18n.tr("Add to favorites")
- onTriggered: {
-
- if (model.isFavourite) {
- calculationHistory.updateCalculationInDatabase(model.index, model.dbId, !model.isFavourite, "");
- editedCalculationIndex = -1;
- textInputField.visible = true;
- textInputField.forceActiveFocus();
- } else {
- editedCalculationIndex = model.index;
- textInputField.visible = false;
- favouriteTextField.forceActiveFocus();
+ leadingActions: ListItemActions {
+ actions: [
+ Action {
+ id: screenDelegateDeleteAction
+ iconName: "delete"
+ text: i18n.tr("Delete")
+ onTriggered: {
+ screenDelegate.remove();
+ }
+ }
+ ]
+ }
+ trailingActions: ListItemActions {
+ actions: [
+ Action {
+ id: screenDelegateCopyAction
+ iconName: "edit-copy"
+ text: i18n.tr("Copy")
+ onTriggered: {
+ var mimeData = Clipboard.newData();
+ mimeData.text = model.formula + "=" + model.result;
+ Clipboard.push(mimeData);
+ }
+ },
+ Action {
+ id: screenDelegateEditAction
+ iconName: "edit"
+ text: i18n.tr("Edit")
+ onTriggered: {
+ longFormula = model.formula;
+ shortFormula = model.result;
+ displayedInputText = model.formula;
+ isLastCalculate = false;
+ previousVisual = "";
scrollableView.scrollToBottom();
}
-
- model.isFavourite = !model.isFavourite;
+ },
+ Action {
+ id: screenDelegateFavouriteAction
+ iconName: (mainView.editedCalculationIndex == model.index || model.isFavourite) ? "starred" : "non-starred"
+
+ text: i18n.tr("Add to favorites")
+ onTriggered: {
+
+ if (model.isFavourite) {
+ calculationHistory.updateCalculationInDatabase(model.index, model.dbId, !model.isFavourite, "");
+ editedCalculationIndex = -1;
+ textInputField.visible = true;
+ textInputField.forceActiveFocus();
+ } else {
+ editedCalculationIndex = model.index;
+ textInputField.visible = false;
+ favouriteTextField.forceActiveFocus();
+ scrollableView.scrollToBottom();
+ }
+
+ model.isFavourite = !model.isFavourite;
+ }
}
- }
- ]
- leftSideAction: Action {
- id: screenDelegateDeleteAction
- iconName: "delete"
- text: i18n.tr("Delete")
- onTriggered: {
- screenDelegate.remove();
- }
+ ]
}
removalAnimation: SequentialAnimation {
@@ -510,13 +511,12 @@
}
}
- delegate: Component {
- Loader {
- property var itemModel: model
- width: parent.width
- height: model.dbId !== -1 ? item.height : 0;
- sourceComponent: screenDelegateComponent
- }
+ delegate: Loader {
+ property var itemModel: model
+ width: parent.width
+ height: model.dbId !== -1 ? item.height : 0;
+ sourceComponent: screenDelegateComponent
+ asynchronous: true
}
}
@@ -527,6 +527,7 @@
}
id: scrollableView
objectName: "scrollableView"
+ visible: keyboardLoader.status == Loader.Ready
Component.onCompleted: {
// FIXME: workaround for qtubuntu not returning values depending on the grid unit definition
@@ -603,7 +604,7 @@
}
}
- text: Formula.returnFormulaToDisplay(displayedInputText)
+ text: Formula.returnFormulaToDisplay(displayedInputText, i18n, decimalPoint)
font.pixelSize: height * 0.7
horizontalAlignment: TextInput.AlignRight
anchors {
@@ -722,6 +723,14 @@
Loader {
id: keyboardLoader
width: parent.width
+ enabled: mathJs != null
+ // FIXME: this works around the fact that the final size
+ // of keyboardLoader (and of mainView) is only set by the window
+ // manager quite late; this avoids unnecessary reloads of the
+ // source
+ active: false
+ property bool sizeReady: Window.active
+ onSizeReadyChanged: if (sizeReady) keyboardLoader.active = true
source: scrollableView.width > scrollableView.height ? "ui/LandscapeKeyboard.qml" : "ui/PortraitKeyboard.qml"
opacity: ((y + height) >= scrollableView.contentY) &&
(y <= (scrollableView.contentY + scrollableView.height)) ? 1 : 0
=== modified file 'app/ui/ActionButton.qml'
--- app/ui/ActionButton.qml 2016-01-19 01:31:11 +0000
+++ app/ui/ActionButton.qml 2016-08-09 12:38:05 +0000
@@ -37,5 +37,6 @@
height: width
anchors.centerIn: parent
color: UbuntuColors.orange
+ asynchronous: true
}
}
=== modified file 'app/ui/FavouritePage.qml'
--- app/ui/FavouritePage.qml 2015-11-27 16:40:30 +0000
+++ app/ui/FavouritePage.qml 2016-08-09 12:38:05 +0000
@@ -25,6 +25,7 @@
Page {
anchors.fill: parent
+ title: i18n.tr("Favorite")
property var removedFavourites: []
@@ -82,6 +83,7 @@
Layout.alignment: Qt.AlignVCenter
name: "starred"
+ asynchronous: true
}
Text {
=== modified file 'app/ui/KeyboardButton.qml'
--- app/ui/KeyboardButton.qml 2015-11-09 14:18:18 +0000
+++ app/ui/KeyboardButton.qml 2016-08-09 12:38:05 +0000
@@ -19,11 +19,10 @@
import QtQuick 2.4
import Ubuntu.Components 1.3
-AbstractButton {
+MouseArea {
id: buttonRect
objectName: modelname + "Button"
- property real baseSize: 1
property alias text: buttonText.text
property string buttonColor: "#eeeeee"
property string pressedColor: "#E2E1E4"
@@ -38,7 +37,7 @@
onKbdPressedChanged: {
if (!kbdPressed) {
- buttonRect.clicked();
+ buttonRect.clicked(null);
}
}
@@ -46,7 +45,7 @@
anchors.fill: parent
border.color: "#d0d0d0"
border.width: units.dp(0.5)
- color: buttonRect.pressed || buttonRect.kbdPressed ? pressedColor : buttonColor
+ color: buttonRect.pressed || buttonRect.kbdPressed ? "#E2E1E4" : "#eeeeee"
Behavior on color {
ColorAnimation {
@@ -62,5 +61,6 @@
font.pixelSize: 0.5 * parent.height
styleColor: "gray"
+ opacity: enabled ? 1.0 : 0.5
}
}
=== modified file 'app/ui/KeyboardPage.qml'
--- app/ui/KeyboardPage.qml 2015-11-09 14:18:18 +0000
+++ app/ui/KeyboardPage.qml 2016-08-09 12:38:05 +0000
@@ -63,12 +63,16 @@
//Space between the buttons
spacing: 0
+ property bool completed: false
Component.onCompleted: {
buildModel();
+ completed = true;
}
onKeyboardModelChanged: {
- buildModel();
+ if (completed) {
+ buildModel();
+ }
}
function buildModel() {
@@ -139,7 +143,6 @@
text: model.text
textColor: model.textColor
objectName: model.objectName
- baseSize: repeater.height
onClicked: {
//If key pressed then scroll down
=== modified file 'app/ui/Screen.qml'
--- app/ui/Screen.qml 2016-01-08 23:48:00 +0000
+++ app/ui/Screen.qml 2016-08-09 12:38:05 +0000
@@ -21,7 +21,7 @@
import "../upstreamcomponents"
import "../engine/formula.js" as Formula
-ListItemWithActions {
+ListItem {
id: root
objectName: "screenroot" + model.index
@@ -53,6 +53,7 @@
color: "white"
height: units.gu(7) + (mainView.isScreenIsWide ? 0 : units.gu(3.7))
+ divider.visible: false
Column {
anchors.fill: parent
Row {
@@ -81,6 +82,7 @@
width: height
name: model.isFavourite ? "starred" : "non-starred"
color: model.isFavourite ? UbuntuColors.orange : "white"
+ asynchronous: true
}
Text {
@@ -113,7 +115,7 @@
anchors.top: parent.top
color: UbuntuColors.darkGrey
- text: Formula.returnFormulaToDisplay(model.result)
+ text: Formula.returnFormulaToDisplay(model.result, i18n, mainView.decimalPoint)
textFormat: Text.PlainText
font.pixelSize: units.gu(3.5)
lineHeight: units.gu(2)
@@ -129,7 +131,7 @@
color: UbuntuColors.darkGrey
textFormat: Text.PlainText
- text: Formula.returnFormulaToDisplay(model.formula) + " ="
+ text: Formula.returnFormulaToDisplay(model.formula, i18n, mainView.decimalPoint) + " ="
font.pixelSize: units.gu(2.5)
verticalAlignment: Text.AlignVCenter
@@ -153,7 +155,7 @@
anchors.bottom: parent.bottom
color: UbuntuColors.darkGrey
- text: Formula.returnFormulaToDisplay(model.result)
+ text: Formula.returnFormulaToDisplay(model.result, i18n, mainView.decimalPoint)
font.pixelSize: units.gu(3.5)
lineHeight: units.gu(2)
lineHeightMode: Text.FixedHeight
=== modified file 'app/upstreamcomponents/EmptyState.qml'
--- app/upstreamcomponents/EmptyState.qml 2015-11-09 14:18:18 +0000
+++ app/upstreamcomponents/EmptyState.qml 2016-08-09 12:38:05 +0000
@@ -24,6 +24,7 @@
height: units.gu(10)
width: height
color: "#BBBBBB"
+ asynchronous: true
}
Label {
=== removed file 'app/upstreamcomponents/ListItemWithActions.qml'
--- app/upstreamcomponents/ListItemWithActions.qml 2015-11-09 14:18:18 +0000
+++ app/upstreamcomponents/ListItemWithActions.qml 1970-01-01 00:00:00 +0000
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2012-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; 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.4
-import Ubuntu.Components 1.3
-
-Item {
- id: root
-
- property Action leftSideAction: null
- property list<Action> rightSideActions
- property double defaultHeight: units.gu(8)
- property bool locked: false
- property Action activeAction: null
- property var activeItem: null
- property bool triggerActionOnMouseRelease: false
- property color color: Theme.palette.normal.background
- property color selectedColor: mainView.backgroundColor
- property bool selected: false
- property bool selectionMode: false
- property alias internalAnchors: mainContents.anchors
- default property alias contents: mainContents.children
-
- readonly property double actionWidth: units.gu(4)
- readonly property double leftActionWidth: units.gu(10)
- readonly property double actionThreshold: actionWidth * 0.4
- readonly property double threshold: 0.4
- readonly property string swipeState: main.x == 0 ? "Normal" : main.x > 0 ? "LeftToRight" : "RightToLeft"
- readonly property alias swipping: mainItemMoving.running
- readonly property bool _showActions: mouseArea.pressed || swipeState != "Normal" || swipping
-
- /* internal */
- property var _visibleRightSideActions: filterVisibleActions(rightSideActions)
-
- signal itemClicked(var mouse)
- signal itemPressAndHold(var mouse)
-
- function returnToBoundsRTL(direction)
- {
- var actionFullWidth = actionWidth + units.gu(2)
-
- // go back to normal state if swipping reverse
- if (direction === "LTR") {
- updatePosition(0)
- return
- } else if (!triggerActionOnMouseRelease) {
- updatePosition(-rightActionsView.width + units.gu(2))
- return
- }
-
- var xOffset = Math.abs(main.x)
- var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length)
- var newX = 0
- if (index === _visibleRightSideActions.length) {
- newX = -(rightActionsView.width - units.gu(2))
- } else if (index >= 1) {
- newX = -(actionFullWidth * index)
- }
- updatePosition(newX)
- }
-
- function returnToBoundsLTR(direction)
- {
- var finalX = leftActionWidth
- if ((direction === "RTL") || (main.x <= (finalX * root.threshold)))
- finalX = 0
- updatePosition(finalX)
- }
-
- function returnToBounds(direction)
- {
- if (main.x < 0) {
- returnToBoundsRTL(direction)
- } else if (main.x > 0) {
- returnToBoundsLTR(direction)
- } else {
- updatePosition(0)
- }
- }
-
- function contains(item, point, marginX)
- {
- var itemStartX = item.x - marginX
- var itemEndX = item.x + item.width + marginX
- return (point.x >= itemStartX) && (point.x <= itemEndX) &&
- (point.y >= item.y) && (point.y <= (item.y + item.height));
- }
-
- function getActionAt(point)
- {
- if (contains(leftActionView, point, 0)) {
- return leftSideAction
- } else if (contains(rightActionsView, point, 0)) {
- var newPoint = root.mapToItem(rightActionsView, point.x, point.y)
- for (var i = 0; i < rightActionsRepeater.count; i++) {
- var child = rightActionsRepeater.itemAt(i)
- if (contains(child, newPoint, units.gu(1))) {
- return i
- }
- }
- }
- return -1
- }
-
- function updateActiveAction()
- {
- if (triggerActionOnMouseRelease &&
- (main.x <= -(root.actionWidth + units.gu(2))) &&
- (main.x > -(rightActionsView.width - units.gu(2)))) {
- var actionFullWidth = actionWidth + units.gu(2)
- var xOffset = Math.abs(main.x)
- var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length)
- index = index - 1
- if (index > -1) {
- root.activeItem = rightActionsRepeater.itemAt(index)
- root.activeAction = root._visibleRightSideActions[index]
- }
- } else {
- root.activeAction = null
- }
- }
-
- function resetSwipe()
- {
- updatePosition(0)
- }
-
- function filterVisibleActions(actions)
- {
- var visibleActions = []
- for(var i = 0; i < actions.length; i++) {
- var action = actions[i]
- if (action.visible) {
- visibleActions.push(action)
- }
- }
- return visibleActions
- }
-
- function updatePosition(pos)
- {
- if (!root.triggerActionOnMouseRelease && (pos !== 0)) {
- mouseArea.state = pos > 0 ? "RightToLeft" : "LeftToRight"
- } else {
- mouseArea.state = ""
- }
- main.x = pos
- }
-
- states: [
- State {
- name: "select"
- when: selectionMode || selected
- PropertyChanges {
- target: selectionIcon
- source: Qt.resolvedUrl("ListItemWithActionsCheckBox.qml")
- anchors.leftMargin: units.gu(2)
- }
- PropertyChanges {
- target: root
- locked: true
- }
- PropertyChanges {
- target: main
- x: 0
- }
- }
- ]
-
- height: defaultHeight
- clip: height !== defaultHeight
-
- Rectangle {
- id: leftActionView
-
- anchors {
- top: parent.top
- bottom: parent.bottom
- right: main.left
- }
- width: root.leftActionWidth + actionThreshold
- visible: leftSideAction
- color: UbuntuColors.red
- opacity: main.x > 0 ? 1 : 0
-
- Icon {
- anchors {
- centerIn: parent
- horizontalCenterOffset: actionThreshold / 2
- }
- name: leftSideAction && _showActions ? leftSideAction.iconName : ""
- color: Theme.palette.selected.field
- height: units.gu(3)
- width: units.gu(3)
- }
- }
-
- Rectangle {
- id: rightActionsView
-
- anchors {
- top: main.top
- left: main.right
- bottom: main.bottom
- }
- visible: _visibleRightSideActions.length > 0
- width: rightActionsRepeater.count > 0 ? rightActionsRepeater.count * (root.actionWidth + units.gu(2)) + root.actionThreshold + units.gu(2) : 0
- color: "white"
- Row {
- anchors{
- top: parent.top
- left: parent.left
- leftMargin: units.gu(2)
- right: parent.right
- rightMargin: units.gu(2)
- bottom: parent.bottom
- }
- spacing: units.gu(2)
- Repeater {
- id: rightActionsRepeater
-
- model: _showActions ? _visibleRightSideActions : []
- Item {
- property alias image: img
-
- height: rightActionsView.height
- width: root.actionWidth
-
- Icon {
- id: img
-
- anchors.centerIn: parent
- width: units.gu(3)
- height: units.gu(3)
- name: modelData.iconName
- color: root.activeAction === modelData ? UbuntuColors.lightAubergine : UbuntuColors.lightGrey
- }
- }
- }
- }
- }
-
-
- Rectangle {
- id: main
- objectName: "mainItem"
-
- anchors {
- top: parent.top
- bottom: parent.bottom
- }
-
- width: parent.width
- color: root.selected ? root.selectedColor : root.color
-
- Loader {
- id: selectionIcon
-
- anchors {
- left: main.left
- verticalCenter: main.verticalCenter
- }
- width: (status === Loader.Ready) ? item.implicitWidth : 0
- visible: (status === Loader.Ready) && (item.width === item.implicitWidth)
- Behavior on width {
- NumberAnimation {
- duration: UbuntuAnimation.SnapDuration
- }
- }
- }
-
-
- Item {
- id: mainContents
-
- anchors {
- left: selectionIcon.right
- leftMargin: units.gu(2)
- top: parent.top
- topMargin: units.gu(1)
- right: parent.right
- rightMargin: units.gu(2)
- bottom: parent.bottom
- bottomMargin: units.gu(1)
- }
- }
-
- Behavior on x {
- UbuntuNumberAnimation {
- id: mainItemMoving
-
- easing.type: Easing.OutElastic
- duration: UbuntuAnimation.SlowDuration
- }
- }
- Behavior on color {
- ColorAnimation {}
- }
- }
-
- SequentialAnimation {
- id: triggerAction
-
- property var currentItem: root.activeItem ? root.activeItem.image : null
-
- running: false
- ParallelAnimation {
- UbuntuNumberAnimation {
- target: triggerAction.currentItem
- property: "opacity"
- from: 1.0
- to: 0.0
- duration: UbuntuAnimation.SlowDuration
- easing {type: Easing.InOutBack; }
- }
- UbuntuNumberAnimation {
- target: triggerAction.currentItem
- properties: "width, height"
- from: units.gu(3)
- to: root.actionWidth
- duration: UbuntuAnimation.SlowDuration
- easing {type: Easing.InOutBack; }
- }
- }
- PropertyAction {
- target: triggerAction.currentItem
- properties: "width, height"
- value: units.gu(3)
- }
- PropertyAction {
- target: triggerAction.currentItem
- properties: "opacity"
- value: 1.0
- }
- ScriptAction {
- script: {
- root.activeAction.triggered(root)
- mouseArea.state = ""
- }
- }
- PauseAnimation {
- duration: 500
- }
- UbuntuNumberAnimation {
- target: main
- property: "x"
- to: 0
-
- }
- }
-
- MouseArea {
- id: mouseArea
-
- property bool locked: root.locked || ((root.leftSideAction === null) && (root._visibleRightSideActions.count === 0))
- property bool manual: false
- property string direction: "None"
- property real lastX: -1
-
- anchors.fill: parent
- drag {
- target: locked ? null : main
- axis: Drag.XAxis
- minimumX: rightActionsView.visible ? -(rightActionsView.width) : 0
- maximumX: leftActionView.visible ? leftActionView.width : 0
- threshold: root.actionThreshold
- }
-
- states: [
- State {
- name: "LeftToRight"
- PropertyChanges {
- target: mouseArea
- drag.maximumX: 0
- }
- },
- State {
- name: "RightToLeft"
- PropertyChanges {
- target: mouseArea
- drag.minimumX: 0
- }
- }
- ]
-
- onMouseXChanged: {
- var offset = (lastX - mouseX)
- if (Math.abs(offset) <= root.actionThreshold) {
- return
- }
- lastX = mouseX
- direction = offset > 0 ? "RTL" : "LTR";
- }
-
- onPressed: {
- lastX = mouse.x
- }
-
- onReleased: {
- if (root.triggerActionOnMouseRelease && root.activeAction) {
- triggerAction.start()
- } else {
- root.returnToBounds(direction)
- root.activeAction = null
- }
- lastX = -1
- direction = "None"
- }
- onClicked: {
- if (main.x === 0) {
- root.itemClicked(mouse)
- } else if (main.x > 0) {
- var action = getActionAt(Qt.point(mouse.x, mouse.y))
- if (action && action !== -1) {
- action.triggered(root)
- }
- } else {
- var actionIndex = getActionAt(Qt.point(mouse.x, mouse.y))
- if (actionIndex !== -1) {
- root.activeItem = rightActionsRepeater.itemAt(actionIndex)
- root.activeAction = root._visibleRightSideActions[actionIndex]
- triggerAction.start()
- return
- }
- }
- root.resetSwipe()
- }
-
- onPositionChanged: {
- if (mouseArea.pressed) {
- updateActiveAction()
- }
- }
- onPressAndHold: {
- if (main.x === 0) {
- root.itemPressAndHold(mouse)
- }
- }
- z: -1
- }
-}
=== removed file 'app/upstreamcomponents/ListItemWithActionsCheckBox.qml'
--- app/upstreamcomponents/ListItemWithActionsCheckBox.qml 2015-11-09 14:18:18 +0000
+++ app/upstreamcomponents/ListItemWithActionsCheckBox.qml 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2012-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; 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.4
-import Ubuntu.Components 1.3
-
-CheckBox {
- checked: root.selected
- width: implicitWidth
- // disable item mouse area to avoid conflicts with parent mouse area
- __mouseArea.enabled: false
-}
=== modified file 'app/welcomewizard/Slide11.qml'
--- app/welcomewizard/Slide11.qml 2016-01-12 05:21:48 +0000
+++ app/welcomewizard/Slide11.qml 2016-08-09 12:38:05 +0000
@@ -40,6 +40,7 @@
anchors.centerIn: parent
source: Qt.resolvedUrl("../graphics/gift.png")
fillMode: Image.PreserveAspectFit
+ asynchronous: true
}
}
=== modified file 'app/welcomewizard/SlideBase.qml'
--- app/welcomewizard/SlideBase.qml 2016-01-12 05:21:48 +0000
+++ app/welcomewizard/SlideBase.qml 2016-08-09 12:38:05 +0000
@@ -48,6 +48,7 @@
anchors.centerIn: parent
source: Qt.resolvedUrl(slideImage)
fillMode: Image.PreserveAspectFit
+ asynchronous: true
}
}
Follow ups