mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Use color generator for nick names
This commit is contained in:
parent
8358720d8e
commit
a5ebff5949
6 changed files with 60 additions and 38 deletions
|
@ -18,7 +18,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>850</width>
|
<width>950</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string notr="true"> Nheko </string>
|
<string notr="true"> nheko </string>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: #f9f9f9</string>
|
<string notr="true">background-color: #f9f9f9</string>
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
static QString chooseRandomColor();
|
static QString chooseRandomColor();
|
||||||
static QString getUserColor(const QString &userid);
|
static QString getUserColor(const QString &userid);
|
||||||
static QMap<QString, QString> NICK_COLORS;
|
static QMap<QString, QString> NICK_COLORS;
|
||||||
static const QList<QString> COLORS;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHistoryView(const RoomInfo &info);
|
void setHistoryView(const RoomInfo &info);
|
||||||
|
|
|
@ -126,38 +126,61 @@ void HistoryViewManager::setHistoryView(const RoomInfo &info)
|
||||||
|
|
||||||
QMap<QString, QString> HistoryViewManager::NICK_COLORS;
|
QMap<QString, QString> HistoryViewManager::NICK_COLORS;
|
||||||
|
|
||||||
const QList<QString> HistoryViewManager::COLORS({"#FFF46E",
|
|
||||||
"#A58BFF",
|
|
||||||
"#50C9BA",
|
|
||||||
"#9EE6CF",
|
|
||||||
"#FFDD67",
|
|
||||||
"#2980B9",
|
|
||||||
"#FC993C",
|
|
||||||
"#2772DB",
|
|
||||||
"#CB8589",
|
|
||||||
"#DDE8B9",
|
|
||||||
"#55A44E",
|
|
||||||
"#A9EEE6",
|
|
||||||
"#53B759",
|
|
||||||
"#9E3997",
|
|
||||||
"#5D89D5",
|
|
||||||
"#BB86B7",
|
|
||||||
"#50a0cf",
|
|
||||||
"#3C989F",
|
|
||||||
"#5A4592",
|
|
||||||
"#235e5b",
|
|
||||||
"#d58247",
|
|
||||||
"#e0a729",
|
|
||||||
"#a2b636",
|
|
||||||
"#4BBE2E"});
|
|
||||||
|
|
||||||
QString HistoryViewManager::chooseRandomColor()
|
QString HistoryViewManager::chooseRandomColor()
|
||||||
{
|
{
|
||||||
std::random_device random_device;
|
std::random_device random_device;
|
||||||
std::mt19937 engine{random_device()};
|
std::mt19937 engine{random_device()};
|
||||||
std::uniform_int_distribution<int> dist(0, HistoryViewManager::COLORS.size() - 1);
|
std::uniform_real_distribution<float> dist(0, 1);
|
||||||
|
|
||||||
return HistoryViewManager::COLORS[dist(engine)];
|
float hue = dist(engine);
|
||||||
|
float saturation = 0.9;
|
||||||
|
float value = 0.7;
|
||||||
|
|
||||||
|
int hue_i = hue * 6;
|
||||||
|
|
||||||
|
float f = hue * 6 - hue_i;
|
||||||
|
|
||||||
|
float p = value * (1 - saturation);
|
||||||
|
float q = value * (1 - f * saturation);
|
||||||
|
float t = value * (1 - (1 - f) * saturation);
|
||||||
|
|
||||||
|
float r = 0;
|
||||||
|
float g = 0;
|
||||||
|
float b = 0;
|
||||||
|
|
||||||
|
if (hue_i == 0) {
|
||||||
|
r = value;
|
||||||
|
g = t;
|
||||||
|
b = p;
|
||||||
|
} else if (hue_i == 1) {
|
||||||
|
r = q;
|
||||||
|
g = value;
|
||||||
|
b = p;
|
||||||
|
} else if (hue_i == 2) {
|
||||||
|
r = p;
|
||||||
|
g = value;
|
||||||
|
b = t;
|
||||||
|
} else if (hue_i == 3) {
|
||||||
|
r = p;
|
||||||
|
g = q;
|
||||||
|
b = value;
|
||||||
|
} else if (hue_i == 4) {
|
||||||
|
r = t;
|
||||||
|
g = p;
|
||||||
|
b = value;
|
||||||
|
} else if (hue_i == 5) {
|
||||||
|
r = value;
|
||||||
|
g = p;
|
||||||
|
b = q;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ri = r * 256;
|
||||||
|
int gi = g * 256;
|
||||||
|
int bi = b * 256;
|
||||||
|
|
||||||
|
QColor color(ri, gi, bi);
|
||||||
|
|
||||||
|
return color.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HistoryViewManager::getUserColor(const QString &userid)
|
QString HistoryViewManager::getUserColor(const QString &userid)
|
||||||
|
|
|
@ -84,8 +84,8 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||||
button_layout_->setContentsMargins(0, 0, 0, 50);
|
button_layout_->setContentsMargins(0, 0, 0, 50);
|
||||||
|
|
||||||
login_button_ = new RaisedButton("LOGIN", this);
|
login_button_ = new RaisedButton("LOGIN", this);
|
||||||
login_button_->setBackgroundColor(QColor("#acc7dc"));
|
login_button_->setBackgroundColor(QColor("#171919"));
|
||||||
login_button_->setForegroundColor(QColor("black"));
|
login_button_->setForegroundColor(QColor("white"));
|
||||||
login_button_->setMinimumSize(350, 65);
|
login_button_->setMinimumSize(350, 65);
|
||||||
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
login_button_->setFontSize(17);
|
login_button_->setFontSize(17);
|
||||||
|
|
|
@ -99,8 +99,8 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||||
error_label_->setStyleSheet("margin-bottom: 20px; color: #E22826; font-size: 11pt;");
|
error_label_->setStyleSheet("margin-bottom: 20px; color: #E22826; font-size: 11pt;");
|
||||||
|
|
||||||
register_button_ = new RaisedButton("REGISTER", this);
|
register_button_ = new RaisedButton("REGISTER", this);
|
||||||
register_button_->setBackgroundColor(QColor("#acc7dc"));
|
register_button_->setBackgroundColor(QColor("#171919"));
|
||||||
register_button_->setForegroundColor(QColor("black"));
|
register_button_->setForegroundColor(QColor("white"));
|
||||||
register_button_->setMinimumSize(350, 65);
|
register_button_->setMinimumSize(350, 65);
|
||||||
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
register_button_->setFontSize(17);
|
register_button_->setFontSize(17);
|
||||||
|
|
|
@ -59,16 +59,16 @@ WelcomePage::WelcomePage(QWidget *parent)
|
||||||
button_layout_->setContentsMargins(0, 20, 0, 80);
|
button_layout_->setContentsMargins(0, 20, 0, 80);
|
||||||
|
|
||||||
register_button_ = new RaisedButton("REGISTER", this);
|
register_button_ = new RaisedButton("REGISTER", this);
|
||||||
register_button_->setBackgroundColor(QColor("#acc7dc"));
|
register_button_->setBackgroundColor(QColor("#555459"));
|
||||||
register_button_->setForegroundColor(QColor("#171919"));
|
register_button_->setForegroundColor(QColor("white"));
|
||||||
register_button_->setMinimumSize(240, 60);
|
register_button_->setMinimumSize(240, 60);
|
||||||
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
register_button_->setFontSize(14);
|
register_button_->setFontSize(14);
|
||||||
register_button_->setCornerRadius(3);
|
register_button_->setCornerRadius(3);
|
||||||
|
|
||||||
login_button_ = new RaisedButton("LOGIN", this);
|
login_button_ = new RaisedButton("LOGIN", this);
|
||||||
login_button_->setBackgroundColor(QColor("#acc7dc"));
|
login_button_->setBackgroundColor(QColor("#555459"));
|
||||||
login_button_->setForegroundColor(QColor("#171919"));
|
login_button_->setForegroundColor(QColor("white"));
|
||||||
login_button_->setMinimumSize(240, 60);
|
login_button_->setMinimumSize(240, 60);
|
||||||
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
login_button_->setFontSize(14);
|
login_button_->setFontSize(14);
|
||||||
|
|
Loading…
Reference in a new issue