diff --git a/src/application.cpp b/src/application.cpp index 5d1bb688e..7a4bc8453 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -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(); diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 50cbd73a9..139a42e92 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -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); diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index 9483f0a4f..2aef90203 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -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; diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 67393db85..ecabe9fc9 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -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 diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 617b22650..72d8b07a3 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -254,15 +254,18 @@ 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()) { + text = text.mid(0, match.capturedStart(1)) + '\n' + text.mid(match.capturedEnd(1)); + } - static QRegularExpression commaReplacement("^.+?, .+?,( ).+$"); - QRegularExpressionMatch match = commaReplacement.match(text); - if (match.hasMatch()) { - text = text.mid(0, match.capturedStart(1)) + '\n' + text.mid(match.capturedEnd(1)); + this->modeButton->getLabel().setText(text); + this->modeButton->show(); } - - this->modeButton->getLabel().setText(text); } 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) { diff --git a/src/widgets/tooltipwidget.cpp b/src/widgets/tooltipwidget.cpp index 6baa80526..e960bbd4f 100644 --- a/src/widgets/tooltipwidget.cpp +++ b/src/widgets/tooltipwidget.cpp @@ -9,11 +9,15 @@ #include #include +#ifdef USEWINSDK +#include +#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"); diff --git a/src/widgets/tooltipwidget.hpp b/src/widgets/tooltipwidget.hpp index 90259e7b0..fd7aa41d9 100644 --- a/src/widgets/tooltipwidget.hpp +++ b/src/widgets/tooltipwidget.hpp @@ -28,6 +28,10 @@ public: return tooltipWidget; } +#ifdef USEWINSDK + void raise(); +#endif + protected: void changeEvent(QEvent *) override; void leaveEvent(QEvent *) override;