diff --git a/colorscheme.cpp b/colorscheme.cpp index 4800b98b1..2769a37bb 100644 --- a/colorscheme.cpp +++ b/colorscheme.cpp @@ -52,9 +52,7 @@ void ColorScheme::setColors(float hue, float multiplyer) SystemMessageColor = QColor(140, 127, 127); - auto isLightTheme = IsLightTheme; - - auto getColor = [isLightTheme, multiplyer](qreal h, qreal s, qreal l, qreal a = 1.0) { + auto getColor = [multiplyer](qreal h, qreal s, qreal l, qreal a = 1.0) { return QColor::fromHslF(h, s, (((l - 0.5) * multiplyer) + 0.5), a); }; @@ -75,10 +73,11 @@ void ColorScheme::setColors(float hue, float multiplyer) TabSelectedBackground = getColor(hue, 0.5, 0.5); TabHighlightedBackground = getColor(hue, 0.5, 0.2); TabNewMessageBackground = QBrush(getColor(hue, 0.5, 0.2), Qt::DiagCrossPattern); - if (hasDarkBorder) + if (hasDarkBorder) { // TabText = QColor(210, 210, 210); // TabHoverText = QColor(210, 210, 210); TabText = QColor(0, 0, 0); + } TabHoverText = QColor(0, 0, 0); TabSelectedText = QColor(255, 255, 255); TabHighlightedText = QColor(0, 0, 0); diff --git a/emotemanager.cpp b/emotemanager.cpp index 4f2e26adc..912229ec4 100644 --- a/emotemanager.cpp +++ b/emotemanager.cpp @@ -206,4 +206,5 @@ LazyLoadedImage *EmoteManager::getCheerBadge(long long amount) return Resources::getCheerBadge1(); } } -} + +} // namespace chatterino diff --git a/emotemanager.h b/emotemanager.h index 3097d3953..f8f8e88f3 100644 --- a/emotemanager.h +++ b/emotemanager.h @@ -80,19 +80,19 @@ private: ConcurrentMap _twitchEmoteFromCache; ConcurrentMap _miscImageFromCache; + boost::signals2::signal _gifUpdateTimerSignal; QTimer _gifUpdateTimer; bool _gifUpdateTimerInitiated; int _generation; - boost::signals2::signal _gifUpdateTimerSignal; - // methods static QString getTwitchEmoteLink(long id, qreal &scale); void loadFfzEmotes(); void loadBttvEmotes(); }; + } // namespace chatterino #endif // EMOTES_H diff --git a/ircmanager.cpp b/ircmanager.cpp index 2e5ab963a..5c1ff174d 100644 --- a/ircmanager.cpp +++ b/ircmanager.cpp @@ -1,12 +1,12 @@ #include "ircmanager.h" +#include "accountmanager.h" #include "asyncexec.h" #include "channel.h" #include "channelmanager.h" #include "messages/messageparseargs.h" +#include "twitch/twitchaccount.h" #include "twitch/twitchmessagebuilder.h" #include "twitch/twitchparsemessage.h" -#include "twitch/twitchaccount.h" -#include "accountmanager.h" #include #include @@ -203,19 +203,20 @@ void IrcManager::partChannel(const QString &channel) _connectionMutex.unlock(); } -void IrcManager::messageReceived(Communi::IrcMessage *message) +void IrcManager::messageReceived(Communi::IrcMessage * /*message*/) { - // qInfo(message->command().toStdString().c_str()); + // qInfo(message->command().toStdString().c_str()); + /* const QString &command = message->command(); - // if (command == "CLEARCHAT") { - // message-> - // } else if (command == "ROOMSTATE") { - // } else if (command == "USERSTATE") { - // } else if (command == "WHISPER") { - // } else if (command == "USERNOTICE") { - // } + if (command == "CLEARCHAT") { + } else if (command == "ROOMSTATE") { + } else if (command == "USERSTATE") { + } else if (command == "WHISPER") { + } else if (command == "USERNOTICE") { + } + */ } void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message) @@ -306,4 +307,4 @@ QNetworkAccessManager &IrcManager::getAccessManager() { return _accessManager; } -} +} // namespace chatterino diff --git a/messages/messageref.cpp b/messages/messageref.cpp index 0f54912fc..739608f68 100644 --- a/messages/messageref.cpp +++ b/messages/messageref.cpp @@ -17,7 +17,6 @@ namespace messages { MessageRef::MessageRef(SharedMessage message) : _message(message) , _wordParts() - , buffer() { } @@ -316,5 +315,6 @@ int MessageRef::getSelectionIndex(QPoint position) return index; } -} -} + +} // namespace messages +} // namespace chatterino diff --git a/messages/messageref.h b/messages/messageref.h index 487100477..c0fe12cc4 100644 --- a/messages/messageref.h +++ b/messages/messageref.h @@ -47,7 +47,8 @@ private: // methods void alignWordParts(int lineStart, int lineHeight); }; -} -} + +} // namespace messages +} // namespace chatterino #endif // MESSAGEREF_H diff --git a/settingsmanager.cpp b/settingsmanager.cpp index e84d13383..7710b334a 100644 --- a/settingsmanager.cpp +++ b/settingsmanager.cpp @@ -11,7 +11,6 @@ namespace chatterino { SettingsManager::SettingsManager() : _settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat) - , _wordTypeMask(Word::Default) , theme(_settingsItems, "theme", "dark") , themeHue(_settingsItems, "themeHue", 0) , selectedUser(_settingsItems, "selectedUser", "") diff --git a/settingsmanager.h b/settingsmanager.h index 6edf7467f..fc5c7bb99 100644 --- a/settingsmanager.h +++ b/settingsmanager.h @@ -14,6 +14,30 @@ class SettingsManager : public QObject Q_OBJECT public: + void load(); + void save(); + + messages::Word::Type getWordTypeMask(); + bool isIgnoredEmote(const QString &emote); + QSettings &getQSettings(); + SettingsSnapshot createSnapshot(); + +signals: + void wordTypeMaskChanged(); + +private: + SettingsManager(); + + // variables + QSettings _settings; + std::vector> _settingsItems; + messages::Word::Type _wordTypeMask = messages::Word::Default; + + // methods + void updateWordTypeMask(); + +public: + // Settings Setting theme; Setting themeHue; Setting selectedUser; @@ -47,28 +71,6 @@ public: Setting hideUserButton; Setting useCustomWindowFrame; - void load(); - void save(); - - messages::Word::Type getWordTypeMask(); - bool isIgnoredEmote(const QString &emote); - QSettings &getQSettings(); - SettingsSnapshot createSnapshot(); - -signals: - void wordTypeMaskChanged(); - -private: - SettingsManager(); - - // variables - QSettings _settings; - std::vector> _settingsItems; - messages::Word::Type _wordTypeMask; - - // methods - void updateWordTypeMask(); - public: static SettingsManager &getInstance() { diff --git a/widgets/chatwidget.cpp b/widgets/chatwidget.cpp index 8c21c4a59..3127f2eea 100644 --- a/widgets/chatwidget.cpp +++ b/widgets/chatwidget.cpp @@ -38,20 +38,17 @@ ChatWidget::~ChatWidget() { } -std::shared_ptr -ChatWidget::getChannel() const +std::shared_ptr ChatWidget::getChannel() const { return _channel; } -const QString & -ChatWidget::getChannelName() const +const QString &ChatWidget::getChannelName() const { return _channelName; } -void -ChatWidget::setChannelName(const QString &name) +void ChatWidget::setChannelName(const QString &name) { QString channel = name.trimmed(); @@ -92,27 +89,25 @@ ChatWidget::setChannelName(const QString &name) _view.update(); } -void -ChatWidget::attachChannel(SharedChannel channel) +void ChatWidget::attachChannel(SharedChannel channel) { // on new message - _messageAppendedConnection = - channel->messageAppended.connect([this](SharedMessage &message) { - SharedMessageRef deleted; + _messageAppendedConnection = channel->messageAppended.connect([this](SharedMessage &message) { + SharedMessageRef deleted; - auto messageRef = new MessageRef(message); + auto messageRef = new MessageRef(message); - if (_messages.appendItem(SharedMessageRef(messageRef), deleted)) { - qreal value = - std::max(0.0, _view.getScrollbar()->getDesiredValue() - 1); + if (_messages.appendItem(SharedMessageRef(messageRef), deleted)) { + qreal value = std::max(0.0, _view.getScrollbar()->getDesiredValue() - 1); - _view.getScrollbar()->setDesiredValue(value, false); - } - }); + _view.getScrollbar()->setDesiredValue(value, false); + } + }); // on message removed - _messageRemovedConnection = - _channel->messageRemovedFromStart.connect([this](SharedMessage &) {}); + _messageRemovedConnection = _channel->messageRemovedFromStart.connect([](SharedMessage &) { + // + }); auto snapshot = _channel.get()->getMessageSnapshot(); @@ -125,8 +120,7 @@ ChatWidget::attachChannel(SharedChannel channel) } } -void -ChatWidget::detachChannel(std::shared_ptr channel) +void ChatWidget::detachChannel(std::shared_ptr channel) { // on message added _messageAppendedConnection.disconnect(); @@ -135,14 +129,12 @@ ChatWidget::detachChannel(std::shared_ptr channel) _messageRemovedConnection.disconnect(); } -LimitedQueueSnapshot -ChatWidget::getMessagesSnapshot() +LimitedQueueSnapshot ChatWidget::getMessagesSnapshot() { return _messages.getSnapshot(); } -void -ChatWidget::showChangeChannelPopup() +void ChatWidget::showChangeChannelPopup() { // create new input dialog and execute it TextInputDialog dialog(this); @@ -154,22 +146,19 @@ ChatWidget::showChangeChannelPopup() } } -void -ChatWidget::layoutMessages() +void ChatWidget::layoutMessages() { if (_view.layoutMessages()) { _view.update(); } } -void -ChatWidget::updateGifEmotes() +void ChatWidget::updateGifEmotes() { _view.updateGifEmotes(); } -void -ChatWidget::paintEvent(QPaintEvent *) +void ChatWidget::paintEvent(QPaintEvent *) { // color the background of the chat QPainter painter(this); @@ -177,19 +166,16 @@ ChatWidget::paintEvent(QPaintEvent *) painter.fillRect(this->rect(), ColorScheme::getInstance().ChatBackground); } -void -ChatWidget::load(const boost::property_tree::ptree &tree) +void ChatWidget::load(const boost::property_tree::ptree &tree) { // load tab text try { - this->setChannelName( - QString::fromStdString(tree.get("channelName"))); + this->setChannelName(QString::fromStdString(tree.get("channelName"))); } catch (boost::property_tree::ptree_error) { } } -boost::property_tree::ptree -ChatWidget::save() +boost::property_tree::ptree ChatWidget::save() { boost::property_tree::ptree tree; diff --git a/widgets/chatwidgetinput.cpp b/widgets/chatwidgetinput.cpp index a66ad3e19..4cb883728 100644 --- a/widgets/chatwidgetinput.cpp +++ b/widgets/chatwidgetinput.cpp @@ -60,7 +60,7 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *widget) completer->setWidget(&_edit); - _edit.keyPressed.connect([this, completer](QKeyEvent *event) { + _edit.keyPressed.connect([this/*, completer*/](QKeyEvent *event) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { auto ptr = _chatWidget->getChannel(); Channel *c = ptr.get(); diff --git a/widgets/notebooktab.cpp b/widgets/notebooktab.cpp index acbfac6aa..08b25eacc 100644 --- a/widgets/notebooktab.cpp +++ b/widgets/notebooktab.cpp @@ -220,10 +220,10 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event) QPoint relPoint = mapToParent(event->pos()); int index; - NotebookPage *page = _notebook->tabAt(relPoint, index); + NotebookPage *clickedPage = _notebook->tabAt(relPoint, index); - if (page != nullptr && page != page) { - _notebook->rearrangePage(page, index); + if (clickedPage != nullptr && clickedPage != page) { + _notebook->rearrangePage(clickedPage, index); } } } diff --git a/widgets/resizingtextedit.h b/widgets/resizingtextedit.h index 7ea4162b9..64e9466e3 100644 --- a/widgets/resizingtextedit.h +++ b/widgets/resizingtextedit.h @@ -39,7 +39,7 @@ protected: return margins.top() + document()->size().height() + margins.bottom() + 5; } - void keyPressEvent(QKeyEvent *event) + void keyPressEvent(QKeyEvent *event) override { event->ignore(); diff --git a/widgets/scrollbar.cpp b/widgets/scrollbar.cpp index 70e676614..cb5143a0a 100644 --- a/widgets/scrollbar.cpp +++ b/widgets/scrollbar.cpp @@ -13,7 +13,7 @@ ScrollBar::ScrollBar(QWidget *widget) : QWidget(widget) , _mutex() , _currentValueAnimation(this, "currentValue") - , _highlights(NULL) + , _highlights(nullptr) , _mouseOverIndex(-1) , _mouseDownIndex(-1) , _lastMousePosition() @@ -25,8 +25,8 @@ ScrollBar::ScrollBar(QWidget *widget) , _largeChange() , _smallChange() , _desiredValue() - , _currentValueChanged() , _currentValue() + , _currentValueChanged() { resize(16, 100); diff --git a/widgets/scrollbar.h b/widgets/scrollbar.h index cebdc3583..5f3094e0b 100644 --- a/widgets/scrollbar.h +++ b/widgets/scrollbar.h @@ -43,10 +43,11 @@ private: Q_PROPERTY(qreal _currentValue READ getCurrentValue WRITE setCurrentValue) QMutex _mutex; - ScrollBarHighlight *_highlights; QPropertyAnimation _currentValueAnimation; + ScrollBarHighlight *_highlights; + void paintEvent(QPaintEvent *); void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); diff --git a/widgets/scrollbarhighlight.cpp b/widgets/scrollbarhighlight.cpp index 96e0b395a..c3347fc62 100644 --- a/widgets/scrollbarhighlight.cpp +++ b/widgets/scrollbarhighlight.cpp @@ -5,12 +5,12 @@ namespace chatterino { namespace widgets { ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex, Style style, QString tag) - : _position(position) + : _style(style) + , _position(position) , _colorIndex(std::max(0, std::min(ColorScheme::getInstance().HighlightColorCount, colorIndex))) - , _style(style) , _tag(tag) - , next(NULL) { } -} -} + +} // namespace widgets +} // namespace chatterino diff --git a/widgets/scrollbarhighlight.h b/widgets/scrollbarhighlight.h index 0fd08a3c9..7d59a7165 100644 --- a/widgets/scrollbarhighlight.h +++ b/widgets/scrollbarhighlight.h @@ -34,7 +34,7 @@ public: return _tag; } - ScrollBarHighlight *next; + ScrollBarHighlight *next = nullptr; private: Style _style; @@ -42,7 +42,8 @@ private: int _colorIndex; QString _tag; }; -} -} + +} // namespace widgets +} // namespace chatterino #endif // SCROLLBARHIGHLIGHT_H diff --git a/widgets/settingsdialog.cpp b/widgets/settingsdialog.cpp index ff475cd8b..1c94c8944 100644 --- a/widgets/settingsdialog.cpp +++ b/widgets/settingsdialog.cpp @@ -140,7 +140,7 @@ void SettingsDialog::addTabs() } QObject::connect(combo, &QComboBox::currentTextChanged, this, - [this, &settings](const QString &value) { settings.theme.set(value); }); + [&settings](const QString &value) { settings.theme.set(value); }); // theme hue slider->setMinimum(0); @@ -150,7 +150,7 @@ void SettingsDialog::addTabs() slider->setValue(std::min(std::max(hue, (float)0.0), (float)1.0) * 1000); - QObject::connect(slider, &QSlider::valueChanged, this, [this, &settings](int value) { + QObject::connect(slider, &QSlider::valueChanged, this, [&settings](int value) { settings.themeHue.set(value / 1000.0); WindowManager::getInstance().updateAll(); }); @@ -318,7 +318,7 @@ QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting &s checkbox->setChecked(setting.get()); QObject::connect(checkbox, &QCheckBox::toggled, this, - [&setting, this](bool state) { setting.set(state); }); + [&setting](bool state) { setting.set(state); }); return checkbox; }