generate just a bit better colors using HSV model

This commit is contained in:
Martin Rotter 2023-07-25 09:38:11 +02:00
parent 7d62aa44fc
commit 4694696c5d
3 changed files with 9 additions and 8 deletions

View File

@ -37,11 +37,11 @@ void ColorToolButton::setColor(const QColor& color) {
}
void ColorToolButton::setRandomColor() {
auto rnd_color = QRandomGenerator::global()->bounded(0xFFFFFF);
auto rnd_color_name = QSL("#%1").arg(QString::number(rnd_color, 16));
int hue = QRandomGenerator::global()->generate() % 360;
auto clr = QColor::fromHsv(hue, 200, 240);
setColor(rnd_color_name);
emit colorChanged(rnd_color_name);
setColor(clr);
emit colorChanged(clr);
}
void ColorToolButton::paintEvent(QPaintEvent* e) {

View File

@ -37,10 +37,10 @@ QColor TextFactory::generateColorFromText(const QString& text) {
color += chr.unicode();
}
color = QRandomGenerator(color).bounded(double(0xFFFFFF)) - 1;
auto color_name = QSL("#%1").arg(color, 6, 16);
// NOTE: https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically
int hue = color % 360;
return QColor(color_name);
return QColor::fromHsv(hue, 200, 240);
}
int TextFactory::stringHeight(const QString& string, const QFontMetrics& metrics) {

View File

@ -214,7 +214,8 @@ void ServiceRoot::cleanAllItemsFromModel(bool clean_labels_too) {
for (RootItem* top_level_item : qAsConst(chi)) {
if (top_level_item->kind() != RootItem::Kind::Bin && top_level_item->kind() != RootItem::Kind::Important &&
top_level_item->kind() != RootItem::Kind::Unread && top_level_item->kind() != RootItem::Kind::Labels) {
top_level_item->kind() != RootItem::Kind::Unread && top_level_item->kind() != RootItem::Kind::Probes &&
top_level_item->kind() != RootItem::Kind::Labels) {
requestItemRemoval(top_level_item);
}
}