mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix missing parent of tooltips for Wayland (#4998)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
3ad2e4b30a
commit
fec8f8c49f
9 changed files with 39 additions and 46 deletions
|
@ -48,6 +48,7 @@
|
|||
- Bugfix: Fixed rare crash with Image Uploader when closing a split right after starting an upload. (#4971)
|
||||
- Bugfix: Fixed support for Windows 11 Snap layouts. (#4994)
|
||||
- Bugfix: Fixed some windows appearing between screens. (#4797)
|
||||
- Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998)
|
||||
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
|
||||
- Dev: Change clang-format from v14 to v16. (#4929)
|
||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "widgets/helper/EffectLabel.hpp"
|
||||
#include "widgets/helper/TitlebarButtons.hpp"
|
||||
#include "widgets/Label.hpp"
|
||||
#include "widgets/TooltipWidget.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -468,11 +467,6 @@ EffectLabel *BaseWindow::addTitleBarLabel(std::function<void()> onClicked)
|
|||
|
||||
void BaseWindow::changeEvent(QEvent *)
|
||||
{
|
||||
if (this->isVisible())
|
||||
{
|
||||
TooltipWidget::instance()->hide();
|
||||
}
|
||||
|
||||
#ifdef USEWINSDK
|
||||
if (this->ui_.titlebarButtons)
|
||||
{
|
||||
|
@ -497,7 +491,6 @@ void BaseWindow::changeEvent(QEvent *)
|
|||
|
||||
void BaseWindow::leaveEvent(QEvent *)
|
||||
{
|
||||
TooltipWidget::instance()->hide();
|
||||
}
|
||||
|
||||
void BaseWindow::moveTo(QPoint point, widgets::BoundsChecking mode)
|
||||
|
|
|
@ -12,12 +12,6 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
TooltipWidget *TooltipWidget::instance()
|
||||
{
|
||||
static TooltipWidget *tooltipWidget = new TooltipWidget();
|
||||
return tooltipWidget;
|
||||
}
|
||||
|
||||
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
: BaseWindow({BaseWindow::TopMost, BaseWindow::DontFocus,
|
||||
BaseWindow::DisableLayoutSave},
|
||||
|
|
|
@ -29,9 +29,7 @@ class TooltipWidget : public BaseWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static TooltipWidget *instance();
|
||||
|
||||
TooltipWidget(BaseWidget *parent = nullptr);
|
||||
TooltipWidget(BaseWidget *parent);
|
||||
~TooltipWidget() override = default;
|
||||
|
||||
void setOne(const TooltipEntry &entry,
|
||||
|
|
|
@ -285,6 +285,7 @@ ChannelView::ChannelView(BaseWidget *parent, Split *split, Context context,
|
|||
, highlightAnimation_(this)
|
||||
, context_(context)
|
||||
, messages_(messagesLimit)
|
||||
, tooltipWidget_(new TooltipWidget(this))
|
||||
{
|
||||
this->setMouseTracking(true);
|
||||
|
||||
|
@ -1632,7 +1633,7 @@ void ChannelView::enterEvent(QEvent * /*event*/)
|
|||
|
||||
void ChannelView::leaveEvent(QEvent * /*event*/)
|
||||
{
|
||||
TooltipWidget::instance()->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
|
||||
this->unpause(PauseReason::Mouse);
|
||||
|
||||
|
@ -1653,7 +1654,6 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
this->pause(PauseReason::Mouse);
|
||||
}
|
||||
|
||||
auto *tooltipWidget = TooltipWidget::instance();
|
||||
std::shared_ptr<MessageLayout> layout;
|
||||
QPoint relativePos;
|
||||
int messageIndex;
|
||||
|
@ -1662,7 +1662,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (!tryGetMessageAt(event->pos(), layout, relativePos, messageIndex))
|
||||
{
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
tooltipWidget->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1700,14 +1700,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (layout->flags.has(MessageLayoutFlag::Collapsed))
|
||||
{
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
tooltipWidget->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (hoverLayoutElement == nullptr)
|
||||
{
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
tooltipWidget->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1721,7 +1721,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (element->getTooltip().isEmpty() ||
|
||||
(isLinkValid && isNotEmote && !getSettings()->linkInfoTooltip))
|
||||
{
|
||||
tooltipWidget->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1739,7 +1739,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
|
||||
if (emoteElement)
|
||||
{
|
||||
tooltipWidget->setOne({
|
||||
this->tooltipWidget_->setOne({
|
||||
showThumbnail
|
||||
? emoteElement->getEmote()->images.getImage(3.0)
|
||||
: nullptr,
|
||||
|
@ -1798,12 +1798,12 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
auto style = layeredEmotes.size() > 2
|
||||
? TooltipStyle::Grid
|
||||
: TooltipStyle::Vertical;
|
||||
tooltipWidget->set(entries, style);
|
||||
this->tooltipWidget_->set(entries, style);
|
||||
}
|
||||
}
|
||||
else if (badgeElement)
|
||||
{
|
||||
tooltipWidget->setOne({
|
||||
this->tooltipWidget_->setOne({
|
||||
showThumbnail
|
||||
? badgeElement->getEmote()->images.getImage(3.0)
|
||||
: nullptr,
|
||||
|
@ -1834,7 +1834,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (thumbnailSize == 0)
|
||||
{
|
||||
// "Show thumbnails" is set to "Off", show text only
|
||||
tooltipWidget->setOne({nullptr, element->getTooltip()});
|
||||
this->tooltipWidget_->setOne({nullptr, element->getTooltip()});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1851,21 +1851,24 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (element->getThumbnailType() ==
|
||||
MessageElement::ThumbnailType::Link_Thumbnail)
|
||||
{
|
||||
tooltipWidget->setOne({std::move(thumb),
|
||||
element->getTooltip(), thumbnailSize,
|
||||
thumbnailSize});
|
||||
this->tooltipWidget_->setOne({
|
||||
std::move(thumb),
|
||||
element->getTooltip(),
|
||||
thumbnailSize,
|
||||
thumbnailSize,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipWidget->setOne({std::move(thumb), ""});
|
||||
this->tooltipWidget_->setOne({std::move(thumb), ""});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tooltipWidget->moveTo(event->globalPos() + QPoint(16, 16),
|
||||
widgets::BoundsChecking::CursorPosition);
|
||||
tooltipWidget->setWordWrap(isLinkValid);
|
||||
tooltipWidget->show();
|
||||
this->tooltipWidget_->moveTo(event->globalPos() + QPoint(16, 16),
|
||||
widgets::BoundsChecking::CursorPosition);
|
||||
this->tooltipWidget_->setWordWrap(isLinkValid);
|
||||
this->tooltipWidget_->show();
|
||||
}
|
||||
|
||||
// check if word has a link
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "messages/Selection.hpp"
|
||||
#include "util/ThreadGuard.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/TooltipWidget.hpp"
|
||||
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <QMenu>
|
||||
|
@ -333,6 +334,8 @@ private:
|
|||
MessagePreferences messagePreferences_;
|
||||
|
||||
void scrollUpdateRequested();
|
||||
|
||||
TooltipWidget *const tooltipWidget_{};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "widgets/splits/SplitHeader.hpp"
|
||||
#include "widgets/splits/SplitInput.hpp"
|
||||
#include "widgets/splits/SplitOverlay.hpp"
|
||||
#include "widgets/TooltipWidget.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -993,8 +992,6 @@ void Split::leaveEvent(QEvent *event)
|
|||
|
||||
this->overlay_->hide();
|
||||
|
||||
TooltipWidget::instance()->hide();
|
||||
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ namespace chatterino {
|
|||
SplitHeader::SplitHeader(Split *split)
|
||||
: BaseWidget(split)
|
||||
, split_(split)
|
||||
, tooltipWidget_(new TooltipWidget(this))
|
||||
{
|
||||
this->initializeLayout();
|
||||
|
||||
|
@ -948,15 +949,16 @@ void SplitHeader::enterEvent(QEvent *event)
|
|||
{
|
||||
auto *channel = this->split_->getChannel().get();
|
||||
|
||||
auto *tooltip = TooltipWidget::instance();
|
||||
tooltip->setOne({nullptr, this->tooltipText_});
|
||||
tooltip->setWordWrap(true);
|
||||
tooltip->adjustSize();
|
||||
auto pos = this->mapToGlobal(this->rect().bottomLeft()) +
|
||||
QPoint((this->width() - tooltip->width()) / 2, 1);
|
||||
this->tooltipWidget_->setOne({nullptr, this->tooltipText_});
|
||||
this->tooltipWidget_->setWordWrap(true);
|
||||
this->tooltipWidget_->adjustSize();
|
||||
auto pos =
|
||||
this->mapToGlobal(this->rect().bottomLeft()) +
|
||||
QPoint((this->width() - this->tooltipWidget_->width()) / 2, 1);
|
||||
|
||||
tooltip->moveTo(pos, widgets::BoundsChecking::CursorPosition);
|
||||
tooltip->show();
|
||||
this->tooltipWidget_->moveTo(pos,
|
||||
widgets::BoundsChecking::CursorPosition);
|
||||
this->tooltipWidget_->show();
|
||||
}
|
||||
|
||||
BaseWidget::enterEvent(event);
|
||||
|
@ -964,7 +966,7 @@ void SplitHeader::enterEvent(QEvent *event)
|
|||
|
||||
void SplitHeader::leaveEvent(QEvent *event)
|
||||
{
|
||||
TooltipWidget::instance()->hide();
|
||||
this->tooltipWidget_->hide();
|
||||
|
||||
BaseWidget::leaveEvent(event);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/TooltipWidget.hpp"
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
|
@ -68,6 +69,7 @@ private:
|
|||
|
||||
Split *const split_{};
|
||||
QString tooltipText_{};
|
||||
TooltipWidget *const tooltipWidget_{};
|
||||
bool isLive_{false};
|
||||
QString thumbnail_;
|
||||
QElapsedTimer lastThumbnail_;
|
||||
|
|
Loading…
Reference in a new issue