Skip to content

Commit

Permalink
BUG: Do not overwrite the full palette in ctkDICOMServerNodeWidget2
Browse files Browse the repository at this point in the history
  • Loading branch information
Punzo authored and lassoan committed Apr 27, 2024
1 parent afec0d3 commit 7ed1da3
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions Libs/DICOM/Widgets/ctkDICOMServerNodeWidget2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class ctkDICOMServerNodeWidget2Private : public Ui_ctkDICOMServerNodeWidget2
int horizontalScrollBarValue,
int verticalScrollBarValue,
bool resetServerStatus = true);
void setDynamicPaletteColorToWidget(QPalette* palette, QWidget* widget);

bool SettingsModified;
QSharedPointer<ctkDICOMScheduler> Scheduler;
Expand Down Expand Up @@ -910,7 +911,7 @@ void ctkDICOMServerNodeWidget2Private::updateServerVerification(const ctkDICOMJo
palette = this->ServerFailedPalette;
}

lineEdit->setPalette(palette);
this->setDynamicPaletteColorToWidget(&palette, lineEdit);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -988,16 +989,13 @@ void ctkDICOMServerNodeWidget2Private::restoreFocus(QModelIndexList selectedInde
}

QWidget *widget = this->NodeTable->cellWidget(row, column);
if (widget)
{
widget->setPalette(this->DefaultPalette);
}
this->setDynamicPaletteColorToWidget(&this->DefaultPalette, widget);
}
}

this->StorageEnabledCheckBox->setPalette(this->DefaultPalette);
this->StorageAETitle->setPalette(this->DefaultPalette);
this->StoragePort->setPalette(this->DefaultPalette);
this->setDynamicPaletteColorToWidget(&this->DefaultPalette, this->StorageEnabledCheckBox);
this->setDynamicPaletteColorToWidget(&this->DefaultPalette, this->StorageAETitle);
this->setDynamicPaletteColorToWidget(&this->DefaultPalette, this->StoragePort);

this->NodeTable->horizontalScrollBar()->setValue(horizontalScrollBarValue);
this->NodeTable->verticalScrollBar()->setValue(verticalScrollBarValue);
Expand All @@ -1012,6 +1010,20 @@ void ctkDICOMServerNodeWidget2Private::restoreFocus(QModelIndexList selectedInde
this->NodeTable->selectRow(index.row());
}

//----------------------------------------------------------------------------
void ctkDICOMServerNodeWidget2Private::setDynamicPaletteColorToWidget(QPalette *palette, QWidget *widget)
{
if (!palette || !widget)
{
return;
}

QPalette widgetPalette = widget->palette();
widgetPalette.setColor(QPalette::Base, palette->color(QPalette::Base));
widgetPalette.setColor(QPalette::Button, palette->color(QPalette::Button));
widget->setPalette(widgetPalette);
}

//----------------------------------------------------------------------------
ctkDICOMServerNodeWidget2::ctkDICOMServerNodeWidget2(QWidget* parentWidget)
: Superclass(parentWidget)
Expand Down Expand Up @@ -1267,10 +1279,7 @@ void ctkDICOMServerNodeWidget2::onSettingsModified()
if (senderObj)
{
QWidget *widget = qobject_cast<QWidget*>(senderObj);
if (widget)
{
widget->setPalette(d->ModifiedPalette);
}
d->setDynamicPaletteColorToWidget(&d->ModifiedPalette, widget);
}

d->settingsModified();
Expand Down Expand Up @@ -1305,7 +1314,7 @@ void ctkDICOMServerNodeWidget2::onCellSettingsModified(int row, int column)
d->DefaultPalette.setColor(QPalette::Base, ctkDICOMServerNodeWidget2DefaultColor);
}

lineEdit->setPalette(d->DefaultPalette);
d->setDynamicPaletteColorToWidget(&d->DefaultPalette, lineEdit);
}

d->SettingsModified = true;
Expand Down

0 comments on commit 7ed1da3

Please sign in to comment.