mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Add useragreement screen on first run of Cura
CURA-4501
This commit is contained in:
parent
fb88dd6326
commit
5db0fc7785
5 changed files with 130 additions and 0 deletions
|
@ -215,6 +215,7 @@ class CuraApplication(QtApplication):
|
|||
|
||||
self.setRequiredPlugins([
|
||||
"CuraEngineBackend",
|
||||
"UserAgreement",
|
||||
"SolidView",
|
||||
"LayerView",
|
||||
"STLReader",
|
||||
|
|
50
plugins/UserAgreementPlugin/UserAgreement.py
Normal file
50
plugins/UserAgreementPlugin/UserAgreement.py
Normal 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)
|
61
plugins/UserAgreementPlugin/UserAgreement.qml
Normal file
61
plugins/UserAgreementPlugin/UserAgreement.qml
Normal 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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
10
plugins/UserAgreementPlugin/__init__.py
Normal file
10
plugins/UserAgreementPlugin/__init__.py
Normal 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()}
|
8
plugins/UserAgreementPlugin/plugin.json
Normal file
8
plugins/UserAgreementPlugin/plugin.json
Normal 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"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue