refactored irc

This commit is contained in:
fourtf
2018-02-05 15:11:50 +01:00
parent 12b30eb2ed
commit b351c40d29
56 changed files with 1397 additions and 1154 deletions
+4 -2
View File
@@ -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);
}
}
+11 -5
View File
@@ -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)
+14 -10
View File
@@ -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()