Add useragreement screen on first run of Cura

CURA-4501
This commit is contained in:
Mark 2017-10-28 15:43:01 +02:00
parent fb88dd6326
commit 5db0fc7785
5 changed files with 130 additions and 0 deletions

View file

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

View file

@ -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)

View file

@ -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
}
}
}
}

View file

@ -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()}

View file

@ -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"
}