Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.cpp
Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | 402 | { | |||
---|---|---|---|---|---|
404 | SpectacleConfig *config = SpectacleConfig::instance(); | 404 | SpectacleConfig *config = SpectacleConfig::instance(); | ||
405 | 405 | | |||
406 | // construct the supported mimetype list | 406 | // construct the supported mimetype list | ||
407 | Q_FOREACH (auto mimeType, QImageWriter::supportedMimeTypes()) { | 407 | Q_FOREACH (auto mimeType, QImageWriter::supportedMimeTypes()) { | ||
408 | supportedFilters.append(QString::fromUtf8(mimeType).trimmed()); | 408 | supportedFilters.append(QString::fromUtf8(mimeType).trimmed()); | ||
409 | } | 409 | } | ||
410 | 410 | | |||
411 | // construct the file name | 411 | // construct the file name | ||
412 | const QString filenameExtension = SpectacleConfig::instance()->saveImageFormat(); | ||||
aacid: const | |||||
413 | const QString mimetype = QMimeDatabase().mimeTypeForFile(QStringLiteral("~/fakefile.") + filenameExtension, QMimeDatabase::MatchExtension).name(); | ||||
aacid: mimeTypeForName
and also const | |||||
Sorry, mimeTypeForName is wrong :D So you should go back to mimeTypeForFile but using QMimeDatabase::MatchExtension so it doesn't try to open a file that may or may not exist aacid: Sorry, mimeTypeForName is wrong :D
So you should go back to mimeTypeForFile but using… | |||||
412 | QFileDialog dialog(parentWindow); | 414 | QFileDialog dialog(parentWindow); | ||
413 | dialog.setAcceptMode(QFileDialog::AcceptSave); | 415 | dialog.setAcceptMode(QFileDialog::AcceptSave); | ||
414 | dialog.setFileMode(QFileDialog::AnyFile); | 416 | dialog.setFileMode(QFileDialog::AnyFile); | ||
415 | dialog.setDirectoryUrl(config->lastSaveAsLocation()); | 417 | dialog.setDirectoryUrl(config->lastSaveAsLocation()); | ||
416 | dialog.selectFile(makeAutosaveFilename() + QStringLiteral(".png")); | 418 | dialog.selectFile(makeAutosaveFilename() + QStringLiteral(".") + filenameExtension); | ||
417 | dialog.setDefaultSuffix(QStringLiteral(".png")); | 419 | dialog.setDefaultSuffix(QStringLiteral(".") + filenameExtension); | ||
418 | dialog.setMimeTypeFilters(supportedFilters); | 420 | dialog.setMimeTypeFilters(supportedFilters); | ||
419 | dialog.selectMimeTypeFilter(QStringLiteral("image/png")); | 421 | dialog.selectMimeTypeFilter(mimetype); | ||
420 | 422 | | |||
421 | // launch the dialog | 423 | // launch the dialog | ||
422 | if (dialog.exec() == QFileDialog::Accepted) { | 424 | if (dialog.exec() == QFileDialog::Accepted) { | ||
423 | const QUrl saveUrl = dialog.selectedUrls().first(); | 425 | const QUrl saveUrl = dialog.selectedUrls().first(); | ||
424 | if (saveUrl.isValid()) { | 426 | if (saveUrl.isValid()) { | ||
425 | if (save(saveUrl)) { | 427 | if (save(saveUrl)) { | ||
426 | emit imageSaved(saveUrl); | 428 | emit imageSaved(saveUrl); | ||
427 | config->setLastSaveAsFile(saveUrl); | 429 | config->setLastSaveAsFile(saveUrl); | ||
Show All 39 Lines |
const