MCPcopy Create free account
hub / github.com/LUX-Core/lux / getSaveFileName

Function getSaveFileName

src/qt/guiutil.cpp:321–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321QString getSaveFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut)
322{
323 QString selectedFilter;
324 QString myDir;
325 if (dir.isEmpty()) // Default to user documents location
326 {
327#if QT_VERSION < 0x050000
328 myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
329#else
330 myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
331#endif
332 } else {
333 myDir = dir;
334 }
335
336 /**
337 * This is a bug of QT. We should not use Native dialog as a workaround.
338 **/
339
340 /* Directly convert path to native OS path separators */
341 QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter, QFileDialog::Option::DontUseNativeDialog));
342
343 /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
344 QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
345 QString selectedSuffix;
346 if (filter_re.exactMatch(selectedFilter)) {
347 selectedSuffix = filter_re.cap(1);
348 }
349
350 /* Add suffix if needed */
351 QFileInfo info(result);
352 if (!result.isEmpty()) {
353 if (info.suffix().isEmpty() && !selectedSuffix.isEmpty()) {
354 /* No suffix specified, add selected suffix */
355 if (!result.endsWith("."))
356 result.append(".");
357 result.append(selectedSuffix);
358 }
359 }
360
361 /* Return selected suffix if asked to */
362 if (selectedSuffixOut) {
363 *selectedSuffixOut = selectedSuffix;
364 }
365 return result;
366}
367
368QString getOpenFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut)
369{

Callers 5

backupWalletMethod · 0.85
exportClickedMethod · 0.85
saveImageMethod · 0.85

Calls 3

isEmptyMethod · 0.45
capMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected