refactored irc
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "basewindow.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
#include "providers/twitch/twitchchannel.hpp"
|
||||
#include "util/concurrentmap.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <QTabWidget>
|
||||
|
||||
#include "messages/messagebuilder.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
#include "providers/twitch/twitchchannel.hpp"
|
||||
|
||||
using namespace chatterino::twitch;
|
||||
using namespace chatterino::providers::twitch;
|
||||
using namespace chatterino::messages;
|
||||
|
||||
namespace chatterino {
|
||||
@@ -68,7 +68,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
|
||||
map.each([&](const QString &key, const util::EmoteData &value) {
|
||||
builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::InsertText, key)));
|
||||
->setLink(Link(Link::InsertText, key)));
|
||||
});
|
||||
|
||||
emoteChannel->addMessage(builder2.getMessage());
|
||||
@@ -107,7 +107,7 @@ void EmotePopup::loadEmojis()
|
||||
|
||||
emojis.each([this, &builder](const QString &key, const util::EmoteData &value) {
|
||||
builder.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::Type::InsertText, key)));
|
||||
->setLink(Link(Link::Type::InsertText, key)));
|
||||
});
|
||||
emojiChannel->addMessage(builder.getMessage());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "messages/layouts/messagelayout.hpp"
|
||||
#include "messages/limitedqueuesnapshot.hpp"
|
||||
#include "messages/message.hpp"
|
||||
#include "providers/twitch/twitchserver.hpp"
|
||||
#include "singletons/channelmanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
@@ -28,6 +29,7 @@
|
||||
#define LAYOUT_WIDTH (this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getScale())
|
||||
|
||||
using namespace chatterino::messages;
|
||||
using namespace chatterino::providers::twitch;
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
@@ -35,7 +37,7 @@ namespace widgets {
|
||||
ChannelView::ChannelView(BaseWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, scrollBar(this)
|
||||
, userPopupWidget(std::shared_ptr<twitch::TwitchChannel>())
|
||||
, userPopupWidget(std::shared_ptr<TwitchChannel>())
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
// this->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
@@ -476,7 +478,7 @@ messages::MessageElement::Flags ChannelView::getFlags() const
|
||||
if (split->getModerationMode()) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
||||
}
|
||||
if (this->channel == singletons::ChannelManager::getInstance().mentionsChannel) {
|
||||
if (this->channel == TwitchServer::getInstance().mentionsChannel) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "widgets/helper/resizingtextedit.hpp"
|
||||
#include "common.hpp"
|
||||
#include "singletons/completionmanager.hpp"
|
||||
|
||||
ResizingTextEdit::ResizingTextEdit()
|
||||
@@ -79,13 +80,17 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Tab &&
|
||||
(event->modifiers() & Qt::ControlModifier) == Qt::NoModifier) {
|
||||
bool doComplete =
|
||||
event->key() == Qt::Key_Tab && (event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
|
||||
|
||||
if (doComplete) {
|
||||
// check if there is a completer
|
||||
return_if_not(this->completer);
|
||||
|
||||
QString currentCompletionPrefix = this->textUnderCursor();
|
||||
|
||||
if (!currentCompletionPrefix.size()) {
|
||||
return;
|
||||
}
|
||||
// check if there is something to complete
|
||||
return_if_not(currentCompletionPrefix.size());
|
||||
|
||||
auto *completionModel =
|
||||
static_cast<chatterino::singletons::CompletionModel *>(this->completer->model());
|
||||
@@ -109,6 +114,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
this->completer->complete();
|
||||
return;
|
||||
}
|
||||
|
||||
// (hemirt)
|
||||
// this resets the selection in the completion list, it should probably only trigger on actual
|
||||
// chat input (space, character) and not on every key input (pressing alt for example)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "widgets/helper/splitheader.hpp"
|
||||
#include "providers/twitch/twitchchannel.hpp"
|
||||
#include "providers/twitch/twitchserver.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
#include "util/layoutcreator.hpp"
|
||||
#include "util/urlfetch.hpp"
|
||||
#include "widgets/helper/label.hpp"
|
||||
@@ -18,6 +19,8 @@
|
||||
#include "widgets/streamview.hpp"
|
||||
#endif
|
||||
|
||||
using namespace chatterino::providers::twitch;
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
@@ -98,7 +101,7 @@ void SplitHeader::addDropdownItems(RippleEffectButton *label)
|
||||
#ifdef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Start watching", this, [this]{
|
||||
ChannelPtr _channel = this->split->getChannel();
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
StreamView *view = new StreamView(_channel, "https://player.twitch.tv/?channel=" + tc->name);
|
||||
@@ -128,7 +131,7 @@ void SplitHeader::initializeChannelSignals()
|
||||
this->onlineStatusChangedConnection.disconnect();
|
||||
|
||||
auto channel = this->split->getChannel();
|
||||
twitch::TwitchChannel *twitchChannel = dynamic_cast<twitch::TwitchChannel *>(channel.get());
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
twitchChannel->onlineStatusChanged.connect([this]() {
|
||||
@@ -150,13 +153,13 @@ void SplitHeader::scaleChangedEvent(float scale)
|
||||
|
||||
void SplitHeader::updateChannelText()
|
||||
{
|
||||
const std::string channelName = this->split->channelName;
|
||||
if (channelName.empty()) {
|
||||
const QString channelName = this->split->channelName;
|
||||
if (channelName.isEmpty()) {
|
||||
this->titleLabel->setText("<no channel>");
|
||||
} else {
|
||||
auto channel = this->split->getChannel();
|
||||
|
||||
twitch::TwitchChannel *twitchChannel = dynamic_cast<twitch::TwitchChannel *>(channel.get());
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel != nullptr && twitchChannel->isLive) {
|
||||
this->isLive = true;
|
||||
@@ -169,10 +172,10 @@ void SplitHeader::updateChannelText()
|
||||
twitchChannel->streamViewerCount +
|
||||
" viewers"
|
||||
"</p>";
|
||||
this->titleLabel->setText(QString::fromStdString(channelName) + " (live)");
|
||||
this->titleLabel->setText(channelName + " (live)");
|
||||
} else {
|
||||
this->isLive = false;
|
||||
this->titleLabel->setText(QString::fromStdString(channelName));
|
||||
this->titleLabel->setText(channelName);
|
||||
this->tooltip = "";
|
||||
}
|
||||
}
|
||||
@@ -188,7 +191,7 @@ void SplitHeader::updateModerationModeIcon()
|
||||
bool modButtonVisible = false;
|
||||
ChannelPtr channel = this->split->getChannel();
|
||||
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(channel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (tc != nullptr && tc->hasModRights()) {
|
||||
modButtonVisible = true;
|
||||
@@ -268,7 +271,8 @@ void SplitHeader::menuReloadChannelEmotes()
|
||||
|
||||
void SplitHeader::menuManualReconnect()
|
||||
{
|
||||
singletons::IrcManager::getInstance().connect();
|
||||
// fourtf: connection
|
||||
providers::twitch::TwitchServer::getInstance().connect();
|
||||
}
|
||||
|
||||
void SplitHeader::menuShowChangelog()
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace widgets {
|
||||
|
||||
Notebook::Notebook(Window *parent, bool _showButtons, const std::string &settingPrefix)
|
||||
: BaseWidget(parent)
|
||||
, parentWindow(parent)
|
||||
, settingRoot(fS("{}/notebook", settingPrefix))
|
||||
, parentWindow(parent)
|
||||
, addButton(this)
|
||||
, settingsButton(this)
|
||||
, userButton(this)
|
||||
|
||||
+16
-21
@@ -1,10 +1,12 @@
|
||||
#include "widgets/split.hpp"
|
||||
#include "providers/twitch/emotevalue.hpp"
|
||||
#include "providers/twitch/twitchchannel.hpp"
|
||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||
#include "providers/twitch/twitchserver.hpp"
|
||||
#include "singletons/channelmanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "singletons/windowmanager.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
#include "twitch/twitchmessagebuilder.hpp"
|
||||
#include "util/urlfetch.hpp"
|
||||
#include "widgets/helper/searchpopup.hpp"
|
||||
#include "widgets/helper/shortcut.hpp"
|
||||
@@ -34,6 +36,7 @@
|
||||
#include <functional>
|
||||
#include <random>
|
||||
|
||||
using namespace chatterino::providers::twitch;
|
||||
using namespace chatterino::messages;
|
||||
|
||||
namespace chatterino {
|
||||
@@ -45,7 +48,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||
, settingRoot(fS("/splits/{}", this->uuid))
|
||||
, channelName(fS("{}/channelName", this->settingRoot))
|
||||
, parentPage(*parent)
|
||||
, channel(singletons::ChannelManager::getInstance().emptyChannel)
|
||||
, channel(Channel::getEmpty())
|
||||
, vbox(this)
|
||||
, header(this)
|
||||
, view(this)
|
||||
@@ -122,7 +125,6 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||
|
||||
Split::~Split()
|
||||
{
|
||||
this->channelNameUpdated("");
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->channelIDChangedConnection.disconnect();
|
||||
}
|
||||
@@ -150,7 +152,7 @@ void Split::setChannel(ChannelPtr _newChannel)
|
||||
|
||||
this->channel = _newChannel;
|
||||
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_newChannel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_newChannel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
this->usermodeChangedConnection =
|
||||
@@ -198,20 +200,13 @@ bool Split::getModerationMode() const
|
||||
return this->moderationMode;
|
||||
}
|
||||
|
||||
void Split::channelNameUpdated(const std::string &newChannelName)
|
||||
void Split::channelNameUpdated(const QString &newChannelName)
|
||||
{
|
||||
auto &cman = singletons::ChannelManager::getInstance();
|
||||
|
||||
// remove current channel
|
||||
if (!this->channel->isEmpty()) {
|
||||
cman.removeTwitchChannel(this->channel->name);
|
||||
}
|
||||
|
||||
// update messages
|
||||
if (newChannelName.empty()) {
|
||||
this->setChannel(cman.emptyChannel);
|
||||
if (newChannelName.isEmpty()) {
|
||||
this->setChannel(Channel::getEmpty());
|
||||
} else {
|
||||
this->setChannel(cman.addTwitchChannel(QString::fromStdString(newChannelName)));
|
||||
this->setChannel(TwitchServer::getInstance().addChannel(newChannelName));
|
||||
}
|
||||
|
||||
// update header
|
||||
@@ -226,13 +221,13 @@ bool Split::showChangeChannelPopup(const char *dialogTitle, bool empty)
|
||||
dialog.setWindowTitle(dialogTitle);
|
||||
|
||||
if (!empty) {
|
||||
dialog.setText(QString::fromStdString(this->channelName));
|
||||
dialog.setText(this->channelName);
|
||||
}
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString newChannelName = dialog.getText().trimmed();
|
||||
|
||||
this->channelName = newChannelName.toStdString();
|
||||
this->channelName = newChannelName;
|
||||
this->parentPage.refreshTitle();
|
||||
|
||||
return true;
|
||||
@@ -355,7 +350,7 @@ void Split::doClearChat()
|
||||
void Split::doOpenChannel()
|
||||
{
|
||||
ChannelPtr _channel = this->channel;
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
QDesktopServices::openUrl("https://twitch.tv/" + tc->name);
|
||||
@@ -365,7 +360,7 @@ void Split::doOpenChannel()
|
||||
void Split::doOpenPopupPlayer()
|
||||
{
|
||||
ChannelPtr _channel = this->channel;
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
QDesktopServices::openUrl("https://player.twitch.tv/?channel=" + tc->name);
|
||||
@@ -379,7 +374,7 @@ void Split::doOpenStreamlink()
|
||||
preferredQuality = preferredQuality.toLower();
|
||||
// TODO(Confuseh): Default streamlink paths
|
||||
QString path = settings.streamlinkPath;
|
||||
QString channel = QString::fromStdString(this->channelName.getValue());
|
||||
QString channel = this->channelName.getValue();
|
||||
QFileInfo fileinfo = QFileInfo(path);
|
||||
|
||||
if (path.isEmpty()) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "messages/layouts/messagelayoutelement.hpp"
|
||||
#include "messages/limitedqueuesnapshot.hpp"
|
||||
#include "messages/messageelement.hpp"
|
||||
#include "util/serialize-custom.hpp"
|
||||
#include "widgets/basewidget.hpp"
|
||||
#include "widgets/helper/channelview.hpp"
|
||||
#include "widgets/helper/rippleeffectlabel.hpp"
|
||||
@@ -46,7 +47,7 @@ public:
|
||||
Split(SplitContainer *parent, const std::string &_uuid);
|
||||
virtual ~Split();
|
||||
|
||||
pajlada::Settings::Setting<std::string> channelName;
|
||||
pajlada::Settings::Setting<QString> channelName;
|
||||
boost::signals2::signal<void()> channelChanged;
|
||||
|
||||
ChannelView &getChannelView()
|
||||
@@ -99,7 +100,7 @@ private:
|
||||
|
||||
void setChannel(ChannelPtr newChannel);
|
||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||
void channelNameUpdated(const std::string &newChannelName);
|
||||
void channelNameUpdated(const QString &newChannelName);
|
||||
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -30,10 +30,9 @@ SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::s
|
||||
: BaseWidget(parent->themeManager, parent)
|
||||
, uuid(_uuid)
|
||||
, settingRoot(fS("/containers/{}", this->uuid))
|
||||
, chats(fS("{}/chats", this->settingRoot))
|
||||
, tab(_tab)
|
||||
, chats(fS("{}/chats", this->settingRoot))
|
||||
, dropPreview(this)
|
||||
, splits()
|
||||
{
|
||||
this->tab->page = this;
|
||||
|
||||
@@ -468,8 +467,7 @@ void SplitContainer::refreshTitle()
|
||||
bool first = true;
|
||||
|
||||
for (const auto &chatWidget : this->splits) {
|
||||
auto channelName = QString::fromStdString(chatWidget->channelName.getValue());
|
||||
|
||||
auto channelName = chatWidget->channelName.getValue();
|
||||
if (channelName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ Window::Window(const QString &windowName, singletons::ThemeManager &_themeManage
|
||||
, settingRoot(fS("/windows/{}", windowName))
|
||||
, windowGeometry(this->settingRoot)
|
||||
, dpi(this->getScale())
|
||||
, themeManager(_themeManager)
|
||||
, notebook(this, _isMainWindow, this->settingRoot)
|
||||
{
|
||||
singletons::AccountManager::getInstance().Twitch.currentUsername.connect(
|
||||
@@ -98,11 +97,11 @@ Window::Window(const QString &windowName, singletons::ThemeManager &_themeManage
|
||||
cheerMessages.emplace_back(R"(@badges=subscriber/3,premium/1;bits=1;color=#FF0000;display-name=kalvarenga;emotes=;id=4744d6f0-de1d-475d-a3ff-38647113265a;mod=0;room-id=11148817;subscriber=1;tmi-sent-ts=1515782860740;turbo=0;user-id=108393131;user-type= :kalvarenga!kalvarenga@kalvarenga.tmi.twitch.tv PRIVMSG #pajlada :trihard1)");
|
||||
// clang-format on
|
||||
|
||||
CreateWindowShortcut(this, "F5", [cheerMessages] {
|
||||
auto &ircManager = singletons::IrcManager::getInstance();
|
||||
static int index = 0;
|
||||
ircManager.addFakeMessage(cheerMessages[index++ % cheerMessages.size()]);
|
||||
});
|
||||
// CreateWindowShortcut(this, "F5", [cheerMessages] {
|
||||
// auto &ircManager = singletons::IrcManager::getInstance();
|
||||
// static int index = 0;
|
||||
// ircManager.addFakeMessage(cheerMessages[index++ % cheerMessages.size()]);
|
||||
// });
|
||||
}
|
||||
|
||||
void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||
|
||||
@@ -60,8 +60,6 @@ protected:
|
||||
virtual bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
singletons::ThemeManager &themeManager;
|
||||
|
||||
float dpi;
|
||||
|
||||
void loadGeometry();
|
||||
|
||||
Reference in New Issue
Block a user