Deprecate and remove uses of AA_DisableHighDpiScaling
Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
8028474e62
commit
90358f6042
@ -54,16 +54,6 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool useHighDpiScaling = true;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
|
||||||
if (qstrcmp(argv[i], "--no-scaling") == 0)
|
|
||||||
useHighDpiScaling = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useHighDpiScaling)
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
WidgetGallery gallery;
|
WidgetGallery gallery;
|
||||||
gallery.show();
|
gallery.show();
|
||||||
|
@ -470,9 +470,13 @@ namespace Qt {
|
|||||||
AA_ShareOpenGLContexts = 18,
|
AA_ShareOpenGLContexts = 18,
|
||||||
AA_SetPalette = 19,
|
AA_SetPalette = 19,
|
||||||
#if QT_DEPRECATED_SINCE(6, 0)
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
AA_EnableHighDpiScaling Q_DECL_ENUMERATOR_DEPRECATED = 20,
|
AA_EnableHighDpiScaling Q_DECL_ENUMERATOR_DEPRECATED_X(
|
||||||
|
"High-DPI scaling is always enabled. " \
|
||||||
|
"This attribute no longer has any effect.") = 20,
|
||||||
|
AA_DisableHighDpiScaling Q_DECL_ENUMERATOR_DEPRECATED_X(
|
||||||
|
"High-DPI scaling is always enabled. " \
|
||||||
|
"This attribute no longer has any effect.") = 21,
|
||||||
#endif
|
#endif
|
||||||
AA_DisableHighDpiScaling = 21,
|
|
||||||
AA_UseStyleSheetPropagationInWidgetStyles = 22,
|
AA_UseStyleSheetPropagationInWidgetStyles = 22,
|
||||||
AA_DontUseNativeDialogs = 23,
|
AA_DontUseNativeDialogs = 23,
|
||||||
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
|
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
|
||||||
|
@ -208,15 +208,6 @@
|
|||||||
\value AA_SetPalette Indicates whether a palette was explicitly set on the
|
\value AA_SetPalette Indicates whether a palette was explicitly set on the
|
||||||
QGuiApplication. This value was added in Qt 5.5.
|
QGuiApplication. This value was added in Qt 5.5.
|
||||||
|
|
||||||
\value AA_DisableHighDpiScaling Disables high-DPI scaling in Qt, exposing window
|
|
||||||
system coordinates. Note that the window system may do its own scaling,
|
|
||||||
so this does not guarantee that QPaintDevice::devicePixelRatio() will
|
|
||||||
be equal to 1. In addition, scale factors set by QT_SCALE_FACTOR will not
|
|
||||||
be affected. This corresponds to setting the
|
|
||||||
QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to 0.
|
|
||||||
This attribute must be set before QGuiApplication is constructed.
|
|
||||||
This value was added in Qt 5.6.
|
|
||||||
|
|
||||||
\value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets
|
\value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets
|
||||||
disable regular QWidget palette and font propagation. When this flag
|
disable regular QWidget palette and font propagation. When this flag
|
||||||
is enabled, font and palette changes propagate as though the user had
|
is enabled, font and palette changes propagate as though the user had
|
||||||
@ -291,6 +282,7 @@
|
|||||||
\omitvalue AA_AttributeCount
|
\omitvalue AA_AttributeCount
|
||||||
\omitvalue AA_EnableHighDpiScaling
|
\omitvalue AA_EnableHighDpiScaling
|
||||||
\omitvalue AA_UseHighDpiPixmaps
|
\omitvalue AA_UseHighDpiPixmaps
|
||||||
|
\omitvalue AA_DisableHighDpiScaling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -951,7 +951,6 @@ void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on)
|
|||||||
if (Q_UNLIKELY(QCoreApplicationPrivate::is_app_running)) {
|
if (Q_UNLIKELY(QCoreApplicationPrivate::is_app_running)) {
|
||||||
#endif
|
#endif
|
||||||
switch (attribute) {
|
switch (attribute) {
|
||||||
case Qt::AA_DisableHighDpiScaling:
|
|
||||||
case Qt::AA_PluginApplication:
|
case Qt::AA_PluginApplication:
|
||||||
case Qt::AA_UseDesktopOpenGL:
|
case Qt::AA_UseDesktopOpenGL:
|
||||||
case Qt::AA_UseOpenGLES:
|
case Qt::AA_UseOpenGLES:
|
||||||
|
@ -208,10 +208,8 @@ static inline qreal initialGlobalScaleFactor()
|
|||||||
factor based on display density information. These platforms
|
factor based on display density information. These platforms
|
||||||
include X11, Windows, and Android.
|
include X11, Windows, and Android.
|
||||||
|
|
||||||
There are two APIs for enabling or disabling this behavior:
|
There is one API for enabling or disabling this behavior:
|
||||||
- The QT_AUTO_SCREEN_SCALE_FACTOR environment variable.
|
- The QT_AUTO_SCREEN_SCALE_FACTOR environment variable.
|
||||||
- The AA_EnableHighDpiScaling and AA_DisableHighDpiScaling
|
|
||||||
application attributes
|
|
||||||
|
|
||||||
Enabling either will make QHighDpiScaling call QPlatformScreen::pixelDensity()
|
Enabling either will make QHighDpiScaling call QPlatformScreen::pixelDensity()
|
||||||
and use the value provided as the scale factor for the screen in
|
and use the value provided as the scale factor for the screen in
|
||||||
@ -265,9 +263,6 @@ static inline bool usePixelDensity()
|
|||||||
// reported by the platform plugin. There are several enablers and several
|
// reported by the platform plugin. There are several enablers and several
|
||||||
// disablers. A single disable may veto all other enablers.
|
// disablers. A single disable may veto all other enablers.
|
||||||
|
|
||||||
// Check if there is an explicit disable
|
|
||||||
if (QCoreApplication::testAttribute(Qt::AA_DisableHighDpiScaling))
|
|
||||||
return false;
|
|
||||||
bool screenEnvValueOk;
|
bool screenEnvValueOk;
|
||||||
const int screenEnvValue = qEnvironmentVariableIntValue(legacyAutoScreenEnvVar, &screenEnvValueOk);
|
const int screenEnvValue = qEnvironmentVariableIntValue(legacyAutoScreenEnvVar, &screenEnvValueOk);
|
||||||
if (screenEnvValueOk && screenEnvValue < 1)
|
if (screenEnvValueOk && screenEnvValue < 1)
|
||||||
@ -488,9 +483,6 @@ void QHighDpiScaling::initHighDpiScaling()
|
|||||||
|
|
||||||
void QHighDpiScaling::updateHighDpiScaling()
|
void QHighDpiScaling::updateHighDpiScaling()
|
||||||
{
|
{
|
||||||
if (QCoreApplication::testAttribute(Qt::AA_DisableHighDpiScaling))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_usePixelDensity = usePixelDensity();
|
m_usePixelDensity = usePixelDensity();
|
||||||
|
|
||||||
if (m_usePixelDensity && !m_pixelDensityScalingActive) {
|
if (m_usePixelDensity && !m_pixelDensityScalingActive) {
|
||||||
|
@ -129,8 +129,7 @@
|
|||||||
|
|
||||||
Finally, if the test class has a static public \c{void initMain()} method,
|
Finally, if the test class has a static public \c{void initMain()} method,
|
||||||
it is called by the QTEST_MAIN macros before the QApplication object
|
it is called by the QTEST_MAIN macros before the QApplication object
|
||||||
is instantiated. For example, this allows for setting application
|
is instantiated. This was added in 5.14.
|
||||||
attributes like Qt::AA_DisableHighDpiScaling. This was added in 5.14.
|
|
||||||
|
|
||||||
For more examples, refer to the \l{Qt Test Tutorial}.
|
For more examples, refer to the \l{Qt Test Tutorial}.
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ bool compareSequence(ActualIterator actualIt, ActualIterator actualEnd,
|
|||||||
#if defined(TESTCASE_LOWDPI)
|
#if defined(TESTCASE_LOWDPI)
|
||||||
void disableHighDpi()
|
void disableHighDpi()
|
||||||
{
|
{
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
|
||||||
}
|
}
|
||||||
Q_CONSTRUCTOR_FUNCTION(disableHighDpi);
|
Q_CONSTRUCTOR_FUNCTION(disableHighDpi);
|
||||||
#endif
|
#endif
|
||||||
|
@ -223,7 +223,8 @@ void tst_NoQtEventLoop::consumeMouseEvents()
|
|||||||
int argc = 1;
|
int argc = 1;
|
||||||
char *argv[] = {const_cast<char*>("test")};
|
char *argv[] = {const_cast<char*>("test")};
|
||||||
// ensure scaling is off since the child window is positioned using QWindow API.
|
// ensure scaling is off since the child window is positioned using QWindow API.
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
// FIXME: Position by taking the screen DPR into account instead
|
||||||
|
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QString clsName(QStringLiteral("tst_NoQtEventLoop_WINDOW"));
|
QString clsName(QStringLiteral("tst_NoQtEventLoop_WINDOW"));
|
||||||
const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
|
const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
|
||||||
|
@ -72,8 +72,6 @@ class tst_QStyleSheetStyle : public QObject
|
|||||||
public:
|
public:
|
||||||
tst_QStyleSheetStyle();
|
tst_QStyleSheetStyle();
|
||||||
|
|
||||||
static void initMain();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
@ -173,12 +171,6 @@ private:
|
|||||||
QSize m_testSize;
|
QSize m_testSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
// highdpiImages() tests HighDPI scaling; disable initially.
|
|
||||||
void tst_QStyleSheetStyle::initMain()
|
|
||||||
{
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
}
|
|
||||||
|
|
||||||
tst_QStyleSheetStyle::tst_QStyleSheetStyle()
|
tst_QStyleSheetStyle::tst_QStyleSheetStyle()
|
||||||
{
|
{
|
||||||
const int testSize = qMax(200, m_availableGeometry.width() / 10);
|
const int testSize = qMax(200, m_availableGeometry.width() / 10);
|
||||||
@ -2215,8 +2207,9 @@ void tst_QStyleSheetStyle::highdpiImages()
|
|||||||
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("::")
|
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("::")
|
||||||
+ QLatin1String(QTest::currentDataTag()));
|
+ QLatin1String(QTest::currentDataTag()));
|
||||||
QScreen *screen = QGuiApplication::primaryScreen();
|
QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
|
auto inverseDpr = 1 / screen->devicePixelRatio();
|
||||||
w.move(screen->availableGeometry().topLeft());
|
w.move(screen->availableGeometry().topLeft());
|
||||||
QHighDpiScaling::setScreenFactor(screen, screenFactor);
|
QHighDpiScaling::setScreenFactor(screen, inverseDpr * screenFactor);
|
||||||
w.setStyleSheet("QWidget { background-image: url(\":/images/testimage.png\"); }");
|
w.setStyleSheet("QWidget { background-image: url(\":/images/testimage.png\"); }");
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
@ -207,9 +207,6 @@ static inline bool isOptionSet(int argc, char *argv[], const char *option)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Check for no scaling before QApplication is instantiated.
|
|
||||||
if (isOptionSet(argc, argv, "-s"))
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
|
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
|
||||||
QGuiApplication::setApplicationDisplayName("Foreign Window Embedding Tester");
|
QGuiApplication::setApplicationDisplayName("Foreign Window Embedding Tester");
|
||||||
|
|
||||||
|
@ -226,9 +226,6 @@ static inline bool isOptionSet(int argc, char *argv[], const char *option)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Check for no scaling before QApplication is instantiated.
|
|
||||||
if (isOptionSet(argc, argv, "-s"))
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
|
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
|
||||||
QGuiApplication::setApplicationDisplayName("Foreign window tester");
|
QGuiApplication::setApplicationDisplayName("Foreign window tester");
|
||||||
|
|
||||||
|
@ -1424,19 +1424,8 @@ void MetricsTest::logScreenChangeSignal(const QObject *o, const char *name, cons
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#define NOSCALINGOPTION "noscaling"
|
|
||||||
|
|
||||||
qInfo("High DPI tester %s", QT_VERSION_STR);
|
qInfo("High DPI tester %s", QT_VERSION_STR);
|
||||||
|
|
||||||
int preAppOptionCount = 0;
|
|
||||||
for (int a = 1; a < argc; ++a) {
|
|
||||||
if (qstrcmp(argv[a], "--" NOSCALINGOPTION) == 0) {
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
preAppOptionCount++;
|
|
||||||
qInfo("AA_DisableHighDpiScaling");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
|
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
|
||||||
|
|
||||||
@ -1449,7 +1438,6 @@ int main(int argc, char **argv)
|
|||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
QCommandLineOption controllerOption("interactive", "Show configuration window.");
|
QCommandLineOption controllerOption("interactive", "Show configuration window.");
|
||||||
parser.addOption(controllerOption);
|
parser.addOption(controllerOption);
|
||||||
parser.addOption(QCommandLineOption(NOSCALINGOPTION, "Set AA_DisableHighDpiScaling"));
|
|
||||||
|
|
||||||
DemoContainerList demoList;
|
DemoContainerList demoList;
|
||||||
demoList << new DemoContainer<PixmapPainter>("pixmap", "Test pixmap painter");
|
demoList << new DemoContainer<PixmapPainter>("pixmap", "Test pixmap painter");
|
||||||
@ -1478,7 +1466,7 @@ int main(int argc, char **argv)
|
|||||||
//controller takes ownership of all demos
|
//controller takes ownership of all demos
|
||||||
DemoController controller(demoList, &parser);
|
DemoController controller(demoList, &parser);
|
||||||
|
|
||||||
if (parser.isSet(controllerOption) || (QCoreApplication::arguments().count() - preAppOptionCount) <= 1)
|
if (parser.isSet(controllerOption) || (QCoreApplication::arguments().count()) <= 1)
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
if (QApplication::topLevelWidgets().isEmpty())
|
if (QApplication::topLevelWidgets().isEmpty())
|
||||||
|
@ -338,11 +338,6 @@ int main(int argc, char *argv[])
|
|||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
std::copy(argv + 1, argv + argc, std::back_inserter(arguments));
|
std::copy(argv + 1, argv + argc, std::back_inserter(arguments));
|
||||||
|
|
||||||
#if QT_VERSION > 0x050000
|
|
||||||
if (arguments.contains("-n"))
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
|
||||||
#endif // Qt 5
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
MainWindowPtrList windows;
|
MainWindowPtrList windows;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user