Browse Source

Add useragreement screen on first run of Cura
CURA-4501

Mark 7 years ago
parent
commit
5db0fc7785

+ 1 - 0
cura/CuraApplication.py

@@ -215,6 +215,7 @@ class CuraApplication(QtApplication):
 
         self.setRequiredPlugins([
             "CuraEngineBackend",
+            "UserAgreement",
             "SolidView",
             "LayerView",
             "STLReader",

+ 50 - 0
plugins/UserAgreementPlugin/UserAgreement.py

@@ -0,0 +1,50 @@
+# Copyright (c) 2015 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from UM.Extension import Extension
+from UM.Preferences import Preferences
+from UM.Application import Application
+from UM.PluginRegistry import PluginRegistry
+from UM.Logger import Logger
+
+from PyQt5.QtQml import QQmlComponent, QQmlContext
+from PyQt5.QtCore import QUrl, QObject, pyqtSlot
+
+import os.path
+
+class UserAgreement(Extension, QObject):
+    def __init__(self, parent = None):
+        QObject.__init__(self, parent)
+        Extension.__init__(self)
+        self._user_agreement_window = None
+        self._user_agreement_context = None
+        Application.getInstance().engineCreatedSignal.connect(self._onEngineCreated)
+        Preferences.getInstance().addPreference("general/accepted_user_agreement", False)
+
+    def _onEngineCreated(self):
+        if not Preferences.getInstance().getValue("general/accepted_user_agreement"):
+            self.showUserAgreement()
+
+    def showUserAgreement(self):
+        if not self._user_agreement_window:
+            self.createUserAgreementWindow()
+
+        self._user_agreement_window.show()
+
+    @pyqtSlot()
+    def disagreed(self):
+        Logger.log("i", "User did NOT Accept the license")
+
+    @pyqtSlot()
+    def agreed(self):
+        Logger.log("i", "User Accepted the license")
+        Preferences.getInstance().setValue("general/accepted_user_agreement", True)
+        self._user_agreement_window.hide()
+
+    def createUserAgreementWindow(self):
+        path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "UserAgreement.qml"))
+
+        component = QQmlComponent(Application.getInstance()._engine, path)
+        self._user_agreement_context = QQmlContext(Application.getInstance()._engine.rootContext())
+        self._user_agreement_context.setContextProperty("manager", self)
+        self._user_agreement_window = component.create(self._user_agreement_context)

+ 61 - 0
plugins/UserAgreementPlugin/UserAgreement.qml

@@ -0,0 +1,61 @@
+// Copyright (c) 2015 Ultimaker B.V.
+// Cura is released under the terms of the LGPLv3 or higher.
+
+import QtQuick 2.1
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import QtQuick.Window 2.1
+
+import UM 1.1 as UM
+
+UM.Dialog
+{
+    id: baseDialog
+    minimumWidth: Math.floor(UM.Theme.getSize("modal_window_minimum").width * 0.75)
+    minimumHeight: Math.floor(UM.Theme.getSize("modal_window_minimum").height * 0.5)
+    width: minimumWidth
+    height: minimumHeight
+    title: "User Agreement"
+
+    TextArea
+    {
+        anchors.top: parent.top
+        width: parent.width
+        anchors.bottom: buttonRow.top
+        text: ' <center><h3>DISCLAIMER BY ULTIMAKER</h3></center>
+                <p>PLEASE READ THIS DISCLAIMER CAREFULLY.</p>
+                <p>EXCEPT WHEN OTHERWISE STATED IN WRITING, ULTIMAKER PROVIDES ANY ULTIMAKER SOFTWARE OR THIRD PARTY SOFTWARE “AS IS” WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF ULTIMAKER SOFTWARE IS WITH YOU.</p>
+                <p>UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, IN NO EVENT WILL ULTIMAKER BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE ANY ULTIMAKER SOFTWARE OR THIRD PARTY SOFTWARE.</p>
+                '
+        readOnly: true;
+        textFormat: TextEdit.RichText
+    }
+
+    Item
+    {
+        id: buttonRow
+        anchors.bottom: parent.bottom
+        width: parent.width
+        anchors.bottomMargin: UM.Theme.getSize("default_margin").height
+
+        Button
+        {
+            anchors.right: parent.right
+            text: "I understand and agree"
+            onClicked: {
+                manager.agreed
+            }
+        }
+
+        Button
+        {
+            anchors.left: parent.left
+            text: "I don't agree"
+            onClicked: {
+                manager.disagreed
+            }
+        }
+
+    }
+
+}

+ 10 - 0
plugins/UserAgreementPlugin/__init__.py

@@ -0,0 +1,10 @@
+# Copyright (c) 2015 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from . import UserAgreement
+
+def getMetaData():
+    return {}
+
+def register(app):
+    return {"extension": UserAgreement.UserAgreement()}

+ 8 - 0
plugins/UserAgreementPlugin/plugin.json

@@ -0,0 +1,8 @@
+{
+    "name": "UserAgreement",
+    "author": "Ultimaker B.V.",
+    "version": "1.0.0",
+    "description": "Ask the user once if he/she agrees with our license",
+    "api": 4,
+    "i18n-catalog": "cura"
+}