Fix all warnings that we care about

This commit is contained in:
Rasmus Karlsson 2017-05-27 16:16:39 +02:00
parent 896cf7a03b
commit c4de5c806a
17 changed files with 95 additions and 104 deletions

View file

@ -52,9 +52,7 @@ void ColorScheme::setColors(float hue, float multiplyer)
SystemMessageColor = QColor(140, 127, 127); SystemMessageColor = QColor(140, 127, 127);
auto isLightTheme = IsLightTheme; auto getColor = [multiplyer](qreal h, qreal s, qreal l, qreal a = 1.0) {
auto getColor = [isLightTheme, multiplyer](qreal h, qreal s, qreal l, qreal a = 1.0) {
return QColor::fromHslF(h, s, (((l - 0.5) * multiplyer) + 0.5), a); 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); TabSelectedBackground = getColor(hue, 0.5, 0.5);
TabHighlightedBackground = getColor(hue, 0.5, 0.2); TabHighlightedBackground = getColor(hue, 0.5, 0.2);
TabNewMessageBackground = QBrush(getColor(hue, 0.5, 0.2), Qt::DiagCrossPattern); TabNewMessageBackground = QBrush(getColor(hue, 0.5, 0.2), Qt::DiagCrossPattern);
if (hasDarkBorder) if (hasDarkBorder) {
// TabText = QColor(210, 210, 210); // TabText = QColor(210, 210, 210);
// TabHoverText = QColor(210, 210, 210); // TabHoverText = QColor(210, 210, 210);
TabText = QColor(0, 0, 0); TabText = QColor(0, 0, 0);
}
TabHoverText = QColor(0, 0, 0); TabHoverText = QColor(0, 0, 0);
TabSelectedText = QColor(255, 255, 255); TabSelectedText = QColor(255, 255, 255);
TabHighlightedText = QColor(0, 0, 0); TabHighlightedText = QColor(0, 0, 0);

View file

@ -206,4 +206,5 @@ LazyLoadedImage *EmoteManager::getCheerBadge(long long amount)
return Resources::getCheerBadge1(); return Resources::getCheerBadge1();
} }
} }
}
} // namespace chatterino

View file

@ -80,19 +80,19 @@ private:
ConcurrentMap<long, messages::LazyLoadedImage *> _twitchEmoteFromCache; ConcurrentMap<long, messages::LazyLoadedImage *> _twitchEmoteFromCache;
ConcurrentMap<QString, messages::LazyLoadedImage *> _miscImageFromCache; ConcurrentMap<QString, messages::LazyLoadedImage *> _miscImageFromCache;
boost::signals2::signal<void()> _gifUpdateTimerSignal;
QTimer _gifUpdateTimer; QTimer _gifUpdateTimer;
bool _gifUpdateTimerInitiated; bool _gifUpdateTimerInitiated;
int _generation; int _generation;
boost::signals2::signal<void()> _gifUpdateTimerSignal;
// methods // methods
static QString getTwitchEmoteLink(long id, qreal &scale); static QString getTwitchEmoteLink(long id, qreal &scale);
void loadFfzEmotes(); void loadFfzEmotes();
void loadBttvEmotes(); void loadBttvEmotes();
}; };
} // namespace chatterino } // namespace chatterino
#endif // EMOTES_H #endif // EMOTES_H

View file

@ -1,12 +1,12 @@
#include "ircmanager.h" #include "ircmanager.h"
#include "accountmanager.h"
#include "asyncexec.h" #include "asyncexec.h"
#include "channel.h" #include "channel.h"
#include "channelmanager.h" #include "channelmanager.h"
#include "messages/messageparseargs.h" #include "messages/messageparseargs.h"
#include "twitch/twitchaccount.h"
#include "twitch/twitchmessagebuilder.h" #include "twitch/twitchmessagebuilder.h"
#include "twitch/twitchparsemessage.h" #include "twitch/twitchparsemessage.h"
#include "twitch/twitchaccount.h"
#include "accountmanager.h"
#include <irccommand.h> #include <irccommand.h>
#include <ircconnection.h> #include <ircconnection.h>
@ -203,19 +203,20 @@ void IrcManager::partChannel(const QString &channel)
_connectionMutex.unlock(); _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(); const QString &command = message->command();
// if (command == "CLEARCHAT") { if (command == "CLEARCHAT") {
// message-> } else if (command == "ROOMSTATE") {
// } else if (command == "ROOMSTATE") { } else if (command == "USERSTATE") {
// } else if (command == "USERSTATE") { } else if (command == "WHISPER") {
// } else if (command == "WHISPER") { } else if (command == "USERNOTICE") {
// } else if (command == "USERNOTICE") { }
// } */
} }
void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message) void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
@ -306,4 +307,4 @@ QNetworkAccessManager &IrcManager::getAccessManager()
{ {
return _accessManager; return _accessManager;
} }
} } // namespace chatterino

View file

@ -17,7 +17,6 @@ namespace messages {
MessageRef::MessageRef(SharedMessage message) MessageRef::MessageRef(SharedMessage message)
: _message(message) : _message(message)
, _wordParts() , _wordParts()
, buffer()
{ {
} }
@ -316,5 +315,6 @@ int MessageRef::getSelectionIndex(QPoint position)
return index; return index;
} }
}
} } // namespace messages
} // namespace chatterino

View file

@ -47,7 +47,8 @@ private:
// methods // methods
void alignWordParts(int lineStart, int lineHeight); void alignWordParts(int lineStart, int lineHeight);
}; };
}
} } // namespace messages
} // namespace chatterino
#endif // MESSAGEREF_H #endif // MESSAGEREF_H

View file

@ -11,7 +11,6 @@ namespace chatterino {
SettingsManager::SettingsManager() SettingsManager::SettingsManager()
: _settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat) : _settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat)
, _wordTypeMask(Word::Default)
, theme(_settingsItems, "theme", "dark") , theme(_settingsItems, "theme", "dark")
, themeHue(_settingsItems, "themeHue", 0) , themeHue(_settingsItems, "themeHue", 0)
, selectedUser(_settingsItems, "selectedUser", "") , selectedUser(_settingsItems, "selectedUser", "")

View file

@ -14,6 +14,30 @@ class SettingsManager : public QObject
Q_OBJECT Q_OBJECT
public: 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<std::reference_wrapper<BaseSetting>> _settingsItems;
messages::Word::Type _wordTypeMask = messages::Word::Default;
// methods
void updateWordTypeMask();
public:
// Settings
Setting<QString> theme; Setting<QString> theme;
Setting<float> themeHue; Setting<float> themeHue;
Setting<QString> selectedUser; Setting<QString> selectedUser;
@ -47,28 +71,6 @@ public:
Setting<bool> hideUserButton; Setting<bool> hideUserButton;
Setting<bool> useCustomWindowFrame; Setting<bool> 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<std::reference_wrapper<BaseSetting>> _settingsItems;
messages::Word::Type _wordTypeMask;
// methods
void updateWordTypeMask();
public: public:
static SettingsManager &getInstance() static SettingsManager &getInstance()
{ {

View file

@ -38,20 +38,17 @@ ChatWidget::~ChatWidget()
{ {
} }
std::shared_ptr<Channel> std::shared_ptr<Channel> ChatWidget::getChannel() const
ChatWidget::getChannel() const
{ {
return _channel; return _channel;
} }
const QString & const QString &ChatWidget::getChannelName() const
ChatWidget::getChannelName() const
{ {
return _channelName; return _channelName;
} }
void void ChatWidget::setChannelName(const QString &name)
ChatWidget::setChannelName(const QString &name)
{ {
QString channel = name.trimmed(); QString channel = name.trimmed();
@ -92,27 +89,25 @@ ChatWidget::setChannelName(const QString &name)
_view.update(); _view.update();
} }
void void ChatWidget::attachChannel(SharedChannel channel)
ChatWidget::attachChannel(SharedChannel channel)
{ {
// on new message // on new message
_messageAppendedConnection = _messageAppendedConnection = channel->messageAppended.connect([this](SharedMessage &message) {
channel->messageAppended.connect([this](SharedMessage &message) {
SharedMessageRef deleted; SharedMessageRef deleted;
auto messageRef = new MessageRef(message); auto messageRef = new MessageRef(message);
if (_messages.appendItem(SharedMessageRef(messageRef), deleted)) { if (_messages.appendItem(SharedMessageRef(messageRef), deleted)) {
qreal value = qreal value = std::max(0.0, _view.getScrollbar()->getDesiredValue() - 1);
std::max(0.0, _view.getScrollbar()->getDesiredValue() - 1);
_view.getScrollbar()->setDesiredValue(value, false); _view.getScrollbar()->setDesiredValue(value, false);
} }
}); });
// on message removed // on message removed
_messageRemovedConnection = _messageRemovedConnection = _channel->messageRemovedFromStart.connect([](SharedMessage &) {
_channel->messageRemovedFromStart.connect([this](SharedMessage &) {}); //
});
auto snapshot = _channel.get()->getMessageSnapshot(); auto snapshot = _channel.get()->getMessageSnapshot();
@ -125,8 +120,7 @@ ChatWidget::attachChannel(SharedChannel channel)
} }
} }
void void ChatWidget::detachChannel(std::shared_ptr<Channel> channel)
ChatWidget::detachChannel(std::shared_ptr<Channel> channel)
{ {
// on message added // on message added
_messageAppendedConnection.disconnect(); _messageAppendedConnection.disconnect();
@ -135,14 +129,12 @@ ChatWidget::detachChannel(std::shared_ptr<Channel> channel)
_messageRemovedConnection.disconnect(); _messageRemovedConnection.disconnect();
} }
LimitedQueueSnapshot<SharedMessageRef> LimitedQueueSnapshot<SharedMessageRef> ChatWidget::getMessagesSnapshot()
ChatWidget::getMessagesSnapshot()
{ {
return _messages.getSnapshot(); return _messages.getSnapshot();
} }
void void ChatWidget::showChangeChannelPopup()
ChatWidget::showChangeChannelPopup()
{ {
// create new input dialog and execute it // create new input dialog and execute it
TextInputDialog dialog(this); TextInputDialog dialog(this);
@ -154,22 +146,19 @@ ChatWidget::showChangeChannelPopup()
} }
} }
void void ChatWidget::layoutMessages()
ChatWidget::layoutMessages()
{ {
if (_view.layoutMessages()) { if (_view.layoutMessages()) {
_view.update(); _view.update();
} }
} }
void void ChatWidget::updateGifEmotes()
ChatWidget::updateGifEmotes()
{ {
_view.updateGifEmotes(); _view.updateGifEmotes();
} }
void void ChatWidget::paintEvent(QPaintEvent *)
ChatWidget::paintEvent(QPaintEvent *)
{ {
// color the background of the chat // color the background of the chat
QPainter painter(this); QPainter painter(this);
@ -177,19 +166,16 @@ ChatWidget::paintEvent(QPaintEvent *)
painter.fillRect(this->rect(), ColorScheme::getInstance().ChatBackground); painter.fillRect(this->rect(), ColorScheme::getInstance().ChatBackground);
} }
void void ChatWidget::load(const boost::property_tree::ptree &tree)
ChatWidget::load(const boost::property_tree::ptree &tree)
{ {
// load tab text // load tab text
try { try {
this->setChannelName( this->setChannelName(QString::fromStdString(tree.get<std::string>("channelName")));
QString::fromStdString(tree.get<std::string>("channelName")));
} catch (boost::property_tree::ptree_error) { } catch (boost::property_tree::ptree_error) {
} }
} }
boost::property_tree::ptree boost::property_tree::ptree ChatWidget::save()
ChatWidget::save()
{ {
boost::property_tree::ptree tree; boost::property_tree::ptree tree;

View file

@ -60,7 +60,7 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *widget)
completer->setWidget(&_edit); 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) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
auto ptr = _chatWidget->getChannel(); auto ptr = _chatWidget->getChannel();
Channel *c = ptr.get(); Channel *c = ptr.get();

View file

@ -220,10 +220,10 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
QPoint relPoint = mapToParent(event->pos()); QPoint relPoint = mapToParent(event->pos());
int index; int index;
NotebookPage *page = _notebook->tabAt(relPoint, index); NotebookPage *clickedPage = _notebook->tabAt(relPoint, index);
if (page != nullptr && page != page) { if (clickedPage != nullptr && clickedPage != page) {
_notebook->rearrangePage(page, index); _notebook->rearrangePage(clickedPage, index);
} }
} }
} }

View file

@ -39,7 +39,7 @@ protected:
return margins.top() + document()->size().height() + margins.bottom() + 5; return margins.top() + document()->size().height() + margins.bottom() + 5;
} }
void keyPressEvent(QKeyEvent *event) void keyPressEvent(QKeyEvent *event) override
{ {
event->ignore(); event->ignore();

View file

@ -13,7 +13,7 @@ ScrollBar::ScrollBar(QWidget *widget)
: QWidget(widget) : QWidget(widget)
, _mutex() , _mutex()
, _currentValueAnimation(this, "currentValue") , _currentValueAnimation(this, "currentValue")
, _highlights(NULL) , _highlights(nullptr)
, _mouseOverIndex(-1) , _mouseOverIndex(-1)
, _mouseDownIndex(-1) , _mouseDownIndex(-1)
, _lastMousePosition() , _lastMousePosition()
@ -25,8 +25,8 @@ ScrollBar::ScrollBar(QWidget *widget)
, _largeChange() , _largeChange()
, _smallChange() , _smallChange()
, _desiredValue() , _desiredValue()
, _currentValueChanged()
, _currentValue() , _currentValue()
, _currentValueChanged()
{ {
resize(16, 100); resize(16, 100);

View file

@ -43,10 +43,11 @@ private:
Q_PROPERTY(qreal _currentValue READ getCurrentValue WRITE setCurrentValue) Q_PROPERTY(qreal _currentValue READ getCurrentValue WRITE setCurrentValue)
QMutex _mutex; QMutex _mutex;
ScrollBarHighlight *_highlights;
QPropertyAnimation _currentValueAnimation; QPropertyAnimation _currentValueAnimation;
ScrollBarHighlight *_highlights;
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);

View file

@ -5,12 +5,12 @@ namespace chatterino {
namespace widgets { namespace widgets {
ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex, Style style, QString tag) 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))) , _colorIndex(std::max(0, std::min(ColorScheme::getInstance().HighlightColorCount, colorIndex)))
, _style(style)
, _tag(tag) , _tag(tag)
, next(NULL)
{ {
} }
}
} } // namespace widgets
} // namespace chatterino

View file

@ -34,7 +34,7 @@ public:
return _tag; return _tag;
} }
ScrollBarHighlight *next; ScrollBarHighlight *next = nullptr;
private: private:
Style _style; Style _style;
@ -42,7 +42,8 @@ private:
int _colorIndex; int _colorIndex;
QString _tag; QString _tag;
}; };
}
} } // namespace widgets
} // namespace chatterino
#endif // SCROLLBARHIGHLIGHT_H #endif // SCROLLBARHIGHLIGHT_H

View file

@ -140,7 +140,7 @@ void SettingsDialog::addTabs()
} }
QObject::connect(combo, &QComboBox::currentTextChanged, this, 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 // theme hue
slider->setMinimum(0); slider->setMinimum(0);
@ -150,7 +150,7 @@ void SettingsDialog::addTabs()
slider->setValue(std::min(std::max(hue, (float)0.0), (float)1.0) * 1000); 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); settings.themeHue.set(value / 1000.0);
WindowManager::getInstance().updateAll(); WindowManager::getInstance().updateAll();
}); });
@ -318,7 +318,7 @@ QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting<bool> &s
checkbox->setChecked(setting.get()); checkbox->setChecked(setting.get());
QObject::connect(checkbox, &QCheckBox::toggled, this, QObject::connect(checkbox, &QCheckBox::toggled, this,
[&setting, this](bool state) { setting.set(state); }); [&setting](bool state) { setting.set(state); });
return checkbox; return checkbox;
} }