Merge branch 'master' into git_is_pepega
This commit is contained in:
@@ -418,7 +418,7 @@ void Split::leaveEvent(QEvent *event)
|
||||
|
||||
this->overlay_->hide();
|
||||
|
||||
TooltipWidget::getInstance()->hide();
|
||||
TooltipWidget::instance()->hide();
|
||||
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
@@ -339,15 +339,13 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
|
||||
{
|
||||
switch (node->type_)
|
||||
{
|
||||
case Node::_Split:
|
||||
{
|
||||
case Node::_Split: {
|
||||
node->split_->giveFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
break;
|
||||
|
||||
case Node::HorizontalContainer:
|
||||
case Node::VerticalContainer:
|
||||
{
|
||||
case Node::VerticalContainer: {
|
||||
auto &children = node->children_;
|
||||
|
||||
auto it = std::find_if(
|
||||
@@ -898,23 +896,19 @@ void SplitContainer::Node::insertSplitRelative(Split *_split,
|
||||
{
|
||||
switch (this->type_)
|
||||
{
|
||||
case Node::EmptyRoot:
|
||||
{
|
||||
case Node::EmptyRoot: {
|
||||
this->setSplit(_split);
|
||||
}
|
||||
break;
|
||||
case Node::_Split:
|
||||
{
|
||||
case Node::_Split: {
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
}
|
||||
break;
|
||||
case Node::HorizontalContainer:
|
||||
{
|
||||
case Node::HorizontalContainer: {
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
}
|
||||
break;
|
||||
case Node::VerticalContainer:
|
||||
{
|
||||
case Node::VerticalContainer: {
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
}
|
||||
break;
|
||||
@@ -1110,16 +1104,14 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
|
||||
switch (this->type_)
|
||||
{
|
||||
case Node::_Split:
|
||||
{
|
||||
case Node::_Split: {
|
||||
QRect rect = this->geometry_.toRect();
|
||||
this->split_->setGeometry(
|
||||
rect.marginsRemoved(QMargins(1, 1, 0, 0)));
|
||||
}
|
||||
break;
|
||||
case Node::VerticalContainer:
|
||||
case Node::HorizontalContainer:
|
||||
{
|
||||
case Node::HorizontalContainer: {
|
||||
bool isVertical = this->type_ == Node::VerticalContainer;
|
||||
|
||||
// vars
|
||||
|
||||
@@ -99,6 +99,12 @@ namespace {
|
||||
.arg(s.uptime)
|
||||
.arg(QString::number(s.viewerCount));
|
||||
}
|
||||
auto formatOfflineTooltip(const TwitchChannel::StreamStatus &s)
|
||||
{
|
||||
return QString("<style>.center { text-align: center; }</style> \
|
||||
<p class=\"center\">Offline<br>%1</p>")
|
||||
.arg(s.title.toHtmlEscaped());
|
||||
}
|
||||
auto formatTitle(const TwitchChannel::StreamStatus &s, Settings &settings)
|
||||
{
|
||||
auto title = QString();
|
||||
@@ -213,14 +219,12 @@ void SplitHeader::initializeLayout()
|
||||
this->dropdownButton_ = makeWidget<Button>([&](auto w) {
|
||||
/// XXX: this never gets disconnected
|
||||
this->split_->channelChanged.connect([this] {
|
||||
auto menu = this->createMainMenu();
|
||||
this->mainMenu_ = menu.get();
|
||||
this->dropdownButton_->setMenu(std::move(menu));
|
||||
this->dropdownButton_->setMenu(this->createMainMenu());
|
||||
});
|
||||
}),
|
||||
// add split
|
||||
this->addButton_ = makeWidget<Button>([&](auto w) {
|
||||
w->setPixmap(getApp()->resources->buttons.addSplitDark);
|
||||
w->setPixmap(getResources().buttons.addSplitDark);
|
||||
w->setEnableMargin(false);
|
||||
|
||||
QObject::connect(w, &Button::leftClicked, this,
|
||||
@@ -301,7 +305,6 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
// sub menu
|
||||
auto moreMenu = new QMenu("More", this);
|
||||
|
||||
|
||||
moreMenu->addAction("Toggle moderation mode", this->split_, [this]() {
|
||||
this->split_->setModerationMode(!this->split_->getModerationMode());
|
||||
});
|
||||
@@ -553,6 +556,10 @@ void SplitHeader::updateChannelText()
|
||||
this->tooltipText_ = formatTooltip(*streamStatus);
|
||||
title += formatTitle(*streamStatus, *getSettings());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->tooltipText_ = formatOfflineTooltip(*streamStatus);
|
||||
}
|
||||
}
|
||||
|
||||
this->titleLabel_->setText(title.isEmpty() ? "<empty>" : title);
|
||||
@@ -564,8 +571,8 @@ void SplitHeader::updateModerationModeIcon()
|
||||
!getApp()->moderationActions->items.empty();
|
||||
|
||||
this->moderationButton_->setPixmap(
|
||||
moderationMode ? getApp()->resources->buttons.modModeEnabled
|
||||
: getApp()->resources->buttons.modModeDisabled);
|
||||
moderationMode ? getResources().buttons.modModeEnabled
|
||||
: getResources().buttons.modModeDisabled);
|
||||
|
||||
auto channel = this->split_->getChannel();
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
@@ -591,17 +598,17 @@ void SplitHeader::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
switch (event->button())
|
||||
{
|
||||
case Qt::LeftButton:
|
||||
{
|
||||
case Qt::LeftButton: {
|
||||
this->dragging_ = true;
|
||||
|
||||
this->dragStart_ = event->pos();
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::RightButton:
|
||||
{
|
||||
this->mainMenu_->popup(this->mapToGlobal(event->pos()));
|
||||
case Qt::RightButton: {
|
||||
auto menu = this->createMainMenu().release();
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
menu->popup(this->mapToGlobal(event->pos() + QPoint(0, 4)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -673,9 +680,15 @@ void SplitHeader::enterEvent(QEvent *event)
|
||||
{
|
||||
if (!this->tooltipText_.isEmpty())
|
||||
{
|
||||
TooltipPreviewImage::getInstance().setImage(nullptr);
|
||||
auto channel = this->split_->getChannel().get();
|
||||
if (channel->getType() == Channel::Type::Twitch)
|
||||
{
|
||||
dynamic_cast<TwitchChannel *>(channel)->refreshTitle();
|
||||
}
|
||||
|
||||
auto tooltip = TooltipWidget::getInstance();
|
||||
TooltipPreviewImage::instance().setImage(nullptr);
|
||||
|
||||
auto tooltip = TooltipWidget::instance();
|
||||
tooltip->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()),
|
||||
false);
|
||||
tooltip->setText(this->tooltipText_);
|
||||
@@ -690,7 +703,7 @@ void SplitHeader::enterEvent(QEvent *event)
|
||||
|
||||
void SplitHeader::leaveEvent(QEvent *event)
|
||||
{
|
||||
TooltipWidget::getInstance()->hide();
|
||||
TooltipWidget::instance()->hide();
|
||||
|
||||
BaseWidget::leaveEvent(event);
|
||||
}
|
||||
@@ -713,14 +726,13 @@ void SplitHeader::themeChangedEvent()
|
||||
// --
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->dropdownButton_->setPixmap(getApp()->resources->buttons.menuDark);
|
||||
this->addButton_->setPixmap(getApp()->resources->buttons.addSplit);
|
||||
this->dropdownButton_->setPixmap(getResources().buttons.menuDark);
|
||||
this->addButton_->setPixmap(getResources().buttons.addSplit);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dropdownButton_->setPixmap(
|
||||
getApp()->resources->buttons.menuLight);
|
||||
this->addButton_->setPixmap(getApp()->resources->buttons.addSplitDark);
|
||||
this->dropdownButton_->setPixmap(getResources().buttons.menuLight);
|
||||
this->addButton_->setPixmap(getResources().buttons.addSplitDark);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ private:
|
||||
|
||||
// ui
|
||||
Button *dropdownButton_{};
|
||||
QMenu *mainMenu_{};
|
||||
Label *titleLabel_{};
|
||||
EffectLabel *modeButton_{};
|
||||
Button *moderationButton_{};
|
||||
|
||||
@@ -154,6 +154,7 @@ void SplitInput::openEmotePopup()
|
||||
if (!this->emotePopup_)
|
||||
{
|
||||
this->emotePopup_ = new EmotePopup(this);
|
||||
this->emotePopup_->setStayInScreenRect(true);
|
||||
this->emotePopup_->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
this->emotePopup_->linkClicked.connect([this](const Link &link) {
|
||||
|
||||
@@ -30,15 +30,14 @@ SplitOverlay::SplitOverlay(Split *parent)
|
||||
layout->setColumnStretch(1, 1);
|
||||
layout->setColumnStretch(3, 1);
|
||||
|
||||
auto *move = new QPushButton(getApp()->resources->split.move, QString());
|
||||
auto *move = new QPushButton(getResources().split.move, QString());
|
||||
auto *left = this->left_ =
|
||||
new QPushButton(getApp()->resources->split.left, QString());
|
||||
new QPushButton(getResources().split.left, QString());
|
||||
auto *right = this->right_ =
|
||||
new QPushButton(getApp()->resources->split.right, QString());
|
||||
auto *up = this->up_ =
|
||||
new QPushButton(getApp()->resources->split.up, QString());
|
||||
new QPushButton(getResources().split.right, QString());
|
||||
auto *up = this->up_ = new QPushButton(getResources().split.up, QString());
|
||||
auto *down = this->down_ =
|
||||
new QPushButton(getApp()->resources->split.down, QString());
|
||||
new QPushButton(getResources().split.down, QString());
|
||||
|
||||
move->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
left->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
@@ -107,27 +106,23 @@ void SplitOverlay::paintEvent(QPaintEvent *)
|
||||
QRect rect;
|
||||
switch (this->hoveredElement_)
|
||||
{
|
||||
case SplitLeft:
|
||||
{
|
||||
case SplitLeft: {
|
||||
rect = QRect(0, 0, this->width() / 2, this->height());
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitRight:
|
||||
{
|
||||
case SplitRight: {
|
||||
rect =
|
||||
QRect(this->width() / 2, 0, this->width() / 2, this->height());
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitUp:
|
||||
{
|
||||
case SplitUp: {
|
||||
rect = QRect(0, 0, this->width(), this->height() / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitDown:
|
||||
{
|
||||
case SplitDown: {
|
||||
rect =
|
||||
QRect(0, this->height() / 2, this->width(), this->height() / 2);
|
||||
}
|
||||
@@ -184,8 +179,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Enter:
|
||||
{
|
||||
case QEvent::Enter: {
|
||||
QGraphicsOpacityEffect *effect =
|
||||
dynamic_cast<QGraphicsOpacityEffect *>(
|
||||
((QWidget *)watched)->graphicsEffect());
|
||||
@@ -199,8 +193,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
this->parent->update();
|
||||
}
|
||||
break;
|
||||
case QEvent::Leave:
|
||||
{
|
||||
case QEvent::Leave: {
|
||||
QGraphicsOpacityEffect *effect =
|
||||
dynamic_cast<QGraphicsOpacityEffect *>(
|
||||
((QWidget *)watched)->graphicsEffect());
|
||||
@@ -214,8 +207,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
this->parent->update();
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
case QEvent::MouseButtonPress: {
|
||||
if (this->hoveredElement == HoveredElement::SplitMove)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
@@ -227,8 +219,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (this->hoveredElement != HoveredElement::SplitMove)
|
||||
{
|
||||
SplitContainer *container =
|
||||
|
||||
Reference in New Issue
Block a user