Skip to content
Snippets Groups Projects
Commit a5ebff59 authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Use color generator for nick names

parent 8358720d
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
</property>
<property name="minimumSize">
<size>
<width>850</width>
<width>950</width>
<height>600</height>
</size>
</property>
......@@ -29,7 +29,7 @@
</font>
</property>
<property name="windowTitle">
<string notr="true"> Nheko </string>
<string notr="true"> nheko </string>
</property>
<property name="styleSheet">
<string notr="true">background-color: #f9f9f9</string>
......
......@@ -43,7 +43,6 @@ public:
static QString chooseRandomColor();
static QString getUserColor(const QString &userid);
static QMap<QString, QString> NICK_COLORS;
static const QList<QString> COLORS;
public slots:
void setHistoryView(const RoomInfo &info);
......
......@@ -126,38 +126,61 @@ void HistoryViewManager::setHistoryView(const RoomInfo &info)
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()
{
std::random_device 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);
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 HistoryViewManager::COLORS[dist(engine)];
return color.name();
}
QString HistoryViewManager::getUserColor(const QString &userid)
......
......@@ -84,8 +84,8 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
button_layout_->setContentsMargins(0, 0, 0, 50);
login_button_ = new RaisedButton("LOGIN", this);
login_button_->setBackgroundColor(QColor("#acc7dc"));
login_button_->setForegroundColor(QColor("black"));
login_button_->setBackgroundColor(QColor("#171919"));
login_button_->setForegroundColor(QColor("white"));
login_button_->setMinimumSize(350, 65);
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
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;");
register_button_ = new RaisedButton("REGISTER", this);
register_button_->setBackgroundColor(QColor("#acc7dc"));
register_button_->setForegroundColor(QColor("black"));
register_button_->setBackgroundColor(QColor("#171919"));
register_button_->setForegroundColor(QColor("white"));
register_button_->setMinimumSize(350, 65);
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
register_button_->setFontSize(17);
......
......@@ -59,16 +59,16 @@ WelcomePage::WelcomePage(QWidget *parent)
button_layout_->setContentsMargins(0, 20, 0, 80);
register_button_ = new RaisedButton("REGISTER", this);
register_button_->setBackgroundColor(QColor("#acc7dc"));
register_button_->setForegroundColor(QColor("#171919"));
register_button_->setBackgroundColor(QColor("#555459"));
register_button_->setForegroundColor(QColor("white"));
register_button_->setMinimumSize(240, 60);
register_button_->setCursor(QCursor(Qt::PointingHandCursor));
register_button_->setFontSize(14);
register_button_->setCornerRadius(3);
login_button_ = new RaisedButton("LOGIN", this);
login_button_->setBackgroundColor(QColor("#acc7dc"));
login_button_->setForegroundColor(QColor("#171919"));
login_button_->setBackgroundColor(QColor("#555459"));
login_button_->setForegroundColor(QColor("white"));
login_button_->setMinimumSize(240, 60);
login_button_->setCursor(QCursor(Qt::PointingHandCursor));
login_button_->setFontSize(14);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment