mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixes #225 fix am/pm for timestamps
This commit is contained in:
parent
4ddb4616ee
commit
f3357cf0f4
|
@ -220,7 +220,10 @@ void TimestampElement::addToContainer(MessageLayoutContainer &container,
|
||||||
|
|
||||||
TextElement *TimestampElement::formatTime(const QTime &time)
|
TextElement *TimestampElement::formatTime(const QTime &time)
|
||||||
{
|
{
|
||||||
QString format = time.toString(singletons::SettingManager::getInstance().timestampFormat);
|
static QLocale locale("en_US");
|
||||||
|
|
||||||
|
QString format =
|
||||||
|
locale.toString(time, singletons::SettingManager::getInstance().timestampFormat);
|
||||||
|
|
||||||
return new TextElement(format, Flags::Timestamp, MessageColor::System, FontStyle::Medium);
|
return new TextElement(format, Flags::Timestamp, MessageColor::System, FontStyle::Medium);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,18 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
QVariant _mod = message->tag("mod");
|
||||||
|
|
||||||
|
if (_mod.isValid()) {
|
||||||
|
auto rawChannelName = message->parameters().at(0);
|
||||||
|
auto trimmedChannelName = rawChannelName.mid(1);
|
||||||
|
|
||||||
|
auto c = this->channelManager.getTwitchChannel(trimmedChannelName);
|
||||||
|
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(c.get());
|
||||||
|
if (tc != nullptr) {
|
||||||
|
tc->setMod(_mod == "1");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||||
|
|
|
@ -188,6 +188,8 @@ void IrcManager::beginConnecting()
|
||||||
|
|
||||||
this->writeConnection->open();
|
this->writeConnection->open();
|
||||||
this->readConnection->open();
|
this->readConnection->open();
|
||||||
|
|
||||||
|
this->connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcManager::disconnect()
|
void IrcManager::disconnect()
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
|
|
||||||
pajlada::Signals::Signal<Communi::IrcPrivateMessage *> onPrivateMessage;
|
pajlada::Signals::Signal<Communi::IrcPrivateMessage *> onPrivateMessage;
|
||||||
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
||||||
|
boost::signals2::signal<void()> connected;
|
||||||
|
|
||||||
Communi::IrcConnection *getReadConnection();
|
Communi::IrcConnection *getReadConnection();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "twitchchannel.hpp"
|
#include "twitchchannel.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitch/twitchmessagebuilder.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ TwitchChannel::TwitchChannel(const QString &channelName)
|
||||||
, channelURL("https://twitch.tv/" + name)
|
, channelURL("https://twitch.tv/" + name)
|
||||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
||||||
, isLive(false)
|
, isLive(false)
|
||||||
|
, mod(false)
|
||||||
{
|
{
|
||||||
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
||||||
|
|
||||||
|
@ -36,10 +38,15 @@ TwitchChannel::TwitchChannel(const QString &channelName)
|
||||||
this->fetchMessages.connect([this] {
|
this->fetchMessages.connect([this] {
|
||||||
this->fetchRecentMessages(); //
|
this->fetchRecentMessages(); //
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this->connectedConnection = singletons::IrcManager::getInstance().connected.connect(
|
||||||
|
[this] { this->userStateChanged(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchChannel::~TwitchChannel()
|
TwitchChannel::~TwitchChannel()
|
||||||
{
|
{
|
||||||
|
this->connectedConnection.disconnect();
|
||||||
|
|
||||||
this->liveStatusTimer->stop();
|
this->liveStatusTimer->stop();
|
||||||
this->liveStatusTimer->deleteLater();
|
this->liveStatusTimer->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -88,9 +95,24 @@ bool TwitchChannel::isMod()
|
||||||
return this->mod;
|
return this->mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwitchChannel::setMod(bool value)
|
||||||
|
{
|
||||||
|
if (this->mod != value) {
|
||||||
|
this->mod = value;
|
||||||
|
|
||||||
|
this->userStateChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TwitchChannel::isBroadcaster()
|
bool TwitchChannel::isBroadcaster()
|
||||||
{
|
{
|
||||||
return this->name == singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserId();
|
QString xD = this->name;
|
||||||
|
QString xD2 = singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName();
|
||||||
|
|
||||||
|
qDebug() << xD << xD2;
|
||||||
|
|
||||||
|
return this->name ==
|
||||||
|
singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchChannel::hasModRights()
|
bool TwitchChannel::hasModRights()
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
void sendMessage(const QString &message) override;
|
void sendMessage(const QString &message) override;
|
||||||
|
|
||||||
bool isMod();
|
bool isMod();
|
||||||
|
void setMod(bool value);
|
||||||
bool isBroadcaster();
|
bool isBroadcaster();
|
||||||
bool hasModRights();
|
bool hasModRights();
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public:
|
||||||
boost::signals2::signal<void()> onlineStatusChanged;
|
boost::signals2::signal<void()> onlineStatusChanged;
|
||||||
|
|
||||||
pajlada::Signals::NoArgBoltSignal fetchMessages;
|
pajlada::Signals::NoArgBoltSignal fetchMessages;
|
||||||
pajlada::Signals::NoArgSignal userStateChanged;
|
boost::signals2::signal<void()> userStateChanged;
|
||||||
|
|
||||||
QString roomID;
|
QString roomID;
|
||||||
bool isLive;
|
bool isLive;
|
||||||
|
@ -53,6 +54,8 @@ private:
|
||||||
|
|
||||||
void fetchRecentMessages();
|
void fetchRecentMessages();
|
||||||
|
|
||||||
|
boost::signals2::connection connectedConnection;
|
||||||
|
|
||||||
bool mod;
|
bool mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,16 @@ void SplitHeader::updateModerationModeIcon()
|
||||||
? resourceManager.moderationmode_enabled->getPixmap()
|
? resourceManager.moderationmode_enabled->getPixmap()
|
||||||
: resourceManager.moderationmode_disabled->getPixmap());
|
: resourceManager.moderationmode_disabled->getPixmap());
|
||||||
|
|
||||||
// this->moderationButton->setVisible(this->split->channel->hasModRights());
|
bool modButtonVisible = false;
|
||||||
|
SharedChannel channel = this->split->getChannel();
|
||||||
|
|
||||||
|
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(channel.get());
|
||||||
|
|
||||||
|
if (tc != nullptr && tc->hasModRights()) {
|
||||||
|
modButtonVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->moderationButton->setVisible(modButtonVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::paintEvent(QPaintEvent *)
|
void SplitHeader::paintEvent(QPaintEvent *)
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <boost/signals2/connection.hpp>
|
#include <boost/signals2/connection.hpp>
|
||||||
|
#include <pajlada/settings/setting.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
#define SCROLL_SMOOTH "Enable smooth scrolling"
|
#define SCROLL_SMOOTH "Enable smooth scrolling"
|
||||||
#define SCROLL_NEWMSG "Enable smooth scrolling for new messages"
|
#define SCROLL_NEWMSG "Enable smooth scrolling for new messages"
|
||||||
|
|
||||||
#define TIMESTAMP_FORMATS "hh:mm a", "h:mm a", "HH:mm", "H:mm"
|
// clang-format off
|
||||||
|
#define TIMESTAMP_FORMATS "hh:mm a", "h:mm a", "hh:mm:ss a", "h:mm:ss a", "HH:mm", "H:mm", "HH:mm:ss", "H:mm:ss"
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -55,7 +57,7 @@ AppearancePage::AppearancePage()
|
||||||
messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps));
|
messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps));
|
||||||
auto tbox = messages.emplace<QHBoxLayout>();
|
auto tbox = messages.emplace<QHBoxLayout>();
|
||||||
{
|
{
|
||||||
tbox.emplace<QLabel>("timestamp format:");
|
tbox.emplace<QLabel>("timestamp format (a = am/pm):");
|
||||||
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat));
|
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat));
|
||||||
}
|
}
|
||||||
messages.append(this->createCheckBox("Show badges", settings.showBadges));
|
messages.append(this->createCheckBox("Show badges", settings.showBadges));
|
||||||
|
|
|
@ -27,9 +27,7 @@ ModerationPage::ModerationPage()
|
||||||
|
|
||||||
auto text = layout.emplace<QTextEdit>().getElement();
|
auto text = layout.emplace<QTextEdit>().getElement();
|
||||||
|
|
||||||
settings.moderationActions.connect([=](const QString &str, auto) {
|
text->setPlainText(settings.moderationActions);
|
||||||
text->setPlainText(str); //
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(text, &QTextEdit::textChanged, this,
|
QObject::connect(text, &QTextEdit::textChanged, this,
|
||||||
[this] { this->itemsChangedTimer.start(200); });
|
[this] { this->itemsChangedTimer.start(200); });
|
||||||
|
|
|
@ -123,6 +123,8 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
Split::~Split()
|
Split::~Split()
|
||||||
{
|
{
|
||||||
this->channelNameUpdated("");
|
this->channelNameUpdated("");
|
||||||
|
this->usermodeChangedConnection.disconnect();
|
||||||
|
this->channelIDChangedConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &Split::getUUID() const
|
const std::string &Split::getUUID() const
|
||||||
|
@ -144,8 +146,19 @@ void Split::setChannel(SharedChannel _newChannel)
|
||||||
{
|
{
|
||||||
this->view.setChannel(_newChannel);
|
this->view.setChannel(_newChannel);
|
||||||
|
|
||||||
|
this->usermodeChangedConnection.disconnect();
|
||||||
|
|
||||||
this->channel = _newChannel;
|
this->channel = _newChannel;
|
||||||
|
|
||||||
|
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_newChannel.get());
|
||||||
|
|
||||||
|
if (tc != nullptr) {
|
||||||
|
this->usermodeChangedConnection =
|
||||||
|
tc->userStateChanged.connect([this] { this->header.updateModerationModeIcon(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
this->header.updateModerationModeIcon();
|
||||||
|
|
||||||
this->channelChanged();
|
this->channelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Split : public BaseWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Split(SplitContainer *parent, const std::string &_uuid);
|
Split(SplitContainer *parent, const std::string &_uuid);
|
||||||
~Split();
|
virtual ~Split();
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> channelName;
|
pajlada::Settings::Setting<std::string> channelName;
|
||||||
boost::signals2::signal<void()> channelChanged;
|
boost::signals2::signal<void()> channelChanged;
|
||||||
|
@ -94,6 +94,7 @@ private:
|
||||||
bool moderationMode;
|
bool moderationMode;
|
||||||
|
|
||||||
boost::signals2::connection channelIDChangedConnection;
|
boost::signals2::connection channelIDChangedConnection;
|
||||||
|
boost::signals2::connection usermodeChangedConnection;
|
||||||
|
|
||||||
void setChannel(SharedChannel newChannel);
|
void setChannel(SharedChannel newChannel);
|
||||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||||
|
|
Loading…
Reference in a new issue