Merge branch 'master' into apa-notification-on-live

This commit is contained in:
pajlada
2018-09-16 17:43:53 +02:00
committed by GitHub
53 changed files with 628 additions and 227 deletions
+50 -35
View File
@@ -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()) {