Reformat according to .clang-format

This commit is contained in:
Rasmus Karlsson 2017-08-12 12:09:26 +02:00
parent f455ef9f24
commit ac6db75dc6
12 changed files with 71 additions and 82 deletions

View file

@ -115,14 +115,16 @@ void ColorScheme::setColors(double hue, double multiplier)
void ColorScheme::normalizeColor(QColor &color) void ColorScheme::normalizeColor(QColor &color)
{ {
if (this->lightTheme) { if (this->lightTheme) {
} else { } else {
if (color.lightnessF() < 0.5f) { if (color.lightnessF() < 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f); color.setHslF(color.hueF(), color.saturationF(), 0.5f);
} }
if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) { if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
color.setHslF(color.hueF(), color.saturationF(), color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) * color.saturationF() * 0.2); color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.2);
} }
} }
} }

View file

@ -47,8 +47,7 @@ void AccountPopupWidget::getUserId()
static auto manager = new QNetworkAccessManager(); static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req); auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=] QObject::connect(reply, &QNetworkReply::finished, this, [=] {
{
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
auto doc = QJsonDocument::fromJson(reply->readAll()); auto doc = QJsonDocument::fromJson(reply->readAll());
auto obj = doc.object(); auto obj = doc.object();
@ -59,7 +58,6 @@ void AccountPopupWidget::getUserId()
getUserData(); getUserData();
} }
}); });
} }
void AccountPopupWidget::getUserData() void AccountPopupWidget::getUserData()
@ -73,8 +71,7 @@ void AccountPopupWidget::getUserData()
static auto manager = new QNetworkAccessManager(); static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req); auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=] QObject::connect(reply, &QNetworkReply::finished, this, [=] {
{
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
auto doc = QJsonDocument::fromJson(reply->readAll()); auto doc = QJsonDocument::fromJson(reply->readAll());
auto obj = doc.object(); auto obj = doc.object();
@ -84,9 +81,7 @@ void AccountPopupWidget::getUserData()
_ui->lblAccountAge->setText(obj.value("created_at").toString().section("T", 0, 0)); _ui->lblAccountAge->setText(obj.value("created_at").toString().section("T", 0, 0));
loadAvatar(QUrl(obj.value("logo").toString())); loadAvatar(QUrl(obj.value("logo").toString()));
} } else {
else
{
_ui->lblFollowers->setText("ERROR"); _ui->lblFollowers->setText("ERROR");
_ui->lblViews->setText("ERROR"); _ui->lblViews->setText("ERROR");
_ui->lblAccountAge->setText("ERROR"); _ui->lblAccountAge->setText("ERROR");
@ -96,36 +91,26 @@ void AccountPopupWidget::getUserData()
void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl) void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl)
{ {
if(!avatarMap.tryGet(userID,this->avatar)) if (!avatarMap.tryGet(userID, this->avatar)) {
{ if (!avatarUrl.isEmpty()) {
if(!avatarUrl.isEmpty())
{
QNetworkRequest req(avatarUrl); QNetworkRequest req(avatarUrl);
static auto manager = new QNetworkAccessManager(); static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req); auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=] QObject::connect(reply, &QNetworkReply::finished, this, [=] {
{ if (reply->error() == QNetworkReply::NoError) {
if(reply->error() == QNetworkReply::NoError)
{
const auto data = reply->readAll(); const auto data = reply->readAll();
this->avatar.loadFromData(data); this->avatar.loadFromData(data);
this->avatarMap.insert(userID, avatar); this->avatarMap.insert(userID, avatar);
_ui->lblAvatar->setPixmap(avatar); _ui->lblAvatar->setPixmap(avatar);
} } else {
else
{
_ui->lblAvatar->setText("ERROR"); _ui->lblAvatar->setText("ERROR");
} }
}); });
} } else {
else
{
_ui->lblAvatar->setText("No Avatar"); _ui->lblAvatar->setText("No Avatar");
} }
} } else {
else
{
_ui->lblAvatar->setPixmap(this->avatar); _ui->lblAvatar->setPixmap(this->avatar);
} }
} }
@ -141,6 +126,5 @@ void AccountPopupWidget::focusOutEvent(QFocusEvent *event)
_ui->lblAvatar->setText("Loading..."); _ui->lblAvatar->setText("Loading...");
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -35,8 +35,10 @@ void FancyButton::fancyPaint(QPainter &painter)
if (this->hoverMultiplier > 0) { if (this->hoverMultiplier > 0) {
QRadialGradient gradient(mousePos.x(), mousePos.y(), 50, mousePos.x(), mousePos.y()); QRadialGradient gradient(mousePos.x(), mousePos.y(), 50, mousePos.x(), mousePos.y());
gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(), (int)(24 * this->hoverMultiplier))); gradient.setColorAt(
gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), (int)(12 * this->hoverMultiplier))); 0, QColor(c.red(), c.green(), c.blue(), (int)(24 * this->hoverMultiplier)));
gradient.setColorAt(
1, QColor(c.red(), c.green(), c.blue(), (int)(12 * this->hoverMultiplier)));
painter.fillRect(this->rect(), gradient); painter.fillRect(this->rect(), gradient);
} }

View file

@ -200,7 +200,8 @@ void ScrollBar::paintEvent(QPaintEvent *)
painter.fillRect(rect(), this->colorScheme.ScrollbarBG); painter.fillRect(rect(), this->colorScheme.ScrollbarBG);
painter.fillRect(QRect(0, 0, width(), _buttonHeight), this->colorScheme.ScrollbarArrow); painter.fillRect(QRect(0, 0, width(), _buttonHeight), this->colorScheme.ScrollbarArrow);
painter.fillRect(QRect(0, height() - _buttonHeight, width(), _buttonHeight), this->colorScheme.ScrollbarArrow); painter.fillRect(QRect(0, height() - _buttonHeight, width(), _buttonHeight),
this->colorScheme.ScrollbarArrow);
// mouse over thumb // mouse over thumb
if (this->_mouseDownIndex == 2) { if (this->_mouseDownIndex == 2) {