Add default file extension configuration (#1995)

* Add default file extension configuration

* Format fix

* Implement ValueHandler for setSaveAsFileExtension

* Fix formatting issues

* Add format to properScreenshotPath call

* Fix SaveFileExtension::check

* Fix format

* Move extension layout to Save Path group
This commit is contained in:
Benja Appel
2021-10-25 14:24:46 -03:00
committed by GitHub
parent a487fb0257
commit 067f4a1914
7 changed files with 91 additions and 14 deletions

View File

@@ -88,7 +88,8 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
const QString& path,
const QString& messagePrefix)
{
QString completePath = FileNameHandler().properScreenshotPath(path);
QString completePath = FileNameHandler().properScreenshotPath(
path, ConfigHandler().setSaveAsFileExtension());
bool ok = capture.save(completePath);
QString saveMessage = messagePrefix;
QString notificationPath = completePath;
@@ -126,9 +127,9 @@ QString ScreenshotSaver::ShowSaveFileDialog(QWidget* parent,
mimeTypeList.append(mimeType);
dialog.setMimeTypeFilters(mimeTypeList);
QString suffix = ConfigHandler().saveAsFileExtension();
QString suffix = ConfigHandler().setSaveAsFileExtension();
QString defaultMimeType =
QMimeDatabase().mimeTypeForFile("image" + suffix).name();
QMimeDatabase().mimeTypeForFile("image." + suffix).name();
dialog.selectMimeTypeFilter(defaultMimeType);
if (dialog.exec() == QDialog::Accepted) {
@@ -148,7 +149,8 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
defaultSavePath =
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
}
QString savePath = FileNameHandler().properScreenshotPath(defaultSavePath);
QString savePath = FileNameHandler().properScreenshotPath(
defaultSavePath, ConfigHandler().setSaveAsFileExtension());
#if defined(Q_OS_MACOS)
for (QWidget* widget : qApp->topLevelWidgets()) {
QString className(widget->metaObject()->className());