fix: qt6 9 support (#1973)

* Fix qt 6.9 support

* add support android sdk 36

* feat: add support SafeMargins from Android

* Fix black screen

---------

Co-authored-by: NickVs2015 <nv@amnezia.org>
This commit is contained in:
vkamn
2025-11-04 11:43:36 +08:00
committed by GitHub
parent aaf0e070dc
commit 741b5cc0f9
61 changed files with 255 additions and 68 deletions

View File

@@ -431,6 +431,63 @@ bool SettingsController::isOnTv()
#endif
}
bool SettingsController::isEdgeToEdgeEnabled()
{
#ifdef Q_OS_ANDROID
return AndroidController::instance()->isEdgeToEdgeEnabled();
#else
return false;
#endif
}
int SettingsController::getStatusBarHeight()
{
#ifdef Q_OS_ANDROID
if (m_cachedStatusBarHeight < 0) {
m_cachedStatusBarHeight = AndroidController::instance()->getStatusBarHeight();
}
return m_cachedStatusBarHeight;
#else
return 0;
#endif
}
int SettingsController::getNavigationBarHeight()
{
#ifdef Q_OS_ANDROID
if (m_cachedNavigationBarHeight < 0) {
m_cachedNavigationBarHeight = AndroidController::instance()->getNavigationBarHeight();
}
return m_cachedNavigationBarHeight;
#else
return 0;
#endif
}
int SettingsController::getSafeAreaTopMargin()
{
#ifdef Q_OS_ANDROID
if (isEdgeToEdgeEnabled()) {
int height = getStatusBarHeight();
int result = height > 0 ? height : 40; // fallback to 40 if system returns 0
return result;
}
#endif
return 0;
}
int SettingsController::getSafeAreaBottomMargin()
{
#ifdef Q_OS_ANDROID
if (isEdgeToEdgeEnabled()) {
int height = getNavigationBarHeight();
int result = height > 0 ? height : 56; // fallback to 56 if system returns 0
return result;
}
#endif
return 0;
}
bool SettingsController::isHomeAdLabelVisible()
{
return m_settings->isHomeAdLabelVisible();

View File

@@ -33,6 +33,8 @@ public:
Q_PROPERTY(bool isHomeAdLabelVisible READ isHomeAdLabelVisible NOTIFY isHomeAdLabelVisibleChanged)
Q_PROPERTY(bool startMinimized READ isStartMinimizedEnabled NOTIFY startMinimizedChanged)
Q_PROPERTY(int safeAreaTopMargin READ getSafeAreaTopMargin CONSTANT)
Q_PROPERTY(int safeAreaBottomMargin READ getSafeAreaBottomMargin CONSTANT)
public slots:
void toggleAmneziaDns(bool enable);
@@ -96,6 +98,11 @@ public slots:
void toggleDevGatewayEnv(bool enabled);
bool isOnTv();
bool isEdgeToEdgeEnabled();
int getStatusBarHeight();
int getNavigationBarHeight();
int getSafeAreaTopMargin();
int getSafeAreaBottomMargin();
bool isHomeAdLabelVisible();
void disableHomeAdLabel();
@@ -134,6 +141,9 @@ private:
QSharedPointer<LanguageModel> m_languageModel;
QSharedPointer<SitesModel> m_sitesModel;
QSharedPointer<AppSplitTunnelingModel> m_appSplitTunnelingModel;
mutable int m_cachedStatusBarHeight = -1;
mutable int m_cachedNavigationBarHeight = -1;
std::shared_ptr<Settings> m_settings;
QString m_appVersion;

View File

@@ -32,7 +32,7 @@ DrawerType2 {
spacing: 8
onImplicitHeightChanged: {
root.expandedHeight = content.implicitHeight + 32
root.expandedHeight = content.implicitHeight + 32 + SettingsController.safeAreaBottomMargin
}
Header2TextType {

View File

@@ -15,7 +15,7 @@ Popup {
leftMargin: 25
rightMargin: 25
bottomMargin: 70
bottomMargin: 70 + SettingsController.safeAreaBottomMargin
width: parent.width - leftMargin - rightMargin

View File

@@ -68,7 +68,7 @@ PageType {
objectName: "homeColumnLayout"
anchors.fill: parent
anchors.topMargin: 12
anchors.topMargin: 12 + SettingsController.safeAreaTopMargin
anchors.bottomMargin: 16
BasicButtonType {

View File

@@ -25,7 +25,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -23,7 +23,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -25,7 +25,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -23,7 +23,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -30,7 +30,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -31,7 +31,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -31,7 +31,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -38,7 +38,7 @@ PageType {
BaseHeaderType {
id: header
Layout.fillWidth: true
Layout.topMargin: 24
Layout.topMargin: 24 + SettingsController.safeAreaTopMargin
Layout.bottomMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16

View File

@@ -20,7 +20,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -23,7 +23,7 @@ PageType {
id: listView
anchors.fill: parent
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
anchors.bottomMargin: 24
model: ApiDevicesModel

View File

@@ -79,7 +79,7 @@ PageType {
id: listView
anchors.fill: parent
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
anchors.bottomMargin: 24
model: instructionsModel

View File

@@ -28,7 +28,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -93,7 +93,7 @@ PageType {
id: backButton
objectName: "backButton"
Layout.topMargin: 20
Layout.topMargin: 20 + SettingsController.safeAreaTopMargin
}
HeaderTypeWithButton {

View File

@@ -59,7 +59,7 @@ PageType {
id: listView
anchors.fill: parent
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
anchors.bottomMargin: 24
model: supportModel

View File

@@ -74,7 +74,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
BackButtonType {
id: backButton
@@ -216,7 +216,7 @@ PageType {
Rectangle {
anchors.fill: addAppButton
anchors.bottomMargin: -24
anchors.bottomMargin: -24 - SettingsController.safeAreaBottomMargin
color: AmneziaStyle.color.midnightBlack
opacity: 0.8
}
@@ -232,7 +232,7 @@ PageType {
anchors.topMargin: 24
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.bottomMargin: 24
anchors.bottomMargin: 24 + SettingsController.safeAreaBottomMargin
TextFieldWithHeaderType {
id: searchField

View File

@@ -20,7 +20,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -40,7 +40,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -20,7 +20,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -20,7 +20,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -17,7 +17,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
}
FlickableType {

View File

@@ -30,7 +30,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
BackButtonType {
id: backButton

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -34,7 +34,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
}
FlickableType {

View File

@@ -19,7 +19,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
BackButtonType {
id: backButton

View File

@@ -62,7 +62,7 @@ PageType {
objectName: "mainLayout"
anchors.fill: parent
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
spacing: 4

View File

@@ -27,7 +27,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -25,7 +25,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
BackButtonType {
id: backButton

View File

@@ -88,7 +88,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
BackButtonType {
id: backButton

View File

@@ -21,7 +21,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
Layout.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -41,7 +41,7 @@ PageType {
property bool isVisible: SettingsController.getInstallationUuid() !== "" || PageController.isStartPageVisible()
Layout.fillWidth: true
Layout.topMargin: 24
Layout.topMargin: 24 + SettingsController.safeAreaTopMargin
Layout.rightMargin: 16
Layout.leftMargin: 16

View File

@@ -19,7 +19,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -40,7 +40,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -35,7 +35,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -41,7 +41,7 @@ PageType {
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -19,7 +19,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -22,7 +22,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {

View File

@@ -173,7 +173,7 @@ PageType {
HeaderTypeWithButton {
id: header
Layout.fillWidth: true
Layout.topMargin: 24
Layout.topMargin: 24 + SettingsController.safeAreaTopMargin
headerText: qsTr("Share VPN Access")

View File

@@ -47,7 +47,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
}
Text {
@@ -55,7 +55,7 @@ PageType {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
anchors.leftMargin: 16
anchors.rightMargin: 16

View File

@@ -25,7 +25,7 @@ PageType {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
onFocusChanged: {
if (this.activeFocus) {

View File

@@ -306,7 +306,7 @@ PageType {
anchors.bottom: parent.bottom
topPadding: 8
bottomPadding: 8
bottomPadding: 8 + SettingsController.safeAreaBottomMargin
leftPadding: 96
rightPadding: 96

View File

@@ -16,6 +16,26 @@ Window {
id: root
objectName: "mainWindow"
Connections {
target: Qt.application
function onStateChanged() {
if (Qt.platform.os === "android" && Qt.application.state === Qt.ApplicationActive) {
refreshTimer.restart()
}
}
}
Timer {
id: refreshTimer
interval: 150
repeat: false
onTriggered: {
if (Qt.platform.os === "android" && SettingsController.isEdgeToEdgeEnabled()) {
console.log("QML: Application resumed with edge-to-edge")
}
}
}
visible: true
width: GC.screenWidth
height: GC.screenHeight
@@ -111,7 +131,6 @@ Window {
PageStart {
objectName: "pageStart"
width: root.width
height: root.height
}
@@ -164,7 +183,7 @@ Window {
id: privateKeyPassphraseDrawer
anchors.fill: parent
expandedHeight: root.height * 0.35
expandedHeight: root.height * 0.35 + SettingsController.safeAreaBottomMargin
expandedStateContent: ColumnLayout {
anchors.top: parent.top