Skip to content

Commit

Permalink
Add QfDialog.
Browse files Browse the repository at this point in the history
Cleaner dialog codes + we can have our custom dialog later.
remove lots of duplication.
  • Loading branch information
mohsenD98 authored and nirvn committed Oct 19, 2024
1 parent 2349d17 commit 01ebeb2
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 165 deletions.
11 changes: 1 addition & 10 deletions src/qml/BluetoothDeviceChooser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,16 @@ Item {
}
}

Dialog {
QfDialog {
id: fullDiscoveryDialog
parent: mainWindow.contentItem

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Make a full service discovery")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr('A full device scan can take longer. You really want to do it?\nCancel to make a minimal device scan instead.')
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
bluetoothDeviceModel.startServiceDiscovery(true);
visible = false;
Expand Down
11 changes: 1 addition & 10 deletions src/qml/BookmarkProperties.qml
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,17 @@ Popup {
}
}

Dialog {
QfDialog {
id: removeBookmarkDialog
parent: mainWindow.contentItem

visible: false
modal: true
font: Theme.defaultFont

z: 10000 // 1000s are embedded feature forms, user a higher value to insure the dialog will always show above embedded feature forms
x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Remove bookmark")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("You are about to remove a bookmark, proceed?")
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
bookmarkModel.removeBookmark(bookmarkProperties.bookmarkId);
bookmarkProperties.close();
Expand Down
12 changes: 1 addition & 11 deletions src/qml/DigitizingToolbar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,15 @@ QfVisibilityFadingRow {
}
}

Dialog {
QfDialog {
id: cancelDialog
parent: mainWindow.contentItem

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Cancel digitizing")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Should the digitized geometry be discarded?")
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
digitizingLogger.clearCoordinates();
rubberbandModel.reset();
Expand Down
13 changes: 1 addition & 12 deletions src/qml/FeatureForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -850,27 +850,16 @@ Page {
}
}
}

Dialog {
QfDialog {
id: cancelDialog
parent: mainWindow.contentItem

visible: false
modal: true
font: Theme.defaultFont

z: 10000 // 1000s are embedded feature forms, user a higher value to insure the dialog will always show above embedded feature forms
x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Cancel editing")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: form.state === 'Add' ? qsTr("You are about to dismiss the new feature, proceed?") : qsTr("You are about to leave editing state, any changes will be lost. Proceed?")
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
form.cancel();
}
Expand Down
38 changes: 4 additions & 34 deletions src/qml/FeatureListForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -796,29 +796,21 @@ Rectangle {
}
}

Dialog {
QfDialog {
id: mergeDialog
parent: mainWindow.contentItem

property int selectedCount: 0
property string featureDisplayName: ''
property bool isMerged: false

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Merge feature(s)")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Should the %n feature(s) selected really be merge?\n\nThe features geometries will be combined into feature '%1', which will keep its attributes.", "0", mergeDialog.selectedCount).arg(mergeDialog.featureDisplayName)
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
if (isMerged) {
return;
Expand All @@ -845,17 +837,9 @@ Rectangle {
}
}

Dialog {
QfDialog {
id: transferDialog
parent: mainWindow.contentItem

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Transfer Feature Attributes")

Column {
Expand Down Expand Up @@ -891,7 +875,6 @@ Rectangle {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
let feature = transferFeatureListModel.getFeatureById(transferComboBox.currentValue);
if (featureForm.model.featureModel.updateAttributesFromFeature(feature)) {
Expand All @@ -914,28 +897,15 @@ Rectangle {
}
}

Dialog {
QfDialog {
id: deleteDialog
parent: mainWindow.contentItem

property int selectedCount: 0
property bool isDeleted: false

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Delete feature(s)")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Should the %n feature(s) selected really be deleted?", "0", deleteDialog.selectedCount)
}

standardButtons: Dialog.Ok | Dialog.Cancel
text: qsTr("Should the %n feature(s) selected really be deleted?", "0", deleteDialog.selectedCount)
onAccepted: {
if (isDeleted) {
return;
Expand Down
6 changes: 1 addition & 5 deletions src/qml/MessageLog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,10 @@ Page {
}
}

Dialog {
QfDialog {
id: applicationLogDialog
title: qsTr("Send application log")
focus: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height - 80) / 2

onAboutToShow: {
Expand Down Expand Up @@ -201,7 +198,6 @@ Page {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
var applicationLogMessage = appliationLogInput.text.trim();
iface.sendLog(applicationLogMessage != '' ? applicationLogMessage : 'Manual log submission', includeCloudInformationCheckBox.checked ? cloudConnection.username : '');
Expand Down
14 changes: 4 additions & 10 deletions src/qml/PluginManagerSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,10 @@ Popup {
}
}

Dialog {
QfDialog {
id: authorDetails
title: authorName
parent: mainWindow.contentItem
x: (mainWindow.width - width) / 2
y: (mainWindow.height - height - 80) / 2

property string authorName: ""
Expand Down Expand Up @@ -264,14 +263,11 @@ Popup {
standardButtons: Dialog.Close
}

Dialog {
QfDialog {
id: installFromUrlDialog
title: "Install Plugin from URL"
parent: mainWindow.contentItem
focus: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height - 80) / 2

onAboutToShow: {
Expand Down Expand Up @@ -304,17 +300,16 @@ Popup {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
pluginManager.installFromUrl(installFromUrlInput.text);
}
}

Dialog {
QfDialog {
id: uninstallConfirmation
title: "Uninstall Plugin"
parent: mainWindow.contentItem
x: (mainWindow.width - width) / 2
modal: false
y: (mainWindow.height - height - 80) / 2

property string pluginName: ""
Expand All @@ -341,7 +336,6 @@ Popup {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
pluginManager.uninstall(pluginUuid);
}
Expand Down
11 changes: 1 addition & 10 deletions src/qml/QFieldCloudPackageLayersFeedback.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,22 @@ import Theme
/**
* \ingroup qml
*/
Dialog {
QfDialog {
parent: mainWindow.contentItem

property int selectedCount: 0
property bool isDeleted: false
property alias packagedLayersListViewModel: packagedLayersListView.model

visible: false
modal: true
width: mainWindow.width - 20
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("QFieldCloud had troubles packaging your project")

ColumnLayout {
id: layout

anchors.fill: parent

Label {
Layout.fillWidth: true

text: qsTr("Some layers have not been packaged correctly on QFieldCloud. These layers might be misconfigured or their data source is not accessible from the QFieldCloud server. Please check the logs of the latest packaging job on the qfield.cloud website.")
wrapMode: Text.WordWrap
}
Expand Down
22 changes: 2 additions & 20 deletions src/qml/QFieldCloudPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -612,29 +612,20 @@ Popup {
}
}

Dialog {
QfDialog {
id: revertDialog
parent: mainWindow.contentItem

property int selectedCount: 0
property bool isDeleted: false

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Revert local changes")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Should local changes be reverted?")
}

standardButtons: Dialog.Ok | Dialog.Cancel

onAccepted: {
revertLocalChangesFromCurrentProject();
}
Expand All @@ -644,29 +635,20 @@ Popup {
}
}

Dialog {
QfDialog {
id: resetDialog
parent: mainWindow.contentItem

property int selectedCount: 0
property bool isDeleted: false

visible: false
modal: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height) / 2

title: qsTr("Reset cloud project")
Label {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Last warning, resetting the cloud project will erase any local changes, are you sure you want to go ahead?")
}

standardButtons: Dialog.Ok | Dialog.Cancel

onAccepted: {
resetCurrentProject();
}
Expand Down
6 changes: 1 addition & 5 deletions src/qml/QFieldLocalDataPickerScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,10 @@ Page {
}
}

Dialog {
QfDialog {
id: importUrlDialog
title: "Import URL"
focus: true
font: Theme.defaultFont

x: (mainWindow.width - width) / 2
y: (mainWindow.height - height - 80) / 2

onAboutToShow: {
Expand Down Expand Up @@ -683,7 +680,6 @@ Page {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
iface.importUrl(importUrlInput.text);
}
Expand Down
Loading

0 comments on commit 01ebeb2

Please sign in to comment.