Browse Source

Cura about dialog when shaked gives extra info

CURA-10770
saumya.jain 1 year ago
parent
commit
0c7d0540b9
4 changed files with 129 additions and 2 deletions
  1. 1 0
      .gitignore
  2. 61 0
      AboutDialogVersionsList.qml.jinja
  3. 24 0
      conanfile.py
  4. 43 2
      resources/qml/Dialogs/AboutDialog.qml

+ 1 - 0
.gitignore

@@ -101,3 +101,4 @@ graph_info.json
 Ultimaker-Cura.spec
 .run/
 /printer-linter/src/printerlinter.egg-info/
+/resources/qml/Dialogs/AboutDialogVersionsList.qml

+ 61 - 0
AboutDialogVersionsList.qml.jinja

@@ -0,0 +1,61 @@
+import QtQuick 2.2
+import QtQuick.Controls 2.9
+
+import UM 1.6 as UM
+import Cura 1.5 as Cura
+
+
+ListView
+{
+    id: projectBuildInfoList
+    visible: false
+    anchors.top: creditsNotes.bottom
+    anchors.topMargin: UM.Theme.getSize("default_margin").height
+    width: parent.width
+    height: base.height - y - (2 * UM.Theme.getSize("default_margin").height + closeButton.height)
+
+    ScrollBar.vertical: UM.ScrollBar
+    {
+        id: projectBuildInfoListScrollBar
+    }
+
+    delegate: Row
+    {
+        spacing: UM.Theme.getSize("narrow_margin").width
+        UM.Label
+        {
+            text: (model.name)
+            width: (projectBuildInfoList.width* 0.4) | 0
+            elide: Text.ElideRight
+        }
+        UM.Label
+        {
+            text: (model.version)
+            width: (projectBuildInfoList.width *0.6) | 0
+            elide: Text.ElideRight
+        }
+
+    }
+    model: ListModel
+    {
+        id: developerInfo
+    }
+    Component.onCompleted:
+    {
+        var conan_installs = {{ conan_installs }};
+        var python_installs = {{ python_installs }};
+        developerInfo.append({ name : "<H1>Conan Installs</H1>", version : '' });
+        for (var n in conan_installs)
+        {
+            developerInfo.append({ name : conan_installs[n][0], version : conan_installs[n][1] });
+        }
+        developerInfo.append({ name : '', version : '' });
+        developerInfo.append({ name : "<H1>Python Installs</H1>", version : '' });
+        for (var n in python_installs)
+        {
+            developerInfo.append({ name : python_installs[n][0], version : python_installs[n][1] });
+        }
+
+    }
+}
+

+ 24 - 0
conanfile.py

@@ -138,6 +138,29 @@ class CuraConan(ConanFile):
             return "'x86_64'"
         return "None"
 
+    def _generate_about_versions(self, location):
+        with open(os.path.join(self.recipe_folder, "AboutDialogVersionsList.qml.jinja"), "r") as f:
+            cura_version_py = Template(f.read())
+
+        conan_installs = []
+        python_installs = []
+
+        # list  of conan installs
+        for _, dependency in self.dependencies.host.items():
+            conan_installs.append([dependency.ref.name,dependency.ref.version])
+
+        #list of python installs
+        import pkg_resources
+        for package in pkg_resources.working_set:
+            python_installs.append([package.key, package.version])
+
+        with open(os.path.join(location, "AboutDialogVersionsList.qml"), "w") as f:
+            f.write(cura_version_py.render(
+                conan_installs = conan_installs,
+                python_installs = python_installs
+            ))
+
+
     def _generate_cura_version(self, location):
         with open(os.path.join(self.recipe_folder, "CuraVersion.py.jinja"), "r") as f:
             cura_version_py = Template(f.read())
@@ -307,6 +330,7 @@ class CuraConan(ConanFile):
         vr.generate()
 
         self._generate_cura_version(os.path.join(self.source_folder, "cura"))
+        self._generate_about_versions(os.path.join(self.source_folder, "resources/qml/Dialogs"))
 
         if self.options.devtools:
             entitlements_file = "'{}'".format(os.path.join(self.source_folder, "packaging", "MacOS", "cura.entitlements"))

+ 43 - 2
resources/qml/Dialogs/AboutDialog.qml

@@ -1,10 +1,10 @@
 // Copyright (c) 2022 UltiMaker
 // Cura is released under the terms of the LGPLv3 or higher.
 
-import QtQuick 2.2
+import QtQuick 2.4
 import QtQuick.Controls 2.9
 
-import UM 1.5 as UM
+import UM 1.6 as UM
 import Cura 1.5 as Cura
 
 UM.Dialog
@@ -21,6 +21,22 @@ UM.Dialog
 
     backgroundColor: UM.Theme.getColor("main_background")
 
+    property real dialogX: base.x
+    property real dialogY: base.y
+    property int shakeDetected: (shakeDetector.shakeIsdetected)
+    property  UM.ShakeDetector shakeDetector: UM.ShakeDetector{    }
+
+    readonly property Timer timer : Timer
+    {
+        interval: 100 // Update interval in milliseconds (adjust as needed)
+        running: onDialogXChanged || onDialogYChanged
+        repeat: true
+        onTriggered:
+        {
+            shakeDetector.checkForShake(dialogX, dialogY)
+        }
+    }
+
     Rectangle
     {
         id: header
@@ -181,6 +197,31 @@ UM.Dialog
         }
     }
 
+    AboutDialogVersionsList{
+        id: projectBuildInfoList
+
+    }
+
+    onShakeDetectedChanged:
+    {
+        if (!projectBuildInfoList.visible)
+        {
+            projectsList.visible= false;
+            projectBuildInfoList.visible = true;
+        }
+        else
+        {
+            projectsList.visible = true;
+            projectBuildInfoList.visible = false;
+        }
+    }
+
+    onVisibleChanged:
+    {
+         projectsList.visible = true;
+         projectBuildInfoList.visible = false;
+    }
+
     rightButtons: Cura.TertiaryButton
     {
         //: Close about dialog button