summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qsplashscreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qsplashscreen.cpp')
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp61
1 files changed, 11 insertions, 50 deletions
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 1f1c71dcb8..2c2d1922be 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -40,7 +40,6 @@
#include "qsplashscreen.h"
#include "qapplication.h"
-#include <private/qdesktopwidget_p.h>
#include "qpainter.h"
#include "qpixmap.h"
#include "qtextdocument.h"
@@ -69,10 +68,6 @@ public:
int currAlign;
inline QSplashScreenPrivate();
-
- void setPixmap(const QPixmap &p, const QScreen *screen = nullptr);
-
- static const QScreen *screenFor(const QWidget *w);
};
/*!
@@ -153,7 +148,9 @@ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowFlags f)
: QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
- d_func()->setPixmap(pixmap, screen);
+ Q_D(QSplashScreen);
+ d->setScreen(screen);
+ setPixmap(pixmap);
}
/*!
@@ -283,52 +280,16 @@ void QSplashScreen::finish(QWidget *mainWin)
*/
void QSplashScreen::setPixmap(const QPixmap &pixmap)
{
- d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(this));
-}
-
-// In setPixmap(), resize and try to position on a screen according to:
-// 1) If the screen for the given widget is available, use that
-// 2) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on
-// QSplashScreen(QWidget *, QPixmap).
-// 3) If a widget with associated QWindow is found, use that
-// 4) When nothing can be found, try to center it over the cursor
-
-const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w)
-{
- if (w && w->screen())
- return w->screen();
-
- for (const QWidget *p = w; p !=nullptr ; p = p->parentWidget()) {
- if (auto dsw = qobject_cast<const QDesktopScreenWidget *>(p))
- return dsw->screen();
- if (QWindow *window = p->windowHandle())
- return window->screen();
- }
-
-#if QT_CONFIG(cursor)
- // Note: We could rely on QPlatformWindow::initialGeometry() to center it
- // over the cursor, but not all platforms (namely Android) use that.
- if (QGuiApplication::screens().size() > 1) {
- if (auto screenAtCursor = QGuiApplication::screenAt(QCursor::pos()))
- return screenAtCursor;
- }
-#endif // cursor
- return QGuiApplication::primaryScreen();
-}
-
-void QSplashScreenPrivate::setPixmap(const QPixmap &p, const QScreen *screen)
-{
- Q_Q(QSplashScreen);
+ Q_D(QSplashScreen);
+ d->pixmap = pixmap;
+ setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
- pixmap = p;
- q->setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
+ const QRect r(QPoint(), pixmap.size() / pixmap.devicePixelRatio());
+ resize(r.size());
- QRect r(QPoint(), pixmap.size() / pixmap.devicePixelRatio());
- q->resize(r.size());
- if (screen)
- q->move(screen->geometry().center() - r.center());
- if (q->isVisible())
- q->repaint();
+ move(screen()->geometry().center() - r.center());
+ if (isVisible())
+ repaint();
}
/*!