fixed split header tooltips not showing

This commit is contained in:
fourtf 2018-05-26 16:31:43 +02:00
parent 08cf701af3
commit 6b24f249f7
8 changed files with 46 additions and 28 deletions

View file

@ -48,7 +48,7 @@ int MessageLayout::getHeight() const
// return true if redraw is required
bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
{
BenchmarkGuard benchmark("MessageLayout::layout()");
// BenchmarkGuard benchmark("MessageLayout::layout()");
auto app = getApp();
@ -107,7 +107,6 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
}
// return if no layout is required
qDebug() << layoutRequired;
if (!layoutRequired) {
return false;

View file

@ -325,6 +325,11 @@ void TwitchChannel::refreshLiveStatus()
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
channel->streamStatus.rerun = false;
if (stream.HasMember("stream_type")) {
channel->streamStatus.streamType = stream["stream_type"].GetString();
} else {
channel->streamStatus.streamType = QString();
}
if (stream.HasMember("broadcast_platform")) {
const auto &broadcastPlatformValue = stream["broadcast_platform"];

View file

@ -32,6 +32,7 @@ public:
QString title;
QString game;
QString uptime;
QString streamType;
};
struct UserState {

View file

@ -18,7 +18,7 @@ class BaseWidget : public QWidget
public:
explicit BaseWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~BaseWidget();
virtual ~BaseWidget() override;
float getScale() const;
pajlada::Signals::Signal<float> scaleChanged;

View file

@ -253,8 +253,8 @@ void BaseWindow::leaveEvent(QEvent *)
void BaseWindow::moveTo(QWidget *parent, QPoint point)
{
point.rx() += 16;
point.ry() += 16;
// point.rx() += 16;
// point.ry() += 16;
this->move(point);
this->moveIntoDesktopRect(parent);

View file

@ -175,7 +175,7 @@ void ChannelView::layoutMessages()
void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
{
BenchmarkGuard benchmark("layout messages");
// BenchmarkGuard benchmark("layout messages");
auto app = getApp();
@ -579,7 +579,7 @@ bool ChannelView::isPaused()
void ChannelView::paintEvent(QPaintEvent * /*event*/)
{
BenchmarkGuard benchmark("paint event");
// BenchmarkGuard benchmark("paint event");
QPainter painter(this);

View file

@ -31,7 +31,6 @@ SplitHeader::SplitHeader(Split *_split)
, split(_split)
{
auto app = getApp();
this->setMouseTracking(true);
util::LayoutCreator<SplitHeader> layoutCreator(this);
auto layout = layoutCreator.emplace<QHBoxLayout>().withoutMargin();
@ -53,13 +52,13 @@ SplitHeader::SplitHeader(Split *_split)
// channel name label
// auto title = layout.emplace<Label>(this).assign(&this->titleLabel);
auto title = layout.emplace<SignalLabel>().assign(&this->titleLabel);
auto title = layout.emplace<QLabel>().assign(&this->titleLabel);
title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
title->setMouseTracking(true);
QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this,
&SplitHeader::mouseDoubleClickEvent);
QObject::connect(this->titleLabel, &SignalLabel::mouseMove, this,
&SplitHeader::mouseMoveEvent);
// title->setMouseTracking(true);
// QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this,
// &SplitHeader::mouseDoubleClickEvent);
// QObject::connect(this->titleLabel, &SignalLabel::mouseMove, this,
// &SplitHeader::mouseMoveEvent);
layout->addStretch(1);
@ -94,6 +93,8 @@ SplitHeader::SplitHeader(Split *_split)
this->split->channelChanged.connect([this]() {
this->initializeChannelSignals(); //
});
this->setMouseTracking(true);
}
SplitHeader::~SplitHeader()
@ -101,7 +102,7 @@ SplitHeader::~SplitHeader()
this->onlineStatusChangedConnection.disconnect();
}
void SplitHeader::addDropdownItems(RippleEffectButton *label)
void SplitHeader::addDropdownItems(RippleEffectButton *)
{
// clang-format off
this->dropdownMenu.addAction("Add new split", this->split, &Split::doAddSplit, QKeySequence(tr("Ctrl+T")));
@ -178,7 +179,7 @@ void SplitHeader::updateChannelText()
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
if (twitchChannel != nullptr) {
const auto &streamStatus = twitchChannel->getStreamStatus();
const auto streamStatus = twitchChannel->getStreamStatus();
if (streamStatus.live) {
this->isLive = true;
@ -192,9 +193,13 @@ void SplitHeader::updateChannelText()
"</p>";
if (streamStatus.rerun) {
title += " (rerun)";
} else if (streamStatus.streamType.isEmpty()) {
title += " (" + streamStatus.streamType + ")";
} else {
title += " (live)";
}
} else {
this->tooltip = QString();
}
}
@ -327,17 +332,9 @@ void SplitHeader::mouseReleaseEvent(QMouseEvent *event)
void SplitHeader::mouseMoveEvent(QMouseEvent *event)
{
if (!this->dragging && this->isLive) {
auto tooltipWidget = TooltipWidget::getInstance();
tooltipWidget->moveTo(this, event->globalPos());
tooltipWidget->setText(tooltip);
tooltipWidget->show();
tooltipWidget->raise();
}
if (this->dragging) {
if (std::abs(this->dragStart.x() - event->pos().x()) > (int)(12 * this->getScale()) ||
std::abs(this->dragStart.y() - event->pos().y()) > (int)(12 * this->getScale())) {
if (std::abs(this->dragStart.x() - event->pos().x()) > int(12 * this->getScale()) ||
std::abs(this->dragStart.y() - event->pos().y()) > int(12 * this->getScale())) {
this->split->drag();
this->dragging = false;
}
@ -352,11 +349,26 @@ void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event)
this->doubleClicked = true;
}
void SplitHeader::enterEvent(QEvent *event)
{
if (!this->tooltip.isEmpty()) {
auto tooltipWidget = TooltipWidget::getInstance();
tooltipWidget->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()));
tooltipWidget->setText(this->tooltip);
tooltipWidget->show();
tooltipWidget->raise();
}
BaseWidget::enterEvent(event);
}
void SplitHeader::leaveEvent(QEvent *event)
{
TooltipWidget::getInstance()->hide();
BaseWidget::leaveEvent(event);
}
void SplitHeader::rightButtonClicked()
{
}

View file

@ -29,7 +29,7 @@ class SplitHeader : public BaseWidget
public:
explicit SplitHeader(Split *_chatWidget);
virtual ~SplitHeader();
virtual ~SplitHeader() override;
// Update channel text from chat widget
void updateChannelText();
@ -44,6 +44,7 @@ protected:
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void enterEvent(QEvent *) override;
virtual void leaveEvent(QEvent *event) override;
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
@ -59,7 +60,7 @@ private:
RippleEffectButton *dropdownButton;
// Label *titleLabel;
SignalLabel *titleLabel;
QLabel *titleLabel;
RippleEffectLabel *modeButton;
RippleEffectButton *moderationButton;