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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-09 03:58:14 +03:00
parent a2101eec56
commit be9d8967f7
7 changed files with 39 additions and 113 deletions

View file

@ -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 <QtCore/QPointer>
#include <QtGui/QCheckBox>
@ -28,19 +39,7 @@
#include <QtGui/QScrollArea>
#include <QtGui/QScrollBar>
#include <QtGui/QTextDocumentFragment>
#include <kapplication.h>
#include <kconfig.h>
#include <kdialog.h>
#include <kdialogqueue_p.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include <knotification.h>
#include <kiconloader.h>
#include <kconfiggroup.h>
#include <ktextedit.h>
#include <ksqueezedtextlabel.h>
#include <kwindowsystem.h>
#include <QtGui/QDesktopWidget>
// 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

View file

@ -23,6 +23,7 @@
#include <QLayout>
#include <QTextDocument>
#include <QTimer>
#include <QDesktopWidget>
#include <kcombobox.h>
#include <kconfig.h>
@ -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));
}

View file

@ -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()

View file

@ -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.

View file

@ -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 <QApplication>
@ -32,17 +37,9 @@
#include <QTimer>
#include <QToolTip>
#include <QSystemTrayIcon>
#include <QDesktopWidget>
#include <QX11Info>
#include <kvbox.h>
#include <kdebug.h>
#include <kdialog.h>
#include <kglobalsettings.h>
#include <kconfig.h>
#include <netwm.h>
#include <config.h>
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"

View file

@ -23,17 +23,16 @@
#include "kcompletionbox.h"
#include "klineedit.h"
#include "kconfig.h"
#include "kdebug.h"
#include <QtCore/QEvent>
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QStyle>
#include <QtGui/QScrollBar>
#include <QtGui/qevent.h>
#include <kdebug.h>
#include <kconfig.h>
#include <kglobalsettings.h>
#include <QtGui/QDesktopWidget>
#include <QtGui/QKeyEvent>
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();

View file

@ -17,16 +17,17 @@
*/
#include "ksqueezedtextlabel.h"
#include <kdebug.h>
#include <klocale.h>
#include <QtGui/qevent.h>
#include <kaction.h>
#include "kaction.h"
#include "klocale.h"
#include "kdebug.h"
#include <QResizeEvent>
#include <QMenu>
#include <QClipboard>
#include <QApplication>
#include <QMimeData>
#include <QTextDocument>
#include <kglobalsettings.h>
#include <QDesktopWidget>
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) {