Browse Source

Merge pull request #4507

Andrew Morgan (1):
      fix(ui): Use native file picker dialog
reviewable/pr4511/r1
sudden6 8 years ago
parent
commit
8c2703b756
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 4
      src/chatlog/content/filetransferwidget.cpp
  2. 9
      src/widget/about/aboutuser.cpp
  3. 4
      src/widget/form/chatform.cpp
  4. 19
      src/widget/form/profileform.cpp
  5. 7
      src/widget/form/settings/generalform.cpp
  6. 6
      src/widget/friendwidget.cpp
  7. 7
      src/widget/tool/profileimporter.cpp

4
src/chatlog/content/filetransferwidget.cpp

@ -502,11 +502,11 @@ void FileTransferWidget::handleButton(QPushButton* btn) @@ -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);
}
}

9
src/widget/about/aboutuser.cpp

@ -64,9 +64,8 @@ void AboutUser::onAutoAcceptDirClicked() @@ -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() @@ -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();

4
src/widget/form/chatform.cpp

@ -245,8 +245,8 @@ void ChatForm::onTextEditChanged() @@ -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;
}

19
src/widget/form/profileform.cpp

@ -265,13 +265,12 @@ void ProfileForm::onAvatarClicked() @@ -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() @@ -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() @@ -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"),

7
src/widget/form/settings/generalform.cpp

@ -258,10 +258,9 @@ void GeneralForm::on_autoSaveFilesDir_clicked() @@ -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;

6
src/widget/friendwidget.cpp

@ -223,9 +223,9 @@ void FriendWidget::onContextMenuCalled(QContextMenuEvent* event) @@ -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;

7
src/widget/tool/profileimporter.cpp

@ -49,8 +49,11 @@ bool ProfileImporter::importProfile() @@ -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…
Cancel
Save