fixed the split overlay not appearing proprly

This commit is contained in:
fourtf 2018-05-17 16:39:38 +02:00
parent c27a4eec33
commit 795758f618
5 changed files with 22 additions and 55 deletions

View file

@ -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();
}

View file

@ -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)

View file

@ -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;

View file

@ -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

View file

@ -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;