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 committed Oct 14, 2024
1 parent 657ef5f commit 960cd18
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 @@ -151,25 +151,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 @@ -174,26 +174,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 @@ -244,25 +244,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 @@ -847,27 +847,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 @@ -793,29 +793,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 @@ -842,17 +834,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 @@ -888,7 +872,6 @@ Rectangle {
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
let feature = transferFeatureListModel.getFeatureById(transferComboBox.currentValue);
if (featureForm.model.featureModel.updateAttributesFromFeature(feature)) {
Expand All @@ -911,28 +894,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 @@ -143,13 +143,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 @@ -198,7 +195,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 @@ -213,11 +213,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 @@ -261,14 +260,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 @@ -301,17 +297,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 @@ -338,7 +333,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 @@ -4,31 +4,22 @@ import QtQuick.Layouts
import org.qfield
import Theme

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 @@ -609,29 +609,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 @@ -641,29 +632,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 @@ -641,13 +641,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 @@ -680,7 +677,6 @@ Page {
}
}

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

0 comments on commit 960cd18

Please sign in to comment.