fixed an annoying OSX-specific bug where checkboxes in the render settings dialog did not get saved

metadata
Wenzel Jakob 2014-07-23 23:12:57 +02:00
parent ae865e7dfa
commit a97731c9f7
2 changed files with 25 additions and 16 deletions

View File

@ -184,11 +184,11 @@ void RenderSettingsDialog::setDocumentation(const QString &text) {
ui->groupBox->setTitle(tr("Documentation")); ui->groupBox->setTitle(tr("Documentation"));
} }
#if defined(__OSX__) #if defined(__OSX__)
ui->helpViewer->setHtml(comments + "<div style='font-size:12pt'>" + m_currentDocumentation + "</div>"); ui->helpViewer->setHtml(comments + "<div style='font-size:12pt'>" + m_currentDocumentation + "</div>");
#else #else
ui->helpViewer->setHtml(comments + "<div style='font-size:10pt'>" + m_currentDocumentation + "</div>"); ui->helpViewer->setHtml(comments + "<div style='font-size:10pt'>" + m_currentDocumentation + "</div>");
#endif #endif
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!hasErrors); 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); return QStyledItemDelegate::displayText(value, locale);
} }
void PropertyDelegate::updateWidgetData() {
emit commitData((QWidget *) sender());
}
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) {
#if defined(BOOLEAN_AS_COMBOBOXES) #if defined(BOOLEAN_AS_COMBOBOXES)
QComboBox *cbox = new QComboBox(parent); QComboBox *cbox = new QComboBox(parent);
/* Nicer boolean editor -- by default, Qt creates a True/False combo box */
cbox->addItem(tr("No")); cbox->addItem(tr("No"));
cbox->addItem(tr("Yes")); cbox->addItem(tr("Yes"));
return cbox; return cbox;
#else #else
return new QCheckBox(parent); QCheckBox *box = new QCheckBox(parent);
connect(box, SIGNAL(toggled(bool)), this, SLOT(updateWidgetData()));
return box;
#endif #endif
} }
QWidget *widget; QWidget *widget;
if (index.data().type() == QVariant::Double) if (index.data().type() == QVariant::Double)
widget = new BetterDoubleSpinBox(parent); widget = new BetterDoubleSpinBox(parent);
else else
widget = QStyledItemDelegate::createEditor(parent, option, index); widget = QStyledItemDelegate::createEditor(parent, option, index);
#if defined(__OSX__)
/* Don't draw focus halos on OSX, they're really distracting */ #if defined(__OSX__)
if (widget != NULL && widget->testAttribute(Qt::WA_MacShowFocusRect)) /* Don't draw focus halos on OSX, they're really distracting */
widget->setAttribute(Qt::WA_MacShowFocusRect, false); if (widget != NULL && widget->testAttribute(Qt::WA_MacShowFocusRect))
if (index.data().type() != QVariant::Bool) { widget->setAttribute(Qt::WA_MacShowFocusRect, false);
widget->setAttribute(Qt::WA_MacMiniSize, true); if (index.data().type() != QVariant::Bool) {
widget->setStyleSheet("font-size: 13pt;"); widget->setAttribute(Qt::WA_MacMiniSize, true);
} widget->setStyleSheet("font-size: 13pt;");
#endif }
#endif
return widget; return widget;
} }

View File

@ -40,6 +40,8 @@ public:
const QModelIndex &index) const; const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const; const QStyleOptionViewItem &option, const QModelIndex &index) const;
protected slots:
void updateWidgetData();
}; };
class RenderSettingsDialog : public QDialog { class RenderSettingsDialog : public QDialog {