diff -r c6f5de03dc0f -r afdab56e8210 widgets/colorbutton.cpp --- a/widgets/colorbutton.cpp Wed Jun 22 22:59:56 2022 +0300 +++ b/widgets/colorbutton.cpp Wed Jun 22 23:32:34 2022 +0300 @@ -1,4 +1,5 @@ #include +#include #include "colorbutton.h" ColorButton::ColorButton(const QColor& color, QWidget* parent) : @@ -28,9 +29,13 @@ { if (this->storedSelectedColor != color) { this->storedSelectedColor = color; - this->setStyleSheet(QString{"background-color: %1"}.arg(color.name())); this->setText(color.name()); + QPalette palette{color}; + const qreal lightness = color.lightnessF(); + const QColor foreground = lightness < 0.4 ? Qt::white : Qt::black; + palette.setColor(QPalette::ButtonText, foreground); + this->setPalette(palette); + this->setStyle(QStyleFactory::create("Fusion")); Q_EMIT this->colorChanged(this->storedSelectedColor); } } -