mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-16 18:36:45 +00:00
Change the way the text color for snore notifications is computed.
This commit is contained in:
parent
b5e77e6d5d
commit
a256dd3ed5
@ -97,8 +97,7 @@ void NotifyWidget::display(const Notification ¬ification)
|
|||||||
color = computeBackgrondColor(notification.application().icon().image().scaled(20, 20));
|
color = computeBackgrondColor(notification.application().icon().image().scaled(20, 20));
|
||||||
notification.application().hints().setPrivateValue(parent(), "backgroundColor", color);
|
notification.application().hints().setPrivateValue(parent(), "backgroundColor", color);
|
||||||
}
|
}
|
||||||
QRgb gray = qGray(qGray(color.rgb()) - qGray(QColor(Qt::white).rgb()));
|
QColor textColor = compueTextColor(color);
|
||||||
QColor textColor = QColor(gray, gray, gray);
|
|
||||||
QMetaObject::invokeMethod(rootObject(), "update", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(rootObject(), "update", Qt::QueuedConnection,
|
||||||
Q_ARG(QVariant, notification.title(Utils::ALL_MARKUP)),
|
Q_ARG(QVariant, notification.title(Utils::ALL_MARKUP)),
|
||||||
Q_ARG(QVariant, notification.text(Utils::ALL_MARKUP)),
|
Q_ARG(QVariant, notification.text(Utils::ALL_MARKUP)),
|
||||||
@ -203,3 +202,10 @@ QColor NotifyWidget::computeBackgrondColor(const QImage &img)
|
|||||||
return QColor(r / s, g / s, b / s);
|
return QColor(r / s, g / s, b / s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor NotifyWidget::compueTextColor(const QColor &backgroundColor)
|
||||||
|
{
|
||||||
|
// based on http://stackoverflow.com/a/946734
|
||||||
|
QRgb compColor = qGray(backgroundColor.rgb()) > 186 ? 0 : 255;
|
||||||
|
return QColor(compColor, compColor, compColor);
|
||||||
|
}
|
||||||
|
@ -70,6 +70,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QColor computeBackgrondColor(const QImage &img);
|
QColor computeBackgrondColor(const QImage &img);
|
||||||
|
QColor compueTextColor(const QColor &backgroundColor);
|
||||||
|
|
||||||
Snore::Notification m_notification;
|
Snore::Notification m_notification;
|
||||||
int m_id;
|
int m_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user