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
+4 -2
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);
} }
} }
} }
+18 -34
View File
@@ -41,15 +41,14 @@ void AccountPopupWidget::getUserId()
QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text()); QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text());
QNetworkRequest req(nameUrl); QNetworkRequest req(nameUrl);
req.setRawHeader(QByteArray("Accept"),QByteArray("application/vnd.twitchtv.v5+json")); req.setRawHeader(QByteArray("Accept"), QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"),QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal")); req.setRawHeader(QByteArray("Client-ID"), QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
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();
auto array = obj.value("users").toArray(); auto array = obj.value("users").toArray();
@@ -59,7 +58,6 @@ void AccountPopupWidget::getUserId()
getUserData(); getUserData();
} }
}); });
} }
void AccountPopupWidget::getUserData() void AccountPopupWidget::getUserData()
@@ -67,26 +65,23 @@ void AccountPopupWidget::getUserData()
QUrl idUrl("https://api.twitch.tv/kraken/channels/" + userID); QUrl idUrl("https://api.twitch.tv/kraken/channels/" + userID);
QNetworkRequest req(idUrl); QNetworkRequest req(idUrl);
req.setRawHeader(QByteArray("Accept"),QByteArray("application/vnd.twitchtv.v5+json")); req.setRawHeader(QByteArray("Accept"), QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"),QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal")); req.setRawHeader(QByteArray("Client-ID"), QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
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();
_ui->lblFollowers->setText(QString::number(obj.value("followers").toInt())); _ui->lblFollowers->setText(QString::number(obj.value("followers").toInt()));
_ui->lblViews->setText(QString::number(obj.value("views").toInt())); _ui->lblViews->setText(QString::number(obj.value("views").toInt()));
_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
+1 -1
View File
@@ -35,7 +35,7 @@ private:
QString userID; QString userID;
QPixmap avatar; QPixmap avatar;
ConcurrentMap<QString,QPixmap> avatarMap; ConcurrentMap<QString, QPixmap> avatarMap;
protected: protected:
virtual void focusOutEvent(QFocusEvent *event) override; virtual void focusOutEvent(QFocusEvent *event) override;
+4 -2
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);
} }
+1 -1
View File
@@ -26,7 +26,7 @@ MainWindow::MainWindow(ChannelManager &_channelManager, ColorScheme &_colorSchem
, colorScheme(_colorScheme) , colorScheme(_colorScheme)
, completionManager(_completionManager) , completionManager(_completionManager)
, notebook(this->channelManager, this) , notebook(this->channelManager, this)
// , windowGeometry("/windows/0/geometry") // , windowGeometry("/windows/0/geometry")
{ {
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);
+1 -1
View File
@@ -140,7 +140,7 @@ private:
}; };
*/ */
//pajlada::Settings::Setting<QRectWrapper> windowGeometry; // pajlada::Settings::Setting<QRectWrapper> windowGeometry;
friend class Notebook; friend class Notebook;
}; };
+3 -3
View File
@@ -26,13 +26,13 @@ void NotebookButton::paintEvent(QPaintEvent *)
background = this->colorScheme.TabPanelBackground; background = this->colorScheme.TabPanelBackground;
if (mouseDown) { if (mouseDown) {
//background = this->colorScheme.TabSelectedBackground; // background = this->colorScheme.TabSelectedBackground;
foreground = this->colorScheme.TabHoverText; foreground = this->colorScheme.TabHoverText;
} else if (mouseOver) { } else if (mouseOver) {
//background = this->colorScheme.TabHoverText; // background = this->colorScheme.TabHoverText;
foreground = this->colorScheme.TabHoverText; foreground = this->colorScheme.TabHoverText;
} else { } else {
//background = this->colorScheme.TabPanelBackground; // background = this->colorScheme.TabPanelBackground;
foreground = QColor(70, 80, 80); foreground = QColor(70, 80, 80);
} }
+1 -1
View File
@@ -252,7 +252,7 @@ void NotebookPage::paintEvent(QPaintEvent *)
painter.setPen(this->colorScheme.Text); painter.setPen(this->colorScheme.Text);
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter)); painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
} else { } else {
//painter.fillRect(rect(), this->colorScheme.TabSelectedBackground); // painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
painter.fillRect(rect(), QColor(127, 127, 127)); painter.fillRect(rect(), QColor(127, 127, 127));
painter.fillRect(0, 0, width(), 2, this->colorScheme.TabSelectedBackground); painter.fillRect(0, 0, width(), 2, this->colorScheme.TabSelectedBackground);
+2 -1
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) {