mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-30 05:15:13 +08:00
Refactor and cleanup
CURA-4501
This commit is contained in:
parent
b45e44b388
commit
9aebb395ab
@ -7,6 +7,8 @@ from UM.Application import Application
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
from UM.Logger import Logger
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
||||
from PyQt5.QtCore import QUrl, QObject, pyqtSlot
|
||||
|
||||
@ -31,15 +33,17 @@ class UserAgreement(Extension, QObject):
|
||||
|
||||
self._user_agreement_window.show()
|
||||
|
||||
@pyqtSlot()
|
||||
def disagreed(self):
|
||||
Logger.log("i", "User did NOT Accept the license")
|
||||
@pyqtSlot(bool)
|
||||
def didAgree(self, userChoice):
|
||||
if userChoice:
|
||||
Logger.log("i", 'User agreed to the user agreement')
|
||||
Preferences.getInstance().setValue("general/accepted_user_agreement", True)
|
||||
self._user_agreement_window.hide()
|
||||
else:
|
||||
Logger.log("i", 'User did NOT agree to the user agreement')
|
||||
Preferences.getInstance().setValue("general/accepted_user_agreement", False)
|
||||
CuraApplication.getInstance().quit()
|
||||
|
||||
@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"))
|
||||
@ -47,4 +51,4 @@ class UserAgreement(Extension, QObject):
|
||||
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)
|
||||
self._user_agreement_window = component.create(self._user_agreement_context)
|
@ -1,12 +1,10 @@
|
||||
// Copyright (c) 2015 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.1
|
||||
|
||||
import UM 1.1 as UM
|
||||
import UM 1.3 as UM
|
||||
|
||||
UM.Dialog
|
||||
{
|
||||
@ -43,7 +41,7 @@ UM.Dialog
|
||||
anchors.right: parent.right
|
||||
text: "I understand and agree"
|
||||
onClicked: {
|
||||
manager.agreed
|
||||
manager.didAgree(true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,10 +50,15 @@ UM.Dialog
|
||||
anchors.left: parent.left
|
||||
text: "I don't agree"
|
||||
onClicked: {
|
||||
manager.disagreed
|
||||
manager.didAgree(false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onClosing: {
|
||||
manager.didAgree(false)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user