MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getSaveFileName

Function getSaveFileName

src/qt/guiutil.cpp:313–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,
314 const QString &filter,
315 QString *selectedSuffixOut)
316{
317 QString selectedFilter;
318 QString myDir;
319 if(dir.isEmpty()) // Default to user documents location
320 {
321 myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
322 }
323 else
324 {
325 myDir = dir;
326 }
327 /* Directly convert path to native OS path separators */
328 QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
329
330 QString selectedSuffix = ExtractFirstSuffixFromFilter(selectedFilter);
331
332 /* Add suffix if needed */
333 QFileInfo info(result);
334 if(!result.isEmpty())
335 {
336 if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
337 {
338 /* No suffix specified, add selected suffix */
339 if(!result.endsWith("."))
340 result.append(".");
341 result.append(selectedSuffix);
342 }
343 }
344
345 /* Return selected suffix if asked to */
346 if(selectedSuffixOut)
347 {
348 *selectedSuffixOut = selectedSuffix;
349 }
350 return result;
351}
352
353QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir,
354 const QString &filter,

Callers 6

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

Calls 1

Tested by

no test coverage detected