mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4507
Andrew Morgan (1): fix(ui): Use native file picker dialog
This commit is contained in:
commit
8c2703b756
@ -502,11 +502,11 @@ void FileTransferWidget::handleButton(QPushButton* btn)
|
||||
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
||||
else if (btn->objectName() == "accept") {
|
||||
QString path =
|
||||
QFileDialog::getSaveFileName(parentWidget(),
|
||||
QFileDialog::getSaveFileName(Q_NULLPTR,
|
||||
tr("Save a file", "Title of the file saving dialog"),
|
||||
Settings::getInstance().getGlobalAutoAcceptDir() + "/"
|
||||
+ fileInfo.fileName,
|
||||
0, 0, QFileDialog::DontUseNativeDialog);
|
||||
0, 0);
|
||||
acceptTransfer(path);
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,8 @@ void AboutUser::onAutoAcceptDirClicked()
|
||||
Settings::getInstance().setAutoAcceptDir(this->friendPk, "");
|
||||
ui->selectSaveDir->setText(tr("Auto accept for this contact is disabled"));
|
||||
} else if (ui->autoacceptfile->isChecked()) {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose an auto accept directory",
|
||||
"popup title"),
|
||||
dir, QFileDialog::DontUseNativeDialog);
|
||||
dir = QFileDialog::getExistingDirectory(Q_NULLPTR, tr("Choose an auto accept directory",
|
||||
"popup title"), dir);
|
||||
if (dir.isEmpty()) {
|
||||
ui->autoacceptfile->setChecked(false);
|
||||
return; // user canellced
|
||||
@ -98,9 +97,9 @@ void AboutUser::onAutoGroupInvite()
|
||||
void AboutUser::onSelectDirClicked()
|
||||
{
|
||||
QString dir;
|
||||
dir = QFileDialog::getExistingDirectory(this,
|
||||
dir = QFileDialog::getExistingDirectory(Q_NULLPTR,
|
||||
tr("Choose an auto accept directory", "popup title"),
|
||||
dir, QFileDialog::DontUseNativeDialog);
|
||||
dir);
|
||||
ui->autoacceptfile->setChecked(true);
|
||||
Settings::getInstance().setAutoAcceptDir(this->friendPk, dir);
|
||||
Settings::getInstance().savePersonal();
|
||||
|
@ -245,8 +245,8 @@ void ChatForm::onTextEditChanged()
|
||||
|
||||
void ChatForm::onAttachClicked()
|
||||
{
|
||||
QStringList paths = QFileDialog::getOpenFileNames(this, tr("Send a file"), QDir::homePath(), 0,
|
||||
0, QFileDialog::DontUseNativeDialog);
|
||||
QStringList paths = QFileDialog::getOpenFileNames(Q_NULLPTR, tr("Send a file"), QDir::homePath(), 0, 0);
|
||||
|
||||
if (paths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -265,13 +265,12 @@ void ProfileForm::onAvatarClicked()
|
||||
return bytes;
|
||||
};
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Choose a profile picture"),
|
||||
QDir::homePath(), Nexus::getSupportedImageFilter(),
|
||||
0, QFileDialog::DontUseNativeDialog);
|
||||
if (filename.isEmpty())
|
||||
QString path = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Choose a profile picture"),
|
||||
QDir::homePath(), Nexus::getSupportedImageFilter(), 0);
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
QFile file(filename);
|
||||
QFile file(path);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.isOpen()) {
|
||||
GUI::showError(tr("Error"), tr("Unable to open this file."));
|
||||
@ -335,10 +334,9 @@ void ProfileForm::onRenameClicked()
|
||||
void ProfileForm::onExportClicked()
|
||||
{
|
||||
QString current = Nexus::getProfile()->getName() + Core::TOX_EXT;
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Export profile", "save dialog title"),
|
||||
QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export profile", "save dialog title"),
|
||||
QDir::home().filePath(current),
|
||||
tr("Tox save file (*.tox)", "save dialog filter"),
|
||||
0, QFileDialog::DontUseNativeDialog);
|
||||
tr("Tox save file (*.tox)", "save dialog filter"), 0);
|
||||
if (!path.isEmpty()) {
|
||||
if (!Nexus::tryRemoveFile(path)) {
|
||||
GUI::showWarning(tr("Location not writable", "Title of permissions popup"),
|
||||
@ -406,10 +404,9 @@ void ProfileForm::onCopyQrClicked()
|
||||
void ProfileForm::onSaveQrClicked()
|
||||
{
|
||||
QString current = Nexus::getProfile()->getName() + ".png";
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Save", "save qr image"),
|
||||
QString path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save", "save qr image"),
|
||||
QDir::home().filePath(current),
|
||||
tr("Save QrCode (*.png)", "save dialog filter"), 0,
|
||||
QFileDialog::DontUseNativeDialog);
|
||||
tr("Save QrCode (*.png)", "save dialog filter"), 0);
|
||||
if (!path.isEmpty()) {
|
||||
if (!Nexus::tryRemoveFile(path)) {
|
||||
GUI::showWarning(tr("Location not writable", "Title of permissions popup"),
|
||||
|
@ -258,10 +258,9 @@ void GeneralForm::on_autoSaveFilesDir_clicked()
|
||||
{
|
||||
QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||
QString directory =
|
||||
QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory",
|
||||
"popup title"), // opens in home directory
|
||||
QDir::homePath(),
|
||||
QFileDialog::DontUseNativeDialog);
|
||||
QFileDialog::getExistingDirectory(Q_NULLPTR,
|
||||
tr("Choose an auto accept directory", "popup title"),
|
||||
QDir::homePath());
|
||||
if (directory.isEmpty()) // cancel was pressed
|
||||
directory = previousDir;
|
||||
|
||||
|
@ -223,9 +223,9 @@ void FriendWidget::onContextMenuCalled(QContextMenuEvent* event)
|
||||
autoAccept->setChecked(false);
|
||||
Settings::getInstance().setAutoAcceptDir(id, "");
|
||||
} else if (autoAccept->isChecked()) {
|
||||
dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory",
|
||||
"popup title"),
|
||||
dir, QFileDialog::DontUseNativeDialog);
|
||||
dir = QFileDialog::getExistingDirectory(Q_NULLPTR,
|
||||
tr("Choose an auto accept directory", "popup title"),
|
||||
dir);
|
||||
|
||||
autoAccept->setChecked(true);
|
||||
qDebug() << "Setting auto accept dir for" << friendId << "to" << dir;
|
||||
|
@ -49,8 +49,11 @@ bool ProfileImporter::importProfile()
|
||||
QString title = tr("Import profile", "import dialog title");
|
||||
QString filter = tr("Tox save file (*.tox)", "import dialog filter");
|
||||
QString dir = QDir::homePath();
|
||||
QString path =
|
||||
QFileDialog::getOpenFileName(this, title, dir, filter, 0, QFileDialog::DontUseNativeDialog);
|
||||
|
||||
// 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);
|
||||
|
||||
return importProfile(path);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user