From e2f59d2e614bfae25a6d37d32e755ca3df3612d6 Mon Sep 17 00:00:00 2001 From: zneix Date: Sat, 31 Jul 2021 22:51:34 +0200 Subject: [PATCH] Use QApplication::screens().first() instead of deprecated methods Also follows-up moving away from QDesktop widget from c99f12e8fec20fa056c1c0f23e07caebf66e3474 Note: `QScreen::availableGeometry()` doesn't take the parent argument as opposed to `QDesktopWidget::availableGeometry(QWidget &xd)` - no idea if not passing an argument breaks anything, but just for the sake of having Chatterino compile I didn't mind it that much while fixing compilation. Reference: - https://doc.qt.io/qt-6/widgets-changes-qt6.html#qdesktopwidget-and-qapplication-desktop --- src/widgets/BaseWindow.cpp | 5 +++-- src/widgets/dialogs/NotificationPopup.cpp | 4 +--- src/widgets/helper/Button.cpp | 4 ++-- src/widgets/splits/SplitHeader.cpp | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 2702fe0d8..29b0e5124 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #ifdef CHATTERINO @@ -601,10 +602,10 @@ void BaseWindow::moveIntoDesktopRect(QWidget *parent, QPoint point) return; // move the widget into the screen geometry if it's not already in there - QDesktopWidget *desktop = QApplication::desktop(); + auto *desktop = QApplication::screens().first(); QPoint globalCursorPos = QCursor::pos(); - QRect s = desktop->availableGeometry(parent); + QRect s = desktop->availableGeometry(/*parent*/); bool stickRight = false; bool stickBottom = false; diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index 11e1b63a9..1315cdae0 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -5,9 +5,7 @@ #include "widgets/helper/ChannelView.hpp" #include -#include #include - #include namespace chatterino { @@ -32,7 +30,7 @@ void NotificationPopup::updatePosition() { Location location = BottomRight; - QDesktopWidget *desktop = QApplication::desktop(); + auto *desktop = QApplication::screens().first(); const QRect rect = desktop->availableGeometry(); switch (location) diff --git a/src/widgets/helper/Button.cpp b/src/widgets/helper/Button.cpp index 6fc8d7330..11a4cab38 100644 --- a/src/widgets/helper/Button.cpp +++ b/src/widgets/helper/Button.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include "BaseTheme.hpp" @@ -345,7 +344,8 @@ void Button::showMenu() return; auto point = [this] { - auto bounds = QApplication::desktop()->availableGeometry(this); + auto bounds = + QApplication::screens().first()->availableGeometry(/*this*/); auto point = this->mapToGlobal( QPoint(this->width() - this->menu_->width(), this->height())); diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index d49c9451f..fe564314c 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -22,7 +22,6 @@ #include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp" -#include #include #include #include