From 6187864e7ffeb1d41c324e7636beca35a659de34 Mon Sep 17 00:00:00 2001 From: Boudewijn Rempt Date: Fri, 27 Sep 2019 14:26:51 +0200 Subject: [PATCH] Remove unused code for moving dialogs around CCBUG:412393 --- libs/widgets/KoDialog.cpp | 100 -------------------------------------- libs/widgets/KoDialog.h | 21 -------- 2 files changed, 121 deletions(-) diff --git a/libs/widgets/KoDialog.cpp b/libs/widgets/KoDialog.cpp index a1c9a4a2e5..de98f3e7b3 100644 --- a/libs/widgets/KoDialog.cpp +++ b/libs/widgets/KoDialog.cpp @@ -24,9 +24,7 @@ #include "KoDialog_p.h" #include -#include #include -#include #include #include #include @@ -550,104 +548,6 @@ void KoDialog::resizeLayout(QLayout *layout, int margin, int spacing) //static } } -static QRect screenRect(QWidget *widget, int screen) -{ - QDesktopWidget *desktop = QApplication::desktop(); - KConfig gc("kdeglobals", KConfig::NoGlobals); - auto screens = QGuiApplication::screens(); - KConfigGroup cg(&gc, "Windows"); - if (QApplication::primaryScreen()->virtualSiblings().count() && - cg.readEntry("XineramaEnabled", true) && - cg.readEntry("XineramaPlacementEnabled", true)) { - - if (screen < 0 || screen >= screens.count()) { - if (screen == -1) { - return QGuiApplication::primaryScreen()->availableVirtualGeometry(); - } else if (screen == -3) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return QGuiApplication::screenAt(QCursor::pos())->availableVirtualGeometry(); -#else - screen = desktop->screenNumber(QCursor::pos()); -#endif - } else { - screen = desktop->screenNumber(widget); - } - } - - return QGuiApplication::screens().at(screen)->availableVirtualGeometry(); - } else { - return desktop->geometry(); - } -} - -void KoDialog::centerOnScreen(QWidget *widget, int screen) -{ - if (!widget) { - return; - } - - QRect rect = screenRect(widget, screen); - - widget->move(rect.center().x() - widget->width() / 2, - rect.center().y() - widget->height() / 2); -} - -bool KoDialog::avoidArea(QWidget *widget, const QRect &area, int screen) -{ - if (!widget) { - return false; - } - - QRect fg = widget->frameGeometry(); - if (!fg.intersects(area)) { - return true; // nothing to do. - } - - const QRect scr = screenRect(widget, screen); - QRect avoid(area); // let's add some margin - avoid.translate(-5, -5); - avoid.setRight(avoid.right() + 10); - avoid.setBottom(avoid.bottom() + 10); - - if (qMax(fg.top(), avoid.top()) <= qMin(fg.bottom(), avoid.bottom())) { - // We need to move the widget up or down - int spaceAbove = qMax(0, avoid.top() - scr.top()); - int spaceBelow = qMax(0, scr.bottom() - avoid.bottom()); - if (spaceAbove > spaceBelow) // where's the biggest side? - if (fg.height() <= spaceAbove) { // big enough? - fg.setY(avoid.top() - fg.height()); - } else { - return false; - } - else if (fg.height() <= spaceBelow) { // big enough? - fg.setY(avoid.bottom()); - } else { - return false; - } - } - - if (qMax(fg.left(), avoid.left()) <= qMin(fg.right(), avoid.right())) { - // We need to move the widget left or right - const int spaceLeft = qMax(0, avoid.left() - scr.left()); - const int spaceRight = qMax(0, scr.right() - avoid.right()); - if (spaceLeft > spaceRight) // where's the biggest side? - if (fg.width() <= spaceLeft) { // big enough? - fg.setX(avoid.left() - fg.width()); - } else { - return false; - } - else if (fg.width() <= spaceRight) { // big enough? - fg.setX(avoid.right()); - } else { - return false; - } - } - - widget->move(fg.x(), fg.y()); - - return true; -} - void KoDialog::showButtonSeparator(bool state) { Q_D(KoDialog); diff --git a/libs/widgets/KoDialog.h b/libs/widgets/KoDialog.h index 315b0a970e..9bac7e5043 100644 --- a/libs/widgets/KoDialog.h +++ b/libs/widgets/KoDialog.h @@ -466,27 +466,6 @@ class KRITAWIDGETS_EXPORT KoDialog : public QDialog //krazy:exclude=qclasses */ static void resizeLayout(QLayout *lay, int margin, int spacing); - /** - * Centers @p widget on the desktop, taking multi-head setups into - * account. If @p screen is -1, @p widget will be centered on its - * current screen (if it was shown already) or on the primary screen. - * If @p screen is -3, @p widget will be centered on the screen that - * currently contains the mouse pointer. - * @p screen will be ignored if a merged display (like Xinerama) is not - * in use, or merged display placement is not enabled in kdeglobals. - */ - static void centerOnScreen(QWidget *widget, int screen = -1); - - /** - * Places @p widget so that it doesn't cover a certain @p area of the screen. - * This is typically used by the "find dialog" so that the match it finds can - * be read. - * For @p screen, see centerOnScreen - * @return true on success (widget doesn't cover area anymore, or never did), - * false on failure (not enough space found) - */ - static bool avoidArea(QWidget *widget, const QRect &area, int screen = -1); - /** * Sets the main widget of the dialog. */