diff options
Diffstat (limited to 'tests')
23 files changed, 11 insertions, 272 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 87d513bacb..24f10e559c 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -33,7 +33,6 @@ #include <qimage.h> #include <qimagereader.h> #ifndef QT_NO_WIDGETS -#include <qdesktopwidget.h> #include <qsplashscreen.h> #endif #include <qpaintengine.h> diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index fc3d0f1c06..632039ec5a 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -41,7 +41,6 @@ #include <QtWidgets/QColorDialog> #include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QFileDialog> -#include <QtWidgets/QDesktopWidget> class tst_languageChange : public QObject { diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index d469b0f9bd..91d0c07efd 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -37,7 +37,6 @@ #include <qstyle.h> #include <QVBoxLayout> #include <QSizeGrip> -#include <QDesktopWidget> #include <QGraphicsProxyWidget> #include <QGraphicsView> #include <QWindow> diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index 19288d07a7..38181c8af0 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -28,7 +28,6 @@ #include <QtTest/QtTestWidgets> -#include <QtWidgets/qdesktopwidget.h> #include <QtWidgets/qgraphicseffect.h> #include <QtWidgets/qgraphicsview.h> #include <QtWidgets/qgraphicsscene.h> diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index e7a79d017b..9ae127dbe0 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -38,7 +38,6 @@ #include <QAbstractTextDocumentLayout> #include <QBitmap> #include <QCursor> -#include <QDesktopWidget> #include <QScreen> #include <QLabel> #include <QDial> diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 1553b6e982..afb1b18af0 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -27,7 +27,6 @@ ** ****************************************************************************/ -#include <QDesktopWidget> #include <QHeaderView> #include <QProxyStyle> #include <QSignalSpy> diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index f85b885b34..531d1e823a 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -28,7 +28,6 @@ #include "../../../../shared/fakedirmodel.h" -#include <QDesktopWidget> #include <QHeaderView> #include <QLabel> #include <QLineEdit> diff --git a/tests/auto/widgets/kernel/qdesktopwidget/.gitignore b/tests/auto/widgets/kernel/qdesktopwidget/.gitignore deleted file mode 100644 index d6f7cc7ca9..0000000000 --- a/tests/auto/widgets/kernel/qdesktopwidget/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qdesktopwidget diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 873d0460ff..b05d6cd96e 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -44,7 +44,6 @@ #include <qstyle.h> #include <qwidget.h> #include <qstylefactory.h> -#include <qdesktopwidget.h> #include <private/qwidget_p.h> #include <private/qwidgetrepaintmanager_p.h> #include <private/qapplication_p.h> @@ -9170,7 +9169,7 @@ void tst_QWidget::translucentWidget() QPixmap widgetSnapshot; #ifdef Q_OS_WIN - QWidget *desktopWidget = QApplication::desktop()->screen(0); + QWidget *desktopWidget = QApplication::desktop(); widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height()); #else widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index f8a91e6ec6..7899f1f523 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -40,7 +40,6 @@ #include <QStyleOption> #include <QVBoxLayout> #include <QLineEdit> -#include <QDesktopWidget> #include <QDockWidget> #include <QScrollBar> #include <QTextEdit> diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 8ce0ea2184..783476cf67 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -38,7 +38,6 @@ #include <QStatusBar> #include <QListWidget> #include <QWidgetAction> -#include <QDesktopWidget> #include <QScreen> #include <QSpinBox> #include <qdialog.h> diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index cb4fc201f6..ccd8d0ec05 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -31,7 +31,6 @@ #include <QtGui/QPainter> #include <QtGui/QScreen> #include <QtGui/QStaticText> -#include <QtWidgets/QDesktopWidget> #include <QtWidgets/QGraphicsView> #include <QtWidgets/QGraphicsScene> #include <QtWidgets/QGraphicsRectItem> @@ -504,8 +503,8 @@ static QPixmap grabWidgetWithoutRepaint(const QWidget *widget, QRect clipArea) // because GDI functions can't grab OpenGL layer content. // Instead the whole screen should be captured, with an adjusted clip area, which contains // the final composited content. - QDesktopWidget *desktopWidget = QApplication::desktop(); - const QWidget *mainScreenWidget = desktopWidget->screen(); + QWidget *desktopWidget = QApplication::desktop(QGuiApplication::primaryScreen()); + const QWidget *mainScreenWidget = desktopWidget; targetWidget = mainScreenWidget; clipArea = QRect(widget->mapToGlobal(clipArea.topLeft()), widget->mapToGlobal(clipArea.bottomRight())); diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h index 6d388fcaad..ed03182597 100644 --- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -31,7 +31,6 @@ #include <QApplication> #include <QTextDocument> -#include <QDesktopWidget> #include <QTextLayout> #include <QFontMetrics> #include <QDebug> diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index a9fba18f53..27f5a90bab 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -33,7 +33,6 @@ #include <QtWidgets/QGraphicsView> #include <QtGui/QImage> #include <QtGui/QPixmapCache> -#include <QtWidgets/QDesktopWidget> #include "chiptester/chiptester.h" //#define CALLGRIND_DEBUG @@ -69,7 +68,7 @@ public: void tryResize(int width, int height) { - QDesktopWidget *desktop = QApplication::desktop(); + QWidget *desktop = QApplication::desktop(); if (desktop->width() < width) width = desktop->width(); if (desktop->height() < height) diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp index 371f3e2311..21007e8df9 100644 --- a/tests/manual/diaglib/qwidgetdump.cpp +++ b/tests/manual/diaglib/qwidgetdump.cpp @@ -43,7 +43,7 @@ namespace QtDiag { static const char *qtWidgetClasses[] = { "QAbstractItemView", "QAbstractScrollArea", "QAbstractSlider", "QAbstractSpinBox", "QCalendarWidget", "QCheckBox", "QColorDialog", "QColumnView", "QComboBox", - "QCommandLinkButton", "QDateEdit", "QDateTimeEdit", "QDesktopWidget", "QDial", + "QCommandLinkButton", "QDateEdit", "QDateTimeEdit", "QDial", "QDialog", "QDialogButtonBox", "QDockWidget", "QDoubleSpinBox", "QErrorMessage", "QFileDialog", "QFontComboBox", "QFontDialog", "QFrame", "QGraphicsView", "QGroupBox", "QHeaderView", "QInputDialog", "QLCDNumber", "QLabel", "QLineEdit", diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index dcd8b43bf3..7f834399e4 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -37,7 +37,6 @@ #include <QPrintPreviewDialog> #include <QPageSetupDialog> #include <QApplication> -#include <QDesktopWidget> #include <QGroupBox> #include <QCheckBox> #include <QLabel> diff --git a/tests/manual/foreignwindows/main.cpp b/tests/manual/foreignwindows/main.cpp index 843f4e39ef..436538df70 100644 --- a/tests/manual/foreignwindows/main.cpp +++ b/tests/manual/foreignwindows/main.cpp @@ -28,7 +28,6 @@ #include <QtGui/QAction> #include <QtWidgets/QApplication> -#include <QtWidgets/QDesktopWidget> #include <QtWidgets/QMainWindow> #include <QtWidgets/QMenu> #include <QtWidgets/QMenuBar> diff --git a/tests/manual/qcursor/qcursorhighdpi/main.cpp b/tests/manual/qcursor/qcursorhighdpi/main.cpp index e70be333fd..5a8bc542b9 100644 --- a/tests/manual/qcursor/qcursorhighdpi/main.cpp +++ b/tests/manual/qcursor/qcursorhighdpi/main.cpp @@ -28,7 +28,6 @@ #include <QAction> #include <QApplication> -#include <QDesktopWidget> #include <QGridLayout> #include <QLabel> #include <QMainWindow> @@ -83,8 +82,7 @@ static QString screenInfo(const QWidget *w) { QString result; QTextStream str(&result); -#if QT_VERSION > 0x050000 - QScreen *screen = Q_NULLPTR; + QScreen *screen = nullptr; if (const QWindow *window = w->windowHandle()) screen = window->screen(); if (screen) { @@ -98,12 +96,6 @@ static QString screenInfo(const QWidget *w) } else { str << "<null>"; } -#else - QDesktopWidget *desktop = QApplication::desktop(); - int screenNumber = desktop->screenNumber(w); - str << "Screen #" <<screenNumber << ' ' << desktop->screenGeometry(screenNumber).width() - << 'x' << desktop->screenGeometry(screenNumber).height() << " PD: " << w->logicalDpiX() << "DPI"; -#endif #ifdef Q_OS_WIN str << ", SM_C_CURSOR: " << GetSystemMetrics(SM_CXCURSOR) << 'x' << GetSystemMetrics(SM_CYCURSOR); #endif diff --git a/tests/manual/qdesktopwidget/CMakeLists.txt b/tests/manual/qdesktopwidget/CMakeLists.txt deleted file mode 100644 index 2034e3c368..0000000000 --- a/tests/manual/qdesktopwidget/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Generated from qdesktopwidget.pro. - -##################################################################### -## qdesktopwidget Binary: -##################################################################### - -add_qt_manual_test(qdesktopwidget - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::Widgets -) - -#### Keys ignored in scope 1:.:.:qdesktopwidget.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/manual/qdesktopwidget/main.cpp b/tests/manual/qdesktopwidget/main.cpp deleted file mode 100644 index 978dc62b0e..0000000000 --- a/tests/manual/qdesktopwidget/main.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QGraphicsView> -#include <QGraphicsRectItem> -#include <QDesktopWidget> -#include <QApplication> -#include <QDebug> - -class DesktopView : public QGraphicsView -{ -#if QT_DEPRECATED_SINCE(5, 11) - Q_OBJECT -public: - DesktopView() - : that(0) - { - scene = new QGraphicsScene; - setScene(scene); - - QDesktopWidget *desktop = QApplication::desktop(); - connect(desktop, SIGNAL(resized(int)), this, SLOT(updateScene())); - connect(desktop, SIGNAL(resized(int)), this, SLOT(desktopResized(int))); - connect(desktop, SIGNAL(workAreaResized(int)), this, SLOT(updateScene())); - connect(desktop, SIGNAL(workAreaResized(int)), this, SLOT(desktopWorkAreaResized(int))); - connect(desktop, SIGNAL(screenCountChanged(int)), this, SLOT(updateScene())); - connect(desktop, SIGNAL(screenCountChanged(int)), this, SLOT(desktopScreenCountChanged(int))); - - updateScene(); - - QTransform transform; - transform.scale(0.25, 0.25); - setTransform(transform); - - setBackgroundBrush(Qt::darkGray); - desktopScreenCountChanged(-1); - } - -protected: - void moveEvent(QMoveEvent *e) - { - if (that) { - that->setRect(appRect()); - scene->update(); - } - QGraphicsView::moveEvent(e); - } - void resizeEvent(QResizeEvent *e) - { - if (that) { - that->setRect(appRect()); - } - QGraphicsView::resizeEvent(e); - } - -private slots: - void updateScene() - { - scene->clear(); - - const QDesktopWidget *desktop = QApplication::desktop(); - const bool isVirtualDesktop = desktop->isVirtualDesktop(); - const int homeScreen = desktop->screenNumber(this); - - QRect sceneRect; - int screenCount = desktop->screenCount(); - for (int s = 0; s < screenCount; ++s) { - const bool isPrimary = desktop->primaryScreen() == s; - const QRect screenRect = desktop->screenGeometry(s); - const QRect workRect = desktop->availableGeometry(s); - const QBrush fillBrush = palette().brush(isPrimary ? QPalette::Active : QPalette::Inactive, QPalette::Highlight); - QGraphicsRectItem *screen = new QGraphicsRectItem(0, 0, screenRect.width(), screenRect.height()); - - if (isVirtualDesktop) { - thatRoot = QPoint(); - screen->setPos(screenRect.x(), screenRect.y()); - } else { - // for non-virtual desktops we assume that screens are - // simply next to each other - if (s) - screen->setPos(sceneRect.right(), 0); - if (s == homeScreen) - thatRoot = screen->pos().toPoint(); - } - - screen->setBrush(fillBrush); - scene->addItem(screen); - sceneRect.setLeft(qMin(sceneRect.left(), screenRect.left())); - sceneRect.setRight(qMax(sceneRect.right(), screenRect.right())); - sceneRect.setTop(qMin(sceneRect.top(), screenRect.top())); - sceneRect.setBottom(qMax(sceneRect.bottom(), screenRect.bottom())); - - QGraphicsRectItem *workArea = new QGraphicsRectItem(screen); - workArea->setRect(0, 0, workRect.width(), workRect.height()); - workArea->setPos(workRect.x() - screenRect.x(), workRect.y() - screenRect.y()); - workArea->setBrush(Qt::white); - - QGraphicsSimpleTextItem *screenNumber = new QGraphicsSimpleTextItem(workArea); - screenNumber->setText(QString::number(s)); - screenNumber->setPen(QPen(Qt::black, 1)); - screenNumber->setBrush(fillBrush); - screenNumber->setFont(QFont("Arial Black", 18)); - screenNumber->setTransform(QTransform().scale(10, 10)); - screenNumber->setTransformOriginPoint(screenNumber->boundingRect().center()); - QSizeF center = (workRect.size() - screenNumber->boundingRect().size()) / 2; - screenNumber->setPos(center.width(), center.height()); - - screen->show(); - screen->setZValue(1); - } - - if (isVirtualDesktop) { - QGraphicsRectItem *virtualDesktop = new QGraphicsRectItem; - virtualDesktop->setRect(sceneRect); - virtualDesktop->setPen(QPen(Qt::black)); - virtualDesktop->setBrush(Qt::DiagCrossPattern); - scene->addItem(virtualDesktop); - virtualDesktop->setZValue(-1); - virtualDesktop->show(); - } - - that = new QGraphicsRectItem; - that->setBrush(Qt::red); - that->setOpacity(0.5); - that->setZValue(2); - that->setRect(appRect()); - that->show(); - scene->addItem(that); - - scene->setSceneRect(sceneRect); - scene->update(); - } - - QRect appRect() const - { - QRect rect = frameGeometry(); - if (!QApplication::desktop()->isVirtualDesktop()) { - rect.translate(thatRoot); - } - return rect; - } - - void desktopResized(int screen) - { - qDebug() << "Screen was resized: " << screen - << ", new size =" << QApplication::desktop()->screenGeometry(screen); - } - void desktopWorkAreaResized(int screen) - { - qDebug() << "Screen workarea was resized: " << screen - << ", new size =" << QApplication::desktop()->availableGeometry(screen); - } - void desktopScreenCountChanged(int screenCount) - { - QDesktopWidget *desktop = QApplication::desktop(); - qDebug() << ""; - if (screenCount != -1) { - qDebug() << "Screen count was changed to " << screenCount; - } else { - screenCount = desktop->screenCount(); - qDebug() << "Screen count: " << screenCount; - } - for (int i = 0; i < screenCount; ++i) { - qDebug() << " #" << i << ": geometry =" << desktop->screenGeometry(i) - << "; available geometry =" << desktop->availableGeometry(i); - } - qDebug() << ""; - } - -private: - QGraphicsScene *scene; - QGraphicsRectItem *that; - QPoint thatRoot; -#endif -}; - -#include "main.moc" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - DesktopView view; - view.show(); - - return app.exec(); -} diff --git a/tests/manual/qdesktopwidget/qdesktopwidget.pro b/tests/manual/qdesktopwidget/qdesktopwidget.pro deleted file mode 100644 index 8979e7ef35..0000000000 --- a/tests/manual/qdesktopwidget/qdesktopwidget.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = app -QT += widgets -SOURCES += main.cpp diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp index d2c9842365..e6f0dc9fd7 100644 --- a/tests/manual/qscreen/main.cpp +++ b/tests/manual/qscreen/main.cpp @@ -39,7 +39,6 @@ #include <QAction> #include <QStatusBar> #include <QLineEdit> -#include <QDesktopWidget> #include <QPushButton> #include <QLabel> #include <QMouseEvent> @@ -229,14 +228,11 @@ void screenAdded(QScreen* screen) (screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name()))); ScreenWatcherMainWindow *w = new ScreenWatcherMainWindow(screen); - // Set the screen via QDesktopWidget. This corresponds to setScreen() for the underlying - // QWindow. This is essential when having separate X screens since the the positioning below is - // not sufficient to get the windows show up on the desired screen. - QList<QScreen *> screens = QGuiApplication::screens(); - int screenNumber = screens.indexOf(screen); - Q_ASSERT(screenNumber >= 0); - // ### Qt 6: Find a replacement for QDesktopWidget::screen() - w->setParent(qApp->desktop()->screen(screenNumber)); + // Set the screen; this corresponds to setScreen() for the underlying + // QWindow. This is essential when having separate X screens since the + // positioning below is not sufficient to get the windows show up on the + // desired screen. + w->setParent(qApp->desktop(screen)); w->show(); diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp index 82bcd838e6..6af80958cd 100644 --- a/tests/manual/qtabbar/main.cpp +++ b/tests/manual/qtabbar/main.cpp @@ -54,7 +54,6 @@ #include <QTabBar> #include <QLabel> #include <QLayout> -#include <QDesktopWidget> #include <QTabWidget> #include <QProxyStyle> #include <qdebug.h> |