From a3b43613ac2926a9b904d5b7c371bf2394f61bf1 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Mon, 27 Jan 2014 18:10:38 +0100 Subject: [PATCH] rendersettingsdlg: some great usability improvements submitted by Anton Kaplanyan --- src/mtsgui/mainwindow.cpp | 3 +- src/mtsgui/rendersettingsdlg.cpp | 92 ++++++++++++++++++++++++-------- src/mtsgui/rendersettingsdlg.ui | 4 +- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index 6be43f50..5407b720 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -1389,7 +1389,6 @@ void MainWindow::on_actionSettings_triggered() { } } - void MainWindow::on_actionStop_triggered() { SceneContext *context = m_context[ui->tabBar->currentIndex()]; m_contextMutex.lock(); @@ -1821,9 +1820,9 @@ void MainWindow::onWorkCanceled(const RenderJob *job, const Point2i &offset, con if (context == NULL) return; VisualWorkUnit vwu(offset, size); + m_contextMutex.lock(); if (context->workUnits.find(vwu) != context->workUnits.end()) context->workUnits.erase(vwu); - m_contextMutex.lock(); m_contextMutex.unlock(); } diff --git a/src/mtsgui/rendersettingsdlg.cpp b/src/mtsgui/rendersettingsdlg.cpp index d8b145fb..cdeef7f7 100644 --- a/src/mtsgui/rendersettingsdlg.cpp +++ b/src/mtsgui/rendersettingsdlg.cpp @@ -122,6 +122,7 @@ RenderSettingsDialog::RenderSettingsDialog(QWidget *parent) : pal.setColor(QPalette::Text, pal.color(QPalette::Foreground)); pal.setColor(QPalette::Base, pal.color(QPalette::Window)); ui->helpViewer->setPalette(pal); + ui->helpViewer->setHtml("Click on any setting for documentation"); } void RenderSettingsDialog::setDocumentation(const QString &text) { @@ -187,12 +188,23 @@ void RenderSettingsDialog::onTreeSelectionChange(const QItemSelection &selected, void RenderSettingsDialog::update() { int index = ui->integratorBox->currentIndex(); Properties integratorProps, samplerProps; + bool needsUpdate = false; - if (sender() == ui->samplerBox) + if (sender() == ui->samplerBox) { m_samplerNode->putProperties(samplerProps); + needsUpdate = true; + } - if (sender() == ui->integratorBox) + if (sender() == ui->integratorBox) { m_integratorNode->putProperties(integratorProps); + needsUpdate = true; + } + + if (sender() == ui->rFilterBox || + sender() == ui->icBox || + sender() == ui->aiBox) { + needsUpdate = true; + } m_integratorNode = m_model->updateClass(m_integratorNode, ui->integratorBox->itemData(index).toList().at(0).toString(), @@ -236,19 +248,21 @@ void RenderSettingsDialog::update() { } } - ui->treeView->expandAll(); + if (needsUpdate) { + /* Make comboboxes etc editable by default */ + for (int i = 0; i < m_model->rowCount(); ++i) { + QModelIndex index = m_model->index(i, 0); - #if 0 - /* Make comboboxes etc editable by default .. does not quite work yet */ - for (int i = 0; i < m_model->rowCount(); ++i) { - QModelIndex index = m_model->index(i, 0); - - for (int j = 1; j < m_model->rowCount(index); ++j) { - ui->treeView->openPersistentEditor( - m_model->index(j, 1, index)); + for (int j = 1; j < m_model->rowCount(index); ++j) { + QModelIndex idx = m_model->index(j, 1, index); + ui->treeView->openPersistentEditor(idx); + QAbstractSpinBox *spinBox = qobject_cast(ui->treeView->indexWidget(idx)); + if (spinBox) + spinBox->findChild()->deselect(); + } } } - #endif + ui->treeView->expandAll(); dataChanged(); } @@ -303,6 +317,19 @@ void RenderSettingsDialog::load(const SceneContext *ctx) { m_model->setProperties(m_samplerNode, samplerProps); m_model->setProperties(m_integratorNode, integratorProps); ui->treeView->expandAll(); + + /* Make comboboxes etc editable by default */ + for (int i = 0; i < m_model->rowCount(); ++i) { + QModelIndex index = m_model->index(i, 0); + + for (int j = 1; j < m_model->rowCount(index); ++j) { + QModelIndex idx = m_model->index(j, 1, index); + ui->treeView->openPersistentEditor(idx); + QAbstractSpinBox *spinBox = qobject_cast(ui->treeView->indexWidget(idx)); + if (spinBox) + spinBox->findChild()->deselect(); + } + } } void RenderSettingsDialog::apply(SceneContext *ctx) { @@ -465,19 +492,28 @@ PropertyDelegate::~PropertyDelegate() { } QString PropertyDelegate::displayText(const QVariant &value, const QLocale &locale) const { - if (value.type() == QVariant::Bool) - return value.toBool() ? tr("Yes") : tr("No"); + if (value.type() == QVariant::Bool) { + #if defined(BOOLEAN_AS_COMBOBOXES) + return value.toBool() ? tr("Yes") : tr("No"); + #else + return QString(""); + #endif + } return QStyledItemDelegate::displayText(value, locale); } QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.data().type() == QVariant::Bool) { - QComboBox *cbox = new QComboBox(parent); - /* Nicer boolean editor -- by default, Qt creates a True/False combo box */ - cbox->addItem(tr("No")); - cbox->addItem(tr("Yes")); - return cbox; + #if defined(BOOLEAN_AS_COMBOBOXES) + QComboBox *cbox = new QComboBox(parent); + /* Nicer boolean editor -- by default, Qt creates a True/False combo box */ + cbox->addItem(tr("No")); + cbox->addItem(tr("Yes")); + return cbox; + #else + return new QCheckBox(parent); + #endif } QWidget *widget = QStyledItemDelegate::createEditor(parent, option, index); #if defined(__OSX__) @@ -494,8 +530,13 @@ QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewI void PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { if (index.data().type() == QVariant::Bool) { - QComboBox *cbox = static_cast(editor); - cbox->setCurrentIndex(index.data().toBool() ? 1 : 0); + #if defined(BOOLEAN_AS_COMBOBOXES) + QComboBox *cbox = static_cast(editor); + cbox->setCurrentIndex(index.data().toBool() ? 1 : 0); + #else + QCheckBox *cbox = static_cast(editor); + cbox->setChecked(index.data().toBool()); + #endif return; } @@ -505,8 +546,13 @@ void PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) void PropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if (index.data().type() == QVariant::Bool) { - QComboBox *cbox = static_cast(editor); - model->setData(index, QVariant(cbox->currentIndex() == 1), Qt::EditRole); + #if defined(BOOLEAN_AS_COMBOBOXES) + QComboBox *cbox = static_cast(editor); + model->setData(index, QVariant(cbox->currentIndex() == 1), Qt::EditRole); + #else + QCheckBox *cbox = static_cast(editor); + model->setData(index, QVariant(cbox->isChecked()), Qt::EditRole); + #endif return; } QStyledItemDelegate::setModelData(editor, model, index); diff --git a/src/mtsgui/rendersettingsdlg.ui b/src/mtsgui/rendersettingsdlg.ui index ccfd9d3f..d4ad8517 100644 --- a/src/mtsgui/rendersettingsdlg.ui +++ b/src/mtsgui/rendersettingsdlg.ui @@ -6,8 +6,8 @@ 0 0 - 436 - 497 + 450 + 530