From cb360508226a320846660709f26457a54782b164 Mon Sep 17 00:00:00 2001 From: Adasauce Date: Fri, 14 Feb 2020 21:35:26 -0400 Subject: [PATCH] use QStandardPaths locations for all file dialogs. --- src/TextInputWidget.cpp | 3 ++- src/UserSettingsPage.cpp | 8 ++++++-- src/dialogs/RoomSettings.cpp | 7 +++++-- src/timeline/TimelineModel.cpp | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp index ce0c7cb..11f7ddd 100644 --- a/src/TextInputWidget.cpp +++ b/src/TextInputWidget.cpp @@ -626,8 +626,9 @@ TextInputWidget::command(QString command, QString args) void TextInputWidget::openFileSelection() { + const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); const auto fileName = - QFileDialog::getOpenFileName(this, tr("Select a file"), "", tr("All Files (*)")); + QFileDialog::getOpenFileName(this, tr("Select a file"), homeFolder, tr("All Files (*)")); if (fileName.isEmpty()) return; diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index a0f37c2..166a0a6 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -513,7 +514,9 @@ UserSettingsPage::paintEvent(QPaintEvent *) void UserSettingsPage::importSessionKeys() { - auto fileName = QFileDialog::getOpenFileName(this, tr("Open Sessions File"), "", ""); + const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); + const QString fileName = + QFileDialog::getOpenFileName(this, tr("Open Sessions File"), homeFolder, ""); QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { @@ -572,7 +575,8 @@ UserSettingsPage::exportSessionKeys() } // Open file dialog to save the file. - auto fileName = + const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); + const QString fileName = QFileDialog::getSaveFileName(this, tr("File to save the exported session keys"), "", ""); QFile file(fileName); diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp index 69d5a9c..cc10ac9 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -740,8 +741,10 @@ RoomSettings::resetErrorLabel() void RoomSettings::updateAvatar() { - const auto fileName = - QFileDialog::getOpenFileName(this, tr("Select an avatar"), "", tr("All Files (*)")); + const QString picturesFolder = + QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); + const QString fileName = QFileDialog::getOpenFileName( + this, tr("Select an avatar"), picturesFolder, tr("All Files (*)")); if (fileName.isEmpty()) return; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 625377f..104d564 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1299,7 +1299,8 @@ TimelineModel::saveMedia(QString eventId) const } const QString filterString = QMimeDatabase().mimeTypeForName(mimeType).filterString(); - const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + const QString downloadsFolder = + QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); const QString openLocation = downloadsFolder + "/" + originalFilename; const QString filename = QFileDialog::getSaveFileName(