diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp
index 3439fadd..faa8e2f5 100644
--- a/src/widgets/helper/splitheader.cpp
+++ b/src/widgets/helper/splitheader.cpp
@@ -1,6 +1,7 @@
#include "widgets/helper/splitheader.hpp"
#include "singletons/thememanager.hpp"
#include "twitch/twitchchannel.hpp"
+#include "util/layoutcreator.hpp"
#include "util/urlfetch.hpp"
#include "widgets/split.hpp"
#include "widgets/splitcontainer.hpp"
@@ -14,79 +15,101 @@
namespace chatterino {
namespace widgets {
-SplitHeader::SplitHeader(Split *_chatWidget)
- : BaseWidget(_chatWidget)
- , chatWidget(_chatWidget)
- , leftLabel(this)
- , leftMenu(this)
- , rightLabel(this)
- , rightMenu(this)
+SplitHeader::SplitHeader(Split *_split)
+ : BaseWidget(_split)
+ , split(_split)
{
this->setMouseTracking(true);
- this->leftLabel.setMouseTracking(true);
- this->channelNameLabel.setMouseTracking(true);
- this->rightLabel.setMouseTracking(true);
+ util::LayoutCreator
");
+ dropdown->getLabel().setScaledContents(true);
+ dropdown->setMouseTracking(true);
+ this->addDropdownItems(dropdown.getElement());
+ QObject::connect(dropdown.getElement(), &RippleEffectLabel::clicked, this, [this] {
+ QTimer::singleShot(80, [&] {
+ this->dropdownMenu.move(
+ this->dropdownLabel->mapToGlobal(QPoint(0, this->dropdownLabel->height())));
+ this->dropdownMenu.show();
+ });
+ });
+
+ // channel name label
+ auto title = layout.emplace
");
+ }
+
+ // ---- misc
+ this->layout()->setMargin(0);
this->refreshTheme();
this->updateChannelText();
- this->setLayout(&this->hbox);
- this->hbox.setMargin(0);
- this->hbox.addWidget(&this->leftLabel);
- this->hbox.addWidget(&this->channelNameLabel, 1);
- this->hbox.addWidget(&this->rightLabel);
-
- // left
- this->leftLabel.getLabel().setTextFormat(Qt::RichText);
- this->leftLabel.getLabel().setText("
");
-
- connect(&this->leftLabel, &RippleEffectLabel::clicked, this, &SplitHeader::leftButtonClicked);
-
- this->leftMenu.addAction("Add new split", this->chatWidget, &Split::doAddSplit,
- QKeySequence(tr("Ctrl+T")));
- this->leftMenu.addAction("Close split", this->chatWidget, &Split::doCloseSplit,
- QKeySequence(tr("Ctrl+W")));
- this->leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
- this->leftMenu.addAction("Popup", this->chatWidget, &Split::doPopup);
- this->leftMenu.addAction("Open viewer list", this->chatWidget, &Split::doOpenViewerList);
- this->leftMenu.addSeparator();
- this->leftMenu.addAction("Change channel", this->chatWidget, &Split::doChangeChannel,
- QKeySequence(tr("Ctrl+R")));
- this->leftMenu.addAction("Clear chat", this->chatWidget, &Split::doClearChat);
- this->leftMenu.addAction("Open channel", this->chatWidget, &Split::doOpenChannel);
- this->leftMenu.addAction("Open popup player", this->chatWidget, &Split::doOpenPopupPlayer);
- this->leftMenu.addAction("Open in Streamlink", this->chatWidget, &Split::doOpenStreamlink);
- this->leftMenu.addSeparator();
- this->leftMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
- this->leftMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
- this->leftMenu.addSeparator();
- this->leftMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
-
- // middle
- this->channelNameLabel.setAlignment(Qt::AlignCenter);
-
- connect(&this->channelNameLabel, &SignalLabel::mouseDoubleClick, this,
- &SplitHeader::mouseDoubleClickEvent);
-
- // right
- this->rightLabel.setMinimumWidth(this->height());
- this->rightLabel.getLabel().setTextFormat(Qt::RichText);
- this->rightLabel.getLabel().setText("ayy");
+ // this->titleLabel.setAlignment(Qt::AlignCenter);
this->initializeChannelSignals();
- this->chatWidget->channelChanged.connect([this]() {
+ this->split->channelChanged.connect([this]() {
this->initializeChannelSignals(); //
});
}
+SplitHeader::~SplitHeader()
+{
+ this->onlineStatusChangedConnection.disconnect();
+}
+
+void SplitHeader::addDropdownItems(RippleEffectLabel *label)
+{
+ connect(this->dropdownLabel, &RippleEffectLabel::clicked, this,
+ &SplitHeader::leftButtonClicked);
+
+ // clang-format off
+ this->dropdownMenu.addAction("Add new split", this->split, &Split::doAddSplit, QKeySequence(tr("Ctrl+T")));
+ this->dropdownMenu.addAction("Close split", this->split, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W")));
+ this->dropdownMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
+ this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup);
+ this->dropdownMenu.addAction("Open viewer list", this->split, &Split::doOpenViewerList);
+ this->dropdownMenu.addSeparator();
+ this->dropdownMenu.addAction("Change channel", this->split, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
+ this->dropdownMenu.addAction("Clear chat", this->split, &Split::doClearChat);
+ this->dropdownMenu.addAction("Open channel", this->split, &Split::doOpenChannel);
+ this->dropdownMenu.addAction("Open popup player", this->split, &Split::doOpenPopupPlayer);
+ this->dropdownMenu.addAction("Open in Streamlink", this->split, &Split::doOpenStreamlink);
+ this->dropdownMenu.addSeparator();
+ this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
+ this->dropdownMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
+ this->dropdownMenu.addSeparator();
+ this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
+ // clang-format on
+}
+
void SplitHeader::initializeChannelSignals()
{
// Disconnect any previous signal first
this->onlineStatusChangedConnection.disconnect();
- auto channel = this->chatWidget->getChannel();
+ auto channel = this->split->getChannel();
twitch::TwitchChannel *twitchChannel = dynamic_cast
"
"Live for " +
twitchChannel->streamUptime + " with " +
- twitchChannel->streamViewerCount + " viewers"
- "