From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: OPNA2608 <opna2608@protonmail.com>
Date: Wed, 1 Jul 2026 17:38:19 +0200
Subject: [PATCH 2/4] qqc2-suru: Make ApplicationWindow & Popup
 Qt-version-specific

(cherry picked from commit 8745aee43d9612eef74b5da056742f3eb71947b5)
---
 qqc2-suru/CMakeLists.txt                      | 33 ++++++----
 qqc2-suru/{ => qml-qt5}/ApplicationWindow.qml |  0
 qqc2-suru/{ => qml-qt5}/Popup.qml             |  0
 qqc2-suru/qml-qt6/ApplicationWindow.qml       | 56 +++++++++++++++++
 qqc2-suru/qml-qt6/Popup.qml                   | 60 +++++++++++++++++++
 qqc2-suru/suru.pri                            |  4 +-
 6 files changed, 139 insertions(+), 14 deletions(-)
 rename qqc2-suru/{ => qml-qt5}/ApplicationWindow.qml (100%)
 rename qqc2-suru/{ => qml-qt5}/Popup.qml (100%)
 create mode 100644 qqc2-suru/qml-qt6/ApplicationWindow.qml
 create mode 100644 qqc2-suru/qml-qt6/Popup.qml

diff --git a/qqc2-suru/CMakeLists.txt b/qqc2-suru/CMakeLists.txt
index c41ebad..140e2df 100644
--- a/qqc2-suru/CMakeLists.txt
+++ b/qqc2-suru/CMakeLists.txt
@@ -13,8 +13,7 @@ list (APPEND QML_IMPL_QTSPECIFIC
     impl/ElevationEffect.qml
 )
 
-list (APPEND QML_MAIN
-    ApplicationWindow.qml
+list (APPEND QML_MAIN_SHARED
     BusyIndicator.qml
     Button.qml
     CheckBox.qml
@@ -35,7 +34,6 @@ list (APPEND QML_MAIN
     Page.qml
     PageIndicator.qml
     Pane.qml
-    Popup.qml
     ProgressBar.qml
     RadioButton.qml
     RadioDelegate.qml
@@ -59,6 +57,10 @@ list (APPEND QML_MAIN
     ToolTip.qml
     Tumbler.qml
 )
+list (APPEND QML_MAIN_QTSPECIFIC
+    ApplicationWindow.qml
+    Popup.qml
+)
 
 list (APPEND PLUGIN_HEADERS
     qquicksurustyle_p.h
@@ -91,17 +93,24 @@ endif()
 
 string (REPLACE "." "/" PLUGIN_IMPORT_PATH "${PLUGIN_URI}")
 
-set (QML_IMPL ${QML_IMPL_SHARED})
-foreach (QML_IMPL_QTSPECIFIC_FILE IN LISTS QML_IMPL_QTSPECIFIC)
-    # Actual location
-    set (QML_IMPL_QTSPECIFIC_PATH "qml-qt${QT_MAJOR_VERSION}/${QML_IMPL_QTSPECIFIC_FILE}")
+function (qqc2surustyle_finalise_qml_list final_qml_list)
+    set (${final_qml_list} ${${final_qml_list}_SHARED})
+
+    foreach (qtspecific_qml_file IN LISTS ${final_qml_list}_QTSPECIFIC)
+        # Actual source location
+        set (qtspecific_qml_path "qml-qt${QT_MAJOR_VERSION}/${qtspecific_qml_file}")
+
+        # Make sure qmldir file gets the name under which it will actually be installed
+        set_source_files_properties (${qtspecific_qml_path} PROPERTIES QT_RESOURCE_ALIAS ${qtspecific_qml_file})
+
+        list (APPEND ${final_qml_list} ${qtspecific_qml_path})
+    endforeach()
 
-    # Make sure qmldir file gets the name under which it will actually be installed
-    set_source_files_properties (${QML_IMPL_QTSPECIFIC_PATH} PROPERTIES QT_RESOURCE_ALIAS ${QML_IMPL_QTSPECIFIC_FILE})
+    set (${final_qml_list} ${${final_qml_list}} PARENT_SCOPE)
+endfunction()
 
-    # Add it to list of impl files
-    list (APPEND QML_IMPL ${QML_IMPL_QTSPECIFIC_PATH})
-endforeach()
+qqc2surustyle_finalise_qml_list (QML_IMPL)
+qqc2surustyle_finalise_qml_list (QML_MAIN)
 
 qt_add_qml_module(${PROJECT_NAME}
     URI ${PLUGIN_URI}
diff --git a/qqc2-suru/ApplicationWindow.qml b/qqc2-suru/qml-qt5/ApplicationWindow.qml
similarity index 100%
rename from qqc2-suru/ApplicationWindow.qml
rename to qqc2-suru/qml-qt5/ApplicationWindow.qml
diff --git a/qqc2-suru/Popup.qml b/qqc2-suru/qml-qt5/Popup.qml
similarity index 100%
rename from qqc2-suru/Popup.qml
rename to qqc2-suru/qml-qt5/Popup.qml
diff --git a/qqc2-suru/qml-qt6/ApplicationWindow.qml b/qqc2-suru/qml-qt6/ApplicationWindow.qml
new file mode 100644
index 0000000..8f65fca
--- /dev/null
+++ b/qqc2-suru/qml-qt6/ApplicationWindow.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2017, 2018 Stefano Verzegnassi <stefano@ubports.com>
+** Copyright (C) 2017 The Qt Company Ltd.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Templates 2.12 as T
+import QtQuick.Controls.Suru 2.2
+
+T.ApplicationWindow {
+    id: window
+
+    color: window.Suru.backgroundColor
+
+    overlay.modal: Rectangle {
+        color: window.Suru.overlayColor
+        Behavior on opacity { NumberAnimation { duration: window.Suru.animations.FastDuration } }
+    }
+
+    overlay.modeless: Rectangle {
+        color: window.Suru.overlayColor
+        Behavior on opacity { NumberAnimation { duration: window.Suru.animations.FastDuration } }
+    }
+
+    Rectangle {
+        parent: window.activeFocusControl
+        anchors.centerIn: parent
+        width: parent ? parent.width + (window.Suru.units.dp(4) * 2) : 0
+        height: parent ? parent.height + 8 : 0
+        visible: parent && !!parent.useSystemFocusVisuals && !!parent.visualFocus
+
+        color: "transparent"
+        border {
+            width: window.Suru.units.dp(2)
+            color: window.Suru.activeFocusColor
+        }
+    }
+}
diff --git a/qqc2-suru/qml-qt6/Popup.qml b/qqc2-suru/qml-qt6/Popup.qml
new file mode 100644
index 0000000..53e3929
--- /dev/null
+++ b/qqc2-suru/qml-qt6/Popup.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2017, 2018 Stefano Verzegnassi <stefano@ubports.com>
+** Copyright (C) 2017 The Qt Company Ltd.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Templates 2.12 as T
+import QtQuick.Controls.Suru 2.2
+import "impl"
+
+T.Popup {
+    id: control
+
+    implicitWidth: Math.max(background ? background.implicitWidth : 0,
+                            contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
+    implicitHeight: Math.max(background ? background.implicitHeight : 0,
+                             contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)
+
+    contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+    contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+
+    padding: control.Suru.units.gu(2)
+
+    enter: Transition {
+        // grow_fade_in
+        NumberAnimation { property: "scale"; from: 0.91; to: 1.0; easing: control.Suru.animations.EasingIn; duration: control.Suru.animations.FastDuration }
+        NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing: control.Suru.animations.EasingIn; duration: control.Suru.animations.FastDuration }
+    }
+
+    exit: Transition {
+        // fade_out
+        NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing: control.Suru.animations.EasingIn; duration: control.Suru.animations.FastDuration }
+    }
+
+    background: Rectangle {
+        color: control.Suru.backgroundColor
+        layer.enabled: true
+        layer.effect: ElevationEffect {
+            elevation: 3
+        }
+    }
+}
diff --git a/qqc2-suru/suru.pri b/qqc2-suru/suru.pri
index 7efdd9e..2cb9edd 100644
--- a/qqc2-suru/suru.pri
+++ b/qqc2-suru/suru.pri
@@ -2,6 +2,8 @@
 qmlfiles_qt5.base = $$PWD/qml-qt5
 qmlfiles_qt5.path = $$[QT_INSTALL_QML]/$$TARGETPATH
 qmlfiles_qt5.files = \
+    $$PWD/qml-qt5/ApplicationWindow.qml \
+    $$PWD/qml-qt5/Popup.qml \
     $$PWD/qml-qt5/impl/ElevationEffect.qml
 
 INSTALLS += qmlfiles_qt5
@@ -18,7 +20,6 @@ QML_FILES += \
 
 # Suru QtQuick Controls 2.x Style files
 QML_FILES += \
-    $$PWD/ApplicationWindow.qml \
     $$PWD/BusyIndicator.qml \
     $$PWD/Button.qml \
     $$PWD/CheckBox.qml \
@@ -39,7 +40,6 @@ QML_FILES += \
     $$PWD/Page.qml \
     $$PWD/PageIndicator.qml \
     $$PWD/Pane.qml \
-    $$PWD/Popup.qml \
     $$PWD/ProgressBar.qml \
     $$PWD/RadioButton.qml \
     $$PWD/RadioDelegate.qml \
