mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #5158
ezavod (2): fix(chatform): check for empty path when exporting profile refactor(chatform): consistent usage of file dialogs
This commit is contained in:
commit
9b46700c6a
|
@ -507,8 +507,7 @@ void FileTransferWidget::handleButton(QPushButton* btn)
|
||||||
QFileDialog::getSaveFileName(Q_NULLPTR,
|
QFileDialog::getSaveFileName(Q_NULLPTR,
|
||||||
tr("Save a file", "Title of the file saving dialog"),
|
tr("Save a file", "Title of the file saving dialog"),
|
||||||
Settings::getInstance().getGlobalAutoAcceptDir() + "/"
|
Settings::getInstance().getGlobalAutoAcceptDir() + "/"
|
||||||
+ fileInfo.fileName,
|
+ fileInfo.fileName);
|
||||||
0, 0);
|
|
||||||
acceptTransfer(path);
|
acceptTransfer(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ static inline bool checkIsValidId(const QString& id)
|
||||||
|
|
||||||
void AddFriendForm::onImportOpenClicked()
|
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()) {
|
if (path.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1067,8 +1067,7 @@ void ChatForm::onExportChat()
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<History::HistMessage> msgs = history->getChatHistoryFromDate(pk, epochStart, now);
|
QList<History::HistMessage> msgs = history->getChatHistoryFromDate(pk, epochStart, now);
|
||||||
|
|
||||||
QString path = QFileDialog::getSaveFileName(0, tr("Save chat log"), QString{}, QString{}, 0,
|
QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save chat log"));
|
||||||
QFileDialog::DontUseNativeDialog);
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,7 @@ void GenericChatForm::onEmoteInsertRequested(QString str)
|
||||||
|
|
||||||
void GenericChatForm::onSaveLogClicked()
|
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())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -348,10 +348,13 @@ void ProfileForm::onExportClicked()
|
||||||
{
|
{
|
||||||
const QString current = profileInfo->getProfileName() + Core::TOX_EXT;
|
const QString current = profileInfo->getProfileName() + Core::TOX_EXT;
|
||||||
//:save dialog title
|
//:save dialog title
|
||||||
const QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export profile"),
|
const QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export profile"), current,
|
||||||
QDir::home().filePath(current),
|
|
||||||
//: save dialog filter
|
//: save dialog filter
|
||||||
tr("Tox save file (*.tox)"), nullptr);
|
tr("Tox save file (*.tox)"));
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const IProfileInfo::SaveResult result = profileInfo->exportProfile(path);
|
const IProfileInfo::SaveResult result = profileInfo->exportProfile(path);
|
||||||
if (result == IProfileInfo::SaveResult::OK) {
|
if (result == IProfileInfo::SaveResult::OK) {
|
||||||
return;
|
return;
|
||||||
|
@ -413,8 +416,11 @@ void ProfileForm::onSaveQrClicked()
|
||||||
{
|
{
|
||||||
const QString current = profileInfo->getProfileName() + ".png";
|
const QString current = profileInfo->getProfileName() + ".png";
|
||||||
const QString path = QFileDialog::getSaveFileName(
|
const QString path = QFileDialog::getSaveFileName(
|
||||||
Q_NULLPTR, tr("Save", "save qr image"), QDir::home().filePath(current),
|
Q_NULLPTR, tr("Save", "save qr image"), current,
|
||||||
tr("Save QrCode (*.png)", "save dialog filter"), nullptr);
|
tr("Save QrCode (*.png)", "save dialog filter"));
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const IProfileInfo::SaveResult result = profileInfo->saveQr(*qr->getImage(), path);
|
const IProfileInfo::SaveResult result = profileInfo->saveQr(*qr->getImage(), path);
|
||||||
if (result == IProfileInfo::SaveResult::OK) {
|
if (result == IProfileInfo::SaveResult::OK) {
|
||||||
|
|
|
@ -99,8 +99,7 @@ void AdvancedForm::on_cbMakeToxPortable_stateChanged()
|
||||||
void AdvancedForm::on_btnExportLog_clicked()
|
void AdvancedForm::on_btnExportLog_clicked()
|
||||||
{
|
{
|
||||||
QString savefile =
|
QString savefile =
|
||||||
QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath(), tr("Logs (*.log)"), 0,
|
QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save File"), QString{}, tr("Logs (*.log)"));
|
||||||
QFileDialog::DontUseNativeDialog);
|
|
||||||
|
|
||||||
if (savefile.isNull() || savefile.isEmpty()) {
|
if (savefile.isNull() || savefile.isEmpty()) {
|
||||||
qDebug() << "Debug log save file was not properly chosen";
|
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
|
// TODO: Change all QFileDialog instances across project to use
|
||||||
// this instead of Q_NULLPTR. Possibly requires >Qt 5.9 due to:
|
// this instead of Q_NULLPTR. Possibly requires >Qt 5.9 due to:
|
||||||
// https://bugreports.qt.io/browse/QTBUG-59184
|
// 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);
|
return importProfile(path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user