Prepare for deprecating the QDesktopWidget
QDesktopWidget is marked as obsolete in docs, but it is not yet completely deprecated, some of its methods are still in use. Replace uses of the following methods marked as obsolete: - QDesktopWidget::screenNumber(QWidget*) -> QWidget::screen() - QDesktopWidget::screenGeometry(QWidget*) -> QWidget::screen()->geometry() - QDesktopWidget::availableGeometry(QWidget*) -> QWidget::screen()->availableGeometry() Task-number: QTBUG-76491 Change-Id: I2cca30f2b4caa6e6848e8190e09f959d2c272f33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
92b9dcfe2b
commit
9cc040a806
@ -51,7 +51,7 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
parser.process(app);
|
||||
|
||||
MainWindow mainWindow;
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWindow);
|
||||
const QRect availableGeometry = mainWindow.screen()->availableGeometry();
|
||||
mainWindow.resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
|
||||
mainWindow.show();
|
||||
|
||||
|
@ -49,8 +49,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDir>
|
||||
#include <QScreen>
|
||||
|
||||
#include "httpwindow.h"
|
||||
|
||||
@ -59,7 +59,7 @@ int main(int argc, char *argv[])
|
||||
QApplication app(argc, argv);
|
||||
|
||||
HttpWindow httpWin;
|
||||
const QRect availableSize = QApplication::desktop()->availableGeometry(&httpWin);
|
||||
const QRect availableSize = httpWin.screen()->availableGeometry();
|
||||
httpWin.resize(availableSize.width() / 5, availableSize.height() / 5);
|
||||
httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2);
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QOpenGLContext>
|
||||
#include <QCommandLineParser>
|
||||
@ -90,7 +90,7 @@ int main( int argc, char ** argv )
|
||||
// The rendering for the four QOpenGLWidgets happens on four separate threads.
|
||||
|
||||
GLWidget topLevelGlWidget;
|
||||
QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200);
|
||||
QPoint pos = topLevelGlWidget.screen()->availableGeometry().topLeft() + QPoint(200, 200);
|
||||
topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
|
||||
topLevelGlWidget.resize(200, 200);
|
||||
topLevelGlWidget.move(pos);
|
||||
|
@ -49,7 +49,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
|
||||
#include "screenshot.h"
|
||||
|
||||
@ -58,7 +58,8 @@ int main(int argc, char *argv[])
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Screenshot screenshot;
|
||||
screenshot.move(QApplication::desktop()->availableGeometry(&screenshot).topLeft() + QPoint(20, 20));
|
||||
screenshot.move(screenshot.screen()->availableGeometry().topLeft() + QPoint(20, 20));
|
||||
screenshot.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ Screenshot::Screenshot()
|
||||
screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
screenshotLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
screenshotLabel->setMinimumSize(screenGeometry.width() / 8, screenGeometry.height() / 8);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
|
@ -49,8 +49,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QStyleHints>
|
||||
#include <QDesktopWidget>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Dialog dialog;
|
||||
if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) {
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&dialog);
|
||||
const QRect availableGeometry = dialog.screen()->availableGeometry();
|
||||
dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3);
|
||||
dialog.move((availableGeometry.width() - dialog.width()) / 2,
|
||||
(availableGeometry.height() - dialog.height()) / 2);
|
||||
|
@ -49,9 +49,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileSystemModel>
|
||||
#include <QFileIconProvider>
|
||||
#include <QScreen>
|
||||
#include <QTreeView>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
@ -92,7 +92,7 @@ int main(int argc, char *argv[])
|
||||
tree.setAnimated(false);
|
||||
tree.setIndentation(20);
|
||||
tree.setSortingEnabled(true);
|
||||
const QSize availableSize = QApplication::desktop()->availableGeometry(&tree).size();
|
||||
const QSize availableSize = tree.screen()->availableGeometry().size();
|
||||
tree.resize(availableSize / 2);
|
||||
tree.setColumnWidth(0, tree.width() / 3);
|
||||
|
||||
|
@ -281,7 +281,7 @@ void MainWindow::readSettings()
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
if (geometry.isEmpty()) {
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
||||
const QRect availableGeometry = screen()->availableGeometry();
|
||||
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
|
||||
move((availableGeometry.width() - width()) / 2,
|
||||
(availableGeometry.height() - height()) / 2);
|
||||
|
@ -464,7 +464,7 @@ void MainWindow::readSettings()
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
if (geometry.isEmpty()) {
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
||||
const QRect availableGeometry = screen()->availableGeometry();
|
||||
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
|
||||
move((availableGeometry.width() - width()) / 2,
|
||||
(availableGeometry.height() - height()) / 2);
|
||||
|
@ -167,7 +167,7 @@ void MainWindow::tile(const QMainWindow *previous)
|
||||
if (!topFrameWidth)
|
||||
topFrameWidth = 40;
|
||||
const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth);
|
||||
if (QApplication::desktop()->availableGeometry(this).contains(rect().bottomRight() + pos))
|
||||
if (screen()->availableGeometry().contains(rect().bottomRight() + pos))
|
||||
move(pos);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ void MainWindow::readSettings()
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
if (geometry.isEmpty()) {
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
||||
const QRect availableGeometry = screen()->availableGeometry();
|
||||
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
|
||||
move((availableGeometry.width() - width()) / 2,
|
||||
(availableGeometry.height() - height()) / 2);
|
||||
|
@ -51,9 +51,9 @@
|
||||
#include "textedit.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
#include <QScreen>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
TextEdit mw;
|
||||
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mw);
|
||||
const QRect availableGeometry = mw.screen()->availableGeometry();
|
||||
mw.resize(availableGeometry.width() / 2, (availableGeometry.height() * 2) / 3);
|
||||
mw.move((availableGeometry.width() - mw.width()) / 2,
|
||||
(availableGeometry.height() - mw.height()) / 2);
|
||||
|
@ -54,12 +54,12 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QRegularExpression>
|
||||
#include <QScreen>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
|
||||
@ -78,7 +78,7 @@ MainWindow::MainWindow()
|
||||
|
||||
setWindowTitle(tr("Codecs"));
|
||||
|
||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
resize(screenGeometry.width() / 2, screenGeometry.height() * 2 / 3);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ void MainWindow::encodingDialog()
|
||||
{
|
||||
if (!m_encodingDialog) {
|
||||
m_encodingDialog = new EncodingDialog(this);
|
||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
m_encodingDialog->setMinimumWidth(screenGeometry.width() / 4);
|
||||
}
|
||||
m_encodingDialog->show();
|
||||
|
@ -52,12 +52,12 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QScreen>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
|
||||
@ -183,7 +183,7 @@ PreviewForm::PreviewForm(QWidget *parent)
|
||||
mainLayout->addWidget(statusLabel, 2, 0, 1, 2);
|
||||
mainLayout->addWidget(buttonBox, 3, 0, 1, 2);
|
||||
|
||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
resize(screenGeometry.width() * 2 / 5, screenGeometry.height() / 2);
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QScreen>
|
||||
#include <QStandardPaths>
|
||||
#include <QStatusBar>
|
||||
|
||||
@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
fallbacksAct->setChecked(true);
|
||||
|
||||
setWindowTitle(QCoreApplication::applicationName());
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
||||
const QRect availableGeometry = screen()->availableGeometry();
|
||||
adjustSize();
|
||||
move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
|
||||
}
|
||||
|
@ -52,8 +52,8 @@
|
||||
#include "variantdelegate.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QHeaderView>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
|
||||
SettingsTree::SettingsTree(QWidget *parent)
|
||||
@ -93,7 +93,7 @@ void SettingsTree::setSettingsObject(const SettingsPtr &newSettings)
|
||||
|
||||
QSize SettingsTree::sizeHint() const
|
||||
{
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
||||
const QRect availableGeometry = screen()->availableGeometry();
|
||||
return QSize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3);
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include <QMenuBar>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QScreen>
|
||||
#include <QScrollArea>
|
||||
#include <QStatusBar>
|
||||
#include <QTextStream>
|
||||
@ -302,7 +303,7 @@ QString FontInfoDialog::text() const
|
||||
|
||||
void MainWindow::showInfo()
|
||||
{
|
||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
FontInfoDialog *dialog = new FontInfoDialog(this);
|
||||
dialog->setWindowTitle(tr("Fonts"));
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
if (!commandLineParser.positionalArguments().isEmpty())
|
||||
mainWin.loadImages(commandLineParser.positionalArguments());
|
||||
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWin);
|
||||
const QRect availableGeometry = mainWin.screen()->availableGeometry();
|
||||
mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3);
|
||||
mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2);
|
||||
|
||||
|
@ -63,7 +63,7 @@ MainWindow::MainWindow()
|
||||
statusBar()->showMessage(tr("Ready"));
|
||||
|
||||
setWindowTitle(tr("DOM Bookmarks"));
|
||||
const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
|
||||
const QSize availableSize = screen()->availableGeometry().size();
|
||||
resize(availableSize.width() / 2, availableSize.height() / 3);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ MainWindow::MainWindow()
|
||||
statusBar()->showMessage(tr("Ready"));
|
||||
|
||||
setWindowTitle(tr("SAX Bookmarks"));
|
||||
const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
|
||||
const QSize availableSize = screen()->availableGeometry().size();
|
||||
resize(availableSize.width() / 2, availableSize.height() / 3);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ MainWindow::MainWindow()
|
||||
statusBar()->showMessage(tr("Ready"));
|
||||
|
||||
setWindowTitle(tr("QXmlStream Bookmarks"));
|
||||
const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
|
||||
const QSize availableSize = screen()->availableGeometry().size();
|
||||
resize(availableSize.width() / 2, availableSize.height() / 3);
|
||||
}
|
||||
//! [0]
|
||||
|
@ -1031,7 +1031,8 @@ void QScrollerPrivate::setDpi(const QPointF &dpi)
|
||||
*/
|
||||
void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
|
||||
{
|
||||
const QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(widget));
|
||||
const QScreen *screen = widget ? widget->screen() : QGuiApplication::primaryScreen();
|
||||
Q_ASSERT(screen);
|
||||
setDpi(QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY()));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QGraphicsItem>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtWidgets/QGraphicsView>
|
||||
@ -617,7 +617,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
|
||||
QPointF pos = touchWidget.rect().center();
|
||||
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
|
||||
QPointF delta(10, 10);
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QTouchEvent::TouchPoint rawTouchPoint;
|
||||
rawTouchPoint.setId(0);
|
||||
@ -753,7 +753,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
|
||||
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
|
||||
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
|
||||
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QList<QTouchEvent::TouchPoint> rawTouchPoints;
|
||||
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
|
||||
@ -968,7 +968,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
|
||||
QPointF pos = touchWidget.rect().center();
|
||||
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
|
||||
QPointF delta(10, 10);
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QVector<QTouchEvent::TouchPoint> rawTouchPoints(3);
|
||||
rawTouchPoints[0].setId(0);
|
||||
@ -1131,7 +1131,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
|
||||
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
|
||||
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
|
||||
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QList<QTouchEvent::TouchPoint> rawTouchPoints;
|
||||
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
|
||||
@ -1348,7 +1348,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
|
||||
screenPos << touchWidget.mapToGlobal(pos[i].toPoint());
|
||||
}
|
||||
QPointF delta(10, 10);
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QVector<QPointF> rawPosList;
|
||||
rawPosList << QPointF(12, 34) << QPointF(56, 78);
|
||||
@ -1629,7 +1629,7 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
|
||||
QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint());
|
||||
QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint());
|
||||
QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint());
|
||||
QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
|
||||
QRectF screenGeometry = touchWidget.screen()->geometry();
|
||||
|
||||
QList<QTouchEvent::TouchPoint> rawTouchPoints;
|
||||
rawTouchPoints.append(QTouchEvent::TouchPoint(0));
|
||||
|
@ -10977,7 +10977,7 @@ static QList<QTouchEvent::TouchPoint>
|
||||
tp.setStartScreenPos(screenPos);
|
||||
tp.setLastScreenPos(screenPos);
|
||||
tp.setEllipseDiameters(ellipseDiameters);
|
||||
const QSizeF screenSize = QApplication::desktop()->screenGeometry(&view).size();
|
||||
const QSizeF screenSize = view.screen()->geometry().size();
|
||||
tp.setNormalizedPos(QPointF(screenPos.x() / screenSize.width(), screenPos.y() / screenSize.height()));
|
||||
return QList<QTouchEvent::TouchPoint>() << tp;
|
||||
}
|
||||
|
@ -5383,7 +5383,7 @@ void tst_QWidget::moveChild()
|
||||
parent.setStyle(style.data());
|
||||
ColorWidget child(&parent, Qt::Widget, Qt::blue);
|
||||
|
||||
parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50),
|
||||
parent.setGeometry(QRect(parent.screen()->availableGeometry().topLeft() + QPoint(50, 50),
|
||||
QSize(200, 200)));
|
||||
child.setGeometry(25, 25, 50, 50);
|
||||
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
|
||||
@ -5430,8 +5430,7 @@ void tst_QWidget::showAndMoveChild()
|
||||
const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
|
||||
parent.setStyle(style.data());
|
||||
|
||||
QDesktopWidget desktop;
|
||||
QRect desktopDimensions = desktop.availableGeometry(&parent);
|
||||
QRect desktopDimensions = parent.screen()->availableGeometry();
|
||||
desktopDimensions = desktopDimensions.adjusted(64, 64, -64, -64);
|
||||
|
||||
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
|
||||
@ -7708,7 +7707,7 @@ void tst_QWidget::repaintWhenChildDeleted()
|
||||
#endif
|
||||
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
|
||||
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
|
||||
QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
|
||||
QPoint startPoint = w.screen()->availableGeometry().topLeft();
|
||||
startPoint.rx() += 50;
|
||||
startPoint.ry() += 50;
|
||||
w.setGeometry(QRect(startPoint, QSize(100, 100)));
|
||||
@ -7733,7 +7732,7 @@ void tst_QWidget::hideOpaqueChildWhileHidden()
|
||||
{
|
||||
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
|
||||
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
|
||||
QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
|
||||
QPoint startPoint = w.screen()->availableGeometry().topLeft();
|
||||
startPoint.rx() += 50;
|
||||
startPoint.ry() += 50;
|
||||
w.setGeometry(QRect(startPoint, QSize(100, 100)));
|
||||
@ -9601,8 +9600,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
|
||||
palette.setColor(QPalette::Window, Qt::red);
|
||||
main.setPalette(palette);
|
||||
|
||||
QDesktopWidget desktop;
|
||||
QRect desktopDimensions = desktop.availableGeometry(&main);
|
||||
QRect desktopDimensions = main.screen()->availableGeometry();
|
||||
QSize mainSize(400, 400);
|
||||
mainSize = mainSize.boundedTo(desktopDimensions.size());
|
||||
main.resize(mainSize);
|
||||
|
@ -1765,7 +1765,7 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes()
|
||||
auto le = new QLineEdit;
|
||||
w.layout()->addWidget(le);
|
||||
|
||||
const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
|
||||
const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200);
|
||||
w.move(pos);
|
||||
w.show();
|
||||
QApplication::setActiveWindow(&w);
|
||||
@ -1806,7 +1806,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice()
|
||||
|
||||
w.layout()->addWidget(new QLineEdit);
|
||||
|
||||
const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
|
||||
const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200);
|
||||
w.move(pos);
|
||||
w.show();
|
||||
QApplication::setActiveWindow(&w);
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <qpa/qplatformtheme.h>
|
||||
|
||||
#include <qfontcombobox.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include <qapplication.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qdialog.h>
|
||||
@ -2212,15 +2211,13 @@ void tst_QComboBox::itemListPosition()
|
||||
QFontComboBox combo(&topLevel);
|
||||
|
||||
layout->addWidget(&combo);
|
||||
//the code to get the available screen space is copied from QComboBox code
|
||||
const int scrNumber = QApplication::desktop()->screenNumber(&combo);
|
||||
|
||||
bool useFullScreenForPopupMenu = false;
|
||||
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
|
||||
useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
|
||||
const QRect screen = useFullScreenForPopupMenu ?
|
||||
QApplication::screens().at(scrNumber)->geometry() :
|
||||
QApplication::screens().at(scrNumber)->availableGeometry();
|
||||
combo.screen()->geometry() :
|
||||
combo.screen()->availableGeometry();
|
||||
|
||||
topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner
|
||||
|
||||
@ -2440,8 +2437,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize()
|
||||
#if defined QT_BUILD_INTERNAL
|
||||
QFrame *container = comboBox.findChild<QComboBoxPrivateContainer *>();
|
||||
QVERIFY(container);
|
||||
QDesktopWidget desktop;
|
||||
QTRY_VERIFY(desktop.screenGeometry(container).contains(container->geometry()));
|
||||
QTRY_VERIFY(container->screen()->geometry().contains(container->geometry()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <qstyle.h>
|
||||
#include <qproxystyle.h>
|
||||
#include <qstylefactory.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include <qaction.h>
|
||||
#include <qstyleoption.h>
|
||||
#include <QVBoxLayout>
|
||||
@ -1149,8 +1148,8 @@ void tst_QMenuBar::check_menuPosition()
|
||||
|
||||
Menu menu;
|
||||
menu.setTitle("&menu");
|
||||
QRect availRect = QApplication::desktop()->availableGeometry(&w);
|
||||
QRect screenRect = QApplication::desktop()->screenGeometry(&w);
|
||||
QRect availRect = w.screen()->availableGeometry();
|
||||
QRect screenRect = w.screen()->geometry();
|
||||
|
||||
while(menu.sizeHint().height() < (screenRect.height()*2/3)) {
|
||||
menu.addAction("item");
|
||||
|
@ -710,8 +710,7 @@ void PrintDialogPanel::showPreviewDialog()
|
||||
applySettings(m_printer.data());
|
||||
PrintPreviewDialog dialog(m_printer.data(), this);
|
||||
#if QT_VERSION >= 0x050000
|
||||
const int screenNumber = QApplication::desktop()->screenNumber(this);
|
||||
const QSize availableSize = QGuiApplication::screens().at(screenNumber)->availableSize();
|
||||
const QSize availableSize = screen()->availableSize();
|
||||
#else
|
||||
const QSize availableSize = QApplication::desktop()->availableGeometry().size();
|
||||
#endif
|
||||
|
@ -218,7 +218,7 @@ protected:
|
||||
|
||||
VerticalRuler::VerticalRuler(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
const int screenWidth = QApplication::desktop()->screenGeometry(this).width();
|
||||
const int screenWidth = screen()->geometry().width();
|
||||
setFixedWidth(screenWidth / 48); // 1920 pixel monitor ->40
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user