Skip to content
Merged
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
10 changes: 9 additions & 1 deletion app/mapsketchingcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ QgsGeometry MapSketchingController::highlightGeometry() const
QStringList MapSketchingController::availableColors() const
{
const QStringList defaultColors = { "#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93" };
return mMapSettings->project()->readListEntry( QStringLiteral( "Mergin" ), QStringLiteral( "MapSketching/Colors" ), defaultColors );

if ( mMapSettings && mMapSettings->project() )
{
return mMapSettings->project()->readListEntry( QStringLiteral( "Mergin" ), QStringLiteral( "MapSketching/Colors" ), defaultColors );
}

return defaultColors;
}

void MapSketchingController::clearHighlight()
Expand Down Expand Up @@ -187,6 +193,8 @@ void MapSketchingController::setMapSettings( InputMapSettings *settings )

mMapSettings = settings;
emit mapSettingsChanged();

setActiveColor( availableColors().first() );
}

InputMapSettings *MapSketchingController::mapSettings() const
Expand Down
2 changes: 0 additions & 2 deletions app/qml/components/MMColorButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ RoundButton {
implicitWidth: __style.margin48
implicitHeight: __style.margin48

anchors.verticalCenter: parent.verticalCenter

contentItem: Rectangle {
color: root.buttonColor
radius: width / 2
Expand Down
14 changes: 4 additions & 10 deletions app/qml/components/MMColorPicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ScrollView {

property color activeColor

signal activeColorChangeRequested( color newColor )

height: scrollRow.height
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
Expand All @@ -29,23 +31,15 @@ ScrollView {

Repeater {
model: root.colors

MMColorButton{
required property color modelData
required property int index

buttonColor: modelData
isSelected: root.activeColor === modelData

onClicked: {
root.activeColor = modelData;
}
Component.onCompleted: {
// set the initial color to be the first one in the list
if ( index === 0 )
{
root.activeColor = modelData
}
}
onClicked: root.activeColorChangeRequested( modelData )
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions app/qml/map/MMMapSketchesDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,17 @@ MMComponents.MMDrawer {

MMComponents.MMColorPicker {
id: colorPicker
colors: root.sketchingController?.availableColors() ?? __style.photoSketchingWhiteColor

colors: root.sketchingController?.availableColors()
activeColor: root.sketchingController?.activeColor

Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width

onActiveColorChanged: {
onActiveColorChangeRequested: {
if ( root.sketchingController )
{
root.sketchingController.activeColor = colorPicker.activeColor
root.sketchingController.activeColor = newColor
root.sketchingController.eraserActive = false
}
}
Expand Down
Loading