Refactor and cleanup

CURA-4501
This commit is contained in:
Mark 2017-10-28 20:29:26 +02:00
parent 910386eaf7
commit 8bfd10f9aa
2 changed files with 22 additions and 15 deletions

View file

@ -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()
def agreed(self):
Logger.log("i", "User Accepted 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()
def createUserAgreementWindow(self):
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "UserAgreement.qml"))

View file

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