mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix warnings/reformat some code
This commit is contained in:
parent
ce61351fe3
commit
a82774543c
16 changed files with 26 additions and 96 deletions
|
@ -92,7 +92,6 @@ SOURCES += \
|
||||||
src/twitch/twitchuser.cpp \
|
src/twitch/twitchuser.cpp \
|
||||||
src/ircaccount.cpp \
|
src/ircaccount.cpp \
|
||||||
src/widgets/accountpopup.cpp \
|
src/widgets/accountpopup.cpp \
|
||||||
src/messagefactory.cpp \
|
|
||||||
src/widgets/basewidget.cpp \
|
src/widgets/basewidget.cpp \
|
||||||
src/widgets/resizingtextedit.cpp \
|
src/widgets/resizingtextedit.cpp \
|
||||||
src/completionmanager.cpp \
|
src/completionmanager.cpp \
|
||||||
|
@ -155,7 +154,6 @@ HEADERS += \
|
||||||
src/ircaccount.hpp \
|
src/ircaccount.hpp \
|
||||||
src/widgets/accountpopup.hpp \
|
src/widgets/accountpopup.hpp \
|
||||||
src/util/distancebetweenpoints.hpp \
|
src/util/distancebetweenpoints.hpp \
|
||||||
src/messagefactory.hpp \
|
|
||||||
src/widgets/basewidget.hpp \
|
src/widgets/basewidget.hpp \
|
||||||
src/completionmanager.hpp
|
src/completionmanager.hpp
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,10 @@ Application::Application()
|
||||||
: completionManager(this->emoteManager)
|
: completionManager(this->emoteManager)
|
||||||
, windowManager(this->channelManager, this->colorScheme, this->completionManager)
|
, windowManager(this->channelManager, this->colorScheme, this->completionManager)
|
||||||
, colorScheme(this->windowManager)
|
, colorScheme(this->windowManager)
|
||||||
, emoteManager(this->windowManager, this->resources)
|
, emoteManager(this->windowManager)
|
||||||
, resources(this->emoteManager, this->windowManager)
|
, resources(this->emoteManager, this->windowManager)
|
||||||
, channelManager(this->windowManager, this->emoteManager, this->ircManager)
|
, channelManager(this->windowManager, this->emoteManager, this->ircManager)
|
||||||
, ircManager(this->channelManager, this->resources, this->emoteManager, this->windowManager)
|
, ircManager(this->channelManager, this->resources, this->emoteManager, this->windowManager)
|
||||||
, messageFactory(this->resources, this->emoteManager, this->windowManager)
|
|
||||||
{
|
{
|
||||||
// TODO(pajlada): Get rid of all singletons
|
// TODO(pajlada): Get rid of all singletons
|
||||||
logging::init();
|
logging::init();
|
||||||
|
@ -34,21 +33,6 @@ Application::Application()
|
||||||
SettingsManager::getInstance().updateWordTypeMask();
|
SettingsManager::getInstance().updateWordTypeMask();
|
||||||
|
|
||||||
this->windowManager.load();
|
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()
|
Application::~Application()
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "completionmanager.hpp"
|
#include "completionmanager.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "emotemanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "ircmanager.hpp"
|
||||||
#include "messagefactory.hpp"
|
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "windowmanager.hpp"
|
#include "windowmanager.hpp"
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ public:
|
||||||
Resources resources;
|
Resources resources;
|
||||||
ChannelManager channelManager;
|
ChannelManager channelManager;
|
||||||
IrcManager ircManager;
|
IrcManager ircManager;
|
||||||
MessageFactory messageFactory;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -24,6 +24,10 @@ class IrcManager;
|
||||||
|
|
||||||
class Channel
|
class Channel
|
||||||
{
|
{
|
||||||
|
WindowManager &windowManager;
|
||||||
|
EmoteManager &emoteManager;
|
||||||
|
IrcManager &ircManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Channel(WindowManager &_windowManager, EmoteManager &_emoteManager,
|
explicit Channel(WindowManager &_windowManager, EmoteManager &_emoteManager,
|
||||||
IrcManager &_ircManager, const QString &channelName, bool isSpecial = false);
|
IrcManager &_ircManager, const QString &channelName, bool isSpecial = false);
|
||||||
|
@ -51,10 +55,6 @@ public:
|
||||||
const QString name;
|
const QString name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowManager &windowManager;
|
|
||||||
EmoteManager &emoteManager;
|
|
||||||
IrcManager &ircManager;
|
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
messages::LimitedQueue<messages::SharedMessage> _messages;
|
messages::LimitedQueue<messages::SharedMessage> _messages;
|
||||||
|
|
||||||
|
|
|
@ -111,15 +111,16 @@ void ChannelManager::removeChannel(const QString &channel)
|
||||||
|
|
||||||
const std::string &ChannelManager::getUserID(const std::string &username)
|
const std::string &ChannelManager::getUserID(const std::string &username)
|
||||||
{
|
{
|
||||||
|
/* TODO: Implement
|
||||||
auto it = this->usernameToID.find(username);
|
auto it = this->usernameToID.find(username);
|
||||||
|
|
||||||
/*
|
|
||||||
if (it != std::end(this->usernameToID)) {
|
if (it != std::end(this->usernameToID)) {
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return "xd";
|
static std::string temporary = "xd";
|
||||||
|
return temporary;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "emotemanager.hpp"
|
#include "emotemanager.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "resources.hpp"
|
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "windowmanager.hpp"
|
#include "windowmanager.hpp"
|
||||||
|
|
||||||
|
@ -21,12 +20,10 @@ using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
EmoteManager::EmoteManager(WindowManager &_windowManager, Resources &_resources)
|
EmoteManager::EmoteManager(WindowManager &_windowManager)
|
||||||
: windowManager(_windowManager)
|
: windowManager(_windowManager)
|
||||||
, resources(_resources)
|
|
||||||
, findShortCodesRegex(":([-+\\w]+):")
|
, findShortCodesRegex(":([-+\\w]+):")
|
||||||
{
|
{
|
||||||
// Note: Do not use this->resources in ctor
|
|
||||||
pajlada::Settings::Setting<std::string> roomID(
|
pajlada::Settings::Setting<std::string> roomID(
|
||||||
"/accounts/current/roomID", "", pajlada::Settings::SettingOption::DoNotWriteToJSON);
|
"/accounts/current/roomID", "", pajlada::Settings::SettingOption::DoNotWriteToJSON);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
class Resources;
|
|
||||||
|
|
||||||
struct EmoteData {
|
struct EmoteData {
|
||||||
EmoteData()
|
EmoteData()
|
||||||
|
@ -38,7 +37,7 @@ class EmoteManager
|
||||||
public:
|
public:
|
||||||
using EmoteMap = ConcurrentMap<QString, EmoteData>;
|
using EmoteMap = ConcurrentMap<QString, EmoteData>;
|
||||||
|
|
||||||
EmoteManager(WindowManager &_windowManager, Resources &_resources);
|
explicit EmoteManager(WindowManager &_windowManager);
|
||||||
|
|
||||||
void loadGlobalEmotes();
|
void loadGlobalEmotes();
|
||||||
|
|
||||||
|
@ -73,7 +72,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowManager &windowManager;
|
WindowManager &windowManager;
|
||||||
Resources &resources;
|
|
||||||
|
|
||||||
/// Emojis
|
/// Emojis
|
||||||
QRegularExpression findShortCodesRegex;
|
QRegularExpression findShortCodesRegex;
|
||||||
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -31,8 +31,8 @@ Message::Message(const QString &text)
|
||||||
|
|
||||||
Message::Message(const QString &text, const std::vector<Word> &words, const bool &highlight)
|
Message::Message(const QString &text, const std::vector<Word> &words, const bool &highlight)
|
||||||
: text(text)
|
: text(text)
|
||||||
, words(words)
|
|
||||||
, highlightTab(highlight)
|
, highlightTab(highlight)
|
||||||
|
, words(words)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ private:
|
||||||
|
|
||||||
int _currentLayoutWidth = -1;
|
int _currentLayoutWidth = -1;
|
||||||
int _fontGeneration = -1;
|
int _fontGeneration = -1;
|
||||||
|
/* TODO(pajlada): Re-implement
|
||||||
int _emoteGeneration = -1;
|
int _emoteGeneration = -1;
|
||||||
|
*/
|
||||||
Word::Type _currentWordTypes = Word::None;
|
Word::Type _currentWordTypes = Word::None;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|
|
@ -53,7 +53,6 @@ private:
|
||||||
std::string roomID;
|
std::string roomID;
|
||||||
|
|
||||||
QColor usernameColor;
|
QColor usernameColor;
|
||||||
bool highlight;
|
|
||||||
|
|
||||||
void parseMessageID();
|
void parseMessageID();
|
||||||
void parseRoomID();
|
void parseRoomID();
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
#include "widgets/textinputdialog.hpp"
|
#include "widgets/textinputdialog.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QProcess>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -40,12 +40,12 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, channelManager(_channelManager)
|
, channelManager(_channelManager)
|
||||||
, completionManager(parent->completionManager)
|
, completionManager(parent->completionManager)
|
||||||
|
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
|
||||||
, channel(_channelManager.emptyChannel)
|
, channel(_channelManager.emptyChannel)
|
||||||
, vbox(this)
|
, vbox(this)
|
||||||
, header(this)
|
, header(this)
|
||||||
, view(this)
|
, view(this)
|
||||||
, input(this)
|
, input(this)
|
||||||
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
|
|
||||||
{
|
{
|
||||||
this->vbox.setSpacing(0);
|
this->vbox.setSpacing(0);
|
||||||
this->vbox.setMargin(1);
|
this->vbox.setMargin(1);
|
||||||
|
@ -288,8 +288,8 @@ void ChatWidget::doOpenStreamlink()
|
||||||
// TODO(Confuseh): Add quality switcher
|
// TODO(Confuseh): Add quality switcher
|
||||||
if (fileinfo.exists() && fileinfo.isExecutable()) {
|
if (fileinfo.exists() && fileinfo.isExecutable()) {
|
||||||
// works on leenux, idk whether it would work on whindows or mehOS
|
// works on leenux, idk whether it would work on whindows or mehOS
|
||||||
QProcess::startDetached(path,
|
QProcess::startDetached(
|
||||||
QStringList({"twitch.tv/" + QString::fromStdString(this->channelName.getValue()),
|
path, QStringList({"twitch.tv/" + QString::fromStdString(this->channelName.getValue()),
|
||||||
"best"}));
|
"best"}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,14 +56,15 @@ public:
|
||||||
void giveFocus(Qt::FocusReason reason);
|
void giveFocus(Qt::FocusReason reason);
|
||||||
bool hasFocus() const;
|
bool hasFocus() const;
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> channelName;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent *) override;
|
virtual void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChannelManager &channelManager;
|
ChannelManager &channelManager;
|
||||||
CompletionManager &completionManager;
|
CompletionManager &completionManager;
|
||||||
|
|
||||||
|
pajlada::Settings::Setting<std::string> channelName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setChannel(std::shared_ptr<Channel> newChannel);
|
void setChannel(std::shared_ptr<Channel> newChannel);
|
||||||
void detachChannel();
|
void detachChannel();
|
||||||
|
|
|
@ -31,13 +31,13 @@ LoginWidget::LoginWidget()
|
||||||
this->close(); //
|
this->close(); //
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&this->ui.loginButton, &QPushButton::clicked, [this]() {
|
connect(&this->ui.loginButton, &QPushButton::clicked, []() {
|
||||||
printf("open login in browser\n");
|
printf("open login in browser\n");
|
||||||
QDesktopServices::openUrl(QUrl("https://pajlada.se/chatterino/#chatterino"));
|
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();
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
QString clipboardString = clipboard->text();
|
QString clipboardString = clipboard->text();
|
||||||
QStringList parameters = clipboardString.split(';');
|
QStringList parameters = clipboardString.split(';');
|
||||||
|
|
|
@ -168,7 +168,7 @@ void SettingsDialog::addTabs()
|
||||||
auto fontManager = FontManager::getInstance();
|
auto fontManager = FontManager::getInstance();
|
||||||
QFontDialog dialog(fontManager.getFont(FontManager::Medium));
|
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();
|
auto fontManager = FontManager::getInstance();
|
||||||
fontManager.currentFontFamily = font.family().toStdString();
|
fontManager.currentFontFamily = font.family().toStdString();
|
||||||
fontManager.currentFontSize = font.pointSize();
|
fontManager.currentFontSize = font.pointSize();
|
||||||
|
@ -590,9 +590,7 @@ QLineEdit *SettingsDialog::createLineEdit(pajlada::Settings::Setting<std::string
|
||||||
auto widget = new QLineEdit(QString::fromStdString(setting.getValue()));
|
auto widget = new QLineEdit(QString::fromStdString(setting.getValue()));
|
||||||
|
|
||||||
QObject::connect(widget, &QLineEdit::textChanged, this,
|
QObject::connect(widget, &QLineEdit::textChanged, this,
|
||||||
[&setting](const QString &newValue) {
|
[&setting](const QString &newValue) { setting = newValue.toStdString(); });
|
||||||
setting = newValue.toStdString();
|
|
||||||
});
|
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue