From 38bbed978a86d5b748ed61540632a25859cab7df Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 22 Nov 2014 16:06:01 -0800 Subject: Use our own file open dialog Clearly the static dialogs don't work. Even with the previous commit the dialog still said "Save" insted of "Open". So let's just assemble our own dialog and be done with it. I hope I got all the options right... Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c455a43fe..a02ff0357 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -211,12 +211,19 @@ void MainWindow::on_actionOpen_triggered() // yes, this look wrong to use getSaveFileName() for the open dialog, but we need to be able // to enter file names that don't exist in order to use our git syntax /path/to/dir[branch] // with is a potentially valid input, but of course won't exist. So getOpenFileName() wouldn't work - QString filename = QFileDialog::getSaveFileName(this, tr("Open file"), lastUsedDir(), filter(), NULL, QFileDialog::DontConfirmOverwrite); - if (filename.isEmpty()) + QFileDialog dialog(this, tr("Open file"), lastUsedDir(), filter()); + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setViewMode(QFileDialog::Detail); + dialog.setLabelText(QFileDialog::Accept, tr("Open")); + dialog.setLabelText(QFileDialog::Reject, tr("Cancel")); + QStringList filenames; + if (dialog.exec()) + filenames = dialog.selectedFiles(); + if (filenames.isEmpty()) return; - updateLastUsedDir(QFileInfo(filename).dir().path()); + updateLastUsedDir(QFileInfo(filenames.first()).dir().path()); closeCurrentFile(); - loadFiles(QStringList() << filename); + loadFiles(filenames); } void MainWindow::on_actionSave_triggered() -- cgit v1.2.3-70-g09d2