Skip to content

Commit

Permalink
Merge pull request #4879 from opengisch/undo_redo_followup
Browse files Browse the repository at this point in the history
Undo redo history follow ups
  • Loading branch information
nirvn authored Dec 21, 2023
2 parents 3e7c1a1 + 66ae80b commit f7fcc89
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 74 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<file>themes/qfield/nodpi/ic_lock_open_green_24dp.svg</file>
<file>themes/qfield/nodpi/ic_measurement_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_folder_open_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_project_folder_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_print_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_home_black_24dp.svg</file>
<file>themes/qfield/hdpi/ic_add_circle_outline_white_24dp.png</file>
Expand Down
4 changes: 4 additions & 0 deletions images/themes/qfield/nodpi/ic_project_folder_black_24dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/qml/QFieldCloudPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Popup {
? qsTr('Revert local changes')
: qsTr('Reset project')
enabled: cloudProjectsModel.layerObserver.deltaFileWrapper.count > 0 || cloudProjectsModel.layerObserver.deltaFileWrapper.hasError()
icon.source: Theme.getThemeVectorIcon('ic_undo_white_24dp')
icon.source: Theme.getThemeVectorIcon('ic_undo_black_24dp')
icon.color: "white"

onClicked: {
Expand Down
2 changes: 1 addition & 1 deletion src/qml/geometryeditors/VertexEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ VisibilityFadingRow {

QfToolButton {
id: undoButton
iconSource: Theme.getThemeVectorIcon( "ic_undo_white_24dp" )
iconSource: Theme.getThemeVectorIcon( "ic_undo_black_24dp" )
iconColor: "white"
round: true
visible: featureModel && featureModel.vertexModel.canUndo
Expand Down
170 changes: 98 additions & 72 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2118,9 +2118,10 @@ ApplicationWindow {
bottomMargin: sceneBottomMargin

width: {
var result = 0;
var result = actionsRow.children.length * 44;
var padding = 0;
for (var i = 0; i < count; ++i) {
// Skip first Row item
for (var i = 1; i < count; ++i) {
var item = itemAt(i);
result = Math.max(item.contentItem.implicitWidth, result);
padding = Math.max(item.padding, padding);
Expand All @@ -2129,64 +2130,122 @@ ApplicationWindow {
}

Row {
bottomPadding: parent.topMargin
id: actionsRow
spacing: 4
height: printItem.height
clip: true

property color hoveredColor: Qt.hsla(Theme.mainTextColor.hslHue, Theme.mainTextColor.hslSaturation, Theme.mainTextColor.hslLightness, 0.2)

QfToolButton {
icon.source: Theme.getThemeVectorIcon( "ic_undo_black_24dp" )
anchors.verticalCenter: parent.verticalCenter
height: 44
width: 44
padding: 6
round: true
iconSource: Theme.getThemeVectorIcon( "ic_home_black_24dp" )
iconColor: Theme.mainTextColor
height: 48
width: 48
enabled: featureHistory.isUndoAvailable
opacity: enabled ? 1 : 0.5
bgcolor: hovered ? actionsRow.hoveredColor : "#00ffffff"

onClicked: {
const msg = featureHistory.undoMessage();
mainMenu.close()
dashBoard.close()
welcomeScreen.visible = true
welcomeScreen.focus = true
highlighted = false
}
}

if ( featureHistory.undo() ) {
displayToast( msg );
}
QfToolButton {
anchors.verticalCenter: parent.verticalCenter
height: 44
width: 44
padding: 6
round: true
iconSource: Theme.getThemeVectorIcon( "ic_measurement_black_24dp" )
iconColor: Theme.mainTextColor
bgcolor: hovered ? actionsRow.hoveredColor : "#00ffffff"

dashBoard.close();
mainMenu.close();
onClicked: {
mainMenu.close()
dashBoard.close()
changeMode( 'measure' )
highlighted = false
}
}

QfToolButton {
icon.source: Theme.getThemeVectorIcon( "ic_redo_black_24dp" )
anchors.verticalCenter: parent.verticalCenter
height: 44
width: 44
padding: 6
round: true
iconSource: Theme.getThemeVectorIcon( "ic_lock_black_24dp" )
iconColor: Theme.mainTextColor
height: 48
width: 48
enabled: featureHistory.isRedoAvailable
opacity: enabled ? 1 : 0.5
bgcolor: hovered ? actionsRow.hoveredColor : "#00ffffff"

onClicked: {
const msg = featureHistory.redoMessage();
mainMenu.close()
dashBoard.close()
screenLocker.enabled = true
}
}

if ( featureHistory.redo() ) {
displayToast( msg );
}
QfToolButton {
id: undoButton
property bool isEnabled: featureHistory && featureHistory.isUndoAvailable
anchors.verticalCenter: parent.verticalCenter
height: 44
width: 44
padding: 6
round: true
iconSource: Theme.getThemeVectorIcon( "ic_undo_black_24dp" )
iconColor: isEnabled ? Theme.mainTextColor : Theme.mainTextDisabledColor
bgcolor: isEnabled && hovered ? actionsRow.hoveredColor : "#00ffffff"

dashBoard.close();
mainMenu.close();
onClicked: {
if (isEnabled) {
const msg = featureHistory.undoMessage();

if ( featureHistory.undo() ) {
displayToast( msg );
}

dashBoard.close();
mainMenu.close();
}
}
}
}

MenuItem {
text: qsTr( 'Measure Tool' )
QfToolButton {
id: redoButton
property bool isEnabled: featureHistory && featureHistory.isRedoAvailable
anchors.verticalCenter: parent.verticalCenter
height: 44
width: 44
padding: 6
round: true
iconSource: Theme.getThemeVectorIcon( "ic_redo_black_24dp" )
iconColor: isEnabled ? Theme.mainTextColor : Theme.mainTextDisabledColor
bgcolor: isEnabled && hovered ? actionsRow.hoveredColor : "#00ffffff"

font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_measurement_black_24dp" )
height: 48
leftPadding: 10
onClicked: {
if (isEnabled) {
const msg = featureHistory.redoMessage();

onTriggered: {
dashBoard.close()
changeMode( 'measure' )
highlighted = false
if ( featureHistory.redo() ) {
displayToast( msg );
}

dashBoard.close();
mainMenu.close();
}
}
}
}

MenuSeparator { width: parent.width }

MenuItem {
id: printItem
text: qsTr( "Print to PDF" )
Expand Down Expand Up @@ -2273,33 +2332,14 @@ ApplicationWindow {
}
}

MenuSeparator { width: parent.width }

MenuItem {
id: openProjectMenuItem
text: qsTr( "Go to Home Screen" )

font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_home_black_24dp" )
height: 48
leftPadding: 10

onTriggered: {
dashBoard.close()
welcomeScreen.visible = true
welcomeScreen.focus = true
highlighted = false
}
}

MenuItem {
id: openProjectFolderMenuItem
text: qsTr( "Open Project Folder" )
text: qsTr( "Project Folder" )

font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_folder_open_black_24dp" )
icon.source: Theme.getThemeVectorIcon( "ic_project_folder_black_24dp" )
height: 48
leftPadding: 10
rightPadding: 40

onTriggered: {
dashBoard.close()
Expand All @@ -2309,20 +2349,6 @@ ApplicationWindow {
}
}

MenuItem {
text: qsTr( 'Lock Screen' )

font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_lock_black_24dp" )
height: 48
leftPadding: 10

onTriggered: {
screenLocker.enabled = true
dashBoard.close()
}
}

MenuSeparator { width: parent.width }

MenuItem {
Expand Down

1 comment on commit f7fcc89

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please sign in to comment.