fix: text color

main
reionwong 4 years ago
parent 691df80a79
commit 7aa179e6b2

@ -67,7 +67,7 @@ Item {
onNewColor: {
background.color = color
rootItem.darkMode = lightness < 128 ? true : false
rootItem.darkMode = darkMode
}
}

@ -39,7 +39,12 @@ void BackgroundHelper::setColor(QColor c)
{
m_color = c;
m_type = 1;
emit newColor(c, c.lightness());
bool isDark = (c.red() * 0.299 +
c.green() * 0.587 +
c.blue() * 0.114) < 186;
emit newColor(c, isDark);
}
void BackgroundHelper::setBackgound(const QString &fileName)
@ -75,8 +80,13 @@ void BackgroundHelper::setBackgound(const QString &fileName)
sumB /= measureArea;
QColor c = QColor(sumR, sumG, sumB);
QColor textColor = (sumR * 0.299 +
sumG * 0.587 +
sumB * 0.114) > 186 ? "#000000" : "#FFFFFF";
qDebug() << c << textColor;
emit newColor(c, c.lightness());
emit newColor(c, textColor == "#FFFFFF");
// clear cache.
QPixmapCache::clear();

@ -38,7 +38,7 @@ private slots:
void onChanged();
signals:
void newColor(QColor color, int lightness);
void newColor(QColor color, bool darkMode);
private:
int m_statusBarHeight;

Loading…
Cancel
Save