From 2a10b0f7c8b1f225c7f2720c684e7745f65bc96e Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 1 Jun 2021 10:12:55 +0800 Subject: [PATCH] More cleanup static_cast will always succeed, not need to check. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- framelesshelper.cpp | 50 ++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/framelesshelper.cpp b/framelesshelper.cpp index ce89ca3..e8e7f95 100644 --- a/framelesshelper.cpp +++ b/framelesshelper.cpp @@ -197,50 +197,36 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) switch (event->type()) { case QEvent::MouseButtonDblClick: { const auto mouseEvent = static_cast(event); - if (mouseEvent) { - if (mouseEvent->button() != Qt::MouseButton::LeftButton) { + if (mouseEvent->button() != Qt::MouseButton::LeftButton) { + break; + } + if (isInTitlebarArea(getMousePos(mouseEvent, false), currentWindow)) { + if (currentWindow->windowState() == Qt::WindowState::WindowFullScreen) { break; } - if (isInTitlebarArea(getMousePos(mouseEvent, false), currentWindow)) { - if (currentWindow->windowState() == Qt::WindowState::WindowFullScreen) { - break; - } - if (currentWindow->windowState() == Qt::WindowState::WindowMaximized) { - currentWindow->showNormal(); - } else { - currentWindow->showMaximized(); - } - currentWindow->setCursor(Qt::CursorShape::ArrowCursor); + if (currentWindow->windowState() == Qt::WindowState::WindowMaximized) { + currentWindow->showNormal(); + } else { + currentWindow->showMaximized(); } + currentWindow->setCursor(Qt::CursorShape::ArrowCursor); } } break; case QEvent::MouseButtonPress: { const auto mouseEvent = static_cast(event); - if (mouseEvent) { - if (mouseEvent->button() != Qt::MouseButton::LeftButton) { - break; - } - moveOrResize(getMousePos(mouseEvent, false), currentWindow); + if (mouseEvent->button() != Qt::MouseButton::LeftButton) { + break; } + moveOrResize(getMousePos(mouseEvent, false), currentWindow); } break; case QEvent::MouseMove: { const auto mouseEvent = static_cast(event); - if (mouseEvent) { - if ((currentWindow->windowState() == Qt::WindowState::WindowNoState) + if ((currentWindow->windowState() == Qt::WindowState::WindowNoState) && getResizable(currentWindow)) { - currentWindow->setCursor( - getCursorShape(getWindowEdges(getMousePos(mouseEvent, false), - currentWindow->width(), - currentWindow->height()))); - } - } - } break; - case QEvent::MouseButtonRelease: { - const auto mouseEvent = static_cast(event); - if (mouseEvent) { - if (mouseEvent->button() != Qt::MouseButton::LeftButton) { - break; - } + currentWindow->setCursor( + getCursorShape(getWindowEdges(getMousePos(mouseEvent, false), + currentWindow->width(), + currentWindow->height()))); } } break; case QEvent::TouchBegin: