Fix warnings/reformat some code

This commit is contained in:
Rasmus Karlsson 2017-08-12 15:58:46 +02:00
parent ce61351fe3
commit a82774543c
16 changed files with 26 additions and 96 deletions

View file

@ -92,7 +92,6 @@ SOURCES += \
src/twitch/twitchuser.cpp \
src/ircaccount.cpp \
src/widgets/accountpopup.cpp \
src/messagefactory.cpp \
src/widgets/basewidget.cpp \
src/widgets/resizingtextedit.cpp \
src/completionmanager.cpp \
@ -155,7 +154,6 @@ HEADERS += \
src/ircaccount.hpp \
src/widgets/accountpopup.hpp \
src/util/distancebetweenpoints.hpp \
src/messagefactory.hpp \
src/widgets/basewidget.hpp \
src/completionmanager.hpp

View file

@ -13,11 +13,10 @@ Application::Application()
: completionManager(this->emoteManager)
, windowManager(this->channelManager, this->colorScheme, this->completionManager)
, colorScheme(this->windowManager)
, emoteManager(this->windowManager, this->resources)
, emoteManager(this->windowManager)
, resources(this->emoteManager, this->windowManager)
, channelManager(this->windowManager, this->emoteManager, this->ircManager)
, ircManager(this->channelManager, this->resources, this->emoteManager, this->windowManager)
, messageFactory(this->resources, this->emoteManager, this->windowManager)
{
// TODO(pajlada): Get rid of all singletons
logging::init();
@ -34,21 +33,6 @@ Application::Application()
SettingsManager::getInstance().updateWordTypeMask();
this->windowManager.load();
this->ircManager.onPrivateMessage.connect([=](Communi::IrcPrivateMessage *message) {
QString channelName = message->target().mid(1);
auto channel = this->channelManager.getChannel(channelName);
if (channel == nullptr) {
// The message doesn't have a channel we listen to
return;
}
messages::MessageParseArgs args;
this->messageFactory.buildMessage(message, *channel.get(), args);
});
}
Application::~Application()

View file

@ -5,7 +5,6 @@
#include "completionmanager.hpp"
#include "emotemanager.hpp"
#include "ircmanager.hpp"
#include "messagefactory.hpp"
#include "resources.hpp"
#include "windowmanager.hpp"
@ -28,7 +27,6 @@ public:
Resources resources;
ChannelManager channelManager;
IrcManager ircManager;
MessageFactory messageFactory;
};
} // namespace chatterino

View file

@ -24,6 +24,10 @@ class IrcManager;
class Channel
{
WindowManager &windowManager;
EmoteManager &emoteManager;
IrcManager &ircManager;
public:
explicit Channel(WindowManager &_windowManager, EmoteManager &_emoteManager,
IrcManager &_ircManager, const QString &channelName, bool isSpecial = false);
@ -51,10 +55,6 @@ public:
const QString name;
private:
WindowManager &windowManager;
EmoteManager &emoteManager;
IrcManager &ircManager;
// variables
messages::LimitedQueue<messages::SharedMessage> _messages;

View file

@ -111,15 +111,16 @@ void ChannelManager::removeChannel(const QString &channel)
const std::string &ChannelManager::getUserID(const std::string &username)
{
/* TODO: Implement
auto it = this->usernameToID.find(username);
/*
if (it != std::end(this->usernameToID)) {
return *it;
}
*/
return "xd";
static std::string temporary = "xd";
return temporary;
}
} // namespace chatterino

View file

@ -1,6 +1,5 @@
#include "emotemanager.hpp"
#include "common.hpp"
#include "resources.hpp"
#include "util/urlfetch.hpp"
#include "windowmanager.hpp"
@ -21,12 +20,10 @@ using namespace chatterino::messages;
namespace chatterino {
EmoteManager::EmoteManager(WindowManager &_windowManager, Resources &_resources)
EmoteManager::EmoteManager(WindowManager &_windowManager)
: windowManager(_windowManager)
, resources(_resources)
, findShortCodesRegex(":([-+\\w]+):")
{
// Note: Do not use this->resources in ctor
pajlada::Settings::Setting<std::string> roomID(
"/accounts/current/roomID", "", pajlada::Settings::SettingOption::DoNotWriteToJSON);

View file

@ -18,7 +18,6 @@
namespace chatterino {
class WindowManager;
class Resources;
struct EmoteData {
EmoteData()
@ -38,7 +37,7 @@ class EmoteManager
public:
using EmoteMap = ConcurrentMap<QString, EmoteData>;
EmoteManager(WindowManager &_windowManager, Resources &_resources);
explicit EmoteManager(WindowManager &_windowManager);
void loadGlobalEmotes();
@ -73,7 +72,6 @@ public:
private:
WindowManager &windowManager;
Resources &resources;
/// Emojis
QRegularExpression findShortCodesRegex;

View file

@ -1,20 +0,0 @@
#include "messagefactory.hpp"
namespace chatterino {
MessageFactory::MessageFactory(Resources &_resources, EmoteManager &_emoteManager,
WindowManager &_windowManager)
: resources(_resources)
, emoteManager(_emoteManager)
, windowManager(_windowManager)
{
}
messages::SharedMessage MessageFactory::buildMessage(Communi::IrcPrivateMessage *message,
Channel &channel,
const messages::MessageParseArgs &args)
{
return nullptr;
}
} // namespace chatterino

View file

@ -1,26 +0,0 @@
#pragma once
#include "messages/message.hpp"
namespace chatterino {
class Resources;
class EmoteManager;
class WindowManager;
class MessageFactory
{
public:
explicit MessageFactory(Resources &_resources, EmoteManager &_emoteManager,
WindowManager &_windowManager);
messages::SharedMessage buildMessage(Communi::IrcPrivateMessage *message, Channel &channel,
const messages::MessageParseArgs &args);
private:
Resources &resources;
EmoteManager &emoteManager;
WindowManager &windowManager;
};
} // namespace chatterino

View file

@ -31,8 +31,8 @@ Message::Message(const QString &text)
Message::Message(const QString &text, const std::vector<Word> &words, const bool &highlight)
: text(text)
, words(words)
, highlightTab(highlight)
, words(words)
{
}

View file

@ -41,7 +41,9 @@ private:
int _currentLayoutWidth = -1;
int _fontGeneration = -1;
/* TODO(pajlada): Re-implement
int _emoteGeneration = -1;
*/
Word::Type _currentWordTypes = Word::None;
// methods

View file

@ -53,7 +53,6 @@ private:
std::string roomID;
QColor usernameColor;
bool highlight;
void parseMessageID();
void parseRoomID();

View file

@ -6,13 +6,13 @@
#include "widgets/textinputdialog.hpp"
#include <QDebug>
#include <QFileInfo>
#include <QFont>
#include <QFontDatabase>
#include <QPainter>
#include <QProcess>
#include <QShortcut>
#include <QVBoxLayout>
#include <QFileInfo>
#include <QProcess>
#include <boost/signals2.hpp>
#include <functional>
@ -40,12 +40,12 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
: BaseWidget(parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
, channel(_channelManager.emptyChannel)
, vbox(this)
, header(this)
, view(this)
, input(this)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
{
this->vbox.setSpacing(0);
this->vbox.setMargin(1);
@ -288,9 +288,9 @@ void ChatWidget::doOpenStreamlink()
// TODO(Confuseh): Add quality switcher
if (fileinfo.exists() && fileinfo.isExecutable()) {
// works on leenux, idk whether it would work on whindows or mehOS
QProcess::startDetached(path,
QStringList({"twitch.tv/" + QString::fromStdString(this->channelName.getValue()),
"best"}));
QProcess::startDetached(
path, QStringList({"twitch.tv/" + QString::fromStdString(this->channelName.getValue()),
"best"}));
}
}

View file

@ -56,14 +56,15 @@ public:
void giveFocus(Qt::FocusReason reason);
bool hasFocus() const;
pajlada::Settings::Setting<std::string> channelName;
protected:
virtual void paintEvent(QPaintEvent *) override;
public:
ChannelManager &channelManager;
CompletionManager &completionManager;
pajlada::Settings::Setting<std::string> channelName;
private:
void setChannel(std::shared_ptr<Channel> newChannel);
void detachChannel();

View file

@ -31,13 +31,13 @@ LoginWidget::LoginWidget()
this->close(); //
});
connect(&this->ui.loginButton, &QPushButton::clicked, [this]() {
connect(&this->ui.loginButton, &QPushButton::clicked, []() {
printf("open login in browser\n");
QDesktopServices::openUrl(QUrl("https://pajlada.se/chatterino/#chatterino"));
});
connect(&this->ui.pasteCodeButton, &QPushButton::clicked, [this]() {
connect(&this->ui.pasteCodeButton, &QPushButton::clicked, []() {
QClipboard *clipboard = QGuiApplication::clipboard();
QString clipboardString = clipboard->text();
QStringList parameters = clipboardString.split(';');

View file

@ -168,7 +168,7 @@ void SettingsDialog::addTabs()
auto fontManager = FontManager::getInstance();
QFontDialog dialog(fontManager.getFont(FontManager::Medium));
dialog.connect(&dialog, &QFontDialog::fontSelected, [&dialog](const QFont &font) {
dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) {
auto fontManager = FontManager::getInstance();
fontManager.currentFontFamily = font.family().toStdString();
fontManager.currentFontSize = font.pointSize();
@ -590,9 +590,7 @@ QLineEdit *SettingsDialog::createLineEdit(pajlada::Settings::Setting<std::string
auto widget = new QLineEdit(QString::fromStdString(setting.getValue()));
QObject::connect(widget, &QLineEdit::textChanged, this,
[&setting](const QString &newValue) {
setting = newValue.toStdString();
});
[&setting](const QString &newValue) { setting = newValue.toStdString(); });
return widget;
}