| 311 | } |
| 312 | |
| 313 | QString 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 | |
| 353 | QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, |
| 354 | const QString &filter, |
no test coverage detected