Merge branch 'master' into apa-notification-on-live
This commit is contained in:
@@ -61,9 +61,9 @@ protected:
|
||||
|
||||
private:
|
||||
struct Item {
|
||||
NotebookTab *tab;
|
||||
QWidget *page;
|
||||
QWidget *selectedWidget = nullptr;
|
||||
NotebookTab *tab{};
|
||||
QWidget *page{};
|
||||
QWidget *selectedWidget{};
|
||||
};
|
||||
|
||||
bool containsPage(QWidget *page);
|
||||
|
||||
@@ -55,6 +55,11 @@ void Scrollbar::unpauseHighlights()
|
||||
this->highlightsPaused_ = false;
|
||||
}
|
||||
|
||||
void Scrollbar::clearHighlights()
|
||||
{
|
||||
this->highlights_.clear();
|
||||
}
|
||||
|
||||
LimitedQueueSnapshot<ScrollbarHighlight> Scrollbar::getHighlightSnapshot()
|
||||
{
|
||||
if (!this->highlightsPaused_) {
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
|
||||
void pauseHighlights();
|
||||
void unpauseHighlights();
|
||||
void clearHighlights();
|
||||
|
||||
void scrollToBottom(bool animate = false);
|
||||
bool isAtBottom() const;
|
||||
|
||||
@@ -87,6 +87,11 @@ void TooltipWidget::setText(QString text)
|
||||
this->displayText_->setText(text);
|
||||
}
|
||||
|
||||
void TooltipWidget::setWordWrap(bool wrap)
|
||||
{
|
||||
this->displayText_->setWordWrap(wrap);
|
||||
}
|
||||
|
||||
void TooltipWidget::changeEvent(QEvent *)
|
||||
{
|
||||
// clear parents event
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
virtual ~TooltipWidget() override;
|
||||
|
||||
void setText(QString text);
|
||||
void setWordWrap(bool wrap);
|
||||
|
||||
#ifdef USEWINSDK
|
||||
void raise();
|
||||
|
||||
@@ -41,7 +41,8 @@ Window::Window(WindowType type)
|
||||
this->addShortcuts();
|
||||
this->addLayout();
|
||||
|
||||
getApp()->accounts->twitch.currentUserChanged.connect(
|
||||
this->signalHolder_.managedConnect(
|
||||
getApp()->accounts->twitch.currentUserChanged,
|
||||
[this] { this->onAccountSelected(); });
|
||||
this->onAccountSelected();
|
||||
|
||||
|
||||
@@ -29,11 +29,17 @@ namespace {
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
for (const auto &emote : map) {
|
||||
builder
|
||||
.emplace<EmoteElement>(emote.second,
|
||||
MessageElementFlag::AlwaysShow)
|
||||
->setLink(Link(Link::InsertText, emote.first.string));
|
||||
if (!map.empty()) {
|
||||
for (const auto &emote : map) {
|
||||
builder
|
||||
.emplace<EmoteElement>(emote.second,
|
||||
MessageElementFlag::AlwaysShow)
|
||||
->setLink(Link(Link::InsertText, emote.first.string));
|
||||
}
|
||||
} else {
|
||||
builder.emplace<TextElement>("no emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
|
||||
return builder.release();
|
||||
@@ -106,7 +112,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
{
|
||||
BenchmarkGuard guard("loadChannel");
|
||||
|
||||
this->setWindowTitle("Emotes from " + _channel->getName());
|
||||
this->setWindowTitle("Emotes in #" + _channel->getName());
|
||||
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
if (twitchChannel == nullptr) return;
|
||||
@@ -139,6 +145,16 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
this->globalEmotesView_->setChannel(globalChannel);
|
||||
this->subEmotesView_->setChannel(subChannel);
|
||||
this->channelEmotesView_->setChannel(channelChannel);
|
||||
|
||||
if (subChannel->getMessageSnapshot().getLength() == 0) {
|
||||
MessageBuilder builder;
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
builder.emplace<TextElement>("no subscription emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
subChannel->addMessage(builder.release());
|
||||
}
|
||||
}
|
||||
|
||||
void EmotePopup::loadEmojis()
|
||||
|
||||
@@ -35,6 +35,7 @@ SettingsDialog::SettingsDialog()
|
||||
this->scaleChangedEvent(this->getScale());
|
||||
|
||||
this->overrideBackgroundColor_ = QColor("#282828");
|
||||
this->themeChangedEvent();
|
||||
}
|
||||
|
||||
void SettingsDialog::initUi()
|
||||
@@ -187,7 +188,7 @@ void SettingsDialog::themeChangedEvent()
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor("#444"));
|
||||
palette.setColor(QPalette::Background, QColor("#222"));
|
||||
this->setPalette(palette);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,18 @@ bool Button::getEnable() const
|
||||
return this->enabled_;
|
||||
}
|
||||
|
||||
void Button::setEnableMargin(bool value)
|
||||
{
|
||||
this->enableMargin_ = value;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
bool Button::getEnableMargin() const
|
||||
{
|
||||
return this->enableMargin_;
|
||||
}
|
||||
|
||||
qreal Button::getCurrentDimAmount() const
|
||||
{
|
||||
return this->dimPixmap_ && !this->mouseOver_ ? 0.7 : 1;
|
||||
@@ -105,7 +117,7 @@ void Button::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
QRect rect = this->rect();
|
||||
int s = int(6 * this->getScale());
|
||||
int s = this->enableMargin_ ? int(6 * this->getScale()) : 0;
|
||||
|
||||
rect.moveLeft(s);
|
||||
rect.setRight(rect.right() - s - s);
|
||||
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
void setEnable(bool value);
|
||||
bool getEnable() const;
|
||||
|
||||
void setEnableMargin(bool value);
|
||||
bool getEnableMargin() const;
|
||||
|
||||
void setBorderColor(const QColor &color);
|
||||
const QColor &getBorderColor() const;
|
||||
|
||||
@@ -73,6 +76,7 @@ private:
|
||||
QColor borderColor_{};
|
||||
QPixmap pixmap_{};
|
||||
bool dimPixmap_{true};
|
||||
bool enableMargin_{true};
|
||||
QPoint mousePos_{};
|
||||
double hoverMultiplier_{0.0};
|
||||
QTimer effectTimer_{};
|
||||
|
||||
@@ -305,6 +305,7 @@ void ChannelView::clearMessages()
|
||||
{
|
||||
// Clear all stored messages in this chat widget
|
||||
this->messages.clear();
|
||||
this->scrollBar_->clearHighlights();
|
||||
|
||||
// Layout chat widget messages, and force an update regardless if there are
|
||||
// no messages
|
||||
@@ -870,11 +871,15 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
const auto &tooltip = hoverLayoutElement->getCreator().getTooltip();
|
||||
bool isLinkValid = hoverLayoutElement->getLink().isValid();
|
||||
|
||||
if (tooltip.isEmpty()) {
|
||||
tooltipWidget->hide();
|
||||
} else if (isLinkValid && !getSettings()->enableLinkInfoTooltip) {
|
||||
tooltipWidget->hide();
|
||||
} else {
|
||||
tooltipWidget->moveTo(this, event->globalPos());
|
||||
tooltipWidget->setWordWrap(isLinkValid);
|
||||
tooltipWidget->setText(tooltip);
|
||||
tooltipWidget->adjustSize();
|
||||
tooltipWidget->show();
|
||||
@@ -882,7 +887,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
|
||||
// check if word has a link
|
||||
if (hoverLayoutElement->getLink().isValid()) {
|
||||
if (isLinkValid) {
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
} else {
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
|
||||
@@ -313,6 +313,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
if (this->shouldDrawXButton()) {
|
||||
QRect xRect = this->getXRect();
|
||||
if (!xRect.isNull()) {
|
||||
if (this->selected_) xRect.moveTop(xRect.top() - 1);
|
||||
|
||||
painter.setBrush(QColor("#fff"));
|
||||
|
||||
if (this->mouseOverX_) {
|
||||
@@ -474,7 +476,7 @@ QRect NotebookTab::getXRect()
|
||||
|
||||
float s = this->getScale();
|
||||
return QRect(this->width() - static_cast<int>(20 * s),
|
||||
static_cast<int>(6 * s), static_cast<int>(16 * s),
|
||||
static_cast<int>(9 * s), static_cast<int>(16 * s),
|
||||
static_cast<int>(16 * s));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,12 @@ FeelPage::FeelPage()
|
||||
form->addRow("Links:",
|
||||
this->createCheckBox("Open links only on double click",
|
||||
getSettings()->linksDoubleClickOnly));
|
||||
form->addRow("",
|
||||
this->createCheckBox("Show link info in tooltips",
|
||||
getSettings()->enableLinkInfoTooltip));
|
||||
form->addRow("",
|
||||
this->createCheckBox("Auto unshort links (requires restart)",
|
||||
getSettings()->enableUnshortLinks));
|
||||
}
|
||||
|
||||
layout->addSpacing(16);
|
||||
|
||||
@@ -41,6 +41,8 @@ KeyboardSettingsPage::KeyboardSettingsPage()
|
||||
form->addRow(new QLabel("Ctrl + R"), new QLabel("Change channel"));
|
||||
form->addRow(new QLabel("Ctrl + F"),
|
||||
new QLabel("Search in current channel"));
|
||||
form->addRow(new QLabel("Ctrl + E"),
|
||||
new QLabel("Open Emote menu"));
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -59,6 +59,7 @@ void LookPage::initializeUi()
|
||||
this->addMessageTab(tabs.appendTab(new QVBoxLayout, "Messages"));
|
||||
this->addEmoteTab(tabs.appendTab(new QVBoxLayout, "Emotes"));
|
||||
this->addSplitHeaderTab(tabs.appendTab(new QVBoxLayout, "Split header"));
|
||||
this->addBadgesTab(tabs.appendTab(new QVBoxLayout, "Badges"));
|
||||
|
||||
layout->addStretch(1);
|
||||
|
||||
@@ -145,10 +146,6 @@ void LookPage::addMessageTab(LayoutCreator<QVBoxLayout> layout)
|
||||
box->addStretch(1);
|
||||
}
|
||||
|
||||
// badges
|
||||
layout.append(
|
||||
this->createCheckBox("Show badges", getSettings()->showBadges));
|
||||
|
||||
// --
|
||||
layout.emplace<Line>(false);
|
||||
|
||||
@@ -270,16 +267,57 @@ void LookPage::addEmoteTab(LayoutCreator<QVBoxLayout> layout)
|
||||
|
||||
void LookPage::addSplitHeaderTab(LayoutCreator<QVBoxLayout> layout)
|
||||
{
|
||||
layout.append(this->createCheckBox("Show viewer count",
|
||||
getSettings()->showViewerCount));
|
||||
layout.append(this->createCheckBox("Show title", getSettings()->showTitle));
|
||||
layout.append(this->createCheckBox("Show game", getSettings()->showGame));
|
||||
layout.append(
|
||||
this->createCheckBox("Show uptime", getSettings()->showUptime));
|
||||
layout.append(this->createCheckBox("Show viewer count",
|
||||
getSettings()->showViewerCount));
|
||||
layout.append(this->createCheckBox("Show game", getSettings()->showGame));
|
||||
layout.append(this->createCheckBox("Show title", getSettings()->showTitle));
|
||||
|
||||
layout->addStretch(1);
|
||||
}
|
||||
|
||||
void LookPage::addBadgesTab(LayoutCreator<QVBoxLayout> layout)
|
||||
{
|
||||
// layout.append(
|
||||
// this->createCheckBox(("Show all badges"), getSettings()->showBadges));
|
||||
auto fastSelection = layout.emplace<QHBoxLayout>();
|
||||
{
|
||||
auto addAll = fastSelection.emplace<QPushButton>("Enable all");
|
||||
QObject::connect(addAll.getElement(), &QPushButton::clicked, this, [] {
|
||||
getSettings()->showBadgesGlobalAuthority = true;
|
||||
getSettings()->showBadgesChannelAuthority = true;
|
||||
getSettings()->showBadgesSubscription = true;
|
||||
getSettings()->showBadgesVanity = true;
|
||||
getSettings()->showBadgesChatterino = true;
|
||||
});
|
||||
auto removeAll = fastSelection.emplace<QPushButton>("Disable all");
|
||||
QObject::connect(removeAll.getElement(), &QPushButton::clicked, this,
|
||||
[] {
|
||||
getSettings()->showBadgesGlobalAuthority = false;
|
||||
getSettings()->showBadgesChannelAuthority = false;
|
||||
getSettings()->showBadgesSubscription = false;
|
||||
getSettings()->showBadgesVanity = false;
|
||||
getSettings()->showBadgesChatterino = false;
|
||||
});
|
||||
}
|
||||
layout.emplace<Line>(false);
|
||||
layout.append(this->createCheckBox(
|
||||
("Show authorty badges (staff, admin, turbo, etc)"),
|
||||
getSettings()->showBadgesGlobalAuthority));
|
||||
layout.append(
|
||||
this->createCheckBox(("Show channel badges (broadcaster, moderator)"),
|
||||
getSettings()->showBadgesChannelAuthority));
|
||||
layout.append(this->createCheckBox(("Show subscriber badges "),
|
||||
getSettings()->showBadgesSubscription));
|
||||
layout.append(
|
||||
this->createCheckBox(("Show vanity badges (prime, bits, subgifter)"),
|
||||
getSettings()->showBadgesVanity));
|
||||
layout.append(this->createCheckBox(("Show chatterino badges"),
|
||||
getSettings()->showBadgesChatterino));
|
||||
layout->addStretch(1);
|
||||
}
|
||||
|
||||
void LookPage::addLastReadMessageIndicatorPatternSelector(
|
||||
LayoutCreator<QVBoxLayout> layout)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ private:
|
||||
void addMessageTab(LayoutCreator<QVBoxLayout> layout);
|
||||
void addEmoteTab(LayoutCreator<QVBoxLayout> layout);
|
||||
void addSplitHeaderTab(LayoutCreator<QVBoxLayout> layout);
|
||||
void addBadgesTab(LayoutCreator<QVBoxLayout> layout);
|
||||
|
||||
void addLastReadMessageIndicatorPatternSelector(
|
||||
LayoutCreator<QVBoxLayout> layout);
|
||||
|
||||
@@ -149,7 +149,7 @@ ModerationPage::ModerationPage()
|
||||
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation buttons");
|
||||
{
|
||||
// clang-format off
|
||||
auto label = modMode.emplace<QLabel>("Click the moderation mod button (<img width='18' height='18' src=':/images/moderatormode_disabled.png'>) in a channel that you moderate to enable moderator mode.<br>");
|
||||
auto label = modMode.emplace<QLabel>("Click the moderation mod button (<img width='18' height='18' src=':/buttons/modModeDisabled.png'>) in a channel that you moderate to enable moderator mode.<br>");
|
||||
label->setWordWrap(true);
|
||||
label->setStyleSheet("color: #bbb");
|
||||
// clang-format on
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "SettingsPage.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -363,6 +363,12 @@ void Split::handleModifiers(Qt::KeyboardModifiers modifiers)
|
||||
}
|
||||
}
|
||||
|
||||
void Split::setIsTopRightSplit(bool value)
|
||||
{
|
||||
this->isTopRightSplit_ = value;
|
||||
this->header_->setAddButtonVisible(value);
|
||||
}
|
||||
|
||||
/// Slots
|
||||
void Split::addSibling()
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
void layoutMessages();
|
||||
void updateGifEmotes();
|
||||
void updateLastReadMessage();
|
||||
void setIsTopRightSplit(bool value);
|
||||
|
||||
void drag();
|
||||
|
||||
@@ -106,10 +107,11 @@ private:
|
||||
|
||||
NullablePtr<SelectChannelDialog> selectChannelDialog_;
|
||||
|
||||
bool moderationMode_ = false;
|
||||
bool moderationMode_{};
|
||||
bool isTopRightSplit_{};
|
||||
|
||||
bool isMouseOver_ = false;
|
||||
bool isDragging_ = false;
|
||||
bool isMouseOver_{};
|
||||
bool isDragging_{};
|
||||
|
||||
pajlada::Signals::Connection channelIDChangedConnection_;
|
||||
pajlada::Signals::Connection usermodeChangedConnection_;
|
||||
|
||||
@@ -310,8 +310,33 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
|
||||
}
|
||||
}
|
||||
|
||||
Split *SplitContainer::getTopRightSplit(Node &node)
|
||||
{
|
||||
switch (node.getType()) {
|
||||
case Node::_Split:
|
||||
return node.getSplit();
|
||||
case Node::VerticalContainer:
|
||||
if (!node.getChildren().empty())
|
||||
return getTopRightSplit(*node.getChildren().front());
|
||||
break;
|
||||
case Node::HorizontalContainer:
|
||||
if (!node.getChildren().empty())
|
||||
return getTopRightSplit(*node.getChildren().back());
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SplitContainer::layout()
|
||||
{
|
||||
// update top right split
|
||||
auto topRight = this->getTopRightSplit(this->baseNode_);
|
||||
if (this->topRight_) this->topRight_->setIsTopRightSplit(false);
|
||||
this->topRight_ = topRight;
|
||||
if (topRight) this->topRight_->setIsTopRightSplit(true);
|
||||
|
||||
// layout
|
||||
this->baseNode_.geometry_ = this->rect().adjusted(-1, -1, 0, 0);
|
||||
|
||||
std::vector<DropRect> _dropRects;
|
||||
@@ -431,9 +456,10 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||
|
||||
if (notebook != nullptr) {
|
||||
if (notebook->getPageCount() > 1) {
|
||||
text += "\n\nTip: After adding a split you can hold <Alt> to "
|
||||
"move it or split it "
|
||||
"further.";
|
||||
text +=
|
||||
"\n\nTip: After adding a split you can hold <Ctrl+Alt> to "
|
||||
"move it or split it "
|
||||
"further.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,6 +219,7 @@ private:
|
||||
void addSplit(Split *split);
|
||||
|
||||
void decodeNodeRecusively(QJsonObject &obj, Node *node);
|
||||
Split *getTopRightSplit(Node &node);
|
||||
|
||||
struct DropRegion {
|
||||
QRect rect;
|
||||
@@ -239,6 +240,7 @@ private:
|
||||
|
||||
Node baseNode_;
|
||||
Split *selected_;
|
||||
Split *topRight_{};
|
||||
|
||||
NotebookTab *tab_;
|
||||
std::vector<Split *> splits_;
|
||||
|
||||
@@ -93,11 +93,11 @@ namespace {
|
||||
title += " (live)";
|
||||
|
||||
// description
|
||||
if (settings.showUptime) title += " - " + s.uptime;
|
||||
if (settings.showViewerCount)
|
||||
title += " - " + QString::number(s.viewerCount);
|
||||
if (settings.showTitle) title += " - " + s.title;
|
||||
if (settings.showGame) title += " - " + s.game;
|
||||
if (settings.showUptime) title += " - " + s.uptime;
|
||||
if (settings.showTitle) title += " - " + s.title;
|
||||
|
||||
return title;
|
||||
}
|
||||
@@ -138,33 +138,42 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
|
||||
void SplitHeader::initializeLayout()
|
||||
{
|
||||
auto layout = makeLayout<QHBoxLayout>(
|
||||
{// title
|
||||
this->titleLabel = makeWidget<Label>([](auto w) {
|
||||
w->setSizePolicy(QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Preferred);
|
||||
w->setCentered(true);
|
||||
w->setHasOffset(false);
|
||||
}),
|
||||
// mode
|
||||
this->modeButton_ = makeWidget<EffectLabel>([&](auto w) {
|
||||
w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
w->hide();
|
||||
this->initializeModeSignals(*w);
|
||||
w->setMenu(this->createChatModeMenu());
|
||||
}),
|
||||
// moderator
|
||||
this->moderationButton_ = makeWidget<Button>([&](auto w) {
|
||||
QObject::connect(w, &Button::clicked, this, [this, w]() mutable {
|
||||
this->split_->setModerationMode(
|
||||
!this->split_->getModerationMode());
|
||||
auto layout = makeLayout<QHBoxLayout>({
|
||||
// title
|
||||
this->titleLabel_ = makeWidget<Label>([](auto w) {
|
||||
w->setSizePolicy(QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Preferred);
|
||||
w->setCentered(true);
|
||||
w->setHasOffset(false);
|
||||
}),
|
||||
// mode
|
||||
this->modeButton_ = makeWidget<EffectLabel>([&](auto w) {
|
||||
w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
w->hide();
|
||||
this->initializeModeSignals(*w);
|
||||
w->setMenu(this->createChatModeMenu());
|
||||
}),
|
||||
// moderator
|
||||
this->moderationButton_ = makeWidget<Button>([&](auto w) {
|
||||
QObject::connect(w, &Button::clicked, this, [this, w]() mutable {
|
||||
this->split_->setModerationMode(
|
||||
!this->split_->getModerationMode());
|
||||
|
||||
w->setDim(!this->split_->getModerationMode());
|
||||
});
|
||||
}),
|
||||
// dropdown
|
||||
this->dropdownButton_ = makeWidget<Button>(
|
||||
[&](auto w) { w->setMenu(this->createMainMenu()); })});
|
||||
w->setDim(!this->split_->getModerationMode());
|
||||
});
|
||||
}),
|
||||
// dropdown
|
||||
this->dropdownButton_ = makeWidget<Button>(
|
||||
[&](auto w) { w->setMenu(this->createMainMenu()); }),
|
||||
// add split
|
||||
this->addButton_ = makeWidget<Button>([&](auto w) {
|
||||
w->setPixmap(getApp()->resources->buttons.addSplitDark);
|
||||
w->setEnableMargin(false);
|
||||
|
||||
QObject::connect(w, &Button::clicked, this,
|
||||
[this]() { this->split_->addSibling(); });
|
||||
}),
|
||||
});
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
@@ -174,18 +183,16 @@ void SplitHeader::initializeLayout()
|
||||
std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
{
|
||||
auto menu = std::make_unique<QMenu>();
|
||||
menu->addAction("New split", this->split_, &Split::addSibling,
|
||||
QKeySequence("Ctrl+T"));
|
||||
menu->addAction("Close split", this->split_, &Split::deleteFromContainer,
|
||||
menu->addAction("Close channel", this->split_, &Split::deleteFromContainer,
|
||||
QKeySequence("Ctrl+W"));
|
||||
menu->addAction("Change channel", this->split_, &Split::changeChannel,
|
||||
QKeySequence("Ctrl+R"));
|
||||
menu->addSeparator();
|
||||
menu->addAction("Popup", this->split_, &Split::popup);
|
||||
menu->addAction("Viewer list", this->split_, &Split::showViewerList);
|
||||
menu->addAction("Search", this->split_, &Split::showSearch,
|
||||
QKeySequence("Ctrl+F"));
|
||||
menu->addSeparator();
|
||||
menu->addAction("Popup", this->split_, &Split::popup);
|
||||
#ifdef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Start watching", this, [this] {
|
||||
ChannelPtr _channel = this->split->getChannel();
|
||||
@@ -224,7 +231,7 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
menu->addSeparator();
|
||||
menu->addAction("Reload channel emotes", this, SLOT(reloadChannelEmotes()));
|
||||
menu->addAction("Reconnect", this, SLOT(reconnect()));
|
||||
// menu->addAction("Clear messages", this->split_, &Split::doClearChat);
|
||||
menu->addAction("Clear messages", this->split_, &Split::clear);
|
||||
// menu->addSeparator();
|
||||
// menu->addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
||||
|
||||
@@ -351,6 +358,12 @@ void SplitHeader::scaleChangedEvent(float scale)
|
||||
this->setFixedHeight(w);
|
||||
this->dropdownButton_->setFixedWidth(w);
|
||||
this->moderationButton_->setFixedWidth(w);
|
||||
this->addButton_->setFixedWidth(w * 5 / 8);
|
||||
}
|
||||
|
||||
void SplitHeader::setAddButtonVisible(bool value)
|
||||
{
|
||||
this->addButton_->setVisible(value);
|
||||
}
|
||||
|
||||
void SplitHeader::updateChannelText()
|
||||
@@ -375,7 +388,7 @@ void SplitHeader::updateChannelText()
|
||||
}
|
||||
}
|
||||
|
||||
this->titleLabel->setText(title.isEmpty() ? "<empty>" : title);
|
||||
this->titleLabel_->setText(title.isEmpty() ? "<empty>" : title);
|
||||
}
|
||||
|
||||
void SplitHeader::updateModerationModeIcon()
|
||||
@@ -475,6 +488,8 @@ void SplitHeader::enterEvent(QEvent *event)
|
||||
tooltip->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()),
|
||||
false);
|
||||
tooltip->setText(this->tooltipText_);
|
||||
tooltip->setWordWrap(false);
|
||||
tooltip->adjustSize();
|
||||
tooltip->show();
|
||||
tooltip->raise();
|
||||
}
|
||||
@@ -499,7 +514,7 @@ void SplitHeader::themeChangedEvent()
|
||||
} else {
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.text);
|
||||
}
|
||||
this->titleLabel->setPalette(palette);
|
||||
this->titleLabel_->setPalette(palette);
|
||||
|
||||
// --
|
||||
if (this->theme->isLightTheme()) {
|
||||
|
||||
@@ -24,6 +24,8 @@ class SplitHeader final : public BaseWidget, pajlada::Signals::SignalHolder
|
||||
public:
|
||||
explicit SplitHeader(Split *_chatWidget);
|
||||
|
||||
void setAddButtonVisible(bool value);
|
||||
|
||||
void updateChannelText();
|
||||
void updateModerationModeIcon();
|
||||
void updateRoomModes();
|
||||
@@ -53,9 +55,10 @@ private:
|
||||
|
||||
// ui
|
||||
Button *dropdownButton_{};
|
||||
Label *titleLabel{};
|
||||
Label *titleLabel_{};
|
||||
EffectLabel *modeButton_{};
|
||||
Button *moderationButton_{};
|
||||
Button *addButton_{};
|
||||
|
||||
// states
|
||||
QPoint dragStart_{};
|
||||
|
||||
@@ -84,21 +84,8 @@ void SplitInput::initLayout()
|
||||
}));
|
||||
|
||||
// open emote popup
|
||||
QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked, [this] {
|
||||
if (!this->emotePopup_) {
|
||||
this->emotePopup_ = std::make_unique<EmotePopup>();
|
||||
this->emotePopup_->linkClicked.connect([this](const Link &link) {
|
||||
if (link.type == Link::InsertText) {
|
||||
this->insertText(link.value + " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()),
|
||||
int(500 * this->emotePopup_->getScale()));
|
||||
this->emotePopup_->loadChannel(this->split_->getChannel());
|
||||
this->emotePopup_->show();
|
||||
});
|
||||
QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked,
|
||||
[=] { this->openEmotePopup(); });
|
||||
|
||||
// clear channelview selection when selecting in the input
|
||||
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
|
||||
@@ -159,6 +146,23 @@ void SplitInput::updateEmoteButton()
|
||||
this->ui_.emoteButton->setFixedHeight(int(18 * scale));
|
||||
}
|
||||
|
||||
void SplitInput::openEmotePopup()
|
||||
{
|
||||
if (!this->emotePopup_) {
|
||||
this->emotePopup_ = std::make_unique<EmotePopup>();
|
||||
this->emotePopup_->linkClicked.connect([this](const Link &link) {
|
||||
if (link.type == Link::InsertText) {
|
||||
this->insertText(link.value + " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()),
|
||||
int(500 * this->emotePopup_->getScale()));
|
||||
this->emotePopup_->loadChannel(this->split_->getChannel());
|
||||
this->emotePopup_->show();
|
||||
}
|
||||
|
||||
void SplitInput::installKeyPressedEvent()
|
||||
{
|
||||
auto app = getApp();
|
||||
@@ -177,7 +181,8 @@ void SplitInput::installKeyPressedEvent()
|
||||
|
||||
c->sendMessage(sendMessage);
|
||||
// don't add duplicate messages and empty message to message history
|
||||
if ((this->prevMsg_.isEmpty() || !this->prevMsg_.endsWith(message)) &&
|
||||
if ((this->prevMsg_.isEmpty() ||
|
||||
!this->prevMsg_.endsWith(message)) &&
|
||||
!message.trimmed().isEmpty())
|
||||
this->prevMsg_.append(message);
|
||||
|
||||
@@ -186,7 +191,7 @@ void SplitInput::installKeyPressedEvent()
|
||||
this->currMsg_ = QString();
|
||||
this->ui_.textEdit->setText(QString());
|
||||
this->prevIndex_ = 0;
|
||||
} else if (this->ui_.textEdit->toPlainText() ==
|
||||
} else if (message ==
|
||||
this->prevMsg_.at(this->prevMsg_.size() - 1)) {
|
||||
this->prevMsg_.removeLast();
|
||||
}
|
||||
@@ -227,6 +232,13 @@ void SplitInput::installKeyPressedEvent()
|
||||
page->selectNextSplit(SplitContainer::Below);
|
||||
}
|
||||
} else {
|
||||
// If user did not write anything before then just do nothing.
|
||||
if (this->prevMsg_.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
bool cursorToEnd = true;
|
||||
QString message = ui_.textEdit->toPlainText();
|
||||
|
||||
if (this->prevIndex_ != (this->prevMsg_.size() - 1) &&
|
||||
this->prevIndex_ != this->prevMsg_.size()) {
|
||||
this->prevIndex_++;
|
||||
@@ -234,12 +246,27 @@ void SplitInput::installKeyPressedEvent()
|
||||
this->prevMsg_.at(this->prevIndex_));
|
||||
} else {
|
||||
this->prevIndex_ = this->prevMsg_.size();
|
||||
this->ui_.textEdit->setText(this->currMsg_);
|
||||
if (message == this->prevMsg_.at(this->prevIndex_ - 1)) {
|
||||
// If user has just come from a message history
|
||||
// Then simply get currMsg_.
|
||||
this->ui_.textEdit->setText(this->currMsg_);
|
||||
} else if (message != this->currMsg_) {
|
||||
// If user are already in current message
|
||||
// And type something new
|
||||
// Then replace currMsg_ with new one.
|
||||
this->currMsg_ = message;
|
||||
}
|
||||
// If user is already in current message
|
||||
// Then don't touch cursos.
|
||||
cursorToEnd =
|
||||
(message == this->prevMsg_.at(this->prevIndex_ - 1));
|
||||
}
|
||||
|
||||
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
this->ui_.textEdit->setTextCursor(cursor);
|
||||
if (cursorToEnd) {
|
||||
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
this->ui_.textEdit->setTextCursor(cursor);
|
||||
}
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Left) {
|
||||
if (event->modifiers() == Qt::AltModifier) {
|
||||
@@ -284,6 +311,9 @@ void SplitInput::installKeyPressedEvent()
|
||||
this->split_->copyToClipboard();
|
||||
event->accept();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_E &&
|
||||
event->modifiers() == Qt::ControlModifier) {
|
||||
this->openEmotePopup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ private:
|
||||
void initLayout();
|
||||
void installKeyPressedEvent();
|
||||
void updateEmoteButton();
|
||||
void openEmotePopup();
|
||||
|
||||
Split *const split_;
|
||||
std::shared_ptr<EmotePopup> emotePopup_;
|
||||
|
||||
Reference in New Issue
Block a user