From a97731c9f7277230a5c7ed676d2e05b07eb1bf26 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Wed, 23 Jul 2014 23:12:57 +0200 Subject: [PATCH] fixed an annoying OSX-specific bug where checkboxes in the render settings dialog did not get saved --- src/mtsgui/rendersettingsdlg.cpp | 39 +++++++++++++++++++------------- src/mtsgui/rendersettingsdlg.h | 2 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/mtsgui/rendersettingsdlg.cpp b/src/mtsgui/rendersettingsdlg.cpp index b886dd9d..9f4f1b0d 100644 --- a/src/mtsgui/rendersettingsdlg.cpp +++ b/src/mtsgui/rendersettingsdlg.cpp @@ -184,11 +184,11 @@ void RenderSettingsDialog::setDocumentation(const QString &text) { ui->groupBox->setTitle(tr("Documentation")); } -#if defined(__OSX__) - ui->helpViewer->setHtml(comments + "
" + m_currentDocumentation + "
"); -#else - ui->helpViewer->setHtml(comments + "
" + m_currentDocumentation + "
"); -#endif + #if defined(__OSX__) + ui->helpViewer->setHtml(comments + "
" + m_currentDocumentation + "
"); + #else + ui->helpViewer->setHtml(comments + "
" + m_currentDocumentation + "
"); + #endif ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!hasErrors); } @@ -546,33 +546,40 @@ QString PropertyDelegate::displayText(const QVariant &value, const QLocale &loca return QStyledItemDelegate::displayText(value, locale); } +void PropertyDelegate::updateWidgetData() { + emit commitData((QWidget *) sender()); +} + QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.data().type() == QVariant::Bool) { #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); + QCheckBox *box = new QCheckBox(parent); + connect(box, SIGNAL(toggled(bool)), this, SLOT(updateWidgetData())); + return box; #endif } + QWidget *widget; if (index.data().type() == QVariant::Double) widget = new BetterDoubleSpinBox(parent); else widget = QStyledItemDelegate::createEditor(parent, option, index); -#if defined(__OSX__) - /* Don't draw focus halos on OSX, they're really distracting */ - if (widget != NULL && widget->testAttribute(Qt::WA_MacShowFocusRect)) - widget->setAttribute(Qt::WA_MacShowFocusRect, false); - if (index.data().type() != QVariant::Bool) { - widget->setAttribute(Qt::WA_MacMiniSize, true); - widget->setStyleSheet("font-size: 13pt;"); - } -#endif + + #if defined(__OSX__) + /* Don't draw focus halos on OSX, they're really distracting */ + if (widget != NULL && widget->testAttribute(Qt::WA_MacShowFocusRect)) + widget->setAttribute(Qt::WA_MacShowFocusRect, false); + if (index.data().type() != QVariant::Bool) { + widget->setAttribute(Qt::WA_MacMiniSize, true); + widget->setStyleSheet("font-size: 13pt;"); + } + #endif return widget; } diff --git a/src/mtsgui/rendersettingsdlg.h b/src/mtsgui/rendersettingsdlg.h index 492dfc3d..679acb4c 100644 --- a/src/mtsgui/rendersettingsdlg.h +++ b/src/mtsgui/rendersettingsdlg.h @@ -40,6 +40,8 @@ public: const QModelIndex &index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; +protected slots: + void updateWidgetData(); }; class RenderSettingsDialog : public QDialog {