Changed: #1302 Added signal 'reset bool property' for returning to default value
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
a175d04f86
commit
b5bea9013f
8 changed files with 52 additions and 3 deletions
BIN
code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/images/resetproperty.png
vendored
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/images/resetproperty.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 169 B |
|
@ -659,6 +659,7 @@ class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate<QtBoolEdit>
|
||||||
public:
|
public:
|
||||||
void slotPropertyChanged(QtProperty *property, bool value);
|
void slotPropertyChanged(QtProperty *property, bool value);
|
||||||
void slotSetValue(bool value);
|
void slotSetValue(bool value);
|
||||||
|
void slotReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value)
|
void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value)
|
||||||
|
@ -669,6 +670,7 @@ void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool va
|
||||||
QListIterator<QtBoolEdit *> itEditor(m_createdEditors[property]);
|
QListIterator<QtBoolEdit *> itEditor(m_createdEditors[property]);
|
||||||
while (itEditor.hasNext()) {
|
while (itEditor.hasNext()) {
|
||||||
QtBoolEdit *editor = itEditor.next();
|
QtBoolEdit *editor = itEditor.next();
|
||||||
|
editor->setStateResetButton(property->isModified());
|
||||||
editor->blockCheckBoxSignals(true);
|
editor->blockCheckBoxSignals(true);
|
||||||
editor->setChecked(value);
|
editor->setChecked(value);
|
||||||
editor->blockCheckBoxSignals(false);
|
editor->blockCheckBoxSignals(false);
|
||||||
|
@ -691,6 +693,22 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCheckBoxFactoryPrivate::slotReset()
|
||||||
|
{
|
||||||
|
QObject *object = q_ptr->sender();
|
||||||
|
|
||||||
|
const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
|
||||||
|
for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
|
||||||
|
if (itEditor.key() == object) {
|
||||||
|
QtProperty *property = itEditor.value();
|
||||||
|
QtBoolPropertyManager *manager = q_ptr->propertyManager(property);
|
||||||
|
if (!manager)
|
||||||
|
return;
|
||||||
|
manager->setResetProperty(property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QtCheckBoxFactory
|
\class QtCheckBoxFactory
|
||||||
|
|
||||||
|
@ -740,8 +758,10 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
{
|
{
|
||||||
QtBoolEdit *editor = d_ptr->createEditor(property, parent);
|
QtBoolEdit *editor = d_ptr->createEditor(property, parent);
|
||||||
|
editor->setStateResetButton(property->isModified());
|
||||||
editor->setChecked(manager->value(property));
|
editor->setChecked(manager->value(property));
|
||||||
|
|
||||||
|
connect(editor, SIGNAL(resetProperty()), this, SLOT(slotReset()));
|
||||||
connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool)));
|
connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool)));
|
||||||
connect(editor, SIGNAL(destroyed(QObject *)),
|
connect(editor, SIGNAL(destroyed(QObject *)),
|
||||||
this, SLOT(slotEditorDestroyed(QObject *)));
|
this, SLOT(slotEditorDestroyed(QObject *)));
|
||||||
|
@ -2645,10 +2665,15 @@ QtTextEditWidget::QtTextEditWidget(QWidget *parent) :
|
||||||
|
|
||||||
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
||||||
m_button->setFixedWidth(20);
|
m_button->setFixedWidth(20);
|
||||||
setFocusProxy(m_button);
|
|
||||||
setFocusPolicy(m_button->focusPolicy());
|
|
||||||
m_button->setText(tr("..."));
|
m_button->setText(tr("..."));
|
||||||
m_button->installEventFilter(this);
|
m_button->installEventFilter(this);
|
||||||
|
|
||||||
|
setFocusProxy(m_button);
|
||||||
|
setFocusPolicy(m_button->focusPolicy());
|
||||||
|
|
||||||
|
m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png"));
|
||||||
|
m_defaultButton->setMaximumWidth(16);
|
||||||
|
|
||||||
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
||||||
lt->addWidget(m_button);
|
lt->addWidget(m_button);
|
||||||
lt->addWidget(m_defaultButton);
|
lt->addWidget(m_defaultButton);
|
||||||
|
|
|
@ -186,6 +186,7 @@ private:
|
||||||
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool))
|
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool))
|
||||||
Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool))
|
Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool))
|
||||||
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void slotReset())
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtDoubleSpinBoxFactoryPrivate;
|
class QtDoubleSpinBoxFactoryPrivate;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<file>images/cursor-vsplit.png</file>
|
<file>images/cursor-vsplit.png</file>
|
||||||
<file>images/cursor-wait.png</file>
|
<file>images/cursor-wait.png</file>
|
||||||
<file>images/cursor-whatsthis.png</file>
|
<file>images/cursor-whatsthis.png</file>
|
||||||
|
<file>images/resetproperty.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,10 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) :
|
||||||
m_defaultButton(new QToolButton(this)),
|
m_defaultButton(new QToolButton(this)),
|
||||||
m_textVisible(true)
|
m_textVisible(true)
|
||||||
{
|
{
|
||||||
|
m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png"));
|
||||||
|
m_defaultButton->setMaximumWidth(16);
|
||||||
|
m_defaultButton->setEnabled(false);
|
||||||
|
|
||||||
QHBoxLayout *lt = new QHBoxLayout;
|
QHBoxLayout *lt = new QHBoxLayout;
|
||||||
if (QApplication::layoutDirection() == Qt::LeftToRight)
|
if (QApplication::layoutDirection() == Qt::LeftToRight)
|
||||||
lt->setContentsMargins(4, 0, 0, 0);
|
lt->setContentsMargins(4, 0, 0, 0);
|
||||||
|
@ -271,9 +275,11 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) :
|
||||||
lt->setContentsMargins(0, 0, 4, 0);
|
lt->setContentsMargins(0, 0, 4, 0);
|
||||||
lt->addWidget(m_checkBox);
|
lt->addWidget(m_checkBox);
|
||||||
lt->addWidget(m_defaultButton);
|
lt->addWidget(m_defaultButton);
|
||||||
m_defaultButton->setEnabled(false);
|
|
||||||
setLayout(lt);
|
setLayout(lt);
|
||||||
|
|
||||||
connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||||
|
connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty()));
|
||||||
|
|
||||||
setFocusProxy(m_checkBox);
|
setFocusProxy(m_checkBox);
|
||||||
m_checkBox->setText(QString());
|
m_checkBox->setText(QString());
|
||||||
}
|
}
|
||||||
|
@ -297,6 +303,11 @@ void QtBoolEdit::setCheckState(Qt::CheckState state)
|
||||||
m_checkBox->setCheckState(state);
|
m_checkBox->setCheckState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtBoolEdit::setStateResetButton(bool enabled)
|
||||||
|
{
|
||||||
|
m_defaultButton->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
bool QtBoolEdit::isChecked() const
|
bool QtBoolEdit::isChecked() const
|
||||||
{
|
{
|
||||||
return m_checkBox->isChecked();
|
return m_checkBox->isChecked();
|
||||||
|
|
|
@ -155,6 +155,7 @@ public:
|
||||||
|
|
||||||
Qt::CheckState checkState() const;
|
Qt::CheckState checkState() const;
|
||||||
void setCheckState(Qt::CheckState state);
|
void setCheckState(Qt::CheckState state);
|
||||||
|
void setStateResetButton(bool enabled);
|
||||||
|
|
||||||
bool isChecked() const;
|
bool isChecked() const;
|
||||||
void setChecked(bool c);
|
void setChecked(bool c);
|
||||||
|
@ -163,6 +164,7 @@ public:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void toggled(bool);
|
void toggled(bool);
|
||||||
|
void resetProperty();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent * event);
|
void mousePressEvent(QMouseEvent * event);
|
||||||
|
|
|
@ -1588,6 +1588,11 @@ void QtBoolPropertyManager::setValue(QtProperty *property, bool val)
|
||||||
property, val);
|
property, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtBoolPropertyManager::setResetProperty(QtProperty *property)
|
||||||
|
{
|
||||||
|
emit resetProperty(property);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\reimp
|
\reimp
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -160,8 +160,12 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setValue(QtProperty *property, bool val);
|
void setValue(QtProperty *property, bool val);
|
||||||
|
void setResetProperty(QtProperty *property);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void valueChanged(QtProperty *property, bool val);
|
void valueChanged(QtProperty *property, bool val);
|
||||||
|
void resetProperty(QtProperty *property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString valueText(const QtProperty *property) const;
|
QString valueText(const QtProperty *property) const;
|
||||||
QIcon valueIcon(const QtProperty *property) const;
|
QIcon valueIcon(const QtProperty *property) const;
|
||||||
|
|
Loading…
Reference in a new issue