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.metadata
parent
17da34eb15
commit
ad63888153
|
@ -539,34 +539,20 @@ void MainWindow::onProgressMessage(const RenderJob *job, const QString &name,
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered() {
|
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;
|
QSettings settings;
|
||||||
dialog->restoreState(settings.value("fileDialogState").toByteArray());
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(),
|
||||||
connect(dialog, SIGNAL(finished(int)), this, SLOT(onOpenDialogClose(int)));
|
settings.value("fileDir").toString(),
|
||||||
m_currentChild = dialog;
|
tr("All supported formats (*.xml *.exr *.rgbe *.hdr *.pfm *.png *.jpg *.jpeg);;"
|
||||||
// prevent a tab drawing artifact on Qt/OSX
|
"Mitsuba scenes (*.xml);;High dynamic-range images (*.exr *.rgbe *.hdr *.pfm);;"
|
||||||
m_activeWindowHack = true;
|
"Low dynamic-range images (*.png *.jpg *.jpeg)"));
|
||||||
dialog->show();
|
|
||||||
qApp->processEvents();
|
|
||||||
m_activeWindowHack = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onOpenDialogClose(int reason) {
|
QStringList::ConstIterator it = fileNames.constBegin();
|
||||||
QSettings settings;
|
if (it != fileNames.constEnd()) {
|
||||||
QFileDialog *dialog = static_cast<QFileDialog *>(sender());
|
QFileInfo info(*it);
|
||||||
m_currentChild = NULL;
|
settings.setValue("fileDir", info.absolutePath());
|
||||||
if (reason == QDialog::Accepted) {
|
}
|
||||||
QStringList fileNames = dialog->selectedFiles();
|
for ( ; it != fileNames.constEnd(); ++it) {
|
||||||
settings.setValue("fileDialogState", dialog->saveState());
|
loadFile(*it);
|
||||||
for (int i=0; i<fileNames.size(); ++i)
|
|
||||||
loadFile(fileNames[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,6 @@ private slots:
|
||||||
void updateUI();
|
void updateUI();
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
void onPreviewSettingsClose();
|
void onPreviewSettingsClose();
|
||||||
void onOpenDialogClose(int reason);
|
|
||||||
void onSaveAsDialogClose(int reason);
|
void onSaveAsDialogClose(int reason);
|
||||||
void onExportDialogClose(int reason);
|
void onExportDialogClose(int reason);
|
||||||
void onRenderSettingsClose(int reason);
|
void onRenderSettingsClose(int reason);
|
||||||
|
|
Loading…
Reference in New Issue