Update fakewindow.cpp

Minor refactoring in FakeWindow::updateGeometry(), removed `if else if` structure and replaced them with a readable `switch` statement.
This commit is contained in:
Kasra Hashemi 2022-06-03 22:41:08 +04:30 committed by GitHub
parent 3e9c89a06f
commit 5dee1a848c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,17 +106,23 @@ void FakeWindow::updateGeometry()
const QRect screenRect = qApp->primaryScreen()->geometry(); const QRect screenRect = qApp->primaryScreen()->geometry();
QRect newRect; QRect newRect;
if (DockSettings::self()->direction() == DockSettings::Left) { switch (DockSettings::self()->direction())
newRect = QRect(screenRect.x() - (length * 2), (screenRect.height() + length) / 2, {
length, screenRect.height()); case DockSettings::Left:
} else if (DockSettings::self()->direction() == DockSettings::Bottom) { newRect = QRect(screenRect.x() - (length * 2),
newRect = QRect(screenRect.x(), (screenRect.height() + length) / 2,
screenRect.y() + screenRect.height() - length, length, screenRect.height());
screenRect.width(), length); break;
} else if (DockSettings::self()->direction() == DockSettings::Right) { case DockSettings::Bottom:
newRect = QRect(screenRect.x() + screenRect.width() - length, newRect = QRect(screenRect.x(),
screenRect.y(), screenRect.y() + screenRect.height() - length,
length, screenRect.height()); screenRect.width(), length);
break;
case DockSettings::Right:
newRect = QRect(screenRect.x() + screenRect.width() - length,
screenRect.y(),
length, screenRect.height());
break;
} }
setGeometry(newRect); setGeometry(newRect);