twice materialChanged signal fixed

This commit is contained in:
2023-05-23 22:22:25 +03:00
parent 893910c431
commit fcc1e98a6e
8 changed files with 29 additions and 23 deletions

View File

@@ -36,7 +36,7 @@ MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) {
ui->label_13->hide();
mat = 0;
active = true;
ignore_next = 0;
ignore_next = false;
}
@@ -51,7 +51,7 @@ void MaterialEditor::changeEvent(QEvent * e) {
void MaterialEditor::materialChanged() {
if (!active || !mat) return;
ignore_next = 2;
ignore_next = true;
mat->_changed = true;
mat->color_diffuse = ui->mapDiffuse->color();
mat->color_emission = ui->mapEmission->color();
@@ -65,8 +65,8 @@ void MaterialEditor::materialChanged() {
void MaterialEditor::setMaterial(Material * m) {
if (ignore_next > 0) {
// ignore_next = false;
if (ignore_next) {
ignore_next = false;
return;
}
active = false;

View File

@@ -40,7 +40,7 @@ protected:
void changeEvent(QEvent * e);
bool active;
int ignore_next;
bool ignore_next;
Ui::MaterialEditor * ui;
Material * mat;

View File

@@ -94,10 +94,10 @@
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>0.000000000000000</double>
<double>-999.000000000000000</double>
</property>
<property name="spinMaximum">
<double>1.000000000000000</double>
<double>9999.000000000000000</double>
</property>
</widget>
</item>
@@ -192,10 +192,10 @@
<item row="1" column="1">
<widget class="SpinSlider" name="sliderAmount">
<property name="minimum">
<double>-1.000000000000000</double>
<double>-2.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
<double>2.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
@@ -210,10 +210,10 @@
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
<double>-999.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
<double>9999.000000000000000</double>
</property>
</widget>
</item>
@@ -242,10 +242,10 @@
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
<double>-999.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
<double>9999.000000000000000</double>
</property>
</widget>
</item>

View File

@@ -107,13 +107,14 @@ void MaterialsEditor::selectionChanged() {
if (!view) return;
// qDebug() << "selectionChanged";
ObjectBase * o = view->selectedObject();
if (o) selectMaterial(o->material());
if (!o) return;
if (o->material()) selectMaterial(o->material());
}
void MaterialsEditor::materialsChanged() {
if (ui->widgetMaterial->ignore_next > 0) {
ui->widgetMaterial->ignore_next--;
if (ui->widgetMaterial->ignore_next) {
ui->widgetMaterial->ignore_next = false;
return;
}
Material * cm = currentMaterial();
@@ -153,6 +154,7 @@ void MaterialsEditor::on_buttonRename_clicked() {
int ind = ui->comboMaterial->currentIndex();
ui->comboMaterial->setItemText(ind, QString("[%1] " + nn).arg(ind + 1));
ui->comboMaterial->setItemData(ind, nn);
view->scene()->treeChanged();
}
@@ -193,6 +195,7 @@ void MaterialsEditor::on_buttonAssign_clicked() {
ObjectBaseList ol = view->selectedObjects();
foreach(ObjectBase * o, ol)
o->setMaterial(m, true);
view->scene()->treeChanged();
}

View File

@@ -60,7 +60,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-287</y>
<y>-300</y>
<width>444</width>
<height>1100</height>
</rect>
@@ -590,7 +590,7 @@
<bool>true</bool>
</property>
<property name="spinMaximum">
<double>999.000000000000000</double>
<double>9999.000000000000000</double>
</property>
</widget>
</item>