From 44342532838e672155c869b21561b6dd97a489cb Mon Sep 17 00:00:00 2001 From: ezavod Date: Tue, 29 May 2018 12:17:13 +0200 Subject: [PATCH] refactor(chatform): consistent usage of file dialogs This makes the usage of QFileDialogs consistent by using he native file picker in all cases. Also makes the usage of the last location consistent. Furthermore this removes default parameter values and uses Q_NULLPTR. --- src/chatlog/content/filetransferwidget.cpp | 3 +-- src/widget/form/addfriendform.cpp | 2 +- src/widget/form/chatform.cpp | 3 +-- src/widget/form/genericchatform.cpp | 2 +- src/widget/form/profileform.cpp | 9 ++++----- src/widget/form/settings/advancedform.cpp | 3 +-- src/widget/tool/profileimporter.cpp | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index d2929495c..82665f6aa 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -507,8 +507,7 @@ void FileTransferWidget::handleButton(QPushButton* btn) QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save a file", "Title of the file saving dialog"), Settings::getInstance().getGlobalAutoAcceptDir() + "/" - + fileInfo.fileName, - 0, 0); + + fileInfo.fileName); acceptTransfer(path); } } diff --git a/src/widget/form/addfriendform.cpp b/src/widget/form/addfriendform.cpp index a499a28d7..882f18d22 100644 --- a/src/widget/form/addfriendform.cpp +++ b/src/widget/form/addfriendform.cpp @@ -231,7 +231,7 @@ static inline bool checkIsValidId(const QString& id) void AddFriendForm::onImportOpenClicked() { - const QString path = QFileDialog::getOpenFileName(tabWidget, tr("Open contact list")); + const QString path = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open contact list")); if (path.isEmpty()) { return; } diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index a6bc1b7d2..5f36c26c8 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -1067,8 +1067,7 @@ void ChatForm::onExportChat() QDateTime now = QDateTime::currentDateTime(); QList msgs = history->getChatHistoryFromDate(pk, epochStart, now); - QString path = QFileDialog::getSaveFileName(0, tr("Save chat log"), QString{}, QString{}, 0, - QFileDialog::DontUseNativeDialog); + QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save chat log")); if (path.isEmpty()) { return; } diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 382f8a541..b8f0fab2f 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -472,7 +472,7 @@ void GenericChatForm::onEmoteInsertRequested(QString str) void GenericChatForm::onSaveLogClicked() { - QString path = QFileDialog::getSaveFileName(0, tr("Save chat log")); + QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save chat log")); if (path.isEmpty()) return; diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 6357f9ea7..e673b19bb 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -348,10 +348,9 @@ void ProfileForm::onExportClicked() { const QString current = profileInfo->getProfileName() + Core::TOX_EXT; //:save dialog title - const QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export profile"), - QDir::home().filePath(current), + const QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export profile"), current, //: save dialog filter - tr("Tox save file (*.tox)"), nullptr); + tr("Tox save file (*.tox)")); if (path.isEmpty()) { return; } @@ -417,8 +416,8 @@ void ProfileForm::onSaveQrClicked() { const QString current = profileInfo->getProfileName() + ".png"; const QString path = QFileDialog::getSaveFileName( - Q_NULLPTR, tr("Save", "save qr image"), QDir::home().filePath(current), - tr("Save QrCode (*.png)", "save dialog filter"), nullptr); + Q_NULLPTR, tr("Save", "save qr image"), current, + tr("Save QrCode (*.png)", "save dialog filter")); if (path.isEmpty()) { return; } diff --git a/src/widget/form/settings/advancedform.cpp b/src/widget/form/settings/advancedform.cpp index 9e4b21fed..c9d04b010 100644 --- a/src/widget/form/settings/advancedform.cpp +++ b/src/widget/form/settings/advancedform.cpp @@ -99,8 +99,7 @@ void AdvancedForm::on_cbMakeToxPortable_stateChanged() void AdvancedForm::on_btnExportLog_clicked() { QString savefile = - QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath(), tr("Logs (*.log)"), 0, - QFileDialog::DontUseNativeDialog); + QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save File"), QString{}, tr("Logs (*.log)")); if (savefile.isNull() || savefile.isEmpty()) { qDebug() << "Debug log save file was not properly chosen"; diff --git a/src/widget/tool/profileimporter.cpp b/src/widget/tool/profileimporter.cpp index 464e2d31a..0ab665083 100644 --- a/src/widget/tool/profileimporter.cpp +++ b/src/widget/tool/profileimporter.cpp @@ -53,7 +53,7 @@ bool ProfileImporter::importProfile() // TODO: Change all QFileDialog instances across project to use // this instead of Q_NULLPTR. Possibly requires >Qt 5.9 due to: // https://bugreports.qt.io/browse/QTBUG-59184 - QString path = QFileDialog::getOpenFileName(Q_NULLPTR, title, dir, filter, 0); + QString path = QFileDialog::getOpenFileName(Q_NULLPTR, title, dir, filter); return importProfile(path); }