Skip to content

Commit fed97d3

Browse files
Fixed color selection for map sketching (#4274)
1 parent 48b0ed3 commit fed97d3

13 files changed

Lines changed: 269 additions & 188 deletions

app/icons/Eraser.svg

Lines changed: 5 additions & 0 deletions
Loading

app/icons/Redo.svg

Lines changed: 3 additions & 0 deletions
Loading

app/icons/icons.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<file>Electricity.svg</file>
2323
<file>Engineering.svg</file>
2424
<file>Environmental.svg</file>
25+
<file>Eraser.svg</file>
2526
<file>ErrorCircle.svg</file>
2627
<file>Facebook.svg</file>
2728
<file>Features.svg</file>
@@ -66,6 +67,7 @@
6667
<file>QGIS.svg</file>
6768
<file>QRCode.svg</file>
6869
<file>Reddit.svg</file>
70+
<file>Redo.svg</file>
6971
<file>RedrawGeometry.svg</file>
7072
<file>Search.svg</file>
7173
<file>Settings.svg</file>

app/mapsketchingcontroller.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ void MapSketchingController::finishDigitizing()
123123
}
124124
}
125125

126+
void MapSketchingController::redo() const
127+
{
128+
if ( !mLayer )
129+
return;
130+
131+
mLayer->undoStack()->redo();
132+
}
133+
126134
void MapSketchingController::undo() const
127135
{
128136
if ( !mLayer )
@@ -174,6 +182,7 @@ void MapSketchingController::setMapSettings( InputMapSettings *settings )
174182
{
175183
mLayer->startEditing();
176184
connect( mLayer->undoStack(), &QUndoStack::canUndoChanged, this, &MapSketchingController::canUndoChanged );
185+
connect( mLayer->undoStack(), &QUndoStack::canRedoChanged, this, &MapSketchingController::canRedoChanged );
177186
}
178187

179188
mMapSettings = settings;
@@ -185,6 +194,14 @@ InputMapSettings *MapSketchingController::mapSettings() const
185194
return mMapSettings;
186195
}
187196

197+
bool MapSketchingController::canRedo() const
198+
{
199+
if ( !mLayer )
200+
return false;
201+
202+
return mLayer->undoStack()->canRedo();
203+
}
204+
188205
bool MapSketchingController::canUndo() const
189206
{
190207
if ( !mLayer )

app/mapsketchingcontroller.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class MapSketchingController : public QObject
2424
Q_PROPERTY( InputMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
2525
Q_PROPERTY( QgsGeometry highlightGeometry READ highlightGeometry NOTIFY highlightGeometryChanged )
2626
Q_PROPERTY( QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged )
27+
Q_PROPERTY( bool canRedo READ canRedo NOTIFY canRedoChanged )
2728
Q_PROPERTY( bool canUndo READ canUndo NOTIFY canUndoChanged )
2829
Q_PROPERTY( bool eraserActive READ eraserActive WRITE setEraserActive NOTIFY eraserActiveChanged )
2930

@@ -35,6 +36,8 @@ class MapSketchingController : public QObject
3536

3637
Q_INVOKABLE void finishDigitizing();
3738

39+
Q_INVOKABLE void redo() const;
40+
3841
Q_INVOKABLE void undo() const;
3942

4043
Q_INVOKABLE QStringList availableColors() const;
@@ -43,6 +46,7 @@ class MapSketchingController : public QObject
4346
void highlightGeometryChanged();
4447
void activeColorChanged();
4548
void mapSettingsChanged();
49+
void canRedoChanged( bool canRedo );
4650
void canUndoChanged( bool canUndo );
4751
void eraserActiveChanged();
4852

@@ -51,6 +55,7 @@ class MapSketchingController : public QObject
5155
void clearHighlight();
5256
void setMapSettings( InputMapSettings *settings );
5357
InputMapSettings *mapSettings() const;
58+
bool canRedo() const;
5459
bool canUndo() const;
5560
bool eraserActive() const;
5661
void setEraserActive( bool active );

app/mmstyle.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ class MMStyle: public QObject
8282
Q_PROPERTY( QColor negativeUltraLightColor READ negativeUltraLightColor CONSTANT )
8383
Q_PROPERTY( QColor informativeColor READ informativeColor CONSTANT )
8484

85+
// Colors - color picker default
86+
Q_PROPERTY( QColor photoSketchingBlackColor READ photoSketchingBlackColor CONSTANT )
87+
Q_PROPERTY( QColor photoSketchingWhiteColor READ photoSketchingWhiteColor CONSTANT )
88+
Q_PROPERTY( QColor photoSketchingGreenColor READ photoSketchingGreenColor CONSTANT )
89+
Q_PROPERTY( QColor photoSketchingYellowColor READ photoSketchingYellowColor CONSTANT )
90+
Q_PROPERTY( QColor photoSketchingOrangeColor READ photoSketchingOrangeColor CONSTANT )
91+
Q_PROPERTY( QColor photoSketchingBlueColor READ photoSketchingBlueColor CONSTANT )
92+
Q_PROPERTY( QColor photoSketchingPinkColor READ photoSketchingPinkColor CONSTANT )
93+
8594
// Colors - others
8695
Q_PROPERTY( QColor shadowColor READ shadowColor CONSTANT )
8796
Q_PROPERTY( QColor snappingColor READ snappingColor CONSTANT )
@@ -115,6 +124,7 @@ class MMStyle: public QObject
115124
Q_PROPERTY( QUrl electricityIcon READ electricityIcon CONSTANT )
116125
Q_PROPERTY( QUrl engineeringIcon READ engineeringIcon CONSTANT )
117126
Q_PROPERTY( QUrl environmentalIcon READ environmentalIcon CONSTANT )
127+
Q_PROPERTY( QUrl eraserIcon READ eraserIcon CONSTANT )
118128
Q_PROPERTY( QUrl facebookIcon READ facebookIcon CONSTANT )
119129
Q_PROPERTY( QUrl featuresIcon READ featuresIcon CONSTANT )
120130
Q_PROPERTY( QUrl globeIcon READ globeIcon CONSTANT )
@@ -160,6 +170,7 @@ class MMStyle: public QObject
160170
Q_PROPERTY( QUrl tractorIcon READ tractorIcon CONSTANT )
161171
Q_PROPERTY( QUrl transportationIcon READ transportationIcon CONSTANT )
162172
Q_PROPERTY( QUrl undoIcon READ undoIcon CONSTANT )
173+
Q_PROPERTY( QUrl redoIcon READ redoIcon CONSTANT )
163174
Q_PROPERTY( QUrl waitingIcon READ waitingIcon CONSTANT )
164175
Q_PROPERTY( QUrl waterResourcesIcon READ waterResourcesIcon CONSTANT )
165176
Q_PROPERTY( QUrl studentIcon READ studentIcon CONSTANT )
@@ -382,6 +393,14 @@ class MMStyle: public QObject
382393
QColor informativeColor() const {return QColor::fromString( "#BEDAF0" );}
383394
QColor snappingColor() const {return QColor::fromString( "#BD74FF" );}
384395

396+
QColor photoSketchingBlackColor() const {return QColor::fromString( "#12181F" );}
397+
QColor photoSketchingWhiteColor() const {return QColor::fromString( "#FFFFFF" );}
398+
QColor photoSketchingGreenColor() const {return QColor::fromString( "#57B46F" );}
399+
QColor photoSketchingYellowColor() const {return QColor::fromString( "#FDCB2A" );}
400+
QColor photoSketchingOrangeColor() const {return QColor::fromString( "#FF9C40" );}
401+
QColor photoSketchingBlueColor() const {return QColor::fromString( "#5E9EE4" );}
402+
QColor photoSketchingPinkColor() const {return QColor::fromString( "#FF8F93" );}
403+
385404
QColor shadowColor() const {return QColor::fromString( "#66777777" );}
386405

387406
QUrl splitGeometryIcon() const {return QUrl( "qrc:/SplitGeometry.svg" );}
@@ -414,6 +433,7 @@ class MMStyle: public QObject
414433
QUrl downloadIcon() const {return QUrl( "qrc:/Download.svg" );}
415434
QUrl uploadIcon() const {return QUrl( "qrc:/Upload.svg" );}
416435
QUrl editIcon() const {return QUrl( "qrc:/Edit.svg" );}
436+
QUrl eraserIcon() const {return QUrl( "qrc:/Eraser.svg" );}
417437
QUrl electricityIcon() const {return QUrl( "qrc:/Electricity.svg" );}
418438
QUrl engineeringIcon() const {return QUrl( "qrc:/Engineering.svg" );}
419439
QUrl environmentalIcon() const {return QUrl( "qrc:/Environmental.svg" );}
@@ -444,6 +464,7 @@ class MMStyle: public QObject
444464
QUrl projectsIcon() const {return QUrl( "qrc:/Projects.svg" );}
445465
QUrl qgisIcon() const {return QUrl( "qrc:/QGIS.svg" );}
446466
QUrl qrCodeIcon() const {return QUrl( "qrc:/QRCode.svg" );}
467+
QUrl redoIcon() const {return QUrl( "qrc:/Redo.svg" );}
447468
QUrl redditIcon() const {return QUrl( "qrc:/Reddit.svg" );}
448469
QUrl satelliteIcon() const {return QUrl( "qrc:/GPSSatellite.svg" );}
449470
QUrl searchIcon() const {return QUrl( "qrc:/Search.svg" );}

app/qml/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ set(MM_QML
4040
components/MMNotificationView.qml
4141
components/MMPage.qml
4242
components/MMPageHeader.qml
43+
components/MMColorPicker.qml
44+
components/MMColorButton.qml
4345
components/MMPopup.qml
4446
components/MMPhoto.qml
4547
components/MMProgressBar.qml
@@ -135,7 +137,7 @@ set(MM_QML
135137
layers/MMLayersListPage.qml
136138
layers/MMLayersListSearchPage.qml
137139
layers/MMLayersController.qml
138-
map/MMSketchesDrawer.qml
140+
map/MMMapSketchesDrawer.qml
139141
map/MMHighlight.qml
140142
map/MMMapCanvas.qml
141143
map/MMMapThemeDrawer.qml
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
* *
3+
* This program is free software; you can redistribute it and/or modify *
4+
* it under the terms of the GNU General Public License as published by *
5+
* the Free Software Foundation; either version 2 of the License, or *
6+
* (at your option) any later version. *
7+
* *
8+
***************************************************************************/
9+
10+
import QtQuick
11+
import QtQuick.Controls
12+
import QtQuick.Controls.Basic
13+
14+
RoundButton {
15+
id: root
16+
17+
required property color buttonColor
18+
property bool isSelected: false
19+
20+
implicitWidth: __style.margin48
21+
implicitHeight: __style.margin48
22+
23+
anchors.verticalCenter: parent.verticalCenter
24+
25+
contentItem: Rectangle {
26+
color: root.buttonColor
27+
radius: width / 2
28+
height: __style.margin32
29+
width: __style.margin32
30+
border{
31+
color: __style.photoSketchingWhiteColor ? __style.lightGreenColor : __style.transparentColor
32+
width: 2
33+
}
34+
}
35+
36+
background: Rectangle {
37+
anchors.centerIn: root
38+
radius: width / 2
39+
width: __style.margin48
40+
height: __style.margin48
41+
color: __style.transparentColor
42+
43+
border{
44+
width: 2
45+
color: root.isSelected ? __style.forestColor : __style.transparentColor
46+
}
47+
}
48+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/***************************************************************************
2+
* *
3+
* This program is free software; you can redistribute it and/or modify *
4+
* it under the terms of the GNU General Public License as published by *
5+
* the Free Software Foundation; either version 2 of the License, or *
6+
* (at your option) any later version. *
7+
* *
8+
***************************************************************************/
9+
pragma ComponentBehavior: Bound
10+
11+
import QtQuick
12+
import QtQuick.Controls
13+
14+
ScrollView {
15+
id: root
16+
17+
required property list<color> colors
18+
19+
property color activeColor
20+
21+
height: scrollRow.height
22+
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
23+
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
24+
25+
Row {
26+
id: scrollRow
27+
spacing: __style.margin2
28+
anchors.centerIn: parent
29+
30+
Repeater {
31+
model: root.colors
32+
MMColorButton{
33+
required property color modelData
34+
required property int index
35+
36+
buttonColor: modelData
37+
isSelected: root.activeColor === modelData
38+
39+
onClicked: {
40+
root.activeColor = modelData;
41+
}
42+
Component.onCompleted: {
43+
// set the initial color to be the first one in the list
44+
if ( index === 0 )
45+
{
46+
root.activeColor = modelData
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}

app/qml/form/components/MMFormPhotoSketchingPageDialog.qml

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ Dialog {
5858
MMComponents.MMRoundButton {
5959
iconSource: __style.undoIcon
6060

61-
bgndColor: __style.lightGreenColor
62-
63-
6461
enabled: root.controller.canUndo
6562

6663
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
@@ -200,55 +197,17 @@ Dialog {
200197

201198
MMComponents.MMListSpacer { implicitHeight: __style.margin20 }
202199

203-
ScrollView {
200+
MMComponents.MMColorPicker{
201+
colors: [__style.photoSketchingWhiteColor, __style.photoSketchingBlackColor, __style.photoSketchingBlueColor, __style.photoSketchingGreenColor, __style.photoSketchingYellowColor, __style.photoSketchingOrangeColor, __style.photoSketchingPinkColor]
202+
204203
Layout.alignment: Qt.AlignHCenter
205-
Layout.preferredHeight: scrollRow.height
206-
Layout.preferredWidth: scrollRow.width
207204
Layout.maximumWidth: parent.width - ( 2 * __style.pageMargins + __style.safeAreaLeft + __style.safeAreaRight )
208205
Layout.bottomMargin: __style.pageMargins + __style.safeAreaBottom
209206
Layout.leftMargin: __style.pageMargins + __style.safeAreaLeft
210207
Layout.rightMargin: __style.pageMargins + __style.safeAreaRight
211208

212-
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
213-
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
214-
215-
Row {
216-
id: scrollRow
217-
spacing: __style.margin12
218-
padding: __style.margin4
219-
anchors.centerIn: parent
220-
221-
Repeater {
222-
// we use more vibrant versions of our product colors
223-
model: ["#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93"]
224-
225-
MMComponents.MMRoundButton {
226-
id: colorButton
227-
required property color modelData
228-
anchors.verticalCenter: parent.verticalCenter
229-
230-
contentItem: Rectangle {
231-
color: colorButton.modelData
232-
radius: width / 2
233-
anchors.fill: parent
234-
}
235-
background: Rectangle {
236-
property bool isActive: colorButton.modelData === root.controller.activeColor
237-
238-
anchors.centerIn: parent
239-
radius: width / 2
240-
width: __style.margin48
241-
height: __style.margin48
242-
color: isActive ? __style.transparentColor : __style.lightGreenColor
243-
border.width: 2
244-
border.color: isActive ? __style.grassColor : __style.transparentColor
245-
}
246-
247-
onClicked: {
248-
root.controller.setActiveColor( modelData )
249-
}
250-
}
251-
}
209+
onActiveColorChanged:{
210+
root.controller.activeColor = activeColor
252211
}
253212
}
254213
}

0 commit comments

Comments
 (0)