summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdasauce <adasauce@with.parts>2020-02-14 21:35:26 -0400
committerAdasauce <adasauce@with.parts>2020-02-14 21:35:26 -0400
commitcb360508226a320846660709f26457a54782b164 (patch)
tree017e53524b4e904888393d90c61b8a1337f0871a
parentuse the standard system download path for downloads (diff)
downloadnheko-cb360508226a320846660709f26457a54782b164.tar.xz
use QStandardPaths locations for all file dialogs.
-rw-r--r--src/TextInputWidget.cpp3
-rw-r--r--src/UserSettingsPage.cpp8
-rw-r--r--src/dialogs/RoomSettings.cpp7
-rw-r--r--src/timeline/TimelineModel.cpp3
4 files changed, 15 insertions, 6 deletions
diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp
index ce0c7cb8..11f7ddda 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 a0f37c26..166a0a67 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -27,6 +27,7 @@
 #include <QPushButton>
 #include <QScrollArea>
 #include <QSettings>
+#include <QStandardPaths>
 #include <QString>
 #include <QTextStream>
 
@@ -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 69d5a9c2..cc10ac91 100644
--- a/src/dialogs/RoomSettings.cpp
+++ b/src/dialogs/RoomSettings.cpp
@@ -11,6 +11,7 @@
 #include <QPushButton>
 #include <QShortcut>
 #include <QShowEvent>
+#include <QStandardPaths>
 #include <QStyleOption>
 #include <QVBoxLayout>
 
@@ -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 625377fb..104d564b 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(