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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,18 @@ void IrcMessageHandler::handleClearChatMessage(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)
|
||||
|
|
|
@ -188,6 +188,8 @@ void IrcManager::beginConnecting()
|
|||
|
||||
this->writeConnection->open();
|
||||
this->readConnection->open();
|
||||
|
||||
this->connected();
|
||||
}
|
||||
|
||||
void IrcManager::disconnect()
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
pajlada::Signals::Signal<Communi::IrcPrivateMessage *> onPrivateMessage;
|
||||
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
||||
boost::signals2::signal<void()> connected;
|
||||
|
||||
Communi::IrcConnection *getReadConnection();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "twitchchannel.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "twitch/twitchmessagebuilder.hpp"
|
||||
#include "util/urlfetch.hpp"
|
||||
|
||||
|
@ -18,6 +19,7 @@ TwitchChannel::TwitchChannel(const QString &channelName)
|
|||
, channelURL("https://twitch.tv/" + name)
|
||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
||||
, isLive(false)
|
||||
, mod(false)
|
||||
{
|
||||
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
||||
|
||||
|
@ -36,10 +38,15 @@ TwitchChannel::TwitchChannel(const QString &channelName)
|
|||
this->fetchMessages.connect([this] {
|
||||
this->fetchRecentMessages(); //
|
||||
});
|
||||
|
||||
this->connectedConnection = singletons::IrcManager::getInstance().connected.connect(
|
||||
[this] { this->userStateChanged(); });
|
||||
}
|
||||
|
||||
TwitchChannel::~TwitchChannel()
|
||||
{
|
||||
this->connectedConnection.disconnect();
|
||||
|
||||
this->liveStatusTimer->stop();
|
||||
this->liveStatusTimer->deleteLater();
|
||||
}
|
||||
|
@ -88,9 +95,24 @@ bool TwitchChannel::isMod()
|
|||
return this->mod;
|
||||
}
|
||||
|
||||
void TwitchChannel::setMod(bool value)
|
||||
{
|
||||
if (this->mod != value) {
|
||||
this->mod = value;
|
||||
|
||||
this->userStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
void sendMessage(const QString &message) override;
|
||||
|
||||
bool isMod();
|
||||
void setMod(bool value);
|
||||
bool isBroadcaster();
|
||||
bool hasModRights();
|
||||
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
boost::signals2::signal<void()> onlineStatusChanged;
|
||||
|
||||
pajlada::Signals::NoArgBoltSignal fetchMessages;
|
||||
pajlada::Signals::NoArgSignal userStateChanged;
|
||||
boost::signals2::signal<void()> userStateChanged;
|
||||
|
||||
QString roomID;
|
||||
bool isLive;
|
||||
|
@ -53,6 +54,8 @@ private:
|
|||
|
||||
void fetchRecentMessages();
|
||||
|
||||
boost::signals2::connection connectedConnection;
|
||||
|
||||
bool mod;
|
||||
};
|
||||
|
||||
|
|
|
@ -161,7 +161,16 @@ void SplitHeader::updateModerationModeIcon()
|
|||
? resourceManager.moderationmode_enabled->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 *)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#define SCROLL_SMOOTH "Enable smooth scrolling"
|
||||
#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 widgets {
|
||||
|
@ -55,7 +57,7 @@ AppearancePage::AppearancePage()
|
|||
messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps));
|
||||
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));
|
||||
}
|
||||
messages.append(this->createCheckBox("Show badges", settings.showBadges));
|
||||
|
|
|
@ -27,9 +27,7 @@ ModerationPage::ModerationPage()
|
|||
|
||||
auto text = layout.emplace<QTextEdit>().getElement();
|
||||
|
||||
settings.moderationActions.connect([=](const QString &str, auto) {
|
||||
text->setPlainText(str); //
|
||||
});
|
||||
text->setPlainText(settings.moderationActions);
|
||||
|
||||
QObject::connect(text, &QTextEdit::textChanged, this,
|
||||
[this] { this->itemsChangedTimer.start(200); });
|
||||
|
|
|
@ -123,6 +123,8 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
|||
Split::~Split()
|
||||
{
|
||||
this->channelNameUpdated("");
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->channelIDChangedConnection.disconnect();
|
||||
}
|
||||
|
||||
const std::string &Split::getUUID() const
|
||||
|
@ -144,8 +146,19 @@ void Split::setChannel(SharedChannel _newChannel)
|
|||
{
|
||||
this->view.setChannel(_newChannel);
|
||||
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Split : public BaseWidget
|
|||
|
||||
public:
|
||||
Split(SplitContainer *parent, const std::string &_uuid);
|
||||
~Split();
|
||||
virtual ~Split();
|
||||
|
||||
pajlada::Settings::Setting<std::string> channelName;
|
||||
boost::signals2::signal<void()> channelChanged;
|
||||
|
@ -94,6 +94,7 @@ private:
|
|||
bool moderationMode;
|
||||
|
||||
boost::signals2::connection channelIDChangedConnection;
|
||||
boost::signals2::connection usermodeChangedConnection;
|
||||
|
||||
void setChannel(SharedChannel newChannel);
|
||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||
|
|
Loading…
Reference in a new issue