summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/iaccessible2/REUSE.toml2
-rw-r--r--src/3rdparty/libpsl/REUSE.toml2
-rw-r--r--src/android/jar/CMakeLists.txt1
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java18
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java21
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegateBase.java20
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java271
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java5
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtLoader.java2
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtNative.java5
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtView.java49
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtWindowInsetsController.java358
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtWindowInterface.java1
-rw-r--r--src/corelib/CMakeLists.txt2
-rw-r--r--src/corelib/doc/src/qtcore.qdoc2
-rw-r--r--src/corelib/kernel/qmetaassociation.cpp299
-rw-r--r--src/corelib/kernel/qmetacontainer.cpp499
-rw-r--r--src/corelib/kernel/qmetasequence.cpp471
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/corelib/kernel/qwinregistry.cpp5
-rw-r--r--src/corelib/kernel/qwinregistry_p.h6
-rw-r--r--src/corelib/serialization/qcborarray.cpp1
-rw-r--r--src/corelib/serialization/qcborcommon_p.h1
-rw-r--r--src/corelib/serialization/qcbormap.cpp1
-rw-r--r--src/corelib/serialization/qcborstream.h1
-rw-r--r--src/corelib/serialization/qjsonparser_p.h1
-rw-r--r--src/corelib/serialization/qjsonwriter_p.h1
-rw-r--r--src/corelib/text/qcollator.cpp1
-rw-r--r--src/corelib/text/qcollator.h1
-rw-r--r--src/corelib/text/qcollator_icu.cpp1
-rw-r--r--src/corelib/text/qcollator_macx.cpp1
-rw-r--r--src/corelib/text/qcollator_p.h1
-rw-r--r--src/corelib/text/qcollator_posix.cpp1
-rw-r--r--src/corelib/text/qcollator_win.cpp1
-rw-r--r--src/corelib/text/qlocale.qdoc1
-rw-r--r--src/corelib/text/qtliterals.qdoc1
-rw-r--r--src/corelib/thread/qthread.cpp3
-rw-r--r--src/gui/accessible/linux/qspiaccessiblebridge.cpp6
-rw-r--r--src/gui/accessible/qaccessible.cpp1
-rw-r--r--src/gui/accessible/qaccessible_base.h1
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp4
-rw-r--r--src/gui/doc/images/plaintext-layout.pngbin46384 -> 0 bytes
-rw-r--r--src/gui/doc/images/plaintext-layout.webpbin0 -> 7714 bytes
-rw-r--r--src/gui/doc/src/qtgui.qdoc2
-rw-r--r--src/gui/doc/src/richtext.qdoc2
-rw-r--r--src/gui/image/qiconloader.cpp13
-rw-r--r--src/gui/kernel/qkeysequence.cpp5
-rw-r--r--src/gui/kernel/qplatformwindow_p.h12
-rw-r--r--src/gui/painting/qpainter.cpp33
-rw-r--r--src/gui/painting/qpainter_p.h3
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp12
-rw-r--r--src/gui/text/qtextformat.cpp4
-rw-r--r--src/gui/util/qundostack.cpp12
-rw-r--r--src/gui/util/qundostack_p.h15
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp3
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp73
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp3
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp16
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm8
-rw-r--r--src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h5
-rw-r--r--src/plugins/platforms/ios/qiosdocumentpickercontroller.h5
-rw-r--r--src/plugins/platforms/ios/qiosplatformaccessibility.h2
-rw-r--r--src/plugins/platforms/ios/qiosplatformaccessibility.mm2
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.h5
-rw-r--r--src/plugins/platforms/ios/qioswindow.h5
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm5
-rw-r--r--src/plugins/platforms/ios/quiview.h5
-rw-r--r--src/plugins/platforms/wasm/qwasmaccessibility.cpp36
-rw-r--r--src/plugins/platforms/wasm/qwasmaccessibility.h1
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp195
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp24
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow_p.h10
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp5
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp1
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp44
-rw-r--r--src/tools/androidtestrunner/main.cpp51
-rw-r--r--src/tools/moc/moc.cpp6
-rw-r--r--src/tools/moc/moc.h1
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp3
-rw-r--r--src/widgets/kernel/qapplication.cpp29
-rw-r--r--src/widgets/kernel/qtooltip.cpp13
-rw-r--r--src/widgets/kernel/qwidget.cpp19
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp4
-rw-r--r--src/widgets/util/qcompleter.cpp15
-rw-r--r--src/widgets/widgets/qcombobox.cpp14
-rw-r--r--src/widgets/widgets/qmenu.cpp19
87 files changed, 1776 insertions, 1043 deletions
diff --git a/src/3rdparty/iaccessible2/REUSE.toml b/src/3rdparty/iaccessible2/REUSE.toml
index f4d00d7f4f1..24da6e46400 100644
--- a/src/3rdparty/iaccessible2/REUSE.toml
+++ b/src/3rdparty/iaccessible2/REUSE.toml
@@ -5,5 +5,5 @@ path = ["**"]
precedence = "closest"
SPDX-FileCopyrightText = ["Copyright (c) 2000, 2006 Sun Microsystems, Inc.",
"Copyright (c) 2006 IBM Corporation",
- "Copyright (c) 2007, 2010, 2012, 2013 Linux Foundation\nIAccessible2 is a trademark of the Linux Foundation. The IAccessible2 mark may be used in accordance with the Linux Foundation Trademark Policy to indicate compliance with the IAccessible2 specification."]
+ "Copyright (c) 2007, 2010, 2012, 2013 Linux Foundation IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 mark may be used in accordance with the Linux Foundation Trademark Policy to indicate compliance with the IAccessible2 specification."]
SPDX-License-Identifier = "BSD-3-Clause"
diff --git a/src/3rdparty/libpsl/REUSE.toml b/src/3rdparty/libpsl/REUSE.toml
index 6c911a98dfe..7b63d4ed725 100644
--- a/src/3rdparty/libpsl/REUSE.toml
+++ b/src/3rdparty/libpsl/REUSE.toml
@@ -10,6 +10,6 @@ SPDX-License-Identifier = "BSD-3-Clause"
[[annotations]]
path = ["psl_data.cpp"]
precedence = "closest"
-SPDX-FileCopyrightText = ["The list was originally provided by Jo Hermans <[email protected]>.\nIt is now maintained on github (https://github.com/publicsuffix/list)."]
+SPDX-FileCopyrightText = ["The list was originally provided by Jo Hermans <[email protected]>.It is now maintained on github (https://github.com/publicsuffix/list)."]
SPDX-License-Identifier = "MPL-2.0"
diff --git a/src/android/jar/CMakeLists.txt b/src/android/jar/CMakeLists.txt
index b073dbea0ea..e0a675ab463 100644
--- a/src/android/jar/CMakeLists.txt
+++ b/src/android/jar/CMakeLists.txt
@@ -53,6 +53,7 @@ set(java_sources
src/org/qtproject/qt/android/BackgroundActionsTracker.java
src/org/qtproject/qt/android/QtApkFileEngine.java
src/org/qtproject/qt/android/QtContentFileEngine.java
+ src/org/qtproject/qt/android/QtWindowInsetsController.java
)
qt_internal_add_jar(Qt${QtBase_VERSION_MAJOR}Android
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java
index aca9e3d3c11..78763e65905 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java
@@ -102,9 +102,11 @@ public class QtActivityBase extends Activity
requestWindowFeature(Window.FEATURE_ACTION_BAR);
if (!m_isCustomThemeSet) {
- setTheme(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ?
- android.R.style.Theme_DeviceDefault_DayNight :
- android.R.style.Theme_Holo_Light);
+ @SuppressWarnings("deprecation")
+ int themeId = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
+ ? android.R.style.Theme_DeviceDefault_DayNight
+ : android.R.style.Theme_Holo_Light;
+ setTheme(themeId);
}
if (QtNative.getStateDetails().isStarted) {
@@ -168,7 +170,7 @@ public class QtActivityBase extends Activity
m_delegate.displayManager().registerDisplayListener();
QtWindow.updateWindows();
// Suspending the app clears the immersive mode, so we need to set it again.
- m_delegate.displayManager().reinstateFullScreen();
+ QtWindowInsetsController.restoreFullScreenVisibility(this);
}
}
@@ -311,9 +313,7 @@ public class QtActivityBase extends Activity
return;
QtNative.setStarted(savedInstanceState.getBoolean("Started"));
- boolean isFullScreen = savedInstanceState.getBoolean("isFullScreen");
- boolean expandedToCutout = savedInstanceState.getBoolean("expandedToCutout");
- m_delegate.displayManager().setSystemUiVisibility(isFullScreen, expandedToCutout);
+ QtWindowInsetsController.restoreFullScreenVisibility(this);
// FIXME restore all surfaces
}
@@ -329,8 +329,6 @@ public class QtActivityBase extends Activity
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
- outState.putBoolean("isFullScreen", m_delegate.displayManager().isFullScreen());
- outState.putBoolean("expandedToCutout", m_delegate.displayManager().expandedToCutout());
outState.putBoolean("Started", QtNative.getStateDetails().isStarted);
}
@@ -339,7 +337,7 @@ public class QtActivityBase extends Activity
{
super.onWindowFocusChanged(hasFocus);
if (hasFocus)
- m_delegate.displayManager().reinstateFullScreen();
+ QtWindowInsetsController.restoreFullScreenVisibility(this);
}
@Override
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
index 118845efcec..aa2964c3ae9 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -86,21 +86,6 @@ class QtActivityDelegate extends QtActivityDelegateBase
}
@Override
- public void setSystemUiVisibility(boolean isFullScreen, boolean expandedToCutout)
- {
- if (m_layout == null)
- return;
-
- QtNative.runAction(() -> {
- if (m_layout != null) {
- m_displayManager.setSystemUiVisibility(isFullScreen, expandedToCutout);
- QtWindow.updateWindows();
- }
- });
- }
-
-
- @Override
final public void onAppStateDetailsChanged(QtNative.ApplicationStateDetails details) {
if (details.isStarted)
registerBackends();
@@ -138,9 +123,9 @@ class QtActivityDelegate extends QtActivityDelegateBase
int orientation = m_activity.getResources().getConfiguration().orientation;
setUpSplashScreen(orientation);
m_activity.registerForContextMenu(m_layout);
- m_activity.setContentView(m_layout,
- new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
+ ViewGroup.LayoutParams rootParams = new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ m_activity.setContentView(m_layout, rootParams);
handleUiModeChange();
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegateBase.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegateBase.java
index 35f519ca9a4..7f6163f164d 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegateBase.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegateBase.java
@@ -46,7 +46,9 @@ abstract class QtActivityDelegateBase
m_activity = activity;
QtNative.setActivity(m_activity);
m_displayManager = new QtDisplayManager(m_activity);
- m_inputDelegate = new QtInputDelegate(m_displayManager::reinstateFullScreen);
+ m_inputDelegate = new QtInputDelegate(() -> {
+ QtWindowInsetsController.restoreFullScreenVisibility(m_activity);
+ });
m_accessibilityDelegate = new QtAccessibilityDelegate();
}
@@ -105,20 +107,20 @@ abstract class QtActivityDelegateBase
Configuration config = resources.getConfiguration();
int uiMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
- if (m_displayManager.decorFitsSystemWindows()) {
+ if (QtWindowInsetsController.decorFitsSystemWindows(m_activity)) {
Window window = m_activity.getWindow();
- QtDisplayManager.enableSystemBarsBackgroundDrawing(window);
- int status = QtDisplayManager.getThemeDefaultStatusBarColor(m_activity);
- QtDisplayManager.setStatusBarColor(window, status);
- int nav = QtDisplayManager.getThemeDefaultNavigationBarColor(m_activity);
- QtDisplayManager.setNavigationBarColor(window, nav);
+ QtWindowInsetsController.enableSystemBarsBackgroundDrawing(window);
+ int status = QtWindowInsetsController.getThemeDefaultStatusBarColor(m_activity);
+ QtWindowInsetsController.setStatusBarColor(window, status);
+ int nav = QtWindowInsetsController.getThemeDefaultNavigationBarColor(m_activity);
+ QtWindowInsetsController.setNavigationBarColor(window, nav);
}
// Don't override color scheme if the app has it set explicitly.
if (canOverrideColorSchemeHint()) {
boolean isLight = uiMode == Configuration.UI_MODE_NIGHT_NO;
- QtDisplayManager.setStatusBarColorHint(m_activity, isLight);
- QtDisplayManager.setNavigationBarColorHint(m_activity, isLight);
+ QtWindowInsetsController.setStatusBarColorHint(m_activity, isLight);
+ QtWindowInsetsController.setNavigationBarColorHint(m_activity, isLight);
}
switch (uiMode) {
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java b/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java
index 8736dfab771..2cabb951813 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java
@@ -7,7 +7,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.os.Build;
@@ -15,22 +14,13 @@ import android.util.DisplayMetrics;
import android.util.Size;
import android.view.Display;
import android.view.Surface;
-import android.view.View;
-import android.view.WindowInsets;
import android.view.WindowManager;
-import android.view.WindowManager.LayoutParams;
import android.view.WindowMetrics;
-import android.view.WindowInsetsController;
-import android.view.Window;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import android.graphics.Color;
-import android.util.TypedValue;
-import android.content.res.Resources.Theme;
-
import android.util.Log;
class QtDisplayManager
@@ -47,9 +37,6 @@ class QtDisplayManager
static native void handleScreenDensityChanged(double density);
// screen methods
- private boolean m_isFullScreen = false;
- private boolean m_expandedToCutout = false;
-
private static int m_previousRotation = -1;
private final DisplayManager.DisplayListener m_displayListener;
@@ -136,264 +123,6 @@ class QtDisplayManager
}
@SuppressWarnings("deprecation")
- void setSystemUiVisibilityPreAndroidR(View decorView)
- {
- int systemUiVisibility;
-
- if (m_isFullScreen || m_expandedToCutout) {
- systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
- if (m_isFullScreen) {
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
- }
- } else {
- systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
- }
-
- decorView.setSystemUiVisibility(systemUiVisibility);
- }
-
- void setSystemUiVisibility(boolean isFullScreen, boolean expandedToCutout)
- {
- if (m_isFullScreen == isFullScreen && m_expandedToCutout == expandedToCutout)
- return;
-
- m_isFullScreen = isFullScreen;
- m_expandedToCutout = expandedToCutout;
-
- Window window = m_activity.getWindow();
- View decorView = window.getDecorView();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- int cutoutMode;
- if (m_isFullScreen || m_expandedToCutout) {
- window.setDecorFitsSystemWindows(false);
- cutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
- } else {
- window.setDecorFitsSystemWindows(true);
- cutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
- }
- LayoutParams layoutParams = window.getAttributes();
- layoutParams.layoutInDisplayCutoutMode = cutoutMode;
- window.setAttributes(layoutParams);
-
- final WindowInsetsController insetsControl = window.getInsetsController();
- if (insetsControl != null) {
- int sysBarsBehavior;
- if (m_isFullScreen) {
- insetsControl.hide(WindowInsets.Type.systemBars());
- sysBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
- } else {
- insetsControl.show(WindowInsets.Type.systemBars());
- sysBarsBehavior = WindowInsetsController.BEHAVIOR_DEFAULT;
- }
- insetsControl.setSystemBarsBehavior(sysBarsBehavior);
- }
- } else {
- setSystemUiVisibilityPreAndroidR(decorView);
- }
-
- if (!isFullScreen && !edgeToEdgeEnabled(m_activity)) {
- // These are needed to operate on system bar colors
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
- | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
-
- // Handle transparent status and navigation bars
- if (m_expandedToCutout) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- window.setStatusBarColor(Color.TRANSPARENT);
- window.setNavigationBarColor(Color.TRANSPARENT);
- } else {
- // Android 9 and prior doesn't add the semi-transparent bars
- // to avoid low contrast system icons, so try to mimick it
- // by taking the current color and only increase the opacity.
- int statusBarColor = window.getStatusBarColor();
- int transparentStatusBar = statusBarColor & 0x00FFFFFF;
- window.setStatusBarColor(transparentStatusBar);
-
- int navigationBarColor = window.getNavigationBarColor();
- int semiTransparentNavigationBar = navigationBarColor & 0x7FFFFFFF;
- window.setNavigationBarColor(semiTransparentNavigationBar);
- }
- } else {
- // Restore theme's system bars colors
- Theme theme = m_activity.getTheme();
- TypedValue typedValue = new TypedValue();
-
- theme.resolveAttribute(android.R.attr.statusBarColor, typedValue, true);
- int defaultStatusBarColor = typedValue.data;
- window.setStatusBarColor(defaultStatusBarColor);
-
- theme.resolveAttribute(android.R.attr.navigationBarColor, typedValue, true);
- int defaultNavigationBarColor = typedValue.data;
- window.setNavigationBarColor(defaultNavigationBarColor);
- }
- }
-
- decorView.post(() -> decorView.requestApplyInsets());
- }
-
- private static boolean edgeToEdgeEnabled(Activity activity) {
- if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return true;
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return false;
- int[] attrs = new int[] { android.R.attr.windowOptOutEdgeToEdgeEnforcement };
- TypedArray ta = activity.getTheme().obtainStyledAttributes(attrs);
- try {
- return !ta.getBoolean(0, false);
- } finally {
- ta.recycle();
- }
- }
-
- boolean isFullScreen()
- {
- return m_isFullScreen;
- }
-
- boolean expandedToCutout()
- {
- return m_expandedToCutout;
- }
-
- boolean decorFitsSystemWindows()
- {
- return !isFullScreen() && !expandedToCutout();
- }
-
- void reinstateFullScreen()
- {
- if (m_isFullScreen) {
- m_isFullScreen = false;
- setSystemUiVisibility(true, m_expandedToCutout);
- }
- }
-
- /*
- * Convenience method to call deprecated API prior to Android R (30).
- */
- @SuppressWarnings ("deprecation")
- private static void setSystemUiVisibility(View decorView, int flags)
- {
- decorView.setSystemUiVisibility(flags);
- }
-
- /*
- * Set the status bar color scheme hint so that the system decides how to color the icons.
- */
- @UsedFromNativeCode
- static void setStatusBarColorHint(Activity activity, boolean isLight)
- {
- Window window = activity.getWindow();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- WindowInsetsController controller = window.getInsetsController();
- if (controller != null) {
- int lightStatusBarMask = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
- int appearance = isLight ? lightStatusBarMask : 0;
- controller.setSystemBarsAppearance(appearance, lightStatusBarMask);
- }
- } else {
- @SuppressWarnings("deprecation")
- int currentFlags = window.getDecorView().getSystemUiVisibility();
- @SuppressWarnings("deprecation")
- int lightStatusBarMask = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
- int appearance = isLight
- ? currentFlags | lightStatusBarMask
- : currentFlags & ~lightStatusBarMask;
- setSystemUiVisibility(window.getDecorView(), appearance);
- }
- }
-
- /*
- * Set the navigation bar color scheme hint so that the system decides how to color the icons.
- */
- @UsedFromNativeCode
- static void setNavigationBarColorHint(Activity activity, boolean isLight)
- {
- Window window = activity.getWindow();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- WindowInsetsController controller = window.getInsetsController();
- if (controller != null) {
- int lightNavigationBarMask = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
- int appearance = isLight ? lightNavigationBarMask : 0;
- controller.setSystemBarsAppearance(appearance, lightNavigationBarMask);
- }
- } else {
- @SuppressWarnings("deprecation")
- int currentFlags = window.getDecorView().getSystemUiVisibility();
- @SuppressWarnings("deprecation")
- int lightNavigationBarMask = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
- int appearance = isLight
- ? currentFlags | lightNavigationBarMask
- : currentFlags & ~lightNavigationBarMask;
- setSystemUiVisibility(window.getDecorView(), appearance);
- }
- }
-
- static int resolveColorAttribute(Activity activity, int attribute)
- {
- Theme theme = activity.getTheme();
- Resources resources = activity.getResources();
- TypedValue tv = new TypedValue();
-
- if (theme.resolveAttribute(attribute, tv, true)) {
- if (tv.resourceId != 0)
- return resources.getColor(tv.resourceId, theme);
- if (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT)
- return tv.data;
- }
-
- return -1;
- }
-
- @SuppressWarnings("deprecation")
- static int getThemeDefaultStatusBarColor(Activity activity)
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return -1;
- return resolveColorAttribute(activity, android.R.attr.statusBarColor);
- }
-
- @SuppressWarnings("deprecation")
- static int getThemeDefaultNavigationBarColor(Activity activity)
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return -1;
- return resolveColorAttribute(activity, android.R.attr.navigationBarColor);
- }
-
- static void enableSystemBarsBackgroundDrawing(Window window)
- {
- // These are needed to operate on system bar colors
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- @SuppressWarnings("deprecation")
- final int translucentFlags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
- | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
- window.clearFlags(translucentFlags);
- }
-
- @SuppressWarnings("deprecation")
- static void setStatusBarColor(Window window, int color)
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return;
- window.setStatusBarColor(color);
- }
-
- @SuppressWarnings("deprecation")
- static void setNavigationBarColor(Window window, int color)
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
- return;
- window.setNavigationBarColor(color);
- }
-
- @SuppressWarnings("deprecation")
static Display getDisplay(Context context)
{
Activity activity = (Activity) context;
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
index ca271c5dd62..e0c6c00a8fd 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
@@ -9,6 +9,7 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.ResultReceiver;
import android.text.method.MetaKeyKeyListener;
import android.util.DisplayMetrics;
@@ -166,7 +167,7 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt
} else {
if (m_imm == null)
return;
- m_imm.showSoftInput(m_currentEditText, 0, new ResultReceiver(new Handler()) {
+ m_imm.showSoftInput(m_currentEditText, 0, new ResultReceiver(new Handler(Looper.getMainLooper())) {
@Override
@SuppressWarnings("fallthrough")
protected void onReceiveResult(int resultCode, Bundle resultData) {
@@ -278,7 +279,7 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt
activity.getWindow().getInsetsController().hide(Type.ime());
} else {
m_imm.hideSoftInputFromWindow(m_currentEditText.getWindowToken(), 0,
- new ResultReceiver(new Handler()) {
+ new ResultReceiver(new Handler(Looper.getMainLooper())) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
switch (resultCode) {
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtLoader.java b/src/android/jar/src/org/qtproject/qt/android/QtLoader.java
index 8fd0213eb91..6d7c0624272 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtLoader.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtLoader.java
@@ -345,7 +345,7 @@ abstract class QtLoader {
if (metadata == null || !metadata.containsKey(key))
return "";
- return String.valueOf(metadata.get(key));
+ return String.valueOf(metadata.getString(key));
}
@SuppressLint("DiscouragedApi")
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
index 080bb787a2d..7e4632f6792 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
@@ -361,8 +361,11 @@ public class QtNative
if (m_stateDetails.isStarted)
return;
+ getQtThread().run(() -> initAndroidQpaPlugin());
final String qtParams = mainLib + " " + params;
getQtThread().post(() -> { startQtNativeApplication(qtParams); });
+ waitForServiceSetup();
+ setStarted(true);
}
@UsedFromNativeCode
@@ -428,7 +431,9 @@ public class QtNative
}
// application methods
+ static native boolean initAndroidQpaPlugin();
static native void startQtNativeApplication(String params);
+ static native void waitForServiceSetup();
static native void terminateQtNativeApplication();
static native boolean updateNativeActivity();
// application methods
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtView.java b/src/android/jar/src/org/qtproject/qt/android/QtView.java
index b60c58013f5..e245f731ce8 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtView.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtView.java
@@ -25,11 +25,11 @@ abstract class QtView extends ViewGroup implements QtNative.AppStateDetailsListe
void onQtWindowLoaded();
}
- protected QtWindow m_window;
- protected long m_windowReference;
- protected long m_parentWindowReference;
- protected QtWindowListener m_windowListener;
- protected final QtEmbeddedViewInterface m_viewInterface;
+ private QtWindow m_window;
+ private long m_windowReference;
+ private long m_parentWindowReference;
+ private QtWindowListener m_windowListener;
+ private final QtEmbeddedViewInterface m_viewInterface;
// Implement in subclass to handle the creation of the QWindow and its parent container.
// TODO could we take care of the parent window creation and parenting outside of the
// window creation method to simplify things if user would extend this? Preferably without
@@ -164,10 +164,43 @@ abstract class QtView extends ViewGroup implements QtNative.AppStateDetailsListe
m_windowReference = windowReference;
}
- long windowReference() {
+ long getWindowReference() {
return m_windowReference;
}
+ void setQtWindow(QtWindow qtWindow) {
+ m_window = qtWindow;
+ }
+
+ QtWindow getQtWindow() {
+ return m_window;
+ }
+
+ long getParentWindowReference()
+ {
+ return m_parentWindowReference;
+ }
+
+ void setParentWindowReference(long reference)
+ {
+ m_parentWindowReference = reference;
+ }
+
+ QtWindowListener getWindowListener()
+ {
+ return m_windowListener;
+ }
+
+ void setWindowListener(QtWindowListener listner)
+ {
+ m_windowListener = listner;
+ }
+
+ QtEmbeddedViewInterface getViewInterface()
+ {
+ return m_viewInterface;
+ }
+
// Set the visibility of the underlying QWindow. If visible is true, showNormal() is called.
// If false, the window is hidden.
void setWindowVisible(boolean visible) {
@@ -203,10 +236,6 @@ abstract class QtView extends ViewGroup implements QtNative.AppStateDetailsListe
setWindowReference(0L);
}
- QtWindow getQtWindow() {
- return m_window;
- }
-
@Override
public void onAppStateDetailsChanged(QtNative.ApplicationStateDetails details) {
if (!details.isStarted) {
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindowInsetsController.java b/src/android/jar/src/org/qtproject/qt/android/QtWindowInsetsController.java
new file mode 100644
index 00000000000..a3d0a0df8e5
--- /dev/null
+++ b/src/android/jar/src/org/qtproject/qt/android/QtWindowInsetsController.java
@@ -0,0 +1,358 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+package org.qtproject.qt.android;
+
+import android.app.Activity;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.view.View;
+import android.view.WindowInsets;
+import android.view.WindowManager;
+import android.view.WindowInsetsController;
+import android.view.Window;
+
+import android.graphics.Color;
+import android.util.TypedValue;
+import android.content.res.Resources.Theme;
+
+class QtWindowInsetsController
+{
+ /*
+ * Convenience method to call deprecated API prior to Android R (30).
+ */
+ @SuppressWarnings ("deprecation")
+ private static void setDecorFitsSystemWindows(Window window, boolean enable)
+ {
+ final int sdk = Build.VERSION.SDK_INT;
+ if (sdk < Build.VERSION_CODES.R || sdk > Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return;
+ window.setDecorFitsSystemWindows(enable);
+ }
+
+ private static void useCutoutShortEdges(Window window, boolean enabled)
+ {
+ if (window == null)
+ return;
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ WindowManager.LayoutParams layoutParams = window.getAttributes();
+ layoutParams.layoutInDisplayCutoutMode = enabled
+ ? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
+ : WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
+ window.setAttributes(layoutParams);
+ }
+ }
+
+ @UsedFromNativeCode
+ static void showNormal(Activity activity)
+ {
+ Window window = activity.getWindow();
+ if (window == null)
+ return;
+
+ final View decor = window.getDecorView();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ setDecorFitsSystemWindows(window, true);
+ WindowInsetsController ctrl = window.getInsetsController();
+ if (ctrl != null) {
+ ctrl.show(WindowInsets.Type.systemBars());
+ ctrl.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_DEFAULT);
+ }
+ } else {
+ @SuppressWarnings("deprecation")
+ int flags = View.SYSTEM_UI_FLAG_VISIBLE; // clear all flags
+ setSystemUiVisibility(decor, flags);
+ }
+
+ setTransparentSystemBars(activity, false);
+ useCutoutShortEdges(window, false);
+
+ decor.post(() -> decor.requestApplyInsets());
+ }
+
+ /*
+ * Make system bars transparent for Andorid versions prior to Android 15.
+ */
+ @SuppressWarnings("deprecation")
+ private static void setTransparentSystemBars(Activity activity, boolean transparent)
+ {
+ Window window = activity.getWindow();
+ if (window == null)
+ return;
+
+ if (edgeToEdgeEnabled(activity))
+ return;
+
+ // These are needed to operate on system bar colors
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+
+ if (transparent) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ window.setStatusBarColor(Color.TRANSPARENT);
+ window.setNavigationBarColor(Color.TRANSPARENT);
+ } else {
+ // Android 9 and prior doesn't add the semi-transparent bars
+ // to avoid low contrast system icons, so try to mimick it
+ // by taking the current color and only increase the opacity.
+ int statusBarColor = window.getStatusBarColor();
+ int transparentStatusBar = statusBarColor & 0x00FFFFFF;
+ window.setStatusBarColor(transparentStatusBar);
+
+ int navigationBarColor = window.getNavigationBarColor();
+ int semiTransparentNavigationBar = navigationBarColor & 0x7FFFFFFF;
+ window.setNavigationBarColor(semiTransparentNavigationBar);
+ }
+ } else {
+ // Restore theme's system bars colors
+ int defaultStatusBarColor = getThemeDefaultStatusBarColor(activity);
+ window.setStatusBarColor(defaultStatusBarColor);
+
+ int defaultNavigationBarColor = getThemeDefaultNavigationBarColor(activity);
+ window.setNavigationBarColor(defaultNavigationBarColor);
+ }
+ }
+
+ @UsedFromNativeCode
+ static void showExpanded(Activity activity)
+ {
+ Window window = activity.getWindow();
+ if (window == null)
+ return;
+
+ final View decor = window.getDecorView();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ setDecorFitsSystemWindows(window, false);
+ WindowInsetsController ctrl = window.getInsetsController();
+ if (ctrl != null) {
+ ctrl.show(WindowInsets.Type.systemBars());
+ ctrl.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_DEFAULT);
+ }
+ } else {
+ @SuppressWarnings("deprecation")
+ int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ setSystemUiVisibility(decor, flags);
+ }
+
+ setTransparentSystemBars(activity, true);
+ useCutoutShortEdges(window, true);
+
+ decor.post(() -> decor.requestApplyInsets());
+ }
+
+ @UsedFromNativeCode
+ public static void showFullScreen(Activity activity)
+ {
+ Window window = activity.getWindow();
+ if (window == null)
+ return;
+
+ final View decor = window.getDecorView();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ setDecorFitsSystemWindows(window, false);
+ WindowInsetsController ctrl = window.getInsetsController();
+ if (ctrl != null) {
+ ctrl.hide(WindowInsets.Type.systemBars());
+ ctrl.setSystemBarsBehavior(
+ WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
+ }
+ } else {
+ @SuppressWarnings("deprecation")
+ int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ setSystemUiVisibility(decor, flags);
+ }
+
+ useCutoutShortEdges(window, true);
+
+ decor.post(() -> decor.requestApplyInsets());
+ }
+
+ private static boolean edgeToEdgeEnabled(Activity activity) {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return true;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return false;
+ int[] attrs = new int[] { android.R.attr.windowOptOutEdgeToEdgeEnforcement };
+ TypedArray ta = activity.getTheme().obtainStyledAttributes(attrs);
+ try {
+ return !ta.getBoolean(0, false);
+ } finally {
+ ta.recycle();
+ }
+ }
+
+ static boolean isFullScreen(Activity activity)
+ {
+ Window window = activity.getWindow();
+ if (window == null)
+ return false;
+
+ final View decor = window.getDecorView();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();
+ if (insets != null)
+ return !insets.isVisible(WindowInsets.Type.statusBars());
+ } else {
+ @SuppressWarnings("deprecation")
+ int flags = decor.getSystemUiVisibility();
+ @SuppressWarnings("deprecation")
+ int immersiveMask = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ return (flags & immersiveMask) == immersiveMask;
+ }
+
+ return false;
+ }
+
+ static boolean isExpandedClientArea(Activity activity)
+ {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return edgeToEdgeEnabled(activity);
+
+ @SuppressWarnings("deprecation")
+ int statusBarColor = activity.getWindow().getStatusBarColor();
+ // If the status bar is not fully opaque assume we have expanded client
+ // area and we're drawing under it.
+ int statusBarAlpha = statusBarColor >>> 24;
+ return statusBarAlpha != 0xFF;
+ }
+
+ static boolean decorFitsSystemWindows(Activity activity)
+ {
+ return !isFullScreen(activity) && !isExpandedClientArea(activity);
+ }
+
+ static void restoreFullScreenVisibility(Activity activity)
+ {
+ if (isFullScreen(activity))
+ showFullScreen(activity);
+ }
+
+ /*
+ * Convenience method to call deprecated API prior to Android R (30).
+ */
+ @SuppressWarnings ("deprecation")
+ private static void setSystemUiVisibility(View decorView, int flags)
+ {
+ decorView.setSystemUiVisibility(flags);
+ }
+
+ /*
+ * Set the status bar color scheme hint so that the system decides how to color the icons.
+ */
+ @UsedFromNativeCode
+ static void setStatusBarColorHint(Activity activity, boolean isLight)
+ {
+ Window window = activity.getWindow();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ WindowInsetsController controller = window.getInsetsController();
+ if (controller != null) {
+ int lightStatusBarMask = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
+ int appearance = isLight ? lightStatusBarMask : 0;
+ controller.setSystemBarsAppearance(appearance, lightStatusBarMask);
+ }
+ } else {
+ @SuppressWarnings("deprecation")
+ int currentFlags = window.getDecorView().getSystemUiVisibility();
+ @SuppressWarnings("deprecation")
+ int lightStatusBarMask = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+ int appearance = isLight
+ ? currentFlags | lightStatusBarMask
+ : currentFlags & ~lightStatusBarMask;
+ setSystemUiVisibility(window.getDecorView(), appearance);
+ }
+ }
+
+ /*
+ * Set the navigation bar color scheme hint so that the system decides how to color the icons.
+ */
+ @UsedFromNativeCode
+ static void setNavigationBarColorHint(Activity activity, boolean isLight)
+ {
+ Window window = activity.getWindow();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ WindowInsetsController controller = window.getInsetsController();
+ if (controller != null) {
+ int lightNavigationBarMask = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
+ int appearance = isLight ? lightNavigationBarMask : 0;
+ controller.setSystemBarsAppearance(appearance, lightNavigationBarMask);
+ }
+ } else {
+ @SuppressWarnings("deprecation")
+ int currentFlags = window.getDecorView().getSystemUiVisibility();
+ @SuppressWarnings("deprecation")
+ int lightNavigationBarMask = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
+ int appearance = isLight
+ ? currentFlags | lightNavigationBarMask
+ : currentFlags & ~lightNavigationBarMask;
+ setSystemUiVisibility(window.getDecorView(), appearance);
+ }
+ }
+
+ private static int resolveColorAttribute(Activity activity, int attribute)
+ {
+ Theme theme = activity.getTheme();
+ Resources resources = activity.getResources();
+ TypedValue tv = new TypedValue();
+
+ if (theme.resolveAttribute(attribute, tv, true)) {
+ if (tv.resourceId != 0)
+ return resources.getColor(tv.resourceId, theme);
+ if (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT)
+ return tv.data;
+ }
+
+ return -1;
+ }
+
+ @SuppressWarnings("deprecation")
+ static int getThemeDefaultStatusBarColor(Activity activity)
+ {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return -1;
+ return resolveColorAttribute(activity, android.R.attr.statusBarColor);
+ }
+
+ @SuppressWarnings("deprecation")
+ static int getThemeDefaultNavigationBarColor(Activity activity)
+ {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return -1;
+ return resolveColorAttribute(activity, android.R.attr.navigationBarColor);
+ }
+
+ static void enableSystemBarsBackgroundDrawing(Window window)
+ {
+ // These are needed to operate on system bar colors
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ @SuppressWarnings("deprecation")
+ final int translucentFlags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
+ window.clearFlags(translucentFlags);
+ }
+
+ @SuppressWarnings("deprecation")
+ static void setStatusBarColor(Window window, int color)
+ {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return;
+ window.setStatusBarColor(color);
+ }
+
+ @SuppressWarnings("deprecation")
+ static void setNavigationBarColor(Window window, int color)
+ {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ return;
+ window.setNavigationBarColor(color);
+ }
+}
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindowInterface.java b/src/android/jar/src/org/qtproject/qt/android/QtWindowInterface.java
index d42b3e6821e..1cd36f06f5c 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtWindowInterface.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtWindowInterface.java
@@ -7,5 +7,4 @@ interface QtWindowInterface {
default void removeTopLevelWindow(final int id) { }
default void bringChildToFront(final int id) { }
default void bringChildToBack(int id) { }
- default void setSystemUiVisibility(boolean isFullScreen, boolean expandedToCutout) { }
}
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index d8743a1c976..337703bda3a 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -175,10 +175,12 @@ qt_internal_add_module(Core
kernel/qfunctions_p.h
kernel/qiterable.cpp kernel/qiterable.h kernel/qiterable_impl.h
kernel/qmath.cpp kernel/qmath.h
+ kernel/qmetaassociation.cpp
kernel/qmetacontainer.cpp kernel/qmetacontainer.h
kernel/qmetaobject.cpp kernel/qmetaobject.h kernel/qmetaobject_p.h
kernel/qmetaobject_moc_p.h
kernel/qmetaobjectbuilder.cpp kernel/qmetaobjectbuilder_p.h
+ kernel/qmetasequence.cpp
kernel/qmetatype.cpp kernel/qmetatype.h kernel/qmetatype_p.h
kernel/qmimedata.cpp kernel/qmimedata.h
kernel/qtmetamacros.h kernel/qtmocconstants.h kernel/qtmochelpers.h
diff --git a/src/corelib/doc/src/qtcore.qdoc b/src/corelib/doc/src/qtcore.qdoc
index ea65d68da58..38d73870af5 100644
--- a/src/corelib/doc/src/qtcore.qdoc
+++ b/src/corelib/doc/src/qtcore.qdoc
@@ -28,7 +28,7 @@
private Qt Core APIs:
\badcode
- find_package(Qt6 REQUIRED COMPONENTS Core)
+ find_package(Qt6 REQUIRED COMPONENTS CorePrivate)
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
\endcode
*/
diff --git a/src/corelib/kernel/qmetaassociation.cpp b/src/corelib/kernel/qmetaassociation.cpp
new file mode 100644
index 00000000000..dc239424e6d
--- /dev/null
+++ b/src/corelib/kernel/qmetaassociation.cpp
@@ -0,0 +1,299 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include <QtCore/qmetacontainer.h>
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QMetaAssociation
+ \inmodule QtCore
+ \since 6.0
+ \brief The QMetaAssociation class allows type erased access to associative containers.
+
+ \ingroup objectmodel
+
+ \compares equality
+
+ The class provides a number of primitive container operations, using void*
+ as operands. This way, you can manipulate a generic container retrieved from
+ a Variant without knowing its type.
+
+ QMetaAssociation covers both, containers with mapped values such as QMap or
+ QHash, and containers that only hold keys such as QSet.
+
+ The void* arguments to the various methods are typically created by using
+ a \l QVariant of the respective container or value type, and calling
+ its \l QVariant::data() or \l QVariant::constData() methods. However, you
+ can also pass plain pointers to objects of the container or value type.
+
+ Iterator invalidation follows the rules given by the underlying containers
+ and is not expressed in the API. Therefore, for a truly generic container,
+ any iterators should be considered invalid after any write operation.
+
+ \sa QMetaContainer, QMetaSequence, QIterable, QIterator
+*/
+
+/*!
+ \fn template<typename C> QMetaAssociation QMetaAssociation::fromContainer()
+ \since 6.0
+
+ Returns the QMetaAssociation corresponding to the type given as template parameter.
+*/
+
+/*!
+ Returns the meta type for keys in the container.
+ */
+QMetaType QMetaAssociation::keyMetaType() const
+{
+ if (auto iface = d())
+ return QMetaType(iface->keyMetaType);
+ return QMetaType();
+}
+
+/*!
+ Returns the meta type for mapped values in the container.
+ */
+QMetaType QMetaAssociation::mappedMetaType() const
+{
+ if (auto iface = d())
+ return QMetaType(iface->mappedMetaType);
+ return QMetaType();
+}
+
+/*!
+ \fn bool QMetaAssociation::canInsertKey() const
+
+ Returns \c true if keys can be added to the container using \l insertKey(),
+ otherwise returns \c false.
+
+ \sa insertKey()
+ */
+
+/*!
+ \fn void QMetaAssociation::insertKey(void *container, const void *key) const
+
+ Inserts the \a key into the \a container if possible. If the container has
+ mapped values a default-create mapped value is associated with the \a key.
+
+ \sa canInsertKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canRemoveKey() const
+
+ Returns \c true if keys can be removed from the container using
+ \l removeKey(), otherwise returns \c false.
+
+ \sa removeKey()
+ */
+
+/*!
+ \fn void QMetaAssociation::removeKey(void *container, const void *key) const
+
+ Removes the \a key and its associated mapped value from the \a container if
+ possible.
+
+ \sa canRemoveKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canContainsKey() const
+
+ Returns \c true if the container can be queried for keys using
+ \l containsKey(), otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QMetaAssociation::containsKey(const void *container, const void *key) const
+
+ Returns \c true if the \a container can be queried for keys and contains the
+ \a key, otherwise returns \c false.
+
+ \sa canContainsKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canGetMappedAtKey() const
+
+ Returns \c true if the container can be queried for values using
+ \l mappedAtKey(), otherwise returns \c false.
+ */
+
+/*!
+ \fn void QMetaAssociation::mappedAtKey(const void *container, const void *key, void *mapped) const
+
+ Retrieves the mapped value associated with the \a key in the \a container
+ and places it in the memory location pointed to by \a mapped, if that is
+ possible.
+
+ \sa canGetMappedAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canSetMappedAtKey() const
+
+ Returns \c true if mapped values can be modified in the container using
+ \l setMappedAtKey(), otherwise returns \c false.
+
+ \sa setMappedAtKey()
+ */
+
+/*!
+ \fn void QMetaAssociation::setMappedAtKey(void *container, const void *key, const void *mapped) const
+
+ Overwrites the value associated with the \a key in the \a container using
+ the \a mapped value passed as argument if that is possible.
+
+ \sa canSetMappedAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canGetKeyAtIterator() const
+
+ Returns \c true if a key can be retrieved from a non-const iterator using
+ \l keyAtIterator(), otherwise returns \c false.
+
+ \sa keyAtIterator()
+ */
+
+/*!
+ \fn void QMetaAssociation::keyAtIterator(const void *iterator, void *key) const
+
+ Retrieves the key pointed to by the non-const \a iterator and stores it
+ in the memory location pointed to by \a key, if possible.
+
+ \sa canGetKeyAtIterator(), begin(), end(), createIteratorAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canGetKeyAtConstIterator() const
+
+ Returns \c true if a key can be retrieved from a const iterator using
+ \l keyAtConstIterator(), otherwise returns \c false.
+
+ \sa keyAtConstIterator()
+ */
+
+/*!
+ \fn void QMetaAssociation::keyAtConstIterator(const void *iterator, void *key) const
+
+ Retrieves the key pointed to by the const \a iterator and stores it
+ in the memory location pointed to by \a key, if possible.
+
+ \sa canGetKeyAtConstIterator(), constBegin(), constEnd(), createConstIteratorAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canGetMappedAtIterator() const
+
+ Returns \c true if a mapped value can be retrieved from a non-const
+ iterator using \l mappedAtIterator(), otherwise returns \c false.
+
+ \sa mappedAtIterator()
+ */
+
+/*!
+ \fn void QMetaAssociation::mappedAtIterator(const void *iterator, void *mapped) const
+
+ Retrieves the mapped value pointed to by the non-const \a iterator and
+ stores it in the memory location pointed to by \a mapped, if possible.
+
+ \sa canGetMappedAtIterator(), begin(), end(), createIteratorAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canGetMappedAtConstIterator() const
+
+ Returns \c true if a mapped value can be retrieved from a const iterator
+ using \l mappedAtConstIterator(), otherwise returns \c false.
+
+ \sa mappedAtConstIterator()
+ */
+
+/*!
+ \fn void QMetaAssociation::mappedAtConstIterator(const void *iterator, void *mapped) const
+
+ Retrieves the mapped value pointed to by the const \a iterator and
+ stores it in the memory location pointed to by \a mapped, if possible.
+
+ \sa canGetMappedAtConstIterator(), constBegin(), constEnd(), createConstIteratorAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canSetMappedAtIterator() const
+
+ Returns \c true if a mapped value can be set via a non-const iterator using
+ \l setMappedAtIterator(), otherwise returns \c false.
+
+ \sa setMappedAtIterator()
+ */
+
+/*!
+ \fn void QMetaAssociation::setMappedAtIterator(const void *iterator, const void *mapped) const
+
+ Writes the \a mapped value to the container location pointed to by the
+ non-const \a iterator, if possible.
+
+ \sa canSetMappedAtIterator(), begin(), end(), createIteratorAtKey()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canCreateIteratorAtKey() const
+
+ Returns \c true if an iterator pointing to an entry in the container can be
+ created using \l createIteratorAtKey(), otherwise returns false.
+
+ \sa createIteratorAtKey()
+ */
+
+/*!
+ \fn void *QMetaAssociation::createIteratorAtKey(void *container, const void *key) const
+
+ Returns a non-const iterator pointing to the entry of \a key in the
+ \a container, if possible. If the entry doesn't exist, creates a non-const
+ iterator pointing to the end of the \a container. If no non-const iterator
+ can be created, returns \c nullptr.
+
+ The non-const iterator has to be destroyed using destroyIterator().
+
+ \sa canCreateIteratorAtKey(), begin(), end(), destroyIterator()
+ */
+
+/*!
+ \fn bool QMetaAssociation::canCreateConstIteratorAtKey() const
+
+ Returns \c true if a const iterator pointing to an entry in the container
+ can be created using \l createConstIteratorAtKey(), otherwise returns false.
+ */
+
+/*!
+ \fn void *QMetaAssociation::createConstIteratorAtKey(const void *container, const void *key) const
+
+ Returns a const iterator pointing to the entry of \a key in the
+ \a container, if possible. If the entry doesn't exist, creates a const
+ iterator pointing to the end of the \a container. If no const iterator can
+ be created, returns \c nullptr.
+
+ The const iterator has to be destroyed using destroyConstIterator().
+
+ \sa canCreateConstIteratorAtKey(), constBegin(), constEnd(), destroyConstIterator()
+ */
+
+/*!
+ \fn bool QMetaAssociation::operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
+
+ Returns \c true if the QMetaAssociation \a lhs represents the same container type
+ as the QMetaAssociation \a rhs, otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QMetaAssociation::operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
+
+ Returns \c true if the QMetaAssociation \a lhs represents a different container
+ type than the QMetaAssociation \a rhs, otherwise returns \c false.
+*/
+
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmetacontainer.cpp b/src/corelib/kernel/qmetacontainer.cpp
index 3a1a33a478a..4b4ea06d8b9 100644
--- a/src/corelib/kernel/qmetacontainer.cpp
+++ b/src/corelib/kernel/qmetacontainer.cpp
@@ -7,37 +7,6 @@
QT_BEGIN_NAMESPACE
/*!
- \class QMetaSequence
- \inmodule QtCore
- \since 6.0
- \brief The QMetaSequence class allows type erased access to sequential containers.
-
- \ingroup objectmodel
-
- \compares equality
-
- The class provides a number of primitive container operations, using void*
- as operands. This way, you can manipulate a generic container retrieved from
- a Variant without knowing its type.
-
- The void* arguments to the various methods are typically created by using
- a \l QVariant of the respective container or value type, and calling
- its \l QVariant::data() or \l QVariant::constData() methods. However, you
- can also pass plain pointers to objects of the container or value type.
-
- Iterator invalidation follows the rules given by the underlying containers
- and is not expressed in the API. Therefore, for a truly generic container,
- any iterators should be considered invalid after any write operation.
-*/
-
-/*!
- \fn template<typename C> QMetaSequence QMetaSequence::fromContainer()
- \since 6.0
-
- Returns the QMetaSequence corresponding to the type given as template parameter.
-*/
-
-/*!
\class QMetaContainer
\inmodule QtCore
\since 6.0
@@ -66,7 +35,7 @@ QT_BEGIN_NAMESPACE
specializations of input iterators. This method will also return
\c true if the container provides one of those.
- QMetaSequence assumes that const and non-const iterators for the same
+ QMetaContainer assumes that const and non-const iterators for the same
container have the same iterator traits.
*/
bool QMetaContainer::hasInputIterator() const
@@ -83,7 +52,7 @@ bool QMetaContainer::hasInputIterator() const
specializations of forward iterators. This method will also return
\c true if the container provides one of those.
- QMetaSequence assumes that const and non-const iterators for the same
+ QMetaContainer assumes that const and non-const iterators for the same
container have the same iterator traits.
*/
bool QMetaContainer::hasForwardIterator() const
@@ -99,7 +68,7 @@ bool QMetaContainer::hasForwardIterator() const
std::bidirectional_iterator_tag and std::random_access_iterator_tag,
respectively. Otherwise returns \c false.
- QMetaSequence assumes that const and non-const iterators for the same
+ QMetaContainer assumes that const and non-const iterators for the same
container have the same iterator traits.
*/
bool QMetaContainer::hasBidirectionalIterator() const
@@ -114,7 +83,7 @@ bool QMetaContainer::hasBidirectionalIterator() const
iterator as defined by std::random_access_iterator_tag, otherwise returns
\c false.
- QMetaSequence assumes that const and non-const iterators for the same
+ QMetaContainer assumes that const and non-const iterators for the same
container have the same iterator traits.
*/
bool QMetaContainer::hasRandomAccessIterator() const
@@ -125,147 +94,6 @@ bool QMetaContainer::hasRandomAccessIterator() const
}
/*!
- Returns the meta type for values stored in the container.
- */
-QMetaType QMetaSequence::valueMetaType() const
-{
- if (auto iface = d())
- return QMetaType(iface->valueMetaType);
- return QMetaType();
-}
-
-/*!
- Returns \c true if the underlying container is sortable, otherwise returns
- \c false. A container is considered sortable if values added to it are
- placed in a defined location. Inserting into or adding to a sortable
- container will always succeed. Inserting into or adding to an unsortable
- container may not succeed, for example if the container is a QSet that
- already contains the value being inserted.
-
- \sa addValue(), insertValueAtIterator(), canAddValueAtBegin(),
- canAddValueAtEnd(), canRemoveValueAtBegin(), canRemoveValueAtEnd()
- */
-bool QMetaSequence::isSortable() const
-{
- if (auto iface = d()) {
- return (iface->addRemoveCapabilities
- & (QtMetaContainerPrivate::CanAddAtBegin | QtMetaContainerPrivate::CanAddAtEnd))
- && (iface->addRemoveCapabilities
- & (QtMetaContainerPrivate::CanRemoveAtBegin
- | QtMetaContainerPrivate::CanRemoveAtEnd));
- }
- return false;
-}
-
-/*!
- Returns \c true if values added using \l addValue() can be placed at the
- beginning of the container, otherwise returns \c false.
-
- \sa addValueAtBegin(), canAddValueAtEnd()
- */
-bool QMetaSequence::canAddValueAtBegin() const
-{
- if (auto iface = d()) {
- return iface->addValueFn
- && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanAddAtBegin;
- }
- return false;
-}
-
-/*!
- Adds \a value to the beginning of \a container if possible. If
- \l canAddValueAtBegin() returns \c false, the \a value is not added.
-
- \sa canAddValueAtBegin(), isSortable(), removeValueAtBegin()
- */
-void QMetaSequence::addValueAtBegin(void *container, const void *value) const
-{
- if (canAddValueAtBegin())
- d()->addValueFn(container, value, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin);
-}
-
-/*!
- Returns \c true if values can be removed from the beginning of the container
- using \l removeValue(), otherwise returns \c false.
-
- \sa removeValueAtBegin(), canRemoveValueAtEnd()
- */
-bool QMetaSequence::canRemoveValueAtBegin() const
-{
- if (auto iface = d()) {
- return iface->removeValueFn
- && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanRemoveAtBegin;
- }
- return false;
-}
-
-/*!
- Removes a value from the beginning of \a container if possible. If
- \l canRemoveValueAtBegin() returns \c false, the value is not removed.
-
- \sa canRemoveValueAtBegin(), isSortable(), addValueAtBegin()
- */
-void QMetaSequence::removeValueAtBegin(void *container) const
-{
- if (canRemoveValueAtBegin())
- d()->removeValueFn(container, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin);
-}
-
-/*!
- Returns \c true if values added using \l addValue() can be placed at the
- end of the container, otherwise returns \c false.
-
- \sa addValueAtEnd(), canAddValueAtBegin()
- */
-bool QMetaSequence::canAddValueAtEnd() const
-{
- if (auto iface = d()) {
- return iface->addValueFn
- && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanAddAtEnd;
- }
- return false;
-}
-
-/*!
- Adds \a value to the end of \a container if possible. If
- \l canAddValueAtEnd() returns \c false, the \a value is not added.
-
- \sa canAddValueAtEnd(), isSortable(), removeValueAtEnd()
- */
-void QMetaSequence::addValueAtEnd(void *container, const void *value) const
-{
- if (canAddValueAtEnd())
- d()->addValueFn(container, value, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd);
-}
-
-/*!
- Returns \c true if values can be removed from the end of the container
- using \l removeValue(), otherwise returns \c false.
-
- \sa removeValueAtEnd(), canRemoveValueAtBegin()
- */
-bool QMetaSequence::canRemoveValueAtEnd() const
-{
- if (auto iface = d()) {
- return iface->removeValueFn
- && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanRemoveAtEnd;
- }
- return false;
-}
-
-/*!
- Removes a value from the end of \a container if possible. If
- \l canRemoveValueAtEnd() returns \c false, the value is not removed.
-
- \sa canRemoveValueAtEnd(), isSortable(), addValueAtEnd()
- */
-void QMetaSequence::removeValueAtEnd(void *container) const
-{
- if (canRemoveValueAtEnd())
- d()->removeValueFn(container, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd);
-}
-
-/*!
Returns \c true if the container can be queried for its size, \c false
otherwise.
@@ -309,122 +137,6 @@ void QMetaContainer::clear(void *container) const
}
/*!
- Returns \c true if values can be retrieved from the container by index,
- otherwise \c false.
-
- \sa valueAtIndex()
- */
-bool QMetaSequence::canGetValueAtIndex() const
-{
- if (auto iface = d())
- return iface->valueAtIndexFn;
- return false;
-}
-
-/*!
- Retrieves the value at \a index in the \a container and places it in the
- memory location pointed to by \a result, if that is possible.
-
- \sa canGetValueAtIndex()
- */
-void QMetaSequence::valueAtIndex(const void *container, qsizetype index, void *result) const
-{
- if (canGetValueAtIndex())
- d()->valueAtIndexFn(container, index, result);
-}
-
-/*!
- Returns \c true if a value can be written to the container by index,
- otherwise \c false.
-
- \sa setValueAtIndex()
-*/
-bool QMetaSequence::canSetValueAtIndex() const
-{
- if (auto iface = d())
- return iface->setValueAtIndexFn;
- return false;
-}
-
-/*!
- Overwrites the value at \a index in the \a container using the \a value
- passed as parameter if that is possible.
-
- \sa canSetValueAtIndex()
- */
-void QMetaSequence::setValueAtIndex(void *container, qsizetype index, const void *value) const
-{
- if (canSetValueAtIndex())
- d()->setValueAtIndexFn(container, index, value);
-}
-
-/*!
- Returns \c true if values can be added to the container, \c false
- otherwise.
-
- \sa addValue(), isSortable()
- */
-bool QMetaSequence::canAddValue() const
-{
- if (auto iface = d())
- return iface->addValueFn;
- return false;
-}
-
-/*!
- Adds \a value to the \a container if possible. If \l canAddValue()
- returns \c false, the \a value is not added. Else, if
- \l canAddValueAtEnd() returns \c true, the \a value is added
- to the end of the \a container. Else, if
- \l canAddValueAtBegin() returns \c true, the \a value is added to
- the beginning of the container. Else, the value is added in an unspecified
- place or not at all. The latter is the case for adding values to an
- unordered container, for example \l QSet.
-
- \sa canAddValue(), canAddValueAtBegin(),
- canAddValueAtEnd(), isSortable(), removeValue()
- */
-void QMetaSequence::addValue(void *container, const void *value) const
-{
- if (canAddValue()) {
- d()->addValueFn(container, value,
- QtMetaContainerPrivate::QMetaSequenceInterface::Unspecified);
- }
-}
-
-/*!
- Returns \c true if values can be removed from the container, \c false
- otherwise.
-
- \sa removeValue(), isSortable()
- */
-bool QMetaSequence::canRemoveValue() const
-{
- if (auto iface = d())
- return iface->removeValueFn;
- return false;
-}
-
-/*!
- Removes a value from the \a container if possible. If
- \l canRemoveValue() returns \c false, no value is removed. Else, if
- \l canRemoveValueAtEnd() returns \c true, the last value in
- the \a container is removed. Else, if \l canRemoveValueAtBegin()
- returns \c true, the first value in the \a container is removed. Else,
- an unspecified value or nothing is removed.
-
- \sa canRemoveValue(), canRemoveValueAtBegin(),
- canRemoveValueAtEnd(), isSortable(), addValue()
- */
-void QMetaSequence::removeValue(void *container) const
-{
- if (canRemoveValue()) {
- d()->removeValueFn(container,
- QtMetaContainerPrivate::QMetaSequenceInterface::Unspecified);
- }
-}
-
-/*!
Returns \c true if the underlying container offers a non-const iterator,
\c false otherwise.
@@ -456,7 +168,7 @@ void *QMetaContainer::begin(void *container) const
{
return hasIterator()
? d_ptr->createIteratorFn(
- container, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin)
+ container, QtMetaContainerPrivate::QMetaContainerInterface::AtBegin)
: nullptr;
}
@@ -473,7 +185,7 @@ void *QMetaContainer::end(void *container) const
{
return hasIterator()
? d_ptr->createIteratorFn(
- container, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd)
+ container, QtMetaContainerPrivate::QMetaContainerInterface::AtEnd)
: nullptr;
}
@@ -541,137 +253,6 @@ qsizetype QMetaContainer::diffIterator(const void *i, const void *j) const
}
/*!
- Returns \c true if the underlying container can retrieve the value pointed
- to by a non-const iterator, \c false otherwise.
-
- \sa hasIterator(), valueAtIterator()
- */
-bool QMetaSequence::canGetValueAtIterator() const
-{
- if (auto iface = d())
- return iface->valueAtIteratorFn;
- return false;
-}
-
-/*!
- Retrieves the value pointed to by the non-const \a iterator and stores it
- in the memory location pointed to by \a result, if possible.
-
- \sa canGetValueAtIterator(), begin(), end()
- */
-void QMetaSequence::valueAtIterator(const void *iterator, void *result) const
-{
- if (canGetValueAtIterator())
- d()->valueAtIteratorFn(iterator, result);
-}
-
-/*!
- Returns \c true if the underlying container can write to the value pointed
- to by a non-const iterator, \c false otherwise.
-
- \sa hasIterator(), setValueAtIterator()
- */
-bool QMetaSequence::canSetValueAtIterator() const
-{
- if (auto iface = d())
- return iface->setValueAtIteratorFn;
- return false;
-}
-
-/*!
- Writes \a value to the value pointed to by the non-const \a iterator, if
- possible.
-
- \sa canSetValueAtIterator(), begin(), end()
- */
-void QMetaSequence::setValueAtIterator(const void *iterator, const void *value) const
-{
- if (canSetValueAtIterator())
- d()->setValueAtIteratorFn(iterator, value);
-}
-
-/*!
- Returns \c true if the underlying container can insert a new value, taking
- the location pointed to by a non-const iterator into account.
-
- \sa hasIterator(), insertValueAtIterator()
- */
-bool QMetaSequence::canInsertValueAtIterator() const
-{
- if (auto iface = d())
- return iface->insertValueAtIteratorFn;
- return false;
-}
-
-/*!
- Inserts \a value into the \a container, if possible, taking the non-const
- \a iterator into account. If \l canInsertValueAtIterator() returns
- \c false, the \a value is not inserted. Else if \l isSortable() returns
- \c true, the value is inserted before the value pointed to by
- \a iterator. Else, the \a value is inserted at an unspecified place or not
- at all. In the latter case, the \a iterator is taken as a hint. If it points
- to the correct place for the \a value, the operation may be faster than a
- \l addValue() without iterator.
-
- \sa canInsertValueAtIterator(), isSortable(), begin(), end()
- */
-void QMetaSequence::insertValueAtIterator(void *container, const void *iterator,
- const void *value) const
-{
- if (canInsertValueAtIterator())
- d()->insertValueAtIteratorFn(container, iterator, value);
-}
-
-/*!
- Returns \c true if the value pointed to by a non-const iterator can be
- erased, \c false otherwise.
-
- \sa hasIterator(), eraseValueAtIterator()
- */
-bool QMetaSequence::canEraseValueAtIterator() const
-{
- if (auto iface = d())
- return iface->eraseValueAtIteratorFn;
- return false;
-}
-
-/*!
- Erases the value pointed to by the non-const \a iterator from the
- \a container, if possible.
-
- \sa canEraseValueAtIterator(), begin(), end()
- */
-void QMetaSequence::eraseValueAtIterator(void *container, const void *iterator) const
-{
- if (canEraseValueAtIterator())
- d()->eraseValueAtIteratorFn(container, iterator);
-}
-
-/*!
- Returns \c true if a range between two iterators can be erased from the
- container, \c false otherwise.
- */
-bool QMetaSequence::canEraseRangeAtIterator() const
-{
- if (auto iface = d())
- return iface->eraseRangeAtIteratorFn;
- return false;
-}
-
-/*!
- Erases the range of values between the iterators \a iterator1 and
- \a iterator2 from the \a container, if possible.
-
- \sa canEraseValueAtIterator(), begin(), end()
- */
-void QMetaSequence::eraseRangeAtIterator(void *container, const void *iterator1,
- const void *iterator2) const
-{
- if (canEraseRangeAtIterator())
- d()->eraseRangeAtIteratorFn(container, iterator1, iterator2);
-}
-
-/*!
Returns \c true if the underlying container offers a const iterator,
\c false otherwise.
@@ -704,7 +285,7 @@ void *QMetaContainer::constBegin(const void *container) const
{
return hasConstIterator()
? d_ptr->createConstIteratorFn(
- container, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin)
+ container, QtMetaContainerPrivate::QMetaContainerInterface::AtBegin)
: nullptr;
}
@@ -721,7 +302,7 @@ void *QMetaContainer::constEnd(const void *container) const
{
return hasConstIterator()
? d_ptr->createConstIteratorFn(
- container, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd)
+ container, QtMetaContainerPrivate::QMetaContainerInterface::AtEnd)
: nullptr;
}
@@ -788,68 +369,4 @@ qsizetype QMetaContainer::diffConstIterator(const void *i, const void *j) const
return hasConstIterator() ? d_ptr->diffConstIteratorFn(i, j) : 0;
}
-/*!
- Returns \c true if the underlying container can retrieve the value pointed
- to by a const iterator, \c false otherwise.
-
- \sa hasConstIterator(), valueAtConstIterator()
- */
-bool QMetaSequence::canGetValueAtConstIterator() const
-{
- if (auto iface = d())
- return iface->valueAtConstIteratorFn;
- return false;
-}
-
-/*!
- Retrieves the value pointed to by the const \a iterator and stores it
- in the memory location pointed to by \a result, if possible.
-
- \sa canGetValueAtConstIterator(), constBegin(), constEnd()
- */
-void QMetaSequence::valueAtConstIterator(const void *iterator, void *result) const
-{
- if (canGetValueAtConstIterator())
- d()->valueAtConstIteratorFn(iterator, result);
-}
-
-/*!
- \fn bool QMetaSequence::operator==(const QMetaSequence &lhs, const QMetaSequence &rhs)
- \since 6.0
-
- Returns \c true if the QMetaSequence \a lhs represents the same container type
- as the QMetaSequence \a rhs, otherwise returns \c false.
-*/
-
-/*!
- \fn bool QMetaSequence::operator!=(const QMetaSequence &lhs, const QMetaSequence &rhs)
- \since 6.0
-
- Returns \c true if the QMetaSequence \a lhs represents a different container
- type than the QMetaSequence \a rhs, otherwise returns \c false.
-*/
-
-
-/*!
- \internal
- Returns the meta type for keys in the container.
- */
-QMetaType QMetaAssociation::keyMetaType() const
-{
- if (auto iface = d())
- return QMetaType(iface->keyMetaType);
- return QMetaType();
-}
-
-/*!
- \internal
- Returns the meta type for mapped values in the container.
- */
-QMetaType QMetaAssociation::mappedMetaType() const
-{
- if (auto iface = d())
- return QMetaType(iface->mappedMetaType);
- return QMetaType();
-}
-
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmetasequence.cpp b/src/corelib/kernel/qmetasequence.cpp
new file mode 100644
index 00000000000..1d3f3dfd080
--- /dev/null
+++ b/src/corelib/kernel/qmetasequence.cpp
@@ -0,0 +1,471 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qmetacontainer.h"
+#include "qmetatype.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QMetaSequence
+ \inmodule QtCore
+ \since 6.0
+ \brief The QMetaSequence class allows type erased access to sequential containers.
+
+ \ingroup objectmodel
+
+ \compares equality
+
+ The class provides a number of primitive container operations, using void*
+ as operands. This way, you can manipulate a generic container retrieved from
+ a Variant without knowing its type.
+
+ The void* arguments to the various methods are typically created by using
+ a \l QVariant of the respective container or value type, and calling
+ its \l QVariant::data() or \l QVariant::constData() methods. However, you
+ can also pass plain pointers to objects of the container or value type.
+
+ Iterator invalidation follows the rules given by the underlying containers
+ and is not expressed in the API. Therefore, for a truly generic container,
+ any iterators should be considered invalid after any write operation.
+*/
+
+/*!
+ \fn template<typename C> QMetaSequence QMetaSequence::fromContainer()
+ \since 6.0
+
+ Returns the QMetaSequence corresponding to the type given as template parameter.
+*/
+
+/*!
+ Returns the meta type for values stored in the container.
+ */
+QMetaType QMetaSequence::valueMetaType() const
+{
+ if (auto iface = d())
+ return QMetaType(iface->valueMetaType);
+ return QMetaType();
+}
+
+/*!
+ Returns \c true if the underlying container is sortable, otherwise returns
+ \c false. A container is considered sortable if values added to it are
+ placed in a defined location. Inserting into or adding to a sortable
+ container will always succeed. Inserting into or adding to an unsortable
+ container may not succeed, for example if the container is a QSet that
+ already contains the value being inserted.
+
+ \sa addValue(), insertValueAtIterator(), canAddValueAtBegin(),
+ canAddValueAtEnd(), canRemoveValueAtBegin(), canRemoveValueAtEnd()
+ */
+bool QMetaSequence::isSortable() const
+{
+ if (auto iface = d()) {
+ return (iface->addRemoveCapabilities
+ & (QtMetaContainerPrivate::CanAddAtBegin | QtMetaContainerPrivate::CanAddAtEnd))
+ && (iface->addRemoveCapabilities
+ & (QtMetaContainerPrivate::CanRemoveAtBegin
+ | QtMetaContainerPrivate::CanRemoveAtEnd));
+ }
+ return false;
+}
+
+/*!
+ Returns \c true if values added using \l addValue() can be placed at the
+ beginning of the container, otherwise returns \c false.
+
+ \sa addValueAtBegin(), canAddValueAtEnd()
+ */
+bool QMetaSequence::canAddValueAtBegin() const
+{
+ if (auto iface = d()) {
+ return iface->addValueFn
+ && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanAddAtBegin;
+ }
+ return false;
+}
+
+/*!
+ Adds \a value to the beginning of \a container if possible. If
+ \l canAddValueAtBegin() returns \c false, the \a value is not added.
+
+ \sa canAddValueAtBegin(), isSortable(), removeValueAtBegin()
+ */
+void QMetaSequence::addValueAtBegin(void *container, const void *value) const
+{
+ if (canAddValueAtBegin())
+ d()->addValueFn(container, value, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin);
+}
+
+/*!
+ Returns \c true if values can be removed from the beginning of the container
+ using \l removeValue(), otherwise returns \c false.
+
+ \sa removeValueAtBegin(), canRemoveValueAtEnd()
+ */
+bool QMetaSequence::canRemoveValueAtBegin() const
+{
+ if (auto iface = d()) {
+ return iface->removeValueFn
+ && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanRemoveAtBegin;
+ }
+ return false;
+}
+
+/*!
+ Removes a value from the beginning of \a container if possible. If
+ \l canRemoveValueAtBegin() returns \c false, the value is not removed.
+
+ \sa canRemoveValueAtBegin(), isSortable(), addValueAtBegin()
+ */
+void QMetaSequence::removeValueAtBegin(void *container) const
+{
+ if (canRemoveValueAtBegin())
+ d()->removeValueFn(container, QtMetaContainerPrivate::QMetaSequenceInterface::AtBegin);
+}
+
+/*!
+ Returns \c true if values added using \l addValue() can be placed at the
+ end of the container, otherwise returns \c false.
+
+ \sa addValueAtEnd(), canAddValueAtBegin()
+ */
+bool QMetaSequence::canAddValueAtEnd() const
+{
+ if (auto iface = d()) {
+ return iface->addValueFn
+ && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanAddAtEnd;
+ }
+ return false;
+}
+
+/*!
+ Adds \a value to the end of \a container if possible. If
+ \l canAddValueAtEnd() returns \c false, the \a value is not added.
+
+ \sa canAddValueAtEnd(), isSortable(), removeValueAtEnd()
+ */
+void QMetaSequence::addValueAtEnd(void *container, const void *value) const
+{
+ if (canAddValueAtEnd())
+ d()->addValueFn(container, value, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd);
+}
+
+/*!
+ Returns \c true if values can be removed from the end of the container
+ using \l removeValue(), otherwise returns \c false.
+
+ \sa removeValueAtEnd(), canRemoveValueAtBegin()
+ */
+bool QMetaSequence::canRemoveValueAtEnd() const
+{
+ if (auto iface = d()) {
+ return iface->removeValueFn
+ && iface->addRemoveCapabilities & QtMetaContainerPrivate::CanRemoveAtEnd;
+ }
+ return false;
+}
+
+/*!
+ Removes a value from the end of \a container if possible. If
+ \l canRemoveValueAtEnd() returns \c false, the value is not removed.
+
+ \sa canRemoveValueAtEnd(), isSortable(), addValueAtEnd()
+ */
+void QMetaSequence::removeValueAtEnd(void *container) const
+{
+ if (canRemoveValueAtEnd())
+ d()->removeValueFn(container, QtMetaContainerPrivate::QMetaSequenceInterface::AtEnd);
+}
+
+/*!
+ Returns \c true if values can be retrieved from the container by index,
+ otherwise \c false.
+
+ \sa valueAtIndex()
+ */
+bool QMetaSequence::canGetValueAtIndex() const
+{
+ if (auto iface = d())
+ return iface->valueAtIndexFn;
+ return false;
+}
+
+/*!
+ Retrieves the value at \a index in the \a container and places it in the
+ memory location pointed to by \a result, if that is possible.
+
+ \sa canGetValueAtIndex()
+ */
+void QMetaSequence::valueAtIndex(const void *container, qsizetype index, void *result) const
+{
+ if (canGetValueAtIndex())
+ d()->valueAtIndexFn(container, index, result);
+}
+
+/*!
+ Returns \c true if a value can be written to the container by index,
+ otherwise \c false.
+
+ \sa setValueAtIndex()
+*/
+bool QMetaSequence::canSetValueAtIndex() const
+{
+ if (auto iface = d())
+ return iface->setValueAtIndexFn;
+ return false;
+}
+
+/*!
+ Overwrites the value at \a index in the \a container using the \a value
+ passed as parameter if that is possible.
+
+ \sa canSetValueAtIndex()
+ */
+void QMetaSequence::setValueAtIndex(void *container, qsizetype index, const void *value) const
+{
+ if (canSetValueAtIndex())
+ d()->setValueAtIndexFn(container, index, value);
+}
+
+/*!
+ Returns \c true if values can be added to the container, \c false
+ otherwise.
+
+ \sa addValue(), isSortable()
+ */
+bool QMetaSequence::canAddValue() const
+{
+ if (auto iface = d())
+ return iface->addValueFn;
+ return false;
+}
+
+/*!
+ Adds \a value to the \a container if possible. If \l canAddValue()
+ returns \c false, the \a value is not added. Else, if
+ \l canAddValueAtEnd() returns \c true, the \a value is added
+ to the end of the \a container. Else, if
+ \l canAddValueAtBegin() returns \c true, the \a value is added to
+ the beginning of the container. Else, the value is added in an unspecified
+ place or not at all. The latter is the case for adding values to an
+ unordered container, for example \l QSet.
+
+ \sa canAddValue(), canAddValueAtBegin(),
+ canAddValueAtEnd(), isSortable(), removeValue()
+ */
+void QMetaSequence::addValue(void *container, const void *value) const
+{
+ if (canAddValue()) {
+ d()->addValueFn(container, value,
+ QtMetaContainerPrivate::QMetaSequenceInterface::Unspecified);
+ }
+}
+
+/*!
+ Returns \c true if values can be removed from the container, \c false
+ otherwise.
+
+ \sa removeValue(), isSortable()
+ */
+bool QMetaSequence::canRemoveValue() const
+{
+ if (auto iface = d())
+ return iface->removeValueFn;
+ return false;
+}
+
+/*!
+ Removes a value from the \a container if possible. If
+ \l canRemoveValue() returns \c false, no value is removed. Else, if
+ \l canRemoveValueAtEnd() returns \c true, the last value in
+ the \a container is removed. Else, if \l canRemoveValueAtBegin()
+ returns \c true, the first value in the \a container is removed. Else,
+ an unspecified value or nothing is removed.
+
+ \sa canRemoveValue(), canRemoveValueAtBegin(),
+ canRemoveValueAtEnd(), isSortable(), addValue()
+ */
+void QMetaSequence::removeValue(void *container) const
+{
+ if (canRemoveValue()) {
+ d()->removeValueFn(container,
+ QtMetaContainerPrivate::QMetaSequenceInterface::Unspecified);
+ }
+}
+
+
+/*!
+ Returns \c true if the underlying container can retrieve the value pointed
+ to by a non-const iterator, \c false otherwise.
+
+ \sa hasIterator(), valueAtIterator()
+ */
+bool QMetaSequence::canGetValueAtIterator() const
+{
+ if (auto iface = d())
+ return iface->valueAtIteratorFn;
+ return false;
+}
+
+/*!
+ Retrieves the value pointed to by the non-const \a iterator and stores it
+ in the memory location pointed to by \a result, if possible.
+
+ \sa canGetValueAtIterator(), begin(), end()
+ */
+void QMetaSequence::valueAtIterator(const void *iterator, void *result) const
+{
+ if (canGetValueAtIterator())
+ d()->valueAtIteratorFn(iterator, result);
+}
+
+/*!
+ Returns \c true if the underlying container can write to the value pointed
+ to by a non-const iterator, \c false otherwise.
+
+ \sa hasIterator(), setValueAtIterator()
+ */
+bool QMetaSequence::canSetValueAtIterator() const
+{
+ if (auto iface = d())
+ return iface->setValueAtIteratorFn;
+ return false;
+}
+
+/*!
+ Writes \a value to the value pointed to by the non-const \a iterator, if
+ possible.
+
+ \sa canSetValueAtIterator(), begin(), end()
+ */
+void QMetaSequence::setValueAtIterator(const void *iterator, const void *value) const
+{
+ if (canSetValueAtIterator())
+ d()->setValueAtIteratorFn(iterator, value);
+}
+
+/*!
+ Returns \c true if the underlying container can insert a new value, taking
+ the location pointed to by a non-const iterator into account.
+
+ \sa hasIterator(), insertValueAtIterator()
+ */
+bool QMetaSequence::canInsertValueAtIterator() const
+{
+ if (auto iface = d())
+ return iface->insertValueAtIteratorFn;
+ return false;
+}
+
+/*!
+ Inserts \a value into the \a container, if possible, taking the non-const
+ \a iterator into account. If \l canInsertValueAtIterator() returns
+ \c false, the \a value is not inserted. Else if \l isSortable() returns
+ \c true, the value is inserted before the value pointed to by
+ \a iterator. Else, the \a value is inserted at an unspecified place or not
+ at all. In the latter case, the \a iterator is taken as a hint. If it points
+ to the correct place for the \a value, the operation may be faster than a
+ \l addValue() without iterator.
+
+ \sa canInsertValueAtIterator(), isSortable(), begin(), end()
+ */
+void QMetaSequence::insertValueAtIterator(void *container, const void *iterator,
+ const void *value) const
+{
+ if (canInsertValueAtIterator())
+ d()->insertValueAtIteratorFn(container, iterator, value);
+}
+
+/*!
+ Returns \c true if the value pointed to by a non-const iterator can be
+ erased, \c false otherwise.
+
+ \sa hasIterator(), eraseValueAtIterator()
+ */
+bool QMetaSequence::canEraseValueAtIterator() const
+{
+ if (auto iface = d())
+ return iface->eraseValueAtIteratorFn;
+ return false;
+}
+
+/*!
+ Erases the value pointed to by the non-const \a iterator from the
+ \a container, if possible.
+
+ \sa canEraseValueAtIterator(), begin(), end()
+ */
+void QMetaSequence::eraseValueAtIterator(void *container, const void *iterator) const
+{
+ if (canEraseValueAtIterator())
+ d()->eraseValueAtIteratorFn(container, iterator);
+}
+
+/*!
+ Returns \c true if a range between two iterators can be erased from the
+ container, \c false otherwise.
+ */
+bool QMetaSequence::canEraseRangeAtIterator() const
+{
+ if (auto iface = d())
+ return iface->eraseRangeAtIteratorFn;
+ return false;
+}
+
+/*!
+ Erases the range of values between the iterators \a iterator1 and
+ \a iterator2 from the \a container, if possible.
+
+ \sa canEraseValueAtIterator(), begin(), end()
+ */
+void QMetaSequence::eraseRangeAtIterator(void *container, const void *iterator1,
+ const void *iterator2) const
+{
+ if (canEraseRangeAtIterator())
+ d()->eraseRangeAtIteratorFn(container, iterator1, iterator2);
+}
+
+
+/*!
+ Returns \c true if the underlying container can retrieve the value pointed
+ to by a const iterator, \c false otherwise.
+
+ \sa hasConstIterator(), valueAtConstIterator()
+ */
+bool QMetaSequence::canGetValueAtConstIterator() const
+{
+ if (auto iface = d())
+ return iface->valueAtConstIteratorFn;
+ return false;
+}
+
+/*!
+ Retrieves the value pointed to by the const \a iterator and stores it
+ in the memory location pointed to by \a result, if possible.
+
+ \sa canGetValueAtConstIterator(), constBegin(), constEnd()
+ */
+void QMetaSequence::valueAtConstIterator(const void *iterator, void *result) const
+{
+ if (canGetValueAtConstIterator())
+ d()->valueAtConstIteratorFn(iterator, result);
+}
+
+/*!
+ \fn bool QMetaSequence::operator==(const QMetaSequence &lhs, const QMetaSequence &rhs)
+ \since 6.0
+
+ Returns \c true if the QMetaSequence \a lhs represents the same container type
+ as the QMetaSequence \a rhs, otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QMetaSequence::operator!=(const QMetaSequence &lhs, const QMetaSequence &rhs)
+ \since 6.0
+
+ Returns \c true if the QMetaSequence \a lhs represents a different container
+ type than the QMetaSequence \a rhs, otherwise returns \c false.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index fe510898429..560a8c7d789 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1894,8 +1894,8 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
A timer event will occur every \a interval until killTimer()
is called. If \a interval is equal to \c{std::chrono::duration::zero()},
- then the timer event occurs once every time there are no more window
- system events to process.
+ then the timer event occurs once every time control returns to the event
+ loop, that is, there are no more native window system events to process.
\include timers-common.qdocinc negative-intervals-not-allowed
diff --git a/src/corelib/kernel/qwinregistry.cpp b/src/corelib/kernel/qwinregistry.cpp
index 9740edbf299..37bf3f99ae1 100644
--- a/src/corelib/kernel/qwinregistry.cpp
+++ b/src/corelib/kernel/qwinregistry.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#define UMDF_USING_NTSTATUS // Avoid ntstatus redefinitions
@@ -190,7 +191,9 @@ QVariant QWinRegistryKey::value(const QString &subKey) const
// Otherwise, the resulting string (which may be empty) is returned.
QString QWinRegistryKey::stringValue(const wchar_t *subKey) const
{
- return value<QString>(subKey).value_or(QString());
+ if (auto v = value<QString>(subKey))
+ return std::move(*v);
+ return QString();
}
QString QWinRegistryKey::stringValue(const QString &subKey) const
diff --git a/src/corelib/kernel/qwinregistry_p.h b/src/corelib/kernel/qwinregistry_p.h
index 5643a35363b..fd6d6dc853f 100644
--- a/src/corelib/kernel/qwinregistry_p.h
+++ b/src/corelib/kernel/qwinregistry_p.h
@@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:trivial-impl-only
#ifndef QWINREGISTRY_H
#define QWINREGISTRY_H
@@ -41,12 +42,17 @@ public:
~QWinRegistryKey();
QWinRegistryKey(QWinRegistryKey &&other) noexcept
+#if 1 // QTBUG-140725
+ = delete;
+ void operator=(QWinRegistryKey &&) = delete;
+#else
: m_key(std::exchange(other.m_key, nullptr)) {}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
void swap(QWinRegistryKey &other) noexcept
{
qt_ptr_swap(m_key, other.m_key);
}
+#endif
[[nodiscard]] bool isValid() const { return m_key != nullptr; }
diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp
index 9a566b999b4..de6edcb75e6 100644
--- a/src/corelib/serialization/qcborarray.cpp
+++ b/src/corelib/serialization/qcborarray.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2018 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcborarray.h"
#include "qcborvalue_p.h"
diff --git a/src/corelib/serialization/qcborcommon_p.h b/src/corelib/serialization/qcborcommon_p.h
index b80451be4bc..66c95ee887f 100644
--- a/src/corelib/serialization/qcborcommon_p.h
+++ b/src/corelib/serialization/qcborcommon_p.h
@@ -1,6 +1,7 @@
// Copyright (C) 2018 Intel Corporation.
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#ifndef QCBORCOMMON_P_H
#define QCBORCOMMON_P_H
diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp
index 32d6d563ac4..9c17e07b70b 100644
--- a/src/corelib/serialization/qcbormap.cpp
+++ b/src/corelib/serialization/qcbormap.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2018 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcbormap.h"
#include "qcborvalue_p.h"
diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h
index 7850d266639..e51296f3cca 100644
--- a/src/corelib/serialization/qcborstream.h
+++ b/src/corelib/serialization/qcborstream.h
@@ -1,6 +1,7 @@
// Copyright (C) 2019 The Qt Company Ltd.
// Copyright (C) 2018 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:header-decls-only
#ifndef QCBORSTREAM_H
#define QCBORSTREAM_H
diff --git a/src/corelib/serialization/qjsonparser_p.h b/src/corelib/serialization/qjsonparser_p.h
index 6b70af38152..8951bb3129b 100644
--- a/src/corelib/serialization/qjsonparser_p.h
+++ b/src/corelib/serialization/qjsonparser_p.h
@@ -1,5 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:header-decls-only
#ifndef QJSONPARSER_P_H
#define QJSONPARSER_P_H
diff --git a/src/corelib/serialization/qjsonwriter_p.h b/src/corelib/serialization/qjsonwriter_p.h
index 446ed906e21..10b89f3c106 100644
--- a/src/corelib/serialization/qjsonwriter_p.h
+++ b/src/corelib/serialization/qjsonwriter_p.h
@@ -1,5 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:header-decls-only
#ifndef QJSONWRITER_P_H
#define QJSONWRITER_P_H
diff --git a/src/corelib/text/qcollator.cpp b/src/corelib/text/qcollator.cpp
index 9ead847843b..6609d17adf4 100644
--- a/src/corelib/text/qcollator.cpp
+++ b/src/corelib/text/qcollator.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2013 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcollator_p.h"
#include "qstringlist.h"
diff --git a/src/corelib/text/qcollator.h b/src/corelib/text/qcollator.h
index 870811fc48e..2b1e3963b0d 100644
--- a/src/corelib/text/qcollator.h
+++ b/src/corelib/text/qcollator.h
@@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// Copyright (C) 2013 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:trivial-impl-only
#ifndef QCOLLATOR_H
#define QCOLLATOR_H
diff --git a/src/corelib/text/qcollator_icu.cpp b/src/corelib/text/qcollator_icu.cpp
index 84f9c515374..e13e96285ef 100644
--- a/src/corelib/text/qcollator_icu.cpp
+++ b/src/corelib/text/qcollator_icu.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// Copyright (C) 2013 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcollator_p.h"
#include "qlocale_p.h"
diff --git a/src/corelib/text/qcollator_macx.cpp b/src/corelib/text/qcollator_macx.cpp
index 23c23bd53a2..c0561877dd1 100644
--- a/src/corelib/text/qcollator_macx.cpp
+++ b/src/corelib/text/qcollator_macx.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2020 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcollator_p.h"
#include "qlocale_p.h"
diff --git a/src/corelib/text/qcollator_p.h b/src/corelib/text/qcollator_p.h
index b96cdbaa32a..400cafc0c8a 100644
--- a/src/corelib/text/qcollator_p.h
+++ b/src/corelib/text/qcollator_p.h
@@ -1,6 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2013 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:trivial-impl-only
#ifndef QCOLLATOR_P_H
#define QCOLLATOR_P_H
diff --git a/src/corelib/text/qcollator_posix.cpp b/src/corelib/text/qcollator_posix.cpp
index 5ed80c1b8ea..2712133521c 100644
--- a/src/corelib/text/qcollator_posix.cpp
+++ b/src/corelib/text/qcollator_posix.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2013 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcollator_p.h"
#include "qstringlist.h"
diff --git a/src/corelib/text/qcollator_win.cpp b/src/corelib/text/qcollator_win.cpp
index b588f5ff46a..54228b79b31 100644
--- a/src/corelib/text/qcollator_win.cpp
+++ b/src/corelib/text/qcollator_win.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2020 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:critical reason:data-parser
#include "qcollator_p.h"
#include "qlocale_p.h"
diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc
index 3980e9d9a6d..bc88b27477d 100644
--- a/src/corelib/text/qlocale.qdoc
+++ b/src/corelib/text/qlocale.qdoc
@@ -1,5 +1,6 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+// Qt-Security score:insignificant reason:docs
/*!
\class QLocale
diff --git a/src/corelib/text/qtliterals.qdoc b/src/corelib/text/qtliterals.qdoc
index c4671415ee4..06ce31848f7 100644
--- a/src/corelib/text/qtliterals.qdoc
+++ b/src/corelib/text/qtliterals.qdoc
@@ -1,5 +1,6 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+// Qt-Security score:insignificant reason:docs
/*!
\namespace QtLiterals
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index ccd944a0824..3e08df2b5ac 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -1291,6 +1291,9 @@ bool QThread::event(QEvent *event)
This function does not stop any event loop running on the thread and
does not terminate it in any way.
+ This function has no effect on the main thread, and does nothing if the thread
+ is not currently running.
+
\sa isInterruptionRequested()
*/
diff --git a/src/gui/accessible/linux/qspiaccessiblebridge.cpp b/src/gui/accessible/linux/qspiaccessiblebridge.cpp
index 1ee1a435ca5..11b3bc57471 100644
--- a/src/gui/accessible/linux/qspiaccessiblebridge.cpp
+++ b/src/gui/accessible/linux/qspiaccessiblebridge.cpp
@@ -184,6 +184,12 @@ static RoleMapping map[] = {
//: Role of an accessible object
{ QAccessible::CheckBox, ATSPI_ROLE_CHECK_BOX, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "check box") },
//: Role of an accessible object
+#if ATSPI_ROLE_COUNT >= 132
+ { QAccessible::Switch, ATSPI_ROLE_SWITCH, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "switch") },
+#else
+ { QAccessible::Switch, ATSPI_ROLE_CHECK_BOX, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "check box") },
+#endif
+ //: Role of an accessible object
{ QAccessible::RadioButton, ATSPI_ROLE_RADIO_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "radio button") },
//: Role of an accessible object
{ QAccessible::ComboBox, ATSPI_ROLE_COMBO_BOX, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "combo box") },
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 97f7eb94e2a..eeb06c535b8 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -342,6 +342,7 @@ Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core");
\value Splitter A splitter distributing available space between its child widgets.
\value StaticText Static text, such as labels for other widgets.
\value StatusBar A status bar.
+ \value [since 6.11] Switch A switch that can be toggled on or off.
\value Table A table representing data in a grid of rows and columns.
\value Terminal A terminal or command line interface.
\value TitleBar The title bar caption of a window.
diff --git a/src/gui/accessible/qaccessible_base.h b/src/gui/accessible/qaccessible_base.h
index 0a1a305b76d..31b97880ffc 100644
--- a/src/gui/accessible/qaccessible_base.h
+++ b/src/gui/accessible/qaccessible_base.h
@@ -267,6 +267,7 @@ public:
WebDocument = 0x00000084,
Section = 0x00000085,
Notification = 0x00000086,
+ Switch = 0x00000087,
// IAccessible2 roles
// IA2_ROLE_CANVAS = 0x401, // An object that can be drawn into and to manage events from the objects drawn into it
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index 5c723cdb289..9edb0dff4fd 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -119,14 +119,14 @@ QWindow *QAccessibleApplication::window() const
return nullptr;
}
-// all toplevel windows except popups and the desktop
+// all toplevel windows except popups
static QObjectList topLevelObjects()
{
QObjectList list;
const QWindowList tlw(QGuiApplication::topLevelWindows());
for (int i = 0; i < tlw.size(); ++i) {
QWindow *w = tlw.at(i);
- if (w->type() != Qt::Popup && w->type()) {
+ if (w->type() != Qt::Popup) {
if (QAccessibleInterface *root = w->accessibleRoot()) {
if (root->object())
list.append(root->object());
diff --git a/src/gui/doc/images/plaintext-layout.png b/src/gui/doc/images/plaintext-layout.png
deleted file mode 100644
index 9172d7a044d..00000000000
--- a/src/gui/doc/images/plaintext-layout.png
+++ /dev/null
Binary files differ
diff --git a/src/gui/doc/images/plaintext-layout.webp b/src/gui/doc/images/plaintext-layout.webp
new file mode 100644
index 00000000000..b8266ec5a8c
--- /dev/null
+++ b/src/gui/doc/images/plaintext-layout.webp
Binary files differ
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index dca2f10bf26..a89872e70f6 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -27,7 +27,7 @@
private Qt GUI APIs:
\badcode
- find_package(Qt6 REQUIRED COMPONENTS Gui)
+ find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
\endcode
*/
diff --git a/src/gui/doc/src/richtext.qdoc b/src/gui/doc/src/richtext.qdoc
index 429233ec8f1..2fa49a31e03 100644
--- a/src/gui/doc/src/richtext.qdoc
+++ b/src/gui/doc/src/richtext.qdoc
@@ -650,7 +650,7 @@
the QTextLayout class, to help developers perform word-wrapping and
layout tasks without the need to create a document first.
- \image plaintext-layout.png {Screenshot of a text that flows around a
+ \image plaintext-layout.webp {Screenshot of a text that flows around a
circle.}
Formatting and drawing a paragraph of plain text is straightforward.
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 8e21c92f9b3..8f29fb503b0 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -352,8 +352,8 @@ QIconTheme::QIconTheme(const QString &themeName)
QFile themeIndex;
const QStringList iconDirs = QIcon::themeSearchPaths();
- for ( int i = 0 ; i < iconDirs.size() ; ++i) {
- QDir iconDir(iconDirs[i]);
+ for (const auto &dirName : iconDirs) {
+ QDir iconDir(dirName);
QString themeDir = iconDir.path() + u'/' + themeName;
QFileInfo themeDirInfo(themeDir);
@@ -479,7 +479,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
const QString pngIconName = iconNameFallback + ".png"_L1;
// Add all relevant files
- for (int i = 0; i < contentDirs.size(); ++i) {
+ for (qsizetype i = 0; i < contentDirs.size(); ++i) {
QList<QIconDirInfo> subDirs = theme.keyList();
// Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save
@@ -504,8 +504,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
}
QString contentDir = contentDirs.at(i) + u'/';
- for (int j = 0; j < subDirs.size() ; ++j) {
- const QIconDirInfo &dirInfo = subDirs.at(j);
+ for (const auto &dirInfo : std::as_const(subDirs)) {
if (searchingGenericFallback &&
(dirInfo.context == QIconDirInfo::Applications ||
dirInfo.context == QIconDirInfo::MimeTypes))
@@ -544,9 +543,9 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
<< "skipping visited" << visited;
// Search recursively through inherited themes
- for (int i = 0 ; i < parents.size() ; ++i) {
+ for (const auto &parent : parents) {
- const QString parentTheme = parents.at(i).trimmed();
+ const QString parentTheme = parent.trimmed();
if (!visited.contains(parentTheme)) // guard against recursion
info = findIconHelper(parentTheme, iconName, visited, QIconLoader::NoFallBack);
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index c7b6e4ebff3..bb71f8fb6fc 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1298,7 +1298,10 @@ QString QKeySequencePrivate::keyName(Qt::Key key, QKeySequence::SequenceFormat f
bool nativeText = (format == QKeySequence::NativeText);
QString p;
- if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
+ if (nativeText && (key > 0x00 && key <= 0x1f)) {
+ // Map C0 control codes to the corresponding Control Pictures
+ p = QChar::fromUcs2(0x2400 + key);
+ } else if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
if (!QChar::requiresSurrogates(key)) {
p = QChar::fromUcs2(key).toUpper();
} else {
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index c446ac760c0..24c0fd7c431 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_p.h
@@ -125,6 +125,14 @@ struct Q_GUI_EXPORT QWaylandWindow : public QObject
public:
QT_DECLARE_NATIVE_INTERFACE(QWaylandWindow, 1, QWindow)
+ enum WindowType {
+ Default,
+ ToolTip,
+ ComboBox,
+ Menu,
+ SubMenu,
+ };
+
virtual wl_surface *surface() const = 0;
virtual void setCustomMargins(const QMargins &margins) = 0;
virtual void requestXdgActivationToken(uint serial) = 0;
@@ -136,6 +144,10 @@ public:
return role ? *role : nullptr;
}
virtual void setSessionRestoreId(const QString &role) = 0;
+
+ virtual void setExtendedWindowType(WindowType windowType) = 0;
+ virtual void setParentControlGeometry(const QRect &parentAnchor) = 0;
+
Q_SIGNALS:
void surfaceCreated();
void surfaceDestroyed();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 3b64a8ecf73..a3f9f069b69 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1527,14 +1527,14 @@ void QPainterPrivate::initFrom(const QPaintDevice *device)
Q_Q(QPainter);
device->initPainter(q);
+}
- if (extended) {
- extended->penChanged();
- } else if (engine) {
- engine->setDirty(QPaintEngine::DirtyPen);
- engine->setDirty(QPaintEngine::DirtyBrush);
- engine->setDirty(QPaintEngine::DirtyFont);
- }
+void QPainterPrivate::setEngineDirtyFlags(QSpan<const QPaintEngine::DirtyFlags> flags)
+{
+ if (!engine)
+ return;
+ for (const QPaintEngine::DirtyFlags f : flags)
+ engine->setDirty(f);
}
/*!
@@ -1801,14 +1801,16 @@ bool QPainter::begin(QPaintDevice *pd)
d->engine->setActive(begun);
}
- // Copy painter properties from original paint device,
- // required for QPixmap::grabWidget()
- if (d->original_device->devType() == QInternal::Widget) {
+ switch (d->original_device->devType()) {
+ case QInternal::Widget:
d->initFrom(d->original_device);
- } else {
+ break;
+
+ default:
d->state->layoutDirection = Qt::LayoutDirectionAuto;
// make sure we have a font compatible with the paintdevice
d->state->deviceFont = d->state->font = QFont(d->state->deviceFont, device());
+ break;
}
QRect systemRect = d->engine->systemRect();
@@ -1834,6 +1836,15 @@ bool QPainter::begin(QPaintDevice *pd)
d->state->emulationSpecifier = 0;
+ switch (d->original_device->devType()) {
+ case QInternal::Widget:
+ // for widgets we've aleady initialized the painter above
+ break;
+ default:
+ d->initFrom(d->original_device);
+ break;
+ }
+
return true;
}
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index dd4653a5788..a6f93134ca0 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -15,6 +15,7 @@
// We mean it.
//
+#include <QtCore/qspan.h>
#include <QtCore/qvarlengtharray.h>
#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qbrush.h"
@@ -242,6 +243,8 @@ public:
std::unique_ptr<QEmulationPaintEngine> emulationEngine;
QPaintEngineEx *extended = nullptr;
QBrush colorBrush; // for fill with solid color
+
+ Q_GUI_EXPORT void setEngineDirtyFlags(QSpan<const QPaintEngine::DirtyFlags>);
};
Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation);
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index 1b6e76c2017..5797d1a68b4 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -16,6 +16,7 @@
#include <qbytearray.h>
#include <qdatastream.h>
#include <qdatetime.h>
+#include <QtCore/private/qstringiterator_p.h>
QT_BEGIN_NAMESPACE
@@ -582,8 +583,11 @@ bool QTextHtmlImporter::appendNodeText()
QString textToInsert;
textToInsert.reserve(text.size());
- for (QChar ch : text) {
- if (ch.isSpace()
+ QStringIterator it(text);
+ while (it.hasNext()) {
+ char32_t ch = it.next();
+
+ if (QChar::isSpace(ch)
&& ch != QChar::Nbsp
&& ch != QChar::ParagraphSeparator) {
@@ -646,12 +650,12 @@ bool QTextHtmlImporter::appendNodeText()
format.setAnchor(true);
format.setAnchorNames(namedAnchors);
- cursor.insertText(ch, format);
+ cursor.insertText(QString::fromUcs4(&ch, 1), format);
namedAnchors.clear();
format.clearProperty(QTextFormat::IsAnchor);
format.clearProperty(QTextFormat::AnchorName);
} else {
- textToInsert += ch;
+ textToInsert += QChar::fromUcs4(ch);
}
}
}
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 53a984306c6..d722bceb289 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -657,8 +657,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextTableCellFormat &
\value FontStyleName
\value FontPointSize
\value FontPixelSize
- \value FontSizeAdjustment Specifies the change in size given to the fontsize already set using
- FontPointSize or FontPixelSize.
+ \value FontSizeAdjustment Specifies an integer adjustment added to the base font size set using
+ \c FontPointSize or \c FontPixelSize.
\value FontFixedPitch
\omitvalue FontSizeIncrement
\value FontWeight
diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp
index 3d1d8a2b788..27b131cd733 100644
--- a/src/gui/util/qundostack.cpp
+++ b/src/gui/util/qundostack.cpp
@@ -425,16 +425,16 @@ void QUndoStackPrivate::setIndex(int idx, bool clean)
emit q->indexChanged(index);
}
- const ActionState newUndoState{q->canUndo(), q->undoText()};
- if (indexChanged || newUndoState != undoActionState) {
- undoActionState = newUndoState;
+ if (ActionState newUndoState{q->canUndo(), q->undoText()};
+ indexChanged || newUndoState != undoActionState) {
+ undoActionState = std::move(newUndoState);
emit q->canUndoChanged(undoActionState.enabled);
emit q->undoTextChanged(undoActionState.text);
}
- const ActionState newRedoState{q->canRedo(), q->redoText()};
- if (indexChanged || newRedoState != redoActionState) {
- redoActionState = newRedoState;
+ if (ActionState newRedoState{q->canRedo(), q->redoText()};
+ indexChanged || newRedoState != redoActionState) {
+ redoActionState = std::move(newRedoState);
emit q->canRedoChanged(redoActionState.enabled);
emit q->redoTextChanged(redoActionState.text);
}
diff --git a/src/gui/util/qundostack_p.h b/src/gui/util/qundostack_p.h
index fea201ce62d..6bdcf5fb20b 100644
--- a/src/gui/util/qundostack_p.h
+++ b/src/gui/util/qundostack_p.h
@@ -59,10 +59,17 @@ public:
bool enabled = false;
QString text;
- bool operator!=(const ActionState &other) const noexcept
- {
- return enabled != other.enabled || text != other.text;
- }
+ friend bool operator==(const ActionState &lhs, const ActionState &rhs) noexcept
+#ifdef __cpp_impl_three_way_comparison
+ = default;
+#else
+ { return lhs.enabled == rhs.enabled && lhs.text == rhs.text; }
+ friend bool operator!=(const ActionState &lhs, const ActionState &rhs) noexcept
+ { return !(lhs == rhs); }
+#endif
+ // some compiler's reject seed = 0) = delete, overload instead:
+ friend void qHash(const ActionState &key, size_t seed) = delete;
+ friend void qHash(const ActionState &key) = delete;
};
QList<QUndoCommand*> command_list;
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index a1edf49da12..028ae6d682a 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -470,7 +470,6 @@ namespace QtAndroidAccessibility
case QAccessible::Role::Link:
{
if (state.checkable)
- // There is also a android.widget.Switch for which we have no match.
return QStringLiteral("android.widget.ToggleButton");
return QStringLiteral("android.widget.Button");
}
@@ -478,6 +477,8 @@ namespace QtAndroidAccessibility
// As of android/accessibility/utils/Role.java::getRole a CheckBox
// is NOT android.widget.CheckBox
return QStringLiteral("android.widget.CompoundButton");
+ case QAccessible::Role::Switch:
+ return QStringLiteral("android.widget.Switch");
case QAccessible::Role::Clock:
return QStringLiteral("android.widget.TextClock");
case QAccessible::Role::ComboBox:
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 8c5335d9c31..9059fab757b 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -359,20 +359,41 @@ namespace QtAndroid
static bool initJavaReferences(QJniEnvironment &env);
-static void initializeBackends()
+static bool initAndroidQpaPlugin(JNIEnv *jenv, jobject object)
{
+ Q_UNUSED(jenv)
+ Q_UNUSED(object)
+
+ // Init all the Java refs, if they haven't already been initialized. They get initialized
+ // when the library is loaded, but in case Qt is terminated, they are cleared, and in case
+ // Qt is then started again JNI_OnLoad will not be called again, since the library is already
+ // loaded - in that case we need to init again here, hence the check.
+ // TODO QTBUG-130614 QtCore also inits some Java references in qjnihelpers - we probably
+ // want to reset those, too.
+ QJniEnvironment qEnv;
+ if (!qEnv.isValid()) {
+ qCritical() << "Failed to initialize the JNI Environment";
+ return false;
+ }
+
+ if (!initJavaReferences(qEnv))
+ return false;
+
+ m_androidPlatformIntegration = nullptr;
+
// File engine handler instantiation registers the handler
m_androidAssetsFileEngineHandler = new AndroidAssetsFileEngineHandler();
m_androidContentFileEngineHandler = new AndroidContentFileEngineHandler();
m_androidApkFileEngineHandler = new QAndroidApkFileEngineHandler();
m_backendRegister = new AndroidBackendRegister();
-}
-static bool initCleanupHandshakeSemaphores()
-{
- return sem_init(&m_exitSemaphore, 0, 0) != -1
- && sem_init(&m_stopQtSemaphore, 0, 0) != -1;
+ if (sem_init(&m_exitSemaphore, 0, 0) == -1 && sem_init(&m_stopQtSemaphore, 0, 0) == -1) {
+ qCritical() << "Failed to init Qt application cleanup semaphores";
+ return false;
+ }
+
+ return true;
}
static void startQtNativeApplication(JNIEnv *jenv, jobject object, jstring paramsString)
@@ -391,23 +412,6 @@ static void startQtNativeApplication(JNIEnv *jenv, jobject object, jstring param
vm->AttachCurrentThread(&env, &args);
}
- // Init all the Java refs, if they haven't already been initialized. They get initialized
- // when the library is loaded, but in case Qt is terminated, they are cleared, and in case
- // Qt is then started again JNI_OnLoad will not be called again, since the library is already
- // loaded - in that case we need to init again here, hence the check.
- // TODO QTBUG-130614 QtCore also inits some Java references in qjnihelpers - we probably
- // want to reset those, too.
- QJniEnvironment qEnv;
- if (!qEnv.isValid()) {
- qCritical() << "Failed to initialize the JNI Environment";
- return;
- }
- if (!initJavaReferences(qEnv))
- return;
-
- m_androidPlatformIntegration = nullptr;
- initializeBackends();
-
const QStringList argsList = QProcess::splitCommand(QJniObject(paramsString).toString());
const int argc = argsList.size();
QVarLengthArray<char *> argv(argc + 1);
@@ -444,11 +448,6 @@ static void startQtNativeApplication(JNIEnv *jenv, jobject object, jstring param
return;
}
- if (!initCleanupHandshakeSemaphores()) {
- qCritical() << "Failed to init Qt application cleanup semaphores";
- return;
- }
-
// Register type for invokeMethod() calls.
qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");
@@ -458,13 +457,6 @@ static void startQtNativeApplication(JNIEnv *jenv, jobject object, jstring param
startQtAndroidPluginCalled.fetchAndAddRelease(1);
- QtNative::callStaticMethod("setStarted", true);
-
- // The service must wait until the QCoreApplication starts,
- // otherwise onBind will be called too early.
- if (QtAndroidPrivate::service().isValid() && QtAndroid::isQtApplication())
- QtAndroidPrivate::waitForServiceSetup();
-
const int ret = m_main(argc, argv.data());
qInfo() << "main() returned" << ret;
@@ -540,6 +532,15 @@ static void clearJavaReferences(JNIEnv *env)
}
}
+static void waitForServiceSetup(JNIEnv *env, jclass /*clazz*/)
+{
+ Q_UNUSED(env);
+ // The service must wait until the QCoreApplication starts otherwise onBind will be
+ // called too early
+ if (QtAndroidPrivate::service().isValid() && QtAndroid::isQtApplication())
+ QtAndroidPrivate::waitForServiceSetup();
+}
+
static void terminateQtNativeApplication(JNIEnv *env, jclass /*clazz*/)
{
// QAndroidEventDispatcherStopper is stopped when the user uses the task manager
@@ -730,8 +731,10 @@ static jobject onBind(JNIEnv */*env*/, jclass /*cls*/, jobject intent)
}
static JNINativeMethod methods[] = {
+ { "initAndroidQpaPlugin", "()Z", (void *)initAndroidQpaPlugin },
{ "startQtNativeApplication", "(Ljava/lang/String;)V", (void *)startQtNativeApplication },
{ "terminateQtNativeApplication", "()V", (void *)terminateQtNativeApplication },
+ { "waitForServiceSetup", "()V", (void *)waitForServiceSetup },
{ "updateApplicationState", "(I)V", (void *)updateApplicationState },
{ "onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult },
{ "onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent },
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index ecbbddb2e36..1d755139b46 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -82,9 +82,6 @@ static bool hasValidFocusObject()
if (!m_androidInputContext)
return false;
- if (!m_androidInputContext->isInputPanelVisible())
- return false;
-
const auto focusObject = m_androidInputContext->focusObject();
if (!focusObject)
return false;
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 822a5357107..0d8673aac03 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -27,7 +27,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus")
-Q_DECLARE_JNI_CLASS(QtDisplayManager, "org/qtproject/qt/android/QtDisplayManager")
+Q_DECLARE_JNI_CLASS(QtWindowInsetsController, "org/qtproject/qt/android/QtWindowInsetsController")
using namespace Qt::StringLiterals;
@@ -448,9 +448,9 @@ void QAndroidPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
const auto iface = qGuiApp->nativeInterface<QNativeInterface::QAndroidApplication>();
iface->runOnAndroidMainThread([=]() {
bool isLight = scheme == Qt::ColorScheme::Light;
- QtJniTypes::QtDisplayManager::callStaticMethod("setStatusBarColorHint",
+ QtJniTypes::QtWindowInsetsController::callStaticMethod("setStatusBarColorHint",
iface->context().object<QtJniTypes::Activity>(), isLight);
- QtJniTypes::QtDisplayManager::callStaticMethod("setNavigationBarColorHint",
+ QtJniTypes::QtWindowInsetsController::callStaticMethod("setNavigationBarColorHint",
iface->context().object<QtJniTypes::Activity>(), isLight);
});
}
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index 937839ace0c..96c4bfa06f1 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -22,6 +22,7 @@ Q_DECLARE_JNI_CLASS(QtInputInterface, "org/qtproject/qt/android/QtInputInterface
Q_DECLARE_JNI_CLASS(QtInputConnectionListener,
"org/qtproject/qt/android/QtInputConnection$QtInputConnectionListener")
Q_DECLARE_JNI_CLASS(QtDisplayManager, "org/qtproject/qt/android/QtWindowInterface")
+Q_DECLARE_JNI_CLASS(QtWindowInsetsController, "org/qtproject/qt/android/QtWindowInsetsController")
QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
: QPlatformWindow(window), m_nativeQtWindow(nullptr),
@@ -260,10 +261,17 @@ void QAndroidPlatformWindow::updateSystemUiVisibility()
const int flags = window()->flags();
const bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window;
if (!isNonRegularWindow) {
- const bool isFullScreen = (m_windowState & Qt::WindowFullScreen);
- const bool expandedToCutout = (flags & Qt::ExpandedClientAreaHint);
- QtAndroid::backendRegister()->callInterface<QtJniTypes::QtWindowInterface, void>(
- "setSystemUiVisibility", isFullScreen, expandedToCutout);
+ auto iface = qGuiApp->nativeInterface<QNativeInterface::QAndroidApplication>();
+ iface->runOnAndroidMainThread([=]() {
+ using namespace QtJniTypes;
+ auto activity = iface->context().object<Activity>();
+ if (m_windowState & Qt::WindowFullScreen)
+ QtWindowInsetsController::callStaticMethod("showFullScreen", activity);
+ else if (flags & Qt::ExpandedClientAreaHint)
+ QtWindowInsetsController::callStaticMethod("showExpanded", activity);
+ else
+ QtWindowInsetsController::callStaticMethod("showNormal", activity);
+ });
}
}
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 69ee3638ac6..08c9f5d5ba2 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -132,6 +132,7 @@ static void populateRoleMap()
roleMap[QAccessible::ComboBox] = NSAccessibilityComboBoxRole;
roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole;
roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole;
+ roleMap[QAccessible::Switch] = NSAccessibilityCheckBoxRole;
roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole;
roleMap[QAccessible::Table] = NSAccessibilityTableRole;
roleMap[QAccessible::StatusBar] = NSAccessibilityStaticTextRole;
@@ -204,6 +205,8 @@ NSString *macSubrole(QAccessibleInterface *interface)
return NSAccessibilitySecureTextFieldSubrole;
if (interface->role() == QAccessible::PageTab)
return NSAccessibilityTabButtonSubrole;
+ if (interface->role() == QAccessible::Switch)
+ return NSAccessibilitySwitchSubrole;
return nil;
}
@@ -328,8 +331,11 @@ NSString *getTranslatedAction(const QString &qtAction)
QString translateAction(NSString *nsAction, QAccessibleInterface *interface)
{
if ([nsAction compare: NSAccessibilityPressAction] == NSOrderedSame) {
- if (interface->role() == QAccessible::CheckBox || interface->role() == QAccessible::RadioButton)
+ if (interface->role() == QAccessible::CheckBox
+ || interface->role() == QAccessible::RadioButton
+ || interface->role() == QAccessible::Switch) {
return QAccessibleActionInterface::toggleAction();
+ }
return QAccessibleActionInterface::pressAction();
} else if ([nsAction compare: NSAccessibilityIncrementAction] == NSOrderedSame)
return QAccessibleActionInterface::increaseAction();
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h
index 60b9bc8fc02..8fdcf88293e 100644
--- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h
+++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h
@@ -2,6 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default
+#ifndef QIOSIMAGEPICKERCONTROLLER_H
+#define QIOSIMAGEPICKERCONTROLLER_H
+
#import <UIKit/UIKit.h>
#include "../../qiosfiledialog.h"
@@ -9,3 +12,5 @@
@interface QIOSImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
- (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog;
@end
+
+#endif // QIOSIMAGEPICKERCONTROLLER_H
diff --git a/src/plugins/platforms/ios/qiosdocumentpickercontroller.h b/src/plugins/platforms/ios/qiosdocumentpickercontroller.h
index 289c3ee3258..a227312c5b0 100644
--- a/src/plugins/platforms/ios/qiosdocumentpickercontroller.h
+++ b/src/plugins/platforms/ios/qiosdocumentpickercontroller.h
@@ -2,6 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default
+#ifndef QIOSDOCUMENTPICKERCONTROLLER_H
+#define QIOSDOCUMENTPICKERCONTROLLER_H
+
#import <UIKit/UIKit.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
@@ -12,3 +15,5 @@
UIAdaptivePresentationControllerDelegate>
- (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog;
@end
+
+#endif // QIOSDOCUMENTPICKERCONTROLLER_H
diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.h b/src/plugins/platforms/ios/qiosplatformaccessibility.h
index 04cddf00f4e..1ccc5bd089a 100644
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.h
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.h
@@ -23,7 +23,7 @@ public:
private:
QMacNotificationObserver m_focusObserver;
- QMacAccessibilityElement *m_focusElement;
+ QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *m_focusElement;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.mm b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
index 26f48468c45..a63c75757e4 100644
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
@@ -12,6 +12,8 @@
#include "qioswindow.h"
#include "quiaccessibilityelement.h"
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
+
QIOSPlatformAccessibility::QIOSPlatformAccessibility()
{
m_focusObserver = QMacNotificationObserver(
diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h
index addfae3d748..7d73ed9821a 100644
--- a/src/plugins/platforms/ios/qiostextresponder.h
+++ b/src/plugins/platforms/ios/qiostextresponder.h
@@ -2,6 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default
+#ifndef QIOSTEXTRESPONDER_H
+#define QIOSTEXTRESPONDER_H
+
#import <UIKit/UIKit.h>
#include <QtCore/qstring.h>
@@ -50,3 +53,5 @@ QT_END_NAMESPACE
@property(nonatomic, assign) id<UITextInputDelegate> inputDelegate;
@end
+
+#endif // QIOSTEXTRESPONDER_H
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index 23a4c506c24..5024013ba77 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -10,9 +10,6 @@
#import <UIKit/UIKit.h>
-class QIOSContext;
-class QIOSWindow;
-
@class QUIView;
QT_BEGIN_NAMESPACE
@@ -84,7 +81,7 @@ private:
QDebug operator<<(QDebug debug, const QIOSWindow *window);
#endif
-QT_MANGLE_NAMESPACE(QUIView) *quiview_cast(UIView *view);
+QUIView *quiview_cast(UIView *view);
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index d10fe40840a..0d6952bddf0 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -115,6 +115,9 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
|| iface->role() == QAccessible::RadioButton)
return @"";
+ if (iface->role() == QAccessible::Switch)
+ return state.checked ? @"1" : @"0";
+
return state.checked
? QCoreApplication::translate(ACCESSIBILITY_ELEMENT, AE_CHECKED).toNSString()
: QCoreApplication::translate(ACCESSIBILITY_ELEMENT, AE_UNCHECKED).toNSString();
@@ -169,6 +172,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
|| accessibleRole == QAccessible::RadioButton) {
if (state.checked)
traits |= UIAccessibilityTraitSelected;
+ } else if (accessibleRole == QAccessible::Switch) {
+ traits |= UIAccessibilityTraitToggleButton;
} else if (accessibleRole == QAccessible::EditableText) {
static auto defaultTextFieldTraits = []{
auto *textField = [[[UITextField alloc] initWithFrame:CGRectZero] autorelease];
diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h
index 84726216021..12ae3646ad9 100644
--- a/src/plugins/platforms/ios/quiview.h
+++ b/src/plugins/platforms/ios/quiview.h
@@ -2,6 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default
+#ifndef QUIVIEW_H
+#define QUIVIEW_H
+
#import <UIKit/UIKit.h>
#include <qhash.h>
@@ -39,3 +42,5 @@ QT_END_NAMESPACE
@interface QUIMetalView : QUIView
@end
#endif
+
+#endif // QUIVIEW_H
diff --git a/src/plugins/platforms/wasm/qwasmaccessibility.cpp b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
index 1cf81453fe7..35e804531bc 100644
--- a/src/plugins/platforms/wasm/qwasmaccessibility.cpp
+++ b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
@@ -363,6 +363,17 @@ emscripten::val QWasmAccessibility::createHtmlElement(QAccessibleInterface *ifac
addEventListener(element, "change");
} break;
+ case QAccessible::Switch: {
+ element = document.call<emscripten::val>("createElement", std::string("button"));
+ setAttribute(element, "type", "button");
+ setAttribute(element, "role", "switch");
+ if (iface->state().checked)
+ setAttribute(element, "aria-checked", "true");
+ else
+ setAttribute(element, "aria-checked", "false");
+ addEventListener(element, "change");
+ } break;
+
case QAccessible::RadioButton: {
element = document.call<emscripten::val>("createElement", std::string("input"));
setAttribute(element, "type", "radio");
@@ -743,6 +754,28 @@ void QWasmAccessibility::handleCheckBoxUpdate(QAccessibleEvent *event)
break;
}
}
+
+void QWasmAccessibility::handleSwitchUpdate(QAccessibleEvent *event)
+{
+ switch (event->type()) {
+ case QAccessible::Focus:
+ case QAccessible::NameChanged: {
+ setHtmlElementTextName(event->accessibleInterface());
+ } break;
+ case QAccessible::StateChanged: {
+ QAccessibleInterface *accessible = event->accessibleInterface();
+ const emscripten::val element = getHtmlElement(accessible);
+ if (accessible->state().checked)
+ setAttribute(element, "aria-checked", "true");
+ else
+ setAttribute(element, "aria-checked", "false");
+ } break;
+ default:
+ qCDebug(lcQpaAccessibility) << "TODO: implement handleSwitchUpdate for event" << event->type();
+ break;
+ }
+}
+
void QWasmAccessibility::handleToolUpdate(QAccessibleEvent *event)
{
QAccessibleInterface *iface = event->accessibleInterface();
@@ -1152,6 +1185,9 @@ void QWasmAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
case QAccessible::CheckBox:
handleCheckBoxUpdate(event);
break;
+ case QAccessible::Switch:
+ handleSwitchUpdate(event);
+ break;
case QAccessible::EditableText:
handleLineEditUpdate(event);
break;
diff --git a/src/plugins/platforms/wasm/qwasmaccessibility.h b/src/plugins/platforms/wasm/qwasmaccessibility.h
index ee2be18e5b7..2b4716d64e7 100644
--- a/src/plugins/platforms/wasm/qwasmaccessibility.h
+++ b/src/plugins/platforms/wasm/qwasmaccessibility.h
@@ -81,6 +81,7 @@ private:
void handleStaticTextUpdate(QAccessibleEvent *event);
void handleButtonUpdate(QAccessibleEvent *event);
void handleCheckBoxUpdate(QAccessibleEvent *event);
+ void handleSwitchUpdate(QAccessibleEvent *event);
void handleDialogUpdate(QAccessibleEvent *event);
void handleMenuUpdate(QAccessibleEvent *event);
void handleToolUpdate(QAccessibleEvent *event);
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index a1a173f0182..17422bd606d 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -201,7 +201,7 @@ void QWaylandXdgSurface::Toplevel::requestWindowFlags(Qt::WindowFlags flags)
delete m_decoration;
m_decoration = nullptr;
} else {
- m_decoration->unsetMode();
+ m_decoration->requestMode(QWaylandXdgToplevelDecorationV1::mode_server_side);
}
}
}
@@ -697,108 +697,135 @@ void QWaylandXdgSurface::setWindowPosition(const QPoint &position)
window()->updateExposure();
}
+static QtWayland::xdg_positioner::gravity gravityFromEdge(Qt::Edges edges)
+{
+ switch (edges) {
+ case Qt::Edges():
+ return QtWayland::xdg_positioner::gravity_none;
+ case Qt::TopEdge:
+ return QtWayland::xdg_positioner::gravity_top;
+ case Qt::TopEdge | Qt::RightEdge:
+ return QtWayland::xdg_positioner::gravity_top_right;
+ case Qt::RightEdge:
+ return QtWayland::xdg_positioner::gravity_right;
+ case Qt::BottomEdge | Qt::RightEdge:
+ return QtWayland::xdg_positioner::gravity_bottom_right;
+ case Qt::BottomEdge:
+ return QtWayland::xdg_positioner::gravity_bottom;
+ case Qt::BottomEdge | Qt::LeftEdge:
+ return QtWayland::xdg_positioner::gravity_bottom_left;
+ case Qt::LeftEdge:
+ return QtWayland::xdg_positioner::gravity_left;
+ case Qt::TopEdge | Qt::LeftEdge:
+ return QtWayland::xdg_positioner::gravity_top_left;
+ }
+ qCWarning(lcQpaWayland) << "Cannot map positioner gravity " << edges;
+ return QtWayland::xdg_positioner::gravity_none;
+}
+
+static QtWayland::xdg_positioner::anchor anchorFromEdge(Qt::Edges edges)
+{
+ switch (edges) {
+ case Qt::Edges():
+ return QtWayland::xdg_positioner::anchor_none;
+ case Qt::TopEdge:
+ return QtWayland::xdg_positioner::anchor_top;
+ case Qt::TopEdge | Qt::RightEdge:
+ return QtWayland::xdg_positioner::anchor_top_right;
+ case Qt::RightEdge:
+ return QtWayland::xdg_positioner::anchor_right;
+ case Qt::BottomEdge | Qt::RightEdge:
+ return QtWayland::xdg_positioner::anchor_bottom_right;
+ case Qt::BottomEdge:
+ return QtWayland::xdg_positioner::anchor_bottom;
+ case Qt::BottomEdge | Qt::LeftEdge:
+ return QtWayland::xdg_positioner::anchor_bottom_left;
+ case Qt::LeftEdge:
+ return QtWayland::xdg_positioner::anchor_left;
+ case Qt::TopEdge | Qt::LeftEdge:
+ return QtWayland::xdg_positioner::anchor_top_left;
+ }
+ qCWarning(lcQpaWayland) << "Cannot map positioner anchor" << edges;
+ return QtWayland::xdg_positioner::anchor_none;
+}
+
std::unique_ptr<QWaylandXdgSurface::Positioner> QWaylandXdgSurface::createPositioner(QWaylandWindow *parent)
{
std::unique_ptr<Positioner> positioner(new Positioner(m_shell));
- // set_popup expects a position relative to the parent
- QRect windowGeometry = m_window->windowContentGeometry();
- QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins();
- QMargins parentMargins = parent->windowContentMargins() - parent->clientSideMargins();
- // These property overrides may be removed when public API becomes available
- QRect placementAnchor = m_window->window()->property("_q_waylandPopupAnchorRect").toRect();
- if (!placementAnchor.isValid()) {
- placementAnchor = QRect(m_window->geometry().topLeft() - parent->geometry().topLeft(), QSize(1,1));
- }
- placementAnchor.translate(windowMargins.left(), windowMargins.top());
- placementAnchor.translate(-parentMargins.left(), -parentMargins.top());
+ // Default case, map the guessed global position to a relative position
+ QRect placementAnchor = QRect(m_window->geometry().topLeft() - parent->geometry().topLeft(), QSize(1,1));
+ Qt::Edges anchor = Qt::TopEdge | Qt::RightEdge;
+ Qt::Edges gravity = Qt::BottomEdge | Qt::RightEdge;
+ uint32_t constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_slide_x | QtWayland::xdg_positioner::constraint_adjustment_slide_y;
- uint32_t anchor = QtWayland::xdg_positioner::anchor_top_left;
+ // Override from window type
+ if (m_window->parentControlGeometry().isValid())
+ placementAnchor = m_window->parentControlGeometry();
+
+ switch (m_window->extendedWindowType()) {
+ case QNativeInterface::Private::QWaylandWindow::Menu:
+ case QNativeInterface::Private::QWaylandWindow::WindowType::ComboBox:
+ anchor = Qt::BottomEdge | Qt::LeftEdge;
+ gravity = Qt::BottomEdge | Qt::RightEdge;
+ constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_slide_x |
+ QtWayland::xdg_positioner::constraint_adjustment_flip_y | QtWayland::xdg_positioner::constraint_adjustment_slide_y;
+ break;
+ case QNativeInterface::Private::QWaylandWindow::SubMenu:
+ anchor = Qt::TopEdge | Qt::RightEdge;
+ gravity = Qt::BottomEdge | Qt::RightEdge;
+ constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_flip_x |
+ QtWayland::xdg_positioner::constraint_adjustment_slide_y;
+ break;
+ case QNativeInterface::Private::QWaylandWindow::ToolTip:
+ anchor = Qt::BottomEdge | Qt::RightEdge;
+ gravity = Qt::BottomEdge | Qt::RightEdge;
+ constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_flip_x | QtWayland::xdg_positioner::constraint_adjustment_slide_x |
+ QtWayland::xdg_positioner::constraint_adjustment_flip_y | QtWayland::xdg_positioner::constraint_adjustment_slide_y;
+ break;
+ default:
+ break;
+ }
+
+ if (qApp->layoutDirection() == Qt::RightToLeft) {
+ if (anchor & (Qt::RightEdge | Qt::LeftEdge))
+ anchor ^= (Qt::RightEdge | Qt::LeftEdge);
+ if (gravity & (Qt::RightEdge | Qt::LeftEdge))
+ gravity ^= (Qt::RightEdge | Qt::LeftEdge);
+ }
+
+ // Override with properties fauxAPI
+ const QVariant placementAnchorVariant = m_window->window()->property("_q_waylandPopupAnchorRect");
+ if (placementAnchorVariant.isValid())
+ placementAnchor = placementAnchorVariant.toRect();
const QVariant anchorVariant = m_window->window()->property("_q_waylandPopupAnchor");
- if (anchorVariant.isValid()) {
- switch (anchorVariant.value<Qt::Edges>()) {
- case Qt::Edges():
- anchor = QtWayland::xdg_positioner::anchor_none;
- break;
- case Qt::TopEdge:
- anchor = QtWayland::xdg_positioner::anchor_top;
- break;
- case Qt::TopEdge | Qt::RightEdge:
- anchor = QtWayland::xdg_positioner::anchor_top_right;
- break;
- case Qt::RightEdge:
- anchor = QtWayland::xdg_positioner::anchor_right;
- break;
- case Qt::BottomEdge | Qt::RightEdge:
- anchor = QtWayland::xdg_positioner::anchor_bottom_right;
- break;
- case Qt::BottomEdge:
- anchor = QtWayland::xdg_positioner::anchor_bottom;
- break;
- case Qt::BottomEdge | Qt::LeftEdge:
- anchor = QtWayland::xdg_positioner::anchor_bottom_left;
- break;
- case Qt::LeftEdge:
- anchor = QtWayland::xdg_positioner::anchor_left;
- break;
- case Qt::TopEdge | Qt::LeftEdge:
- anchor = QtWayland::xdg_positioner::anchor_top_left;
- break;
- }
- }
-
- uint32_t gravity = QtWayland::xdg_positioner::gravity_bottom_right;
+ if (anchorVariant.isValid())
+ anchor = anchorVariant.value<Qt::Edges>();
const QVariant popupGravityVariant = m_window->window()->property("_q_waylandPopupGravity");
- if (popupGravityVariant.isValid()) {
- switch (popupGravityVariant.value<Qt::Edges>()) {
- case Qt::Edges():
- gravity = QtWayland::xdg_positioner::gravity_none;
- break;
- case Qt::TopEdge:
- gravity = QtWayland::xdg_positioner::gravity_top;
- break;
- case Qt::TopEdge | Qt::RightEdge:
- gravity = QtWayland::xdg_positioner::gravity_top_right;
- break;
- case Qt::RightEdge:
- gravity = QtWayland::xdg_positioner::gravity_right;
- break;
- case Qt::BottomEdge | Qt::RightEdge:
- gravity = QtWayland::xdg_positioner::gravity_bottom_right;
- break;
- case Qt::BottomEdge:
- gravity = QtWayland::xdg_positioner::gravity_bottom;
- break;
- case Qt::BottomEdge | Qt::LeftEdge:
- gravity = QtWayland::xdg_positioner::gravity_bottom_left;
- break;
- case Qt::LeftEdge:
- gravity = QtWayland::xdg_positioner::gravity_left;
- break;
- case Qt::TopEdge | Qt::LeftEdge:
- gravity = QtWayland::xdg_positioner::gravity_top_left;
- break;
- }
- }
-
- uint32_t constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_slide_x | QtWayland::xdg_positioner::constraint_adjustment_slide_y;
+ if (popupGravityVariant.isValid())
+ gravity = popupGravityVariant.value<Qt::Edges>();
const QVariant constraintAdjustmentVariant = m_window->window()->property("_q_waylandPopupConstraintAdjustment");
- if (constraintAdjustmentVariant.isValid()) {
+ if (constraintAdjustmentVariant.isValid())
constraintAdjustment = constraintAdjustmentVariant.toUInt();
- }
+
+ // set_popup expects a position relative to the parent
+ QRect windowGeometry = m_window->windowContentGeometry();
+ QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins();
+ QMargins parentMargins = parent->windowContentMargins() - parent->clientSideMargins();
+ placementAnchor.translate(windowMargins.left(), windowMargins.top());
+ placementAnchor.translate(-parentMargins.left(), -parentMargins.top());
positioner->set_anchor_rect(placementAnchor.x(),
placementAnchor.y(),
placementAnchor.width(),
placementAnchor.height());
- positioner->set_anchor(anchor);
- positioner->set_gravity(gravity);
+ positioner->set_anchor(anchorFromEdge(anchor));
+ positioner->set_gravity(gravityFromEdge(gravity));
positioner->set_size(windowGeometry.width(), windowGeometry.height());
positioner->set_constraint_adjustment(constraintAdjustment);
return positioner;
}
-
void QWaylandXdgSurface::setIcon(const QIcon &icon)
{
if (!m_shell->m_topLevelIconManager || !m_toplevel)
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index 7c300843518..be527b08f4d 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -481,8 +481,9 @@ void QWaylandWindow::setGeometry(const QRect &r)
if (mShellSurface && !mInResizeFromApplyConfigure) {
const QRect frameGeometry = r.marginsAdded(clientSideMargins()).marginsRemoved(windowContentMargins());
- if (qt_window_private(window())->positionAutomatic)
+ if (qt_window_private(window())->positionAutomatic || m_popupInfo.parentControlGeometry.isValid())
mShellSurface->setWindowSize(frameGeometry.size());
+
else
mShellSurface->setWindowGeometry(frameGeometry);
}
@@ -1945,6 +1946,27 @@ QString QWaylandWindow::sessionRestoreId() const
return mSessionRestoreId;
}
+void QWaylandWindow::setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::WindowType windowType) {
+ m_popupInfo.extendedWindowType = windowType;
+}
+
+QNativeInterface::Private::QWaylandWindow::WindowType QWaylandWindow::extendedWindowType() const
+{
+ return m_popupInfo.extendedWindowType;
+}
+
+void QWaylandWindow::setParentControlGeometry(const QRect &parentControlGeometry) {
+ m_popupInfo.parentControlGeometry = parentControlGeometry;
+ if (mExposed) {
+ mShellSurface->setWindowPosition(window()->position());
+ }
+}
+
+QRect QWaylandWindow::parentControlGeometry() const
+{
+ return m_popupInfo.parentControlGeometry;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h
index 854724daf82..d6b24d0569f 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow_p.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h
@@ -255,6 +255,11 @@ public:
void setSessionRestoreId(const QString &role) override;
QString sessionRestoreId() const;
+ void setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::WindowType) override;
+ QNativeInterface::Private::QWaylandWindow::WindowType extendedWindowType() const;
+ void setParentControlGeometry(const QRect &parentAnchor) override;
+ QRect parentControlGeometry() const;
+
public Q_SLOTS:
void applyConfigure();
@@ -397,6 +402,11 @@ private:
void handleFrameCallback(struct ::wl_callback* callback);
const QPlatformWindow *lastParent = nullptr;
+ struct {
+ QRect parentControlGeometry;
+ QNativeInterface::Private::QWaylandWindow::WindowType extendedWindowType = QNativeInterface::Private::QWaylandWindow::Default;
+ } m_popupInfo;
+
static QWaylandWindow *mMouseGrab;
static QWaylandWindow *mTopPopup;
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index fc0e053f396..0144786ce5e 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -82,8 +82,9 @@ void QWindowsUiaMainProvider::notifyStateChange(QAccessibleStateChangeEvent *eve
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {
if (event->changedStates().checked || event->changedStates().checkStateMixed) {
- // Notifies states changes in checkboxes.
- if (accessible->role() == QAccessible::CheckBox) {
+ // Notifies states changes in checkboxes and switches.
+ if (accessible->role() == QAccessible::CheckBox
+ || accessible->role() == QAccessible::Switch) {
if (auto provider = providerForAccessible(accessible)) {
long toggleState = ToggleState_Off;
if (accessible->state().checked)
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp
index 4146a56b226..b2675d5b884 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp
@@ -132,6 +132,7 @@ long roleToControlTypeId(QAccessible::Role role)
{QAccessible::EditableText, UIA_EditControlTypeId},
{QAccessible::Button, UIA_ButtonControlTypeId},
{QAccessible::CheckBox, UIA_CheckBoxControlTypeId},
+ {QAccessible::Switch, UIA_ButtonControlTypeId},
{QAccessible::RadioButton, UIA_RadioButtonControlTypeId},
{QAccessible::ComboBox, UIA_ComboBoxControlTypeId},
{QAccessible::ProgressBar, UIA_ProgressBarControlTypeId},
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index 28b12bd81f9..25142612c4f 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -1331,11 +1331,12 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
}
break;
- case QStyle::CE_ProgressBarGroove:{
- if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
- QRect rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
+#if QT_CONFIG(progressbar)
+ case CE_ProgressBarGroove:
+ if (const auto baropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
+ QRect rect = option->rect;
QPointF center = rect.center();
- if (progbaropt->state & QStyle::State_Horizontal) {
+ if (baropt->state & QStyle::State_Horizontal) {
rect.setHeight(1);
rect.moveTop(center.y());
} else {
@@ -1347,11 +1348,10 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->drawRect(rect);
}
break;
- }
- case QStyle::CE_ProgressBarContents:
+ case CE_ProgressBarContents:
if (const auto baropt = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
QPainterStateGuard psg(painter);
- QRectF rect = subElementRect(SE_ProgressBarContents, baropt, widget);
+ QRectF rect = option->rect;
painter->translate(rect.topLeft());
rect.translate(-rect.topLeft());
@@ -1411,16 +1411,17 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
drawRoundedRect(painter, rect, Qt::NoPen, baropt->palette.accent());
}
break;
- case QStyle::CE_ProgressBarLabel:
- if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
- const bool vertical = !(progbaropt->state & QStyle::State_Horizontal);
+ case CE_ProgressBarLabel:
+ if (const auto baropt = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ const bool vertical = !(baropt->state & QStyle::State_Horizontal);
if (!vertical) {
- QRect rect = subElementRect(SE_ProgressBarLabel, progbaropt, widget);
- painter->setPen(progbaropt->palette.text().color());
- painter->drawText(rect, progbaropt->text, progbaropt->textAlignment);
+ proxy()->drawItemText(painter, baropt->rect, Qt::AlignCenter | Qt::TextSingleLine,
+ baropt->palette, baropt->state & State_Enabled, baropt->text,
+ QPalette::Text);
}
}
break;
+#endif // QT_CONFIG(progressbar)
case CE_PushButtonLabel:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
QRect textRect = btn->rect;
@@ -1914,15 +1915,18 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
}
break;
- case QStyle::SE_ProgressBarLabel:
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- if (pb->textAlignment.testFlags(Qt::AlignVCenter)) {
- ret = option->rect.adjusted(0, 6, 0, 0);
- } else {
- ret = QWindowsVistaStyle::subElementRect(element, option, widget);
- }
+#if QT_CONFIG(progressbar)
+ case SE_ProgressBarGroove:
+ case SE_ProgressBarContents:
+ case SE_ProgressBarLabel:
+ if (const auto *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ QStyleOptionProgressBar optCopy(*pb);
+ // we only support label right from content
+ optCopy.textAlignment = Qt::AlignRight;
+ return QWindowsVistaStyle::subElementRect(element, &optCopy, widget);
}
break;
+#endif // QT_CONFIG(progressbar)
case QStyle::SE_HeaderLabel:
case QStyle::SE_HeaderArrow:
ret = QCommonStyle::subElementRect(element, option, widget);
diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp
index 0e04d10e692..b517d85c5fb 100644
--- a/src/tools/androidtestrunner/main.cpp
+++ b/src/tools/androidtestrunner/main.cpp
@@ -328,6 +328,53 @@ static bool processAndroidManifest()
return true;
}
+static QStringList queryDangerousPermissions()
+{
+ QByteArray output;
+ const QStringList args({ "shell"_L1, "dumpsys"_L1, "package"_L1, "permissions"_L1 });
+ if (!execAdbCommand(args, &output, false)) {
+ qWarning("Failed to query permissions via dumpsys");
+ return {};
+ }
+
+ /*
+ * Permissions section from this command look like:
+ *
+ * Permission [android.permission.INTERNET] (c8cafdc):
+ * sourcePackage=android
+ * uid=1000 gids=[3003] type=0 prot=normal|instant
+ * perm=PermissionInfo{5f5bfbb android.permission.INTERNET}
+ * flags=0x0
+ */
+ const static QRegularExpression regex("^\\s*Permission\\s+\\[([^\\]]+)\\]\\s+\\(([^)]+)\\):"_L1);
+ QStringList dangerousPermissions;
+ QString currentPerm;
+
+ const QStringList lines = QString::fromUtf8(output).split(u'\n');
+ for (const QString &line : lines) {
+ QRegularExpressionMatch match = regex.match(line);
+ if (match.hasMatch()) {
+ currentPerm = match.captured(1);
+ continue;
+ }
+
+ if (currentPerm.isEmpty())
+ continue;
+
+ int protIndex = line.indexOf("prot="_L1);
+ if (protIndex == -1)
+ continue;
+
+ QString protectionTypes = line.mid(protIndex + 5).trimmed();
+ if (protectionTypes.contains("dangerous"_L1, Qt::CaseInsensitive)) {
+ dangerousPermissions.append(currentPerm);
+ currentPerm.clear();
+ }
+ }
+
+ return dangerousPermissions;
+}
+
static void setOutputFile(QString file, QString format)
{
if (format.isEmpty())
@@ -938,7 +985,11 @@ int main(int argc, char *argv[])
return EXIT_ERROR;
}
+ const QStringList dangerousPermisisons = queryDangerousPermissions();
for (const auto &permission : g_options.permissions) {
+ if (!dangerousPermisisons.contains(permission))
+ continue;
+
if (!execAdbCommand({ "shell"_L1, "pm"_L1, "grant"_L1, g_options.package, permission },
nullptr)) {
qWarning("Unable to grant '%s' to '%s'. Probably the Android version mismatch.",
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 9cfd877d945..64af8c10fc1 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -68,6 +68,8 @@ bool Moc::parseClassHead(ClassDef *def)
const QByteArrayView lex = lexemView();
if (lex != "final" && lex != "sealed" && lex != "Q_DECL_FINAL")
name = lexem();
+ else
+ def->isFinal = true;
}
def->qualified += name;
@@ -85,6 +87,8 @@ bool Moc::parseClassHead(ClassDef *def)
const QByteArrayView lex = lexemView();
if (lex != "final" && lex != "sealed" && lex != "Q_DECL_FINAL")
return false;
+ else
+ def->isFinal = true;
}
if (test(COLON)) {
@@ -2055,6 +2059,8 @@ QJsonObject ClassDef::toJson() const
cls["className"_L1] = QString::fromUtf8(classname.constData());
cls["qualifiedClassName"_L1] = QString::fromUtf8(qualified.constData());
cls["lineNumber"_L1] = lineNumber;
+ if (isFinal)
+ cls["final"_L1] = true;
QJsonArray classInfos;
for (const auto &info: std::as_const(classInfoList)) {
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index bf55aa7c44f..aafa80d2164 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -207,6 +207,7 @@ struct ClassDef : BaseDef {
bool hasQGadget = false;
bool hasQNamespace = false;
bool requireCompleteMethodTypes = false;
+ bool isFinal = false;
QJsonObject toJson() const;
};
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index e4159ad2cf0..51aea4079a1 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -3298,7 +3298,8 @@ void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
bool QAbstractItemView::isPersistentEditorOpen(const QModelIndex &index) const
{
Q_D(const QAbstractItemView);
- return d->editorForIndex(index).widget;
+ QWidget *editor = d->editorForIndex(index).widget;
+ return editor && d->persistent.contains(editor);
}
/*!
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 6fcfcf1b1ef..53ce4dd8211 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1432,8 +1432,8 @@ void QApplicationPrivate::notifyWindowIconChanged()
// in case there are any plain QWindows in this QApplication-using
// application, also send the notification to them
- for (int i = 0; i < windowList.size(); ++i)
- QCoreApplication::sendEvent(windowList.at(i), &ev);
+ for (QWindow *w : std::as_const(windowList))
+ QCoreApplication::sendEvent(w, &ev);
}
/*!
@@ -1774,9 +1774,9 @@ void QApplicationPrivate::notifyLayoutDirectionChange()
// in case there are any plain QWindows in this QApplication-using
// application, also send the notification to them
- for (int i = 0; i < windowList.size(); ++i) {
+ for (QWindow *w: std::as_const(windowList)) {
QEvent ev(QEvent::ApplicationLayoutDirectionChange);
- QCoreApplication::sendEvent(windowList.at(i), &ev);
+ QCoreApplication::sendEvent(w, &ev);
}
}
@@ -1863,14 +1863,12 @@ void QApplicationPrivate::setActiveWindow(QWidget* act)
QEvent windowActivate(QEvent::WindowActivate);
QEvent windowDeactivate(QEvent::WindowDeactivate);
- for (int i = 0; i < toBeActivated.size(); ++i) {
- QWidget *w = toBeActivated.at(i);
+ for (QWidget *w : std::as_const(toBeActivated)) {
QApplication::sendSpontaneousEvent(w, &windowActivate);
QApplication::sendSpontaneousEvent(w, &activationChange);
}
- for(int i = 0; i < toBeDeactivated.size(); ++i) {
- QWidget *w = toBeDeactivated.at(i);
+ for (QWidget *w : std::as_const(toBeDeactivated)) {
QApplication::sendSpontaneousEvent(w, &windowDeactivate);
QApplication::sendSpontaneousEvent(w, &activationChange);
}
@@ -2082,8 +2080,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con
}
QEvent leaveEvent(QEvent::Leave);
- for (int i = 0; i < leaveList.size(); ++i) {
- auto *w = leaveList.at(i);
+ for (QWidget *w : std::as_const(leaveList)) {
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) {
QCoreApplication::sendEvent(w, &leaveEvent);
if (w->testAttribute(Qt::WA_Hover) &&
@@ -2125,8 +2122,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con
// Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor.
// This is not required on Windows as the cursor is reset on every single mouse move.
QWidget *parentOfLeavingCursor = nullptr;
- for (int i = 0; i < leaveList.size(); ++i) {
- auto *w = leaveList.at(i);
+ for (QWidget *w : std::as_const(leaveList)) {
if (!isAlien(w))
break;
if (w->testAttribute(Qt::WA_SetCursor)) {
@@ -3085,7 +3081,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
const QPoint offset = w->pos();
w = w->parentWidget();
QMutableTouchEvent::setTarget(touchEvent, w);
- for (int i = 0; i < touchEvent->pointCount(); ++i) {
+ for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) {
auto &pt = touchEvent->point(i);
QMutableEventPoint::setPosition(pt, pt.position() + offset);
}
@@ -3164,8 +3160,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
res = d->notify_helper(w, &ge);
gestureEvent->m_spont = false;
eventAccepted = ge.isAccepted();
- for (int i = 0; i < gestures.size(); ++i) {
- QGesture *g = gestures.at(i);
+ for (QGesture *g : std::as_const(gestures)) {
// Ignore res [event return value] because handling of multiple gestures
// packed into a single QEvent depends on not consuming the event
if (eventAccepted || ge.isAccepted(g)) {
@@ -3708,7 +3703,7 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
{
bool containsPress = false;
- for (int i = 0; i < touchEvent->pointCount(); ++i) {
+ for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) {
auto &pt = touchEvent->point(i);
QMutableEventPoint::setPosition(pt, widget->mapFromGlobal(pt.globalPosition()));
@@ -3768,7 +3763,7 @@ void QApplicationPrivate::activateImplicitTouchGrab(QWidget *widget, QTouchEvent
// If the widget dispatched the event further (see QGraphicsProxyWidget), then
// there might already be an implicit grabber. Don't override that. A widget that
// has partially recognized a gesture needs to grab all points.
- for (int i = 0; i < touchEvent->pointCount(); ++i) {
+ for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) {
auto &ep = touchEvent->point(i);
if (!QMutableEventPoint::target(ep) && (ep.isAccepted() || grabMode == GrabAllPoints))
QMutableEventPoint::setTarget(ep, widget);
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 9e6aaf4b95f..d989feb7f91 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -20,6 +20,8 @@
#if QT_CONFIG(style_stylesheet)
#include <private/qstylesheetstyle_p.h>
#endif
+#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformwindow_p.h>
#include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h>
@@ -386,6 +388,17 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
p += offset;
+#if QT_CONFIG(wayland)
+ create();
+ if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow*>(windowHandle()->handle())) {
+ // based on the existing code below, by default position at 'p' stored at the bottom right of our rect
+ // then flip to the other arbitrary 4x24 space if constrained
+ const QRect controlGeometry(QRect(p.x() - 4, p.y() - 24, 4, 24));
+ waylandWindow->setParentControlGeometry(controlGeometry);
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::ToolTip);
+ }
+#endif
+
QRect screenRect = screen->geometry();
if (p.x() + this->width() > screenRect.x() + screenRect.width())
p.rx() -= 4 + this->width();
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 36446c3e5c4..9499c88af12 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -13144,11 +13144,22 @@ int QWidget::metric(PaintDeviceMetric m) const
void QWidget::initPainter(QPainter *painter) const
{
const QPalette &pal = palette();
- painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1);
- painter->d_func()->state->bgBrush = pal.brush(backgroundRole());
+ QPainterPrivate *painterPrivate = QPainterPrivate::get(painter);
+
+ painterPrivate->state->pen = QPen(pal.brush(foregroundRole()), 1);
+ painterPrivate->state->bgBrush = pal.brush(backgroundRole());
QFont f(font(), this);
- painter->d_func()->state->deviceFont = f;
- painter->d_func()->state->font = f;
+ painterPrivate->state->deviceFont = f;
+ painterPrivate->state->font = f;
+
+ painterPrivate->setEngineDirtyFlags({
+ QPaintEngine::DirtyPen,
+ QPaintEngine::DirtyBrush,
+ QPaintEngine::DirtyFont,
+ });
+
+ if (painterPrivate->extended)
+ painterPrivate->extended->penChanged();
}
/*!
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 737ccb0e807..622f1548756 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -591,6 +591,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
}
}
+ // Event delivery above might have destroyed this object. See QTBUG-138419.
+ if (self.isNull())
+ return;
+
if (QApplication::activePopupWidget() != activePopupWidget
&& QApplicationPrivate::replayMousePress
&& QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 220f600ea41..735b574d293 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -122,6 +122,8 @@
#include "QtGui/qevent.h"
#include <private/qapplication_p.h>
#include <private/qwidget_p.h>
+#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformwindow_p.h>
#if QT_CONFIG(lineedit)
#include "QtWidgets/qlineedit.h"
#endif
@@ -925,10 +927,15 @@ void QCompleterPrivate::showPopup(const QRect& rect)
popup->setGeometry(pos.x(), pos.y(), w, h);
if (!popup->isVisible()) {
- // Make sure popup has a transient parent set, Wayland needs it. QTBUG-130474
- popup->winId(); // force creation of windowHandle
- popup->windowHandle()->setTransientParent(widget->window()->windowHandle());
-
+#if QT_CONFIG(wayland)
+ popup->createWinId();
+ if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow*>(popup->windowHandle()->handle())) {
+ popup->windowHandle()->setTransientParent(widget->window()->windowHandle());
+ const QRect controlGeometry = QRect(widget->mapTo(widget->topLevelWidget(), QPoint(0,0)), widget->size());
+ waylandWindow->setParentControlGeometry(controlGeometry);
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::ComboBox);
+ }
+#endif
popup->show();
}
}
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 6f25b8bde67..2f51b83a49d 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -7,6 +7,9 @@
#include <qstylepainter.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformmenu.h>
+#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformwindow_p.h>
+
#include <qlineedit.h>
#include <qapplication.h>
#include <qlistview.h>
@@ -2868,6 +2871,17 @@ void QComboBox::showPopup()
container->hide();
}
}
+
+#if QT_CONFIG(wayland)
+ if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow*>(container->windowHandle()->handle())) {
+ const QRect popup(style->subControlRect(QStyle::CC_ComboBox, &opt,
+ QStyle::SC_ComboBoxListBoxPopup, this));
+ const QRect controlGeometry = QRect(mapTo(window(), popup.topLeft()), popup.size());
+ waylandWindow->setParentControlGeometry(controlGeometry);
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::ComboBox);
+ }
+#endif
+
container->show();
if (!neededHorizontalScrollBar && needHorizontalScrollBar()) {
listRect.adjust(0, 0, 0, sb->height());
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 5cda8f33f4c..7d4228709be 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -40,6 +40,8 @@
#include <private/qaction_p.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
+#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformwindow_p.h>
#include <private/qstyle_p.h>
QT_BEGIN_NAMESPACE
@@ -2535,6 +2537,23 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po
}
popupScreen = QGuiApplication::screenAt(pos);
q->setGeometry(QRect(pos, size));
+
+#if QT_CONFIG(wayland)
+ q->create();
+ if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow*>(q->windowHandle()->handle())) {
+ if (causedButton) {
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::Menu);
+ waylandWindow->setParentControlGeometry(causedButton->geometry());
+ } else if (caused) {
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::SubMenu);
+ waylandWindow->setParentControlGeometry(caused->d_func()->actionRect(caused->d_func()->currentAction));
+ } else if (auto menubar = qobject_cast<QMenuBar*>(causedPopup.widget)) {
+ waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::Menu);
+ waylandWindow->setParentControlGeometry(menubar->actionGeometry(causedPopup.action));
+ }
+ }
+#endif
+
#if QT_CONFIG(effects)
int hGuess = q->isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;