mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Refactor and cleanup
CURA-4501
This commit is contained in:
parent
910386eaf7
commit
8bfd10f9aa
2 changed files with 22 additions and 15 deletions
|
@ -7,6 +7,8 @@ from UM.Application import Application
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
||||||
from PyQt5.QtCore import QUrl, QObject, pyqtSlot
|
from PyQt5.QtCore import QUrl, QObject, pyqtSlot
|
||||||
|
|
||||||
|
@ -31,15 +33,17 @@ class UserAgreement(Extension, QObject):
|
||||||
|
|
||||||
self._user_agreement_window.show()
|
self._user_agreement_window.show()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot(bool)
|
||||||
def disagreed(self):
|
def didAgree(self, userChoice):
|
||||||
Logger.log("i", "User did NOT Accept the license")
|
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):
|
def createUserAgreementWindow(self):
|
||||||
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "UserAgreement.qml"))
|
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)
|
component = QQmlComponent(Application.getInstance()._engine, path)
|
||||||
self._user_agreement_context = QQmlContext(Application.getInstance()._engine.rootContext())
|
self._user_agreement_context = QQmlContext(Application.getInstance()._engine.rootContext())
|
||||||
self._user_agreement_context.setContextProperty("manager", self)
|
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.
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// 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.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
|
UM.Dialog
|
||||||
{
|
{
|
||||||
|
@ -43,7 +41,7 @@ UM.Dialog
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
text: "I understand and agree"
|
text: "I understand and agree"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
manager.agreed
|
manager.didAgree(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +50,15 @@ UM.Dialog
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
text: "I don't agree"
|
text: "I don't agree"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
manager.disagreed
|
manager.didAgree(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClosing: {
|
||||||
|
manager.didAgree(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue