From ad63888153fefdde474099eebfcea3eb6bba7365 Mon Sep 17 00:00:00 2001 From: Edgar Velazquez-Armendariz Date: Mon, 8 Oct 2012 15:45:40 -0400 Subject: [PATCH] Use the static functions of QFileDialog to open a file in mtsgui The path of the selected files is stored in the setting variable 'fileDir'. This was done in order to use the OS native file dialog; the Qt-based one was terribly outdated on Windows. This is the first commit in the way to replace all file-open dialogs in mtsgui. --- src/mtsgui/mainwindow.cpp | 38 ++++++++++++-------------------------- src/mtsgui/mainwindow.h | 1 - 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index 06d2f6d4..1019755b 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -539,34 +539,20 @@ void MainWindow::onProgressMessage(const RenderJob *job, const QString &name, } void MainWindow::on_actionOpen_triggered() { - QFileDialog *dialog = new QFileDialog(this, Qt::Sheet); - dialog->setNameFilter(tr("All supported formats (*.xml *.exr *.rgbe *.hdr *.pfm *.png *.jpg *.jpeg);;" - "Mitsuba scenes (*.xml);;High dynamic-range images (*.exr *.rgbe *.hdr *.pfm);;Low " - "dynamic-range images (*.png *.jpg *.jpeg)")); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setAcceptMode(QFileDialog::AcceptOpen); - dialog->setViewMode(QFileDialog::Detail); - dialog->setWindowModality(Qt::WindowModal); QSettings settings; - dialog->restoreState(settings.value("fileDialogState").toByteArray()); - connect(dialog, SIGNAL(finished(int)), this, SLOT(onOpenDialogClose(int))); - m_currentChild = dialog; - // prevent a tab drawing artifact on Qt/OSX - m_activeWindowHack = true; - dialog->show(); - qApp->processEvents(); - m_activeWindowHack = false; -} + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), + settings.value("fileDir").toString(), + tr("All supported formats (*.xml *.exr *.rgbe *.hdr *.pfm *.png *.jpg *.jpeg);;" + "Mitsuba scenes (*.xml);;High dynamic-range images (*.exr *.rgbe *.hdr *.pfm);;" + "Low dynamic-range images (*.png *.jpg *.jpeg)")); -void MainWindow::onOpenDialogClose(int reason) { - QSettings settings; - QFileDialog *dialog = static_cast(sender()); - m_currentChild = NULL; - if (reason == QDialog::Accepted) { - QStringList fileNames = dialog->selectedFiles(); - settings.setValue("fileDialogState", dialog->saveState()); - for (int i=0; i