From be9d8967f71d01f5131a87e3c330ff2d9ae59479 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 9 Aug 2023 03:58:14 +0300 Subject: [PATCH] kdeui: remove redundant KGlobalSettings::desktopGeometry() methods QDesktopWidget is Xinerama aware and it can be disabled because I implemented option for that, see the following commit in the Katie repo: b7e4bae65f0cae7f3029b98980f638c077ecfc22 Signed-off-by: Ivailo Monev --- kdeui/dialogs/kmessagebox.cpp | 27 ++++++++--------- kdeui/dialogs/kpassworddialog.cpp | 3 +- kdeui/kernel/kglobalsettings.cpp | 44 +--------------------------- kdeui/kernel/kglobalsettings.h | 31 -------------------- kdeui/util/kpassivepopup.cpp | 23 +++++++-------- kdeui/widgets/kcompletionbox.cpp | 11 ++++--- kdeui/widgets/ksqueezedtextlabel.cpp | 13 ++++---- 7 files changed, 39 insertions(+), 113 deletions(-) diff --git a/kdeui/dialogs/kmessagebox.cpp b/kdeui/dialogs/kmessagebox.cpp index d2da0177..71c40203 100644 --- a/kdeui/dialogs/kmessagebox.cpp +++ b/kdeui/dialogs/kmessagebox.cpp @@ -18,6 +18,17 @@ */ #include "kmessagebox.h" +#include "kapplication.h" +#include "kconfig.h" +#include "kdialog.h" +#include "kdialogqueue_p.h" +#include "klocale.h" +#include "knotification.h" +#include "kiconloader.h" +#include "kconfiggroup.h" +#include "ktextedit.h" +#include "ksqueezedtextlabel.h" +#include "kwindowsystem.h" #include #include @@ -28,19 +39,7 @@ #include #include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // Some i18n filters, that standard button texts are piped through // (the new KGuiItem object with filtered text is created from the old one). @@ -199,7 +198,7 @@ int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon, } messageLabel->setTextInteractionFlags(flags); - QRect desktop = KGlobalSettings::desktopGeometry(dialog); + QRect desktop = QApplication::desktop()->screenGeometry(dialog); bool usingSqueezedTextLabel = false; if (messageLabel->sizeHint().width() > desktop.width() * 0.5) { // enable automatic wrapping of messages which are longer than 50% of screen width diff --git a/kdeui/dialogs/kpassworddialog.cpp b/kdeui/dialogs/kpassworddialog.cpp index 1929d6bb..a6dc3c69 100644 --- a/kdeui/dialogs/kpassworddialog.cpp +++ b/kdeui/dialogs/kpassworddialog.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -127,7 +128,7 @@ void KPasswordDialog::KPasswordDialogPrivate::init() updateFields(); - QRect desktop = KGlobalSettings::desktopGeometry(q->window()); + QRect desktop = QApplication::desktop()->screenGeometry(q->window()); q->setMinimumWidth(qMin(1000, qMax(q->sizeHint().width(), desktop.width() / 4))); q->setPixmap(KIcon("dialog-password").pixmap(KIconLoader::SizeHuge)); } diff --git a/kdeui/kernel/kglobalsettings.cpp b/kdeui/kernel/kglobalsettings.cpp index 829eabf8..d9343065 100644 --- a/kdeui/kernel/kglobalsettings.cpp +++ b/kdeui/kernel/kglobalsettings.cpp @@ -391,49 +391,7 @@ bool KGlobalSettings::wheelMouseZooms() QRect KGlobalSettings::splashScreenDesktopGeometry() { QDesktopWidget *dw = QApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - int scr = group.readEntry("Unmanaged", -3); - if (group.readEntry("XineramaEnabled", true) && scr != -2) { - if (scr == -3) { - scr = dw->screenNumber(QCursor::pos()); - } - return dw->screenGeometry(scr); - } - } - return dw->geometry(); -} - -QRect KGlobalSettings::desktopGeometry(const QPoint& point) -{ - QDesktopWidget *dw = QApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - if (group.readEntry("XineramaEnabled", true) && - group.readEntry("XineramaPlacementEnabled", true)) { - return dw->screenGeometry(dw->screenNumber(point)); - } - } - return dw->geometry(); -} - -QRect KGlobalSettings::desktopGeometry(const QWidget* w) -{ - QDesktopWidget *dw = QApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - if (group.readEntry("XineramaEnabled", true) && - group.readEntry("XineramaPlacementEnabled", true)) { - if (w) { - return dw->screenGeometry(dw->screenNumber(w)); - } - return dw->screenGeometry(-1); - } - } - return dw->geometry(); + return dw->screenGeometry(dw->screenNumber(QCursor::pos())); } bool KGlobalSettings::showIconsOnPushButtons() diff --git a/kdeui/kernel/kglobalsettings.h b/kdeui/kernel/kglobalsettings.h index 1813f7e9..8d45da29 100644 --- a/kdeui/kernel/kglobalsettings.h +++ b/kdeui/kernel/kglobalsettings.h @@ -371,37 +371,6 @@ public: */ static QRect splashScreenDesktopGeometry(); - /** - * This function returns the desktop geometry for an application that needs - * to set the geometry of a widget on the screen manually. It takes into - * account the user's display settings (number of screens, Xinerama, etc), - * and the user's preferences (if KDE should be Xinerama aware). - * - * Note that this can break in multi-head (not Xinerama) mode because this - * point could be on multiple screens. Use with care. - * - * @param point a reference point for the widget, for instance one that the - * widget should be adjacent or on top of. - * - * @return the geometry to use for the desktop. Note that it might not - * start at (0,0). - */ - static QRect desktopGeometry(const QPoint& point); - - /** - * This function returns the desktop geometry for an application that needs - * to set the geometry of a widget on the screen manually. It takes into - * account the user's display settings (number of screens, Xinerama, etc), - * and the user's preferences (if KDE should be Xinerama aware). - * - * @param w the widget in question. This is used to determine which screen - * to use in Xinerama or multi-head mode. - * - * @return the geometry to use for the desktop. Note that it might not - * start at (0,0). - */ - static QRect desktopGeometry(const QWidget* w); - /** * This function determines if the user wishes to see icons on the * push buttons. diff --git a/kdeui/util/kpassivepopup.cpp b/kdeui/util/kpassivepopup.cpp index cc84f092..a5d561d9 100644 --- a/kdeui/util/kpassivepopup.cpp +++ b/kdeui/util/kpassivepopup.cpp @@ -17,8 +17,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, */ +#include "config.h" #include "kpassivepopup.h" -#include "moc_kpassivepopup.cpp" +#include "kvbox.h" +#include "kdialog.h" +#include "kconfig.h" +#include "kdebug.h" +#include "netwm.h" // Qt #include @@ -32,17 +37,9 @@ #include #include #include +#include #include -#include -#include -#include -#include -#include -#include - -#include - static const int DEFAULT_POPUP_TYPE = KPassivePopup::Boxed; static const int DEFAULT_POPUP_TIME = 6*1000; static const Qt::WindowFlags POPUP_FLAGS = Qt::Tool | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint; @@ -353,7 +350,7 @@ QPoint KPassivePopup::calculateNearbyPoint(const QRect &target) int w = minimumSizeHint().width(); int h = minimumSizeHint().height(); - QRect r = KGlobalSettings::desktopGeometry(QPoint(x + w / 2,y + h / 2)); + QRect r = QApplication::desktop()->screenGeometry(QPoint(x + w / 2,y + h / 2)); if (d->popupStyle == KPassivePopup::Balloon) { // find a point to anchor to @@ -417,7 +414,7 @@ void KPassivePopup::updateMask() { // get screen-geometry for screen our anchor is on // (geometry can differ from screen to screen! - QRect deskRect = KGlobalSettings::desktopGeometry(d->anchor); + QRect deskRect = QApplication::desktop()->screenGeometry(d->anchor); int xh = 70, xl = 40; if (width() < 80) { @@ -602,3 +599,5 @@ KPassivePopup *KPassivePopup::message(int popupStyle, const QString &caption, co { return message(popupStyle, caption, text, QPixmap(), parent); } + +#include "moc_kpassivepopup.cpp" diff --git a/kdeui/widgets/kcompletionbox.cpp b/kdeui/widgets/kcompletionbox.cpp index 46af12f7..8cfe9243 100644 --- a/kdeui/widgets/kcompletionbox.cpp +++ b/kdeui/widgets/kcompletionbox.cpp @@ -23,17 +23,16 @@ #include "kcompletionbox.h" #include "klineedit.h" +#include "kconfig.h" +#include "kdebug.h" #include #include #include #include #include -#include - -#include -#include -#include +#include +#include class KCompletionBox::KCompletionBoxPrivate { @@ -283,7 +282,7 @@ void KCompletionBox::sizeAndPosition() if ( d->m_parent ) { if ( !isVisible() ) { QPoint orig = globalPositionHint(); - QRect screenSize = KGlobalSettings::desktopGeometry(orig); + QRect screenSize = QApplication::desktop()->screenGeometry(orig); x = orig.x() + geom.x(); y = orig.y() + geom.y(); diff --git a/kdeui/widgets/ksqueezedtextlabel.cpp b/kdeui/widgets/ksqueezedtextlabel.cpp index 8e229d2e..a5dd49da 100644 --- a/kdeui/widgets/ksqueezedtextlabel.cpp +++ b/kdeui/widgets/ksqueezedtextlabel.cpp @@ -17,16 +17,17 @@ */ #include "ksqueezedtextlabel.h" -#include -#include -#include -#include +#include "kaction.h" +#include "klocale.h" +#include "kdebug.h" + +#include #include #include #include #include #include -#include +#include class KSqueezedTextLabelPrivate { @@ -77,7 +78,7 @@ QSize KSqueezedTextLabel::minimumSizeHint() const QSize KSqueezedTextLabel::sizeHint() const { - int maxWidth = KGlobalSettings::desktopGeometry(this).width() * 3 / 4; + int maxWidth = QApplication::desktop()->screenGeometry(this).width() * 3 / 4; QFontMetrics fm(fontMetrics()); int textWidth = fm.width(d->fullText); if (textWidth > maxWidth) {