Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set(MM_QML
components/MMNotificationView.qml
components/MMPage.qml
components/MMPageHeader.qml
components/MMPhotoColorPicker.qml
components/MMPopup.qml
components/MMPhoto.qml
components/MMProgressBar.qml
Expand Down
77 changes: 77 additions & 0 deletions app/qml/components/MMPhotoColorPicker.qml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer calling it MMColorPicker, it sounds more descriptive and we don't use it for just photos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import QtQuick
import QtQuick.Controls

ScrollView {
id: root

required property var colors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required property var colors
required property list<color> colors

it would be nice to specify fully what we want there

required property var controller
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't couple controller tightly with this component. Using signals is preferred here

required property bool showEraseButton

height: scrollRow.height
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

Row {
id: scrollRow
spacing: __style.margin12
padding: __style.margin4
anchors.centerIn: parent

Repeater {
model: colors ?? null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be always specified and never null


MMRoundButton {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it would be also nice to make component out of this button too MMColorButton

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to use the more explicit notation required property color modelData

anchors.verticalCenter: parent.verticalCenter

contentItem: Rectangle {
color: modelData
radius: width / 2
anchors.fill: parent
}

background: Rectangle {
property bool isActive: modelData.toLowerCase() === controller.activeColor.toString().toLowerCase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeColor will become the components property (read only preferably) and the component which uses this component will specify onActiveColorChanged to update controller

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In map sketching no color is selected anymore by default, while in photo sketching it is


anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
radius: width / 2
width: __style.margin48
height: __style.margin48
color: isActive ? __style.transparentColor : __style.lightGreenColor
border.width: 2
border.color: isActive ? __style.grassColor : __style.transparentColor
}

onClicked: {
if (showEraseButton) {
controller.eraserActive = false;
}
controller.activeColor = modelData;
Comment on lines +48 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again these two should change only stuff in this component and eraserActive can be exposed as property

}
}
}

MMButton {
text: qsTr("Eraser")
iconSourceLeft: __style.editIcon
// in some instances the erase button is not needed, because there is an "undo" feature already implemented
visible: showEraseButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
visible: showEraseButton
visible: root.showEraseButton


type: MMButton.Types.Primary
size: MMButton.Sizes.Small

fontColor: controller?.eraserActive ? __style.negativeColor : __style.grapeColor
iconColor: controller?.eraserActive ? __style.negativeColor : __style.grapeColor
bgndColor: controller?.eraserActive ? __style.grapeColor : __style.negativeColor
fontColorHover: controller?.eraserActive ? __style.grapeColor : __style.negativeColor
iconColorHover: controller?.eraserActive ? __style.grapeColor : __style.negativeColor
bgndColorHover: controller?.eraserActive ? __style.negativeColor : __style.grapeColor

onClicked: {
controller.activeColor = null;
controller.eraserActive = true;
}
Comment on lines +64 to +74
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as above

}
}
}
50 changes: 5 additions & 45 deletions app/qml/form/components/MMFormPhotoSketchingPageDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -200,56 +200,16 @@ Dialog {

MMComponents.MMListSpacer { implicitHeight: __style.margin20 }

ScrollView {
MMComponents.MMPhotoColorPicker{
colors: ["#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have done this before, but please define these colors in MMStyle

showEraseButton: false
controller: root.controller

Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: scrollRow.height
Layout.preferredWidth: scrollRow.width
Layout.maximumWidth: parent.width - ( 2 * __style.pageMargins + __style.safeAreaLeft + __style.safeAreaRight )
Layout.bottomMargin: __style.pageMargins + __style.safeAreaBottom
Layout.leftMargin: __style.pageMargins + __style.safeAreaLeft
Layout.rightMargin: __style.pageMargins + __style.safeAreaRight

ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

Row {
id: scrollRow
spacing: __style.margin12
padding: __style.margin4
anchors.centerIn: parent

Repeater {
// we use more vibrant versions of our product colors
model: ["#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93"]

MMComponents.MMRoundButton {
id: colorButton
required property color modelData
anchors.verticalCenter: parent.verticalCenter

contentItem: Rectangle {
color: colorButton.modelData
radius: width / 2
anchors.fill: parent
}
background: Rectangle {
property bool isActive: colorButton.modelData === root.controller.activeColor

anchors.centerIn: parent
radius: width / 2
width: __style.margin48
height: __style.margin48
color: isActive ? __style.transparentColor : __style.lightGreenColor
border.width: 2
border.color: isActive ? __style.grassColor : __style.transparentColor
}

onClicked: {
root.controller.setActiveColor( modelData )
}
}
}
}
}
}

Expand Down
93 changes: 12 additions & 81 deletions app/qml/map/MMSketchesDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,87 +54,18 @@ MMComponents.MMDrawer {
onClicked: root.sketchingController.undo()
}

drawerContent: Column {
id: mainColumn

width: parent.width
spacing: __style.margin10

ScrollView {
width: parent.width
height: scrollRow.height

ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

Row {
id: scrollRow
width: parent.width
spacing: __style.margin12
leftPadding: __style.margin6

Repeater {
id: colorsView

model: root.sketchingController?.availableColors() ?? null

MMComponents.MMRoundButton {
anchors.verticalCenter: parent.verticalCenter

contentItem: Rectangle {
color: modelData
radius: width / 2
anchors.fill: parent
}

background: Rectangle {
property bool isActive: modelData.toLowerCase() === root.sketchingController.activeColor.toString().toLowerCase()

anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
radius: width / 2
width: scrollRow.height
height: scrollRow.height
color: isActive ? __style.transparentColor : __style.lightGreenColor
border.width: 2
border.color: isActive ? __style.grassColor : __style.transparentColor
}

onClicked: {
root.sketchingController.eraserActive = false
root.sketchingController.activeColor = modelData
}

Component.onCompleted: {
// set the initial color to be the first one in the list
if ( index === 0 )
{
root.sketchingController.activeColor = modelData
}
}
}
}

MMComponents.MMButton {
text: qsTr( "Eraser" )
iconSourceLeft: __style.editIcon

type: MMButton.Types.Primary
size: MMButton.Sizes.Small

fontColor: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor
iconColor: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor
bgndColor: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor
fontColorHover: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor
iconColorHover: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor
bgndColorHover: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor

onClicked: {
root.sketchingController.activeColor = null
root.sketchingController.eraserActive = true
}
}
}
drawerContent: ColumnLayout {
anchors {
left: parent.left
right: parent.right
}
Comment on lines +57 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you have to specify ColumnLayout here if you have just one element


MMComponents.MMPhotoColorPicker{
colors: root.sketchingController?.availableColors() ?? null
showEraseButton: true
controller: root.sketchingController

Layout.fillWidth: true
}
}
}
Loading