mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
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.
This commit is contained in:
parent
757791eea4
commit
4434253283
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1067,8 +1067,7 @@ void ChatForm::onExportChat()
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QList<History::HistMessage> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user