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

@ -68,7 +68,7 @@ void ColorScheme::setColors(double hue, double multiplier)
DropPreviewBackground = getColor(hue, 0.5, 0.5, 0.6);
Text = TextCaret = lightTheme ? QColor(0, 0, 0) : QColor(255, 255, 255);
TextLink = lightTheme ? QColor(66, 134, 244) : QColor(66, 134, 244);
TextLink = lightTheme ? QColor(66, 134, 244) : QColor(66, 134, 244);
// tab
if (hasDarkBorder) {
@ -100,9 +100,9 @@ void ColorScheme::setColors(double hue, double multiplier)
ChatInputBorder = getColor(0, 0.1, 0.9);
ScrollbarBG = ChatBackground;
ScrollbarThumb = getColor(0, 0.1, 0.85);
ScrollbarThumbSelected = getColor(0, 0.1, 0.7);
ScrollbarArrow = getColor(0, 0.1, 0.4);
ScrollbarThumb = getColor(0, 0.1, 0.85);
ScrollbarThumbSelected = getColor(0, 0.1, 0.7);
ScrollbarArrow = getColor(0, 0.1, 0.4);
// stylesheet
InputStyleSheet = "background:" + ChatInputBackground.name() + ";" +
@ -114,17 +114,19 @@ void ColorScheme::setColors(double hue, double multiplier)
void ColorScheme::normalizeColor(QColor &color)
{
if (this->lightTheme) {
} else {
if (color.lightnessF() < 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
}
if (this->lightTheme) {
} else {
if (color.lightnessF() < 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
}
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);
}
}
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);
}
}
}
} // namespace chatterino

View file

@ -60,10 +60,10 @@ void MessageBuilder::appendTimestamp(time_t time)
QString MessageBuilder::matchLink(const QString &string)
{
auto match = linkRegex.match(string);
if (!match.hasMatch()) {
return QString();
}
if (!match.hasMatch()) {
return QString();
}
QString captured = match.captured();

View file

@ -207,14 +207,14 @@ SharedMessage TwitchMessageBuilder::parse()
// Actually just text
QString linkString = this->matchLink(string);
Link link;
Link link;
if (linkString.isEmpty()) {
link = Link();
} else {
link = Link(Link::Url, linkString);
textColor = this->colorScheme.TextLink;
}
if (linkString.isEmpty()) {
link = Link();
} else {
link = Link(Link::Url, linkString);
textColor = this->colorScheme.TextLink;
}
this->appendWord(Word(string, Word::Text, textColor, string, QString(), link));
} else { // is emoji

View file

@ -41,15 +41,14 @@ void AccountPopupWidget::getUserId()
QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text());
QNetworkRequest req(nameUrl);
req.setRawHeader(QByteArray("Accept"),QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"),QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
req.setRawHeader(QByteArray("Accept"), QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"), QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=]
{
if(reply->error() == QNetworkReply::NoError){
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
if (reply->error() == QNetworkReply::NoError) {
auto doc = QJsonDocument::fromJson(reply->readAll());
auto obj = doc.object();
auto array = obj.value("users").toArray();
@ -59,7 +58,6 @@ void AccountPopupWidget::getUserId()
getUserData();
}
});
}
void AccountPopupWidget::getUserData()
@ -67,26 +65,23 @@ void AccountPopupWidget::getUserData()
QUrl idUrl("https://api.twitch.tv/kraken/channels/" + userID);
QNetworkRequest req(idUrl);
req.setRawHeader(QByteArray("Accept"),QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"),QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
req.setRawHeader(QByteArray("Accept"), QByteArray("application/vnd.twitchtv.v5+json"));
req.setRawHeader(QByteArray("Client-ID"), QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal"));
static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=]
{
if(reply->error() == QNetworkReply::NoError){
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
if (reply->error() == QNetworkReply::NoError) {
auto doc = QJsonDocument::fromJson(reply->readAll());
auto obj = doc.object();
_ui->lblFollowers->setText(QString::number(obj.value("followers").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()));
}
else
{
} else {
_ui->lblFollowers->setText("ERROR");
_ui->lblViews->setText("ERROR");
_ui->lblAccountAge->setText("ERROR");
@ -96,36 +91,26 @@ void AccountPopupWidget::getUserData()
void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl)
{
if(!avatarMap.tryGet(userID,this->avatar))
{
if(!avatarUrl.isEmpty())
{
if (!avatarMap.tryGet(userID, this->avatar)) {
if (!avatarUrl.isEmpty()) {
QNetworkRequest req(avatarUrl);
static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req);
QObject::connect(reply,&QNetworkReply::finished,this,[=]
{
if(reply->error() == QNetworkReply::NoError)
{
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
if (reply->error() == QNetworkReply::NoError) {
const auto data = reply->readAll();
this->avatar.loadFromData(data);
this->avatarMap.insert(userID,avatar);
this->avatarMap.insert(userID, avatar);
_ui->lblAvatar->setPixmap(avatar);
}
else
{
} else {
_ui->lblAvatar->setText("ERROR");
}
});
}
else
{
} else {
_ui->lblAvatar->setText("No Avatar");
}
}
else
{
} else {
_ui->lblAvatar->setPixmap(this->avatar);
}
}
@ -141,6 +126,5 @@ void AccountPopupWidget::focusOutEvent(QFocusEvent *event)
_ui->lblAvatar->setText("Loading...");
}
} // namespace widgets
} // namespace chatterino

View file

@ -35,7 +35,7 @@ private:
QString userID;
QPixmap avatar;
ConcurrentMap<QString,QPixmap> avatarMap;
ConcurrentMap<QString, QPixmap> avatarMap;
protected:
virtual void focusOutEvent(QFocusEvent *event) override;

View file

@ -36,7 +36,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *_chatWidget)
// Whenever the scrollbar value has been changed, re-render the ChatWidgetView
this->update();
this->layoutMessages();
this->layoutMessages();
});
}

View file

@ -35,8 +35,10 @@ void FancyButton::fancyPaint(QPainter &painter)
if (this->hoverMultiplier > 0) {
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(1, QColor(c.red(), c.green(), c.blue(), (int)(12 * this->hoverMultiplier)));
gradient.setColorAt(
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);
}

View file

@ -26,7 +26,7 @@ MainWindow::MainWindow(ChannelManager &_channelManager, ColorScheme &_colorSchem
, colorScheme(_colorScheme)
, completionManager(_completionManager)
, notebook(this->channelManager, this)
// , windowGeometry("/windows/0/geometry")
// , windowGeometry("/windows/0/geometry")
{
QVBoxLayout *layout = new QVBoxLayout(this);

View file

@ -140,7 +140,7 @@ private:
};
*/
//pajlada::Settings::Setting<QRectWrapper> windowGeometry;
// pajlada::Settings::Setting<QRectWrapper> windowGeometry;
friend class Notebook;
};

View file

@ -23,17 +23,17 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor background;
QColor foreground;
background = this->colorScheme.TabPanelBackground;
if (mouseDown) {
//background = this->colorScheme.TabSelectedBackground;
background = this->colorScheme.TabPanelBackground;
if (mouseDown) {
// background = this->colorScheme.TabSelectedBackground;
foreground = this->colorScheme.TabHoverText;
} else if (mouseOver) {
//background = this->colorScheme.TabHoverText;
// background = this->colorScheme.TabHoverText;
foreground = this->colorScheme.TabHoverText;
} else {
//background = this->colorScheme.TabPanelBackground;
foreground = QColor(70, 80, 80);
// background = this->colorScheme.TabPanelBackground;
foreground = QColor(70, 80, 80);
}
painter.setPen(Qt::NoPen);

View file

@ -252,7 +252,7 @@ void NotebookPage::paintEvent(QPaintEvent *)
painter.setPen(this->colorScheme.Text);
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
} else {
//painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
// painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
painter.fillRect(rect(), QColor(127, 127, 127));
painter.fillRect(0, 0, width(), 2, this->colorScheme.TabSelectedBackground);

View file

@ -200,16 +200,17 @@ void ScrollBar::paintEvent(QPaintEvent *)
painter.fillRect(rect(), this->colorScheme.ScrollbarBG);
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
if (this->_mouseDownIndex == 2) {
painter.fillRect(_thumbRect, this->colorScheme.ScrollbarThumbSelected);
}
// mouse not over thumb
else {
painter.fillRect(_thumbRect, this->colorScheme.ScrollbarThumb);
}
// mouse over thumb
if (this->_mouseDownIndex == 2) {
painter.fillRect(_thumbRect, this->colorScheme.ScrollbarThumbSelected);
}
// mouse not over thumb
else {
painter.fillRect(_thumbRect, this->colorScheme.ScrollbarThumb);
}
// ScrollBarHighlight *highlight = highlights;