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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-11-22 16:06:01 -08:00
parent ba1631f52d
commit 38bbed978a

View file

@ -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()