mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Reformat according to .clang-format
This commit is contained in:
parent
f455ef9f24
commit
ac6db75dc6
12 changed files with 71 additions and 82 deletions
|
@ -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) {
|
||||
if (this->lightTheme) {
|
||||
} else {
|
||||
if (color.lightnessF() < 0.5f) {
|
||||
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
|
||||
}
|
||||
|
||||
} 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
|
||||
|
|
|
@ -61,9 +61,9 @@ 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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
QString userID;
|
||||
QPixmap avatar;
|
||||
|
||||
ConcurrentMap<QString,QPixmap> avatarMap;
|
||||
ConcurrentMap<QString, QPixmap> avatarMap;
|
||||
|
||||
protected:
|
||||
virtual void focusOutEvent(QFocusEvent *event) override;
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ private:
|
|||
};
|
||||
*/
|
||||
|
||||
//pajlada::Settings::Setting<QRectWrapper> windowGeometry;
|
||||
// pajlada::Settings::Setting<QRectWrapper> windowGeometry;
|
||||
|
||||
friend class Notebook;
|
||||
};
|
||||
|
|
|
@ -23,17 +23,17 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
QColor background;
|
||||
QColor foreground;
|
||||
|
||||
background = this->colorScheme.TabPanelBackground;
|
||||
background = this->colorScheme.TabPanelBackground;
|
||||
|
||||
if (mouseDown) {
|
||||
//background = this->colorScheme.TabSelectedBackground;
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue