rendersettingsdlg: some great usability improvements submitted by Anton Kaplanyan

metadata
Wenzel Jakob 2014-01-27 18:10:38 +01:00
parent 369dcf06fc
commit a3b43613ac
3 changed files with 72 additions and 27 deletions

View File

@ -1389,7 +1389,6 @@ void MainWindow::on_actionSettings_triggered() {
} }
} }
void MainWindow::on_actionStop_triggered() { void MainWindow::on_actionStop_triggered() {
SceneContext *context = m_context[ui->tabBar->currentIndex()]; SceneContext *context = m_context[ui->tabBar->currentIndex()];
m_contextMutex.lock(); m_contextMutex.lock();
@ -1821,9 +1820,9 @@ void MainWindow::onWorkCanceled(const RenderJob *job, const Point2i &offset, con
if (context == NULL) if (context == NULL)
return; return;
VisualWorkUnit vwu(offset, size); VisualWorkUnit vwu(offset, size);
m_contextMutex.lock();
if (context->workUnits.find(vwu) != context->workUnits.end()) if (context->workUnits.find(vwu) != context->workUnits.end())
context->workUnits.erase(vwu); context->workUnits.erase(vwu);
m_contextMutex.lock();
m_contextMutex.unlock(); m_contextMutex.unlock();
} }

View File

@ -122,6 +122,7 @@ RenderSettingsDialog::RenderSettingsDialog(QWidget *parent) :
pal.setColor(QPalette::Text, pal.color(QPalette::Foreground)); pal.setColor(QPalette::Text, pal.color(QPalette::Foreground));
pal.setColor(QPalette::Base, pal.color(QPalette::Window)); pal.setColor(QPalette::Base, pal.color(QPalette::Window));
ui->helpViewer->setPalette(pal); ui->helpViewer->setPalette(pal);
ui->helpViewer->setHtml("Click on any setting for documentation");
} }
void RenderSettingsDialog::setDocumentation(const QString &text) { void RenderSettingsDialog::setDocumentation(const QString &text) {
@ -187,12 +188,23 @@ void RenderSettingsDialog::onTreeSelectionChange(const QItemSelection &selected,
void RenderSettingsDialog::update() { void RenderSettingsDialog::update() {
int index = ui->integratorBox->currentIndex(); int index = ui->integratorBox->currentIndex();
Properties integratorProps, samplerProps; Properties integratorProps, samplerProps;
bool needsUpdate = false;
if (sender() == ui->samplerBox) if (sender() == ui->samplerBox) {
m_samplerNode->putProperties(samplerProps); m_samplerNode->putProperties(samplerProps);
needsUpdate = true;
}
if (sender() == ui->integratorBox) if (sender() == ui->integratorBox) {
m_integratorNode->putProperties(integratorProps); 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, m_integratorNode = m_model->updateClass(m_integratorNode,
ui->integratorBox->itemData(index).toList().at(0).toString(), 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 for (int j = 1; j < m_model->rowCount(index); ++j) {
/* Make comboboxes etc editable by default .. does not quite work yet */ QModelIndex idx = m_model->index(j, 1, index);
for (int i = 0; i < m_model->rowCount(); ++i) { ui->treeView->openPersistentEditor(idx);
QModelIndex index = m_model->index(i, 0); QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(ui->treeView->indexWidget(idx));
if (spinBox)
for (int j = 1; j < m_model->rowCount(index); ++j) { spinBox->findChild<QLineEdit*>()->deselect();
ui->treeView->openPersistentEditor( }
m_model->index(j, 1, index));
} }
} }
#endif ui->treeView->expandAll();
dataChanged(); dataChanged();
} }
@ -303,6 +317,19 @@ void RenderSettingsDialog::load(const SceneContext *ctx) {
m_model->setProperties(m_samplerNode, samplerProps); m_model->setProperties(m_samplerNode, samplerProps);
m_model->setProperties(m_integratorNode, integratorProps); m_model->setProperties(m_integratorNode, integratorProps);
ui->treeView->expandAll(); 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<QAbstractSpinBox *>(ui->treeView->indexWidget(idx));
if (spinBox)
spinBox->findChild<QLineEdit*>()->deselect();
}
}
} }
void RenderSettingsDialog::apply(SceneContext *ctx) { void RenderSettingsDialog::apply(SceneContext *ctx) {
@ -465,19 +492,28 @@ PropertyDelegate::~PropertyDelegate() {
} }
QString PropertyDelegate::displayText(const QVariant &value, const QLocale &locale) const { QString PropertyDelegate::displayText(const QVariant &value, const QLocale &locale) const {
if (value.type() == QVariant::Bool) if (value.type() == QVariant::Bool) {
return value.toBool() ? tr("Yes") : tr("No"); #if defined(BOOLEAN_AS_COMBOBOXES)
return value.toBool() ? tr("Yes") : tr("No");
#else
return QString("");
#endif
}
return QStyledItemDelegate::displayText(value, locale); return QStyledItemDelegate::displayText(value, locale);
} }
QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const { const QModelIndex &index) const {
if (index.data().type() == QVariant::Bool) { if (index.data().type() == QVariant::Bool) {
QComboBox *cbox = new QComboBox(parent); #if defined(BOOLEAN_AS_COMBOBOXES)
/* Nicer boolean editor -- by default, Qt creates a True/False combo box */ QComboBox *cbox = new QComboBox(parent);
cbox->addItem(tr("No")); /* Nicer boolean editor -- by default, Qt creates a True/False combo box */
cbox->addItem(tr("Yes")); cbox->addItem(tr("No"));
return cbox; cbox->addItem(tr("Yes"));
return cbox;
#else
return new QCheckBox(parent);
#endif
} }
QWidget *widget = QStyledItemDelegate::createEditor(parent, option, index); QWidget *widget = QStyledItemDelegate::createEditor(parent, option, index);
#if defined(__OSX__) #if defined(__OSX__)
@ -494,8 +530,13 @@ QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
void PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { void PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
if (index.data().type() == QVariant::Bool) { if (index.data().type() == QVariant::Bool) {
QComboBox *cbox = static_cast<QComboBox *>(editor); #if defined(BOOLEAN_AS_COMBOBOXES)
cbox->setCurrentIndex(index.data().toBool() ? 1 : 0); QComboBox *cbox = static_cast<QComboBox *>(editor);
cbox->setCurrentIndex(index.data().toBool() ? 1 : 0);
#else
QCheckBox *cbox = static_cast<QCheckBox *>(editor);
cbox->setChecked(index.data().toBool());
#endif
return; return;
} }
@ -505,8 +546,13 @@ void PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
void PropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, void PropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const { const QModelIndex &index) const {
if (index.data().type() == QVariant::Bool) { if (index.data().type() == QVariant::Bool) {
QComboBox *cbox = static_cast<QComboBox *>(editor); #if defined(BOOLEAN_AS_COMBOBOXES)
model->setData(index, QVariant(cbox->currentIndex() == 1), Qt::EditRole); QComboBox *cbox = static_cast<QComboBox *>(editor);
model->setData(index, QVariant(cbox->currentIndex() == 1), Qt::EditRole);
#else
QCheckBox *cbox = static_cast<QCheckBox *>(editor);
model->setData(index, QVariant(cbox->isChecked()), Qt::EditRole);
#endif
return; return;
} }
QStyledItemDelegate::setModelData(editor, model, index); QStyledItemDelegate::setModelData(editor, model, index);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>450</width>
<height>497</height> <height>530</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">