@@ -59,6 +59,46 @@ Page {
5959 return " "
6060 }
6161
62+ Dialog {
63+ id: invalidFileDialog
64+ title: " Invalid File"
65+
66+ // The dialog to reopen when user clicks 'OK'
67+ property var redial: null
68+
69+ height: 120
70+
71+ // What appears in the dialog
72+ Row {
73+ MaterialLabel { text: MaterialIcons .warning ; color: " #FF9800" ; font .pointSize : 30 }
74+ Label { width: 20 } // A kind of spacer
75+
76+ Column {
77+ Label { text: " The filepath provided is not valid. Please provide a valid file path/name to save the file." }
78+ Label { id: message; text: " " ; color: " #FF9800" }
79+ Label { text: " Click OK to return to File Dialog, Cancel to cancel the save process." }
80+ }
81+ }
82+
83+ // Standard buttons for the Dialog
84+ standardButtons: Dialog .Ok | Dialog .Cancel
85+
86+ onAccepted: {
87+ if (redial) redial .open ()
88+ }
89+ onRejected: {
90+ if (redial) redial .closed (Platform .Dialog .Rejected )
91+ }
92+
93+ function show (filepath ) {
94+ // Update the message which is displayed on the error dialog
95+ message .text = " Provided Path: " + filepath
96+
97+ // open the dialog
98+ this .open ()
99+ }
100+ }
101+
62102 // File dialogs
63103 Platform .FileDialog {
64104 id: saveFileDialog
@@ -71,6 +111,15 @@ Page {
71111 defaultSuffix: " .mg"
72112 fileMode: Platform .FileDialog .SaveFile
73113 onAccepted: {
114+ // Validate if the filename without any spaces is just .mg ?
115+ if (Filepath .basename (currentFile).trim () === " .mg" ) {
116+ // If that's the case then show an error to the user about the filepath being wrong
117+ invalidFileDialog .redial = saveFileDialog
118+ invalidFileDialog .show (Filepath .urlToString (currentFile))
119+ return
120+ }
121+
122+ // Only save a valid file
74123 _reconstruction .saveAs (currentFile)
75124 MeshroomApp .addRecentProjectFile (currentFile .toString ())
76125 closed (Platform .Dialog .Accepted )
@@ -89,6 +138,15 @@ Page {
89138 defaultSuffix: " .mg"
90139 fileMode: Platform .FileDialog .SaveFile
91140 onAccepted: {
141+ // Validate if the filename without any spaces is just .mg ?
142+ if (Filepath .basename (currentFile).trim () === " .mg" ) {
143+ // If that's the case then show an error to the user about the filepath being wrong
144+ invalidFileDialog .redial = saveTemplateDialog
145+ invalidFileDialog .show (Filepath .urlToString (currentFile))
146+ return
147+ }
148+
149+ // Only save a valid template
92150 _reconstruction .saveAsTemplate (currentFile)
93151 closed (Platform .Dialog .Accepted )
94152 MeshroomApp .reloadTemplateList ()
0 commit comments