ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #02673
[Merge] lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-ui-toolkit-upgrade into lp:ubuntu-calculator-app
Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-ui-toolkit-upgrade into lp:ubuntu-calculator-app.
Commit message:
Migrate to Ubuntu.Components 1.2
Requested reviews:
Ubuntu Calculator Developers (ubuntu-calculator-dev)
Related bugs:
Bug #1463400 in Ubuntu Calculator App: "Updgrade Ubuntu.Components to version 1.2"
https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1463400
For more details, see:
https://code.launchpad.net/~gang65/ubuntu-calculator-app/ubuntu-calculator-app-ui-toolkit-upgrade/+merge/261580
Initial migrate to Ubuntu.Components 1.2
--
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-ui-toolkit-upgrade into lp:ubuntu-calculator-app.
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml 2015-04-26 22:41:49 +0000
+++ app/ubuntu-calculator-app.qml 2015-06-09 23:22:27 +0000
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
import Ubuntu.Components.Themes.Ambiance 0.1
import "ui"
@@ -31,8 +31,6 @@
objectName: "calculator";
applicationName: "com.ubuntu.calculator";
- // Removes the old toolbar and enables new features of the new header.
- useDeprecatedToolbar: false;
automaticOrientation: true
anchorToKeyboard: textInputField.visible ? false : true
@@ -357,27 +355,26 @@
property var model: itemModel
visible: model.dbId !== -1
-
- selectionMode: visualModel.isInSelectionMode
- selected: visualModel.isSelected(visualDelegate)
-
+ // parent is the loader component
+ property var visualDelegate: parent ? parent : null
+
+ //selectMode: visualModel.isInSelectionMode
+ //selected: visualModel.isSelected(visualDelegate)
+
property var removalAnimation
function remove() {
removalAnimation.start();
}
- // parent is the loader component
- property var visualDelegate: parent ? parent : null
-
- onSwippingChanged: {
- visualModel.updateSwipeState(screenDelegate);
- }
-
- onSwipeStateChanged: {
- visualModel.updateSwipeState(screenDelegate);
- }
-
- onItemClicked: {
+ //onSwippingChanged: {
+ // visualModel.updateSwipeState(screenDelegate);
+ //}
+
+ //onSwipeStateChanged: {
+ // visualModel.updateSwipeState(screenDelegate);
+ //}
+
+ onClicked: {
if (visualModel.isInSelectionMode) {
if (!visualModel.selectItem(visualDelegate)) {
visualModel.deselectItem(visualDelegate);
@@ -385,71 +382,64 @@
}
}
- onItemPressAndHold: {
+ onPressAndHold: {
visualModel.startSelection();
visualModel.selectItem(visualDelegate);
}
- rightSideActions: [ screenDelegateCopyAction.item,
- screenDelegateEditAction.item,
- screenDelegateFavouriteAction.item ]
- leftSideAction: screenDelegateDeleteAction.item
-
- Loader {
- id: screenDelegateCopyAction
- sourceComponent: Action {
- iconName: "edit-copy"
- text: i18n.tr("Copy")
- onTriggered: {
- var mimeData = Clipboard.newData();
- mimeData.text = model.formula + "=" + model.result;
- Clipboard.push(mimeData);
- }
- }
- }
-
- Loader {
- id: screenDelegateEditAction
- sourceComponent: Action {
- iconName: "edit"
- text: i18n.tr("Edit")
- onTriggered: {
- longFormula = model.formula;
- shortFormula = model.result;
- displayedInputText = model.formula;
- isLastCalculate = false;
- previousVisual = "";
- scrollableView.scrollToBottom();
- }
- }
- }
- Loader {
- id: screenDelegateFavouriteAction
- sourceComponent: Action {
- iconName: (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: leading
+ trailingActions: trailing
+
+ ListItemActions {
+ id: trailing
+ actions: [
+ Action {
+ iconName: "edit-copy"
+ text: i18n.tr("Copy")
+ onTriggered: {
+ var mimeData = Clipboard.newData();
+ mimeData.text = model.formula + "=" + model.result;
+ Clipboard.push(mimeData);
+ }
+ },
+ Action {
+ 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 {
+ iconName: (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;
+ }
}
- }
+ ]
}
- Loader {
- id: screenDelegateDeleteAction
- sourceComponent: Action {
+ ListItemActions {
+ id: leading
+ actions: Action {
iconName: "delete"
text: i18n.tr("Delete")
onTriggered: {
=== modified file 'app/ui/CalcKeyboard.qml'
--- app/ui/CalcKeyboard.qml 2015-03-05 22:57:16 +0000
+++ app/ui/CalcKeyboard.qml 2015-06-09 23:22:27 +0000
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
Rectangle {
id: virtualKeyboard
=== modified file 'app/ui/FavouritePage.qml'
--- app/ui/FavouritePage.qml 2015-03-26 16:22:09 +0000
+++ app/ui/FavouritePage.qml 2015-06-09 23:22:27 +0000
@@ -17,7 +17,7 @@
*/
import QtQuick 2.3
import QtQuick.Layouts 1.1
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
import Ubuntu.Components.ListItems 1.0 as ListItem
import "../engine"
=== modified file 'app/ui/KeyboardButton.qml'
--- app/ui/KeyboardButton.qml 2015-05-27 23:55:16 +0000
+++ app/ui/KeyboardButton.qml 2015-06-09 23:22:27 +0000
@@ -17,7 +17,7 @@
*/
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
AbstractButton {
id: buttonRect
=== modified file 'app/ui/KeyboardPage.qml'
--- app/ui/KeyboardPage.qml 2015-03-06 21:13:52 +0000
+++ app/ui/KeyboardPage.qml 2015-06-09 23:22:27 +0000
@@ -1,5 +1,5 @@
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
Grid {
id: keyboardRoot
=== modified file 'app/ui/LandscapeKeyboard.qml'
--- app/ui/LandscapeKeyboard.qml 2015-03-12 21:21:47 +0000
+++ app/ui/LandscapeKeyboard.qml 2015-06-09 23:22:27 +0000
@@ -1,5 +1,5 @@
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
CalcKeyboard {
id: calcKeyboard
=== modified file 'app/ui/PortraitKeyboard.qml'
--- app/ui/PortraitKeyboard.qml 2015-03-12 21:21:47 +0000
+++ app/ui/PortraitKeyboard.qml 2015-06-09 23:22:27 +0000
@@ -1,5 +1,5 @@
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
CalcKeyboard {
id: calcKeyboard
=== modified file 'app/ui/Screen.qml'
--- app/ui/Screen.qml 2015-03-12 21:21:47 +0000
+++ app/ui/Screen.qml 2015-06-09 23:22:27 +0000
@@ -16,12 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.3
-import Ubuntu.Components 1.1
+import Ubuntu.Components 1.2
-import "../upstreamcomponents"
import "../engine/formula.js" as Formula
-ListItemWithActions {
+ListItem {
id: root
function formatDate(date) {
@@ -50,14 +49,16 @@
return Qt.formatDateTime(calcDate, i18n.tr("dd MMM yyyy"));
}
+ divider.visible: false
color: "white"
Column {
anchors.fill: parent
+ anchors.rightMargin: units.gu(2)
+
Row {
id: creationDateRow
width: parent.width
anchors.right: parent.right
- spacing: units.gu(1)
layoutDirection: Qt.RightToLeft
@@ -93,7 +94,6 @@
anchors.right: parent.right
layoutDirection: Qt.RightToLeft
- spacing: units.gu(1)
Text {
id: result
=== removed file 'app/upstreamcomponents/ListItemWithActions.qml'
--- app/upstreamcomponents/ListItemWithActions.qml 2015-02-02 20:35:38 +0000
+++ app/upstreamcomponents/ListItemWithActions.qml 1970-01-01 00:00:00 +0000
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2012-2014 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.2
-import Ubuntu.Components 1.1
-
-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 2014-12-03 22:54:49 +0000
+++ app/upstreamcomponents/ListItemWithActionsCheckBox.qml 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2012-2014 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.2
-import Ubuntu.Components 1.1
-
-CheckBox {
- checked: root.selected
- width: implicitWidth
- // disable item mouse area to avoid conflicts with parent mouse area
- __mouseArea.enabled: false
-}
=== modified file 'manifest.json.in'
--- manifest.json.in 2015-01-26 22:56:40 +0000
+++ manifest.json.in 2015-06-09 23:22:27 +0000
@@ -1,7 +1,7 @@
{
"architecture": "all",
"description": "A calculator for Ubuntu Touch",
- "framework": "ubuntu-sdk-14.10",
+ "framework": "ubuntu-sdk-15.04",
"hooks": {
"@APP_HARDCODE@": {
"apparmor": "@APP_HARDCODE@.apparmor",
Follow ups