From 795758f618180ff95c1f803b49fa24f2c8241e58 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 17 May 2018 16:39:38 +0200 Subject: [PATCH] fixed the split overlay not appearing proprly --- src/providers/twitch/twitchchannel.cpp | 2 + src/widgets/helper/splitoverlay.cpp | 10 +++-- src/widgets/helper/splitoverlay.hpp | 1 + src/widgets/split.cpp | 58 ++++++-------------------- src/widgets/split.hpp | 6 --- 5 files changed, 22 insertions(+), 55 deletions(-) diff --git a/src/providers/twitch/twitchchannel.cpp b/src/providers/twitch/twitchchannel.cpp index 51da12992..2b7300d21 100644 --- a/src/providers/twitch/twitchchannel.cpp +++ b/src/providers/twitch/twitchchannel.cpp @@ -191,6 +191,8 @@ bool TwitchChannel::isBroadcaster() { auto app = getApp(); + qDebug() << "ASD" << (this->name == app->accounts->Twitch.getCurrent()->getUserName()); + return this->name == app->accounts->Twitch.getCurrent()->getUserName(); } diff --git a/src/widgets/helper/splitoverlay.cpp b/src/widgets/helper/splitoverlay.cpp index 664177aa3..ccde94cd1 100644 --- a/src/widgets/helper/splitoverlay.cpp +++ b/src/widgets/helper/splitoverlay.cpp @@ -126,9 +126,13 @@ void SplitOverlay::resizeEvent(QResizeEvent *event) void SplitOverlay::mouseMoveEvent(QMouseEvent *event) { - if ((event->modifiers() & Qt::AltModifier) == 0) { - this->hide(); - } + BaseWidget::mouseMoveEvent(event); + + // qDebug() << QGuiApplication::queryKeyboardModifiers(); + + // if ((QGuiApplication::queryKeyboardModifiers() & Qt::AltModifier) == Qt::AltModifier) { + // this->hide(); + // } } SplitOverlay::ButtonEventFilter::ButtonEventFilter(SplitOverlay *_parent, HoveredElement _element) diff --git a/src/widgets/helper/splitoverlay.hpp b/src/widgets/helper/splitoverlay.hpp index f7e8c16dd..9dc067991 100644 --- a/src/widgets/helper/splitoverlay.hpp +++ b/src/widgets/helper/splitoverlay.hpp @@ -17,6 +17,7 @@ public: explicit SplitOverlay(Split *parent = nullptr); protected: + // bool event(QEvent *event) override; void paintEvent(QPaintEvent *event) override; void resizeEvent(QResizeEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/widgets/split.cpp b/src/widgets/split.cpp index 1d1b9a5e2..2f30d4e78 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -129,10 +129,15 @@ Split::Split(QWidget *parent) this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers status) { + + qDebug() << "xD" << status; + if ((status == Qt::AltModifier || status == (Qt::AltModifier | Qt::ControlModifier)) && this->isMouseOver) { + qDebug() << "show"; this->overlay->show(); } else { + qDebug() << "hide"; this->overlay->hide(); } }); @@ -271,26 +276,19 @@ void Split::paintEvent(QPaintEvent *) void Split::mouseMoveEvent(QMouseEvent *event) { - this->handleModifiers(event, event->modifiers()); -} - -void Split::mousePressEvent(QMouseEvent *event) -{ - // if (event->buttons() == Qt::LeftButton && event->modifiers() & Qt::AltModifier) { - // this->drag(); - // } + this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers()); } void Split::keyPressEvent(QKeyEvent *event) { this->view.unsetCursor(); - this->handleModifiers(event, event->modifiers()); + this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers()); } void Split::keyReleaseEvent(QKeyEvent *event) { this->view.unsetCursor(); - this->handleModifiers(event, event->modifiers()); + this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers()); } void Split::resizeEvent(QResizeEvent *event) @@ -304,7 +302,7 @@ void Split::enterEvent(QEvent *event) { this->isMouseOver = true; - auto a = modifierStatus; + this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers()); if (modifierStatus == Qt::AltModifier || modifierStatus == (Qt::AltModifier | Qt::ControlModifier)) { @@ -315,7 +313,10 @@ void Split::enterEvent(QEvent *event) void Split::leaveEvent(QEvent *event) { this->isMouseOver = false; + this->overlay->hide(); + + this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers()); } void Split::handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers) @@ -324,41 +325,6 @@ void Split::handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers) modifierStatus = modifiers; modifierStatusChanged.invoke(modifiers); } - - // if (modifiers == Qt::AltModifier) { - // if (!modifierStatus) { - // modifierStatus = true; - // modifierStatusChanged.invoke(true); - // } - // } else { - // if (modifierStatus) { - // modifierStatus = false; - // modifierStatusChanged.invoke(false); - // } - // this->setCursor(Qt::ArrowCursor); - // } -} - -void Split::dragEnterEvent(QDragEnterEvent *event) -{ - event->acceptProposedAction(); - this->isDragging = true; - QTimer::singleShot(1, [this] { this->overlay->show(); }); -} - -void Split::dragLeaveEvent(QDragLeaveEvent *event) -{ - this->overlay->hide(); - this->isDragging = false; -} - -void Split::dragMoveEvent(QDragMoveEvent *event) -{ - event->acceptProposedAction(); -} - -void Split::dropEvent(QDropEvent *event) -{ } /// Slots diff --git a/src/widgets/split.hpp b/src/widgets/split.hpp index 565844b38..45a09d887 100644 --- a/src/widgets/split.hpp +++ b/src/widgets/split.hpp @@ -77,18 +77,12 @@ public: protected: void paintEvent(QPaintEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; void resizeEvent(QResizeEvent *event) override; void enterEvent(QEvent *event) override; void leaveEvent(QEvent *event) override; - void dragEnterEvent(QDragEnterEvent *event) override; - void dragLeaveEvent(QDragLeaveEvent *event) override; - void dragMoveEvent(QDragMoveEvent *event) override; - void dropEvent(QDropEvent *event) override; - private: SplitContainer *container; IndirectChannel channel;