Merge branch 'master' of https://github.com/fourtf/chatterino2
This commit is contained in:
@@ -19,11 +19,11 @@ ChannelManager::ChannelManager()
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<SharedChannel> ChannelManager::getItems()
|
||||
const std::vector<ChannelPtr> ChannelManager::getItems()
|
||||
{
|
||||
QMutexLocker locker(&this->channelsMutex);
|
||||
|
||||
std::vector<SharedChannel> items;
|
||||
std::vector<ChannelPtr> items;
|
||||
|
||||
for (auto &item : this->twitchChannels.values()) {
|
||||
items.push_back(std::get<0>(item));
|
||||
@@ -32,7 +32,7 @@ const std::vector<SharedChannel> ChannelManager::getItems()
|
||||
return items;
|
||||
}
|
||||
|
||||
SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName)
|
||||
ChannelPtr ChannelManager::addTwitchChannel(const QString &rawChannelName)
|
||||
{
|
||||
QString channelName = rawChannelName.toLower();
|
||||
|
||||
@@ -63,7 +63,7 @@ SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName)
|
||||
return std::get<0>(it.value());
|
||||
}
|
||||
|
||||
SharedChannel ChannelManager::getTwitchChannel(const QString &channel)
|
||||
ChannelPtr ChannelManager::getTwitchChannel(const QString &channel)
|
||||
{
|
||||
QMutexLocker locker(&this->channelsMutex);
|
||||
|
||||
@@ -128,7 +128,7 @@ const std::string &ChannelManager::getUserID(const std::string &username)
|
||||
return temporary;
|
||||
}
|
||||
|
||||
void ChannelManager::doOnAll(std::function<void(SharedChannel)> func)
|
||||
void ChannelManager::doOnAll(std::function<void(ChannelPtr)> func)
|
||||
{
|
||||
for (const auto &channel : this->twitchChannels) {
|
||||
func(std::get<0>(channel));
|
||||
|
||||
@@ -17,20 +17,20 @@ class ChannelManager
|
||||
public:
|
||||
static ChannelManager &getInstance();
|
||||
|
||||
const std::vector<SharedChannel> getItems();
|
||||
const std::vector<ChannelPtr> getItems();
|
||||
|
||||
SharedChannel addTwitchChannel(const QString &channel);
|
||||
SharedChannel getTwitchChannel(const QString &channel);
|
||||
ChannelPtr addTwitchChannel(const QString &channel);
|
||||
ChannelPtr getTwitchChannel(const QString &channel);
|
||||
void removeTwitchChannel(const QString &channel);
|
||||
|
||||
const std::string &getUserID(const std::string &username);
|
||||
|
||||
void doOnAll(std::function<void(SharedChannel)> func);
|
||||
void doOnAll(std::function<void(ChannelPtr)> func);
|
||||
|
||||
// Special channels
|
||||
const SharedChannel whispersChannel;
|
||||
const SharedChannel mentionsChannel;
|
||||
const SharedChannel emptyChannel;
|
||||
const ChannelPtr whispersChannel;
|
||||
const ChannelPtr mentionsChannel;
|
||||
const ChannelPtr emptyChannel;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> usernameToID;
|
||||
|
||||
@@ -88,7 +88,7 @@ QStringList CommandManager::getCommands()
|
||||
return this->commandsStringList;
|
||||
}
|
||||
|
||||
QString CommandManager::execCommand(const QString &text, SharedChannel channel,
|
||||
QString CommandManager::execCommand(const QString &text, ChannelPtr channel,
|
||||
bool dryRun)
|
||||
{
|
||||
QStringList words = text.split(' ', QString::SkipEmptyParts);
|
||||
|
||||
@@ -246,16 +246,23 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||
return;
|
||||
}
|
||||
|
||||
auto xd = message->content();
|
||||
auto xd2 = message->toData();
|
||||
// auto xd = message->content();
|
||||
// auto xd2 = message->toData();
|
||||
|
||||
debug::Log("HEHE: {}", xd2.toStdString());
|
||||
// debug::Log("HEHE: {}", xd2.toStdString());
|
||||
|
||||
messages::MessageParseArgs args;
|
||||
|
||||
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
||||
|
||||
c->addMessage(builder.parse());
|
||||
if (!builder.isIgnored()) {
|
||||
messages::MessagePtr _message = builder.build();
|
||||
if (_message->flags & messages::Message::Highlighted) {
|
||||
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(_message);
|
||||
}
|
||||
|
||||
c->addMessage(_message);
|
||||
}
|
||||
}
|
||||
|
||||
void IrcManager::messageReceived(Communi::IrcMessage *message)
|
||||
@@ -384,7 +391,7 @@ void IrcManager::onConnected()
|
||||
MessagePtr connMsg = Message::createSystemMessage("connected to chat");
|
||||
MessagePtr reconnMsg = Message::createSystemMessage("reconnected to chat");
|
||||
|
||||
this->channelManager.doOnAll([connMsg, reconnMsg](SharedChannel channel) {
|
||||
this->channelManager.doOnAll([connMsg, reconnMsg](ChannelPtr channel) {
|
||||
assert(channel);
|
||||
|
||||
LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot();
|
||||
@@ -407,7 +414,7 @@ void IrcManager::onDisconnected()
|
||||
MessagePtr msg = Message::createSystemMessage("disconnected from chat");
|
||||
msg->flags &= Message::DisconnectedMessage;
|
||||
|
||||
this->channelManager.doOnAll([msg](SharedChannel channel) {
|
||||
this->channelManager.doOnAll([msg](ChannelPtr channel) {
|
||||
assert(channel);
|
||||
channel->addMessage(msg);
|
||||
});
|
||||
|
||||
@@ -345,7 +345,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
||||
QString cheermoteURL = "https://api.twitch.tv/kraken/bits/actions?channel_id=" + roomID;
|
||||
|
||||
util::twitch::get2(
|
||||
cheermoteURL, QThread::currentThread(), [this, roomID](const rapidjson::Document &d) {
|
||||
cheermoteURL, QThread::currentThread(), true, [this, roomID](const rapidjson::Document &d) {
|
||||
ResourceManager::Channel &ch = this->channels[roomID];
|
||||
|
||||
ParseCheermoteSets(ch.jsonCheermoteSets, d);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "debug/log.hpp"
|
||||
#include "singletons/pathmanager.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
#include "singletons/windowmanager.hpp"
|
||||
|
||||
using namespace chatterino::messages;
|
||||
|
||||
@@ -17,6 +18,7 @@ void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
||||
|
||||
SettingManager::SettingManager()
|
||||
: snapshot(nullptr)
|
||||
, _ignoredKeywords(new std::vector<QString>)
|
||||
{
|
||||
this->wordFlagsListener.addSetting(this->showTimestamps);
|
||||
this->wordFlagsListener.addSetting(this->showBadges);
|
||||
@@ -29,6 +31,10 @@ SettingManager::SettingManager()
|
||||
};
|
||||
|
||||
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
||||
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
||||
|
||||
this->timestampFormat.connect(
|
||||
[](auto, auto) { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); });
|
||||
}
|
||||
|
||||
MessageElement::Flags SettingManager::getWordFlags()
|
||||
@@ -135,6 +141,11 @@ std::vector<ModerationAction> SettingManager::getModerationActions() const
|
||||
return this->_moderationActions;
|
||||
}
|
||||
|
||||
const std::shared_ptr<std::vector<QString>> SettingManager::getIgnoredKeywords() const
|
||||
{
|
||||
return this->_ignoredKeywords;
|
||||
}
|
||||
|
||||
void SettingManager::updateModerationActions()
|
||||
{
|
||||
auto &resources = singletons::ResourceManager::getInstance();
|
||||
@@ -202,5 +213,22 @@ void SettingManager::updateModerationActions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingManager::updateIgnoredKeywords()
|
||||
{
|
||||
static QRegularExpression newLineRegex("(\r\n?|\n)+");
|
||||
|
||||
auto items = new std::vector<QString>();
|
||||
|
||||
for (const QString &line : this->ignoredKeywords.getValue().split(newLineRegex)) {
|
||||
QString line2 = line.trimmed();
|
||||
|
||||
if (!line2.isEmpty()) {
|
||||
items->push_back(line2);
|
||||
}
|
||||
}
|
||||
|
||||
this->_ignoredKeywords = std::shared_ptr<std::vector<QString>>(items);
|
||||
}
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -75,6 +75,10 @@ public:
|
||||
/// Links
|
||||
BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false};
|
||||
|
||||
/// Ingored Users
|
||||
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true};
|
||||
QStringSetting ignoredKeywords = {"/ignore/ignoredKeywords", ""};
|
||||
|
||||
/// Moderation
|
||||
QStringSetting moderationActions = {"/moderation/actions", "/ban {user}\n/timeout {user} 300"};
|
||||
|
||||
@@ -107,6 +111,7 @@ public:
|
||||
void recallSnapshot();
|
||||
|
||||
std::vector<ModerationAction> getModerationActions() const;
|
||||
const std::shared_ptr<std::vector<QString>> getIgnoredKeywords() const;
|
||||
|
||||
signals:
|
||||
void wordFlagsChanged();
|
||||
@@ -114,10 +119,12 @@ signals:
|
||||
private:
|
||||
std::vector<ModerationAction> _moderationActions;
|
||||
std::unique_ptr<rapidjson::Document> snapshot;
|
||||
std::shared_ptr<std::vector<QString>> _ignoredKeywords;
|
||||
|
||||
SettingManager();
|
||||
|
||||
void updateModerationActions();
|
||||
void updateIgnoredKeywords();
|
||||
|
||||
messages::MessageElement::Flags wordFlags = messages::MessageElement::Default;
|
||||
|
||||
|
||||
@@ -59,24 +59,23 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||
QColor themeColor = QColor::fromHslF(hue, 0.5, 0.5);
|
||||
QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5);
|
||||
|
||||
//#ifdef USEWINSDK
|
||||
// isLightTabs = isLight;
|
||||
// QColor tabFg = isLight ? "#000" : "#fff";
|
||||
// this->windowBg = isLight ? "#fff" : "#444";
|
||||
|
||||
//#else
|
||||
isLightTabs = true;
|
||||
QColor tabFg = isLightTabs ? "#000" : "#fff";
|
||||
this->windowBg = "#fff";
|
||||
|
||||
//#endif
|
||||
|
||||
qreal sat = 0.05;
|
||||
qreal sat = 0.1;
|
||||
// 0.05;
|
||||
|
||||
auto getColor = [multiplier](double h, double s, double l, double a = 1.0) {
|
||||
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
|
||||
};
|
||||
|
||||
//#ifdef USEWINSDK
|
||||
// isLightTabs = isLight;
|
||||
// QColor tabFg = isLight ? "#000" : "#fff";
|
||||
// this->windowBg = isLight ? "#fff" : getColor(0, sat, 0.9);
|
||||
//#else
|
||||
isLightTabs = true;
|
||||
QColor tabFg = isLightTabs ? "#000" : "#fff";
|
||||
this->windowBg = "#fff";
|
||||
//#endif
|
||||
|
||||
// Ubuntu style
|
||||
// TODO: add setting for this
|
||||
// TabText = QColor(210, 210, 210);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "debug/log.hpp"
|
||||
#include "singletons/fontmanager.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "widgets/accountswitchpopupwidget.hpp"
|
||||
#include "widgets/settingsdialog.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -14,6 +16,35 @@ WindowManager &WindowManager::getInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
void WindowManager::showSettingsDialog()
|
||||
{
|
||||
QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); });
|
||||
}
|
||||
|
||||
void WindowManager::showAccountSelectPopup(QPoint point)
|
||||
{
|
||||
// static QWidget *lastFocusedWidget = nullptr;
|
||||
static widgets::AccountSwitchPopupWidget *w = new widgets::AccountSwitchPopupWidget();
|
||||
|
||||
if (w->hasFocus()) {
|
||||
w->hide();
|
||||
// if (lastFocusedWidget) {
|
||||
// lastFocusedWidget->setFocus();
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// lastFocusedWidget = this->focusWidget();
|
||||
|
||||
w->refresh();
|
||||
|
||||
QPoint buttonPos = point;
|
||||
w->move(buttonPos.x(), buttonPos.y());
|
||||
|
||||
w->show();
|
||||
w->setFocus();
|
||||
}
|
||||
|
||||
WindowManager::WindowManager(ThemeManager &_themeManager)
|
||||
: themeManager(_themeManager)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,9 @@ class WindowManager
|
||||
public:
|
||||
static WindowManager &getInstance();
|
||||
|
||||
void showSettingsDialog();
|
||||
void showAccountSelectPopup(QPoint point);
|
||||
|
||||
void initMainWindow();
|
||||
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user