From 5dee1a848c92a500adde0b4e3e2279edd5a2de0d Mon Sep 17 00:00:00 2001 From: Kasra Hashemi <73937934+zencatalyst@users.noreply.github.com> Date: Fri, 3 Jun 2022 22:41:08 +0430 Subject: [PATCH] Update fakewindow.cpp Minor refactoring in FakeWindow::updateGeometry(), removed `if else if` structure and replaced them with a readable `switch` statement. --- src/fakewindow.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/fakewindow.cpp b/src/fakewindow.cpp index 1078161..2a6ec16 100644 --- a/src/fakewindow.cpp +++ b/src/fakewindow.cpp @@ -106,17 +106,23 @@ void FakeWindow::updateGeometry() const QRect screenRect = qApp->primaryScreen()->geometry(); QRect newRect; - if (DockSettings::self()->direction() == DockSettings::Left) { - newRect = QRect(screenRect.x() - (length * 2), (screenRect.height() + length) / 2, - length, screenRect.height()); - } else if (DockSettings::self()->direction() == DockSettings::Bottom) { - newRect = QRect(screenRect.x(), - screenRect.y() + screenRect.height() - length, - screenRect.width(), length); - } else if (DockSettings::self()->direction() == DockSettings::Right) { - newRect = QRect(screenRect.x() + screenRect.width() - length, - screenRect.y(), - length, screenRect.height()); + switch (DockSettings::self()->direction()) + { + case DockSettings::Left: + newRect = QRect(screenRect.x() - (length * 2), + (screenRect.height() + length) / 2, + length, screenRect.height()); + break; + case DockSettings::Bottom: + newRect = QRect(screenRect.x(), + screenRect.y() + screenRect.height() - length, + screenRect.width(), length); + break; + case DockSettings::Right: + newRect = QRect(screenRect.x() + screenRect.width() - length, + screenRect.y(), + length, screenRect.height()); + break; } setGeometry(newRect);