MCPcopy Create free account
hub / github.com/ElementsProject/elements / getSaveFileName

Function getSaveFileName

src/qt/guiutil.cpp:303–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,
304 const QString &filter,
305 QString *selectedSuffixOut)
306{
307 QString selectedFilter;
308 QString myDir;
309 if(dir.isEmpty()) // Default to user documents location
310 {
311 myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
312 }
313 else
314 {
315 myDir = dir;
316 }
317 /* Directly convert path to native OS path separators */
318 QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
319
320 /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
321 QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
322 QString selectedSuffix;
323 if(filter_re.exactMatch(selectedFilter))
324 {
325 selectedSuffix = filter_re.cap(1);
326 }
327
328 /* Add suffix if needed */
329 QFileInfo info(result);
330 if(!result.isEmpty())
331 {
332 if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
333 {
334 /* No suffix specified, add selected suffix */
335 if(!result.endsWith("."))
336 result.append(".");
337 result.append(selectedSuffix);
338 }
339 }
340
341 /* Return selected suffix if asked to */
342 if(selectedSuffixOut)
343 {
344 *selectedSuffixOut = selectedSuffix;
345 }
346 return result;
347}
348
349QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir,
350 const QString &filter,

Callers 6

backupWalletMethod · 0.85
exportClickedMethod · 0.85
saveTransactionMethod · 0.85
presentPSBTMethod · 0.85
saveImageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected