mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed tooltips not showing over topmost windows on windows
This commit is contained in:
parent
59110ad4bd
commit
abc2b9724f
|
@ -61,6 +61,7 @@ void Application::construct()
|
|||
isAppConstructed = true;
|
||||
|
||||
// 1. Instantiate all classes
|
||||
this->settings = new singletons::SettingManager;
|
||||
this->paths = new singletons::PathManager(this->argc, this->argv);
|
||||
this->themes = new singletons::ThemeManager;
|
||||
this->windows = new singletons::WindowManager;
|
||||
|
@ -70,7 +71,6 @@ void Application::construct()
|
|||
this->ignores = new controllers::ignores::IgnoreController;
|
||||
this->accounts = new singletons::AccountManager;
|
||||
this->emotes = new singletons::EmoteManager;
|
||||
this->settings = new singletons::SettingManager;
|
||||
this->fonts = new singletons::FontManager;
|
||||
this->resources = new singletons::ResourceManager;
|
||||
|
||||
|
@ -92,12 +92,12 @@ void Application::initialize()
|
|||
|
||||
// 2. Initialize/load classes
|
||||
this->settings->initialize();
|
||||
this->windows->initialize();
|
||||
|
||||
this->nativeMessaging->registerHost();
|
||||
|
||||
this->settings->load();
|
||||
this->commands->load();
|
||||
this->windows->initialize();
|
||||
|
||||
this->resources->initialize();
|
||||
|
||||
|
|
|
@ -32,10 +32,12 @@
|
|||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
BaseWindow::BaseWindow(QWidget *parent, Flags flags)
|
||||
: BaseWidget(parent, Qt::Window)
|
||||
, enableCustomFrame(flags & EnableCustomFrame)
|
||||
, frameless(flags & FrameLess)
|
||||
BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
||||
: BaseWidget(parent,
|
||||
Qt::Window | ((_flags & TopMost) ? Qt::WindowStaysOnTopHint : (Qt::WindowFlags)0))
|
||||
, enableCustomFrame(_flags & EnableCustomFrame)
|
||||
, frameless(_flags & FrameLess)
|
||||
, flags(_flags)
|
||||
{
|
||||
if (this->frameless) {
|
||||
this->enableCustomFrame = false;
|
||||
|
@ -45,6 +47,11 @@ BaseWindow::BaseWindow(QWidget *parent, Flags flags)
|
|||
this->init();
|
||||
}
|
||||
|
||||
BaseWindow::Flags BaseWindow::getFlags()
|
||||
{
|
||||
return this->flags;
|
||||
}
|
||||
|
||||
void BaseWindow::init()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
@ -124,14 +131,19 @@ void BaseWindow::init()
|
|||
#endif
|
||||
|
||||
#ifdef USEWINSDK
|
||||
app->settings->windowTopMost.connect([this](bool topMost, auto) {
|
||||
::SetWindowPos((HWND)this->winId(), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
// fourtf: don't ask me why we need to delay this
|
||||
QTimer::singleShot(1, this, [this] {
|
||||
if (!(this->flags & Flags::TopMost)) {
|
||||
getApp()->settings->windowTopMost.connect([this](bool topMost, auto) {
|
||||
::SetWindowPos((HWND)this->winId(), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0,
|
||||
0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
});
|
||||
}
|
||||
});
|
||||
#else
|
||||
if (app->settings->windowTopMost.getValue()) {
|
||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
// if (getApp()->settings->windowTopMost.getValue()) {
|
||||
// this->setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -425,8 +437,9 @@ void BaseWindow::showEvent(QShowEvent *event)
|
|||
{
|
||||
if (!this->shown && this->isVisible() && this->hasCustomWindowFrame()) {
|
||||
this->shown = true;
|
||||
SetWindowLongPtr((HWND)this->winId(), GWL_STYLE,
|
||||
WS_POPUP | WS_CAPTION | WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
|
||||
// SetWindowLongPtr((HWND)this->winId(), GWL_STYLE,
|
||||
// WS_POPUP | WS_CAPTION | WS_THICKFRAME | WS_MAXIMIZEBOX |
|
||||
// WS_MINIMIZEBOX);
|
||||
|
||||
const MARGINS shadow = {8, 8, 8, 8};
|
||||
DwmExtendFrameIntoClientArea((HWND)this->winId(), &shadow);
|
||||
|
|
|
@ -19,7 +19,7 @@ class BaseWindow : public BaseWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Flags { None = 0, EnableCustomFrame = 1, FrameLess = 2 };
|
||||
enum Flags { None = 0, EnableCustomFrame = 1, FrameLess = 2, TopMost = 4 };
|
||||
|
||||
explicit BaseWindow(QWidget *parent = nullptr, Flags flags = None);
|
||||
|
||||
|
@ -33,6 +33,8 @@ public:
|
|||
|
||||
void moveTo(QWidget *widget, QPoint point);
|
||||
|
||||
Flags getFlags();
|
||||
|
||||
protected:
|
||||
#ifdef USEWINSDK
|
||||
void showEvent(QShowEvent *) override;
|
||||
|
@ -56,6 +58,7 @@ private:
|
|||
bool frameless;
|
||||
bool stayInScreenRect = false;
|
||||
bool shown = false;
|
||||
Flags flags;
|
||||
|
||||
struct {
|
||||
QHBoxLayout *titlebarBox = nullptr;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#define LAYOUT_WIDTH (this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getScale())
|
||||
#define SELECTION_RESUME_SCROLLING_MSG_THRESHOLD 3
|
||||
#define CHAT_HOVER_PAUSE_DURATION 300
|
||||
#define CHAT_HOVER_PAUSE_DURATION 400
|
||||
|
||||
using namespace chatterino::messages;
|
||||
using namespace chatterino::providers::twitch;
|
||||
|
@ -800,6 +800,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
tooltipWidget->moveTo(this, event->globalPos());
|
||||
tooltipWidget->setText(tooltip);
|
||||
tooltipWidget->show();
|
||||
tooltipWidget->raise();
|
||||
}
|
||||
|
||||
// check if word has a link
|
||||
|
|
|
@ -254,8 +254,9 @@ void SplitHeader::updateModes()
|
|||
text = text.mid(0, text.size() - 2);
|
||||
}
|
||||
|
||||
qDebug() << text;
|
||||
|
||||
if (text.isEmpty()) {
|
||||
this->modeButton->hide();
|
||||
} else {
|
||||
static QRegularExpression commaReplacement("^.+?, .+?,( ).+$");
|
||||
QRegularExpressionMatch match = commaReplacement.match(text);
|
||||
if (match.hasMatch()) {
|
||||
|
@ -263,6 +264,8 @@ void SplitHeader::updateModes()
|
|||
}
|
||||
|
||||
this->modeButton->getLabel().setText(text);
|
||||
this->modeButton->show();
|
||||
}
|
||||
}
|
||||
|
||||
void SplitHeader::paintEvent(QPaintEvent *)
|
||||
|
@ -326,6 +329,7 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
|||
tooltipWidget->moveTo(this, event->globalPos());
|
||||
tooltipWidget->setText(tooltip);
|
||||
tooltipWidget->show();
|
||||
tooltipWidget->raise();
|
||||
}
|
||||
|
||||
if (this->dragging) {
|
||||
|
|
|
@ -9,11 +9,15 @@
|
|||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#ifdef USEWINSDK
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
: BaseWindow(parent)
|
||||
: BaseWindow(parent, BaseWindow::TopMost)
|
||||
, displayText(new QLabel())
|
||||
{
|
||||
auto app = getApp();
|
||||
|
@ -24,9 +28,8 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
|||
this->setStayInScreenRect(true);
|
||||
|
||||
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
|
||||
Qt::X11BypassWindowManagerHint | Qt::BypassWindowManagerHint |
|
||||
Qt::SubWindow);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint |
|
||||
Qt::BypassWindowManagerHint);
|
||||
|
||||
displayText->setAlignment(Qt::AlignHCenter);
|
||||
displayText->setText("tooltip text");
|
||||
|
@ -43,6 +46,14 @@ TooltipWidget::~TooltipWidget()
|
|||
this->fontChangedConnection.disconnect();
|
||||
}
|
||||
|
||||
#ifdef USEWINSDK
|
||||
void TooltipWidget::raise()
|
||||
{
|
||||
::SetWindowPos((HWND)this->winId(), HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TooltipWidget::themeRefreshEvent()
|
||||
{
|
||||
this->setStyleSheet("color: #fff; background: #000");
|
||||
|
|
|
@ -28,6 +28,10 @@ public:
|
|||
return tooltipWidget;
|
||||
}
|
||||
|
||||
#ifdef USEWINSDK
|
||||
void raise();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *) override;
|
||||
void leaveEvent(QEvent *) override;
|
||||
|
|
Loading…
Reference in a new issue