New style more info dialog for SliceInfo

CURA-6057
This commit is contained in:
Lipu Fei 2019-04-08 14:12:03 +02:00
parent ac1b1a9902
commit 3bf8a1f257
3 changed files with 99 additions and 94 deletions

View file

@ -1,47 +1,56 @@
// Copyright (c) 2018 Ultimaker B.V. // Copyright (c) 2019 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.7 import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import UM 1.3 as UM import UM 1.3 as UM
import Cura 1.0 as Cura import Cura 1.1 as Cura
UM.Dialog Window
{ {
UM.I18nCatalog { id: catalog; name: "cura" }
id: baseDialog id: baseDialog
title: catalog.i18nc("@title:window", "More information on anonymous data collection") title: catalog.i18nc("@title:window", "More information on anonymous data collection")
visible: false visible: false
modality: Qt.ApplicationModal
minimumWidth: 500 * screenScaleFactor minimumWidth: 500 * screenScaleFactor
minimumHeight: 400 * screenScaleFactor minimumHeight: 400 * screenScaleFactor
width: minimumWidth width: minimumWidth
height: minimumHeight height: minimumHeight
property bool allowSendData: true // for saving the user's choice color: UM.Theme.getColor("main_background")
onAccepted: manager.setSendSliceInfo(allowSendData) property bool allowSendData: true // for saving the user's choice
onVisibilityChanged: onVisibilityChanged:
{ {
if (visible) if (visible)
{ {
baseDialog.allowSendData = UM.Preferences.getValue("info/send_slice_info"); baseDialog.allowSendData = UM.Preferences.getValue("info/send_slice_info")
if (baseDialog.allowSendData) if (baseDialog.allowSendData)
{ {
allowSendButton.checked = true; allowSendButton.checked = true
} }
else else
{ {
dontSendButton.checked = true; dontSendButton.checked = true
} }
} }
} }
// Main content area
Item Item
{
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
Item // Text part
{ {
id: textRow id: textRow
anchors anchors
@ -62,14 +71,13 @@ UM.Dialog
left: parent.left left: parent.left
right: parent.right right: parent.right
} }
text: catalog.i18nc("@text:window", "Cura sends anonymous data to Ultimaker in order to improve the print quality and user experience. Below is an example of all the data that is sent.") text: catalog.i18nc("@text:window", "Cura sends anonymous data to Ultimaker in order to improve the print quality and user experience. Below is an example of all the data that is sent.")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
renderType: Text.NativeRendering
} }
TextArea Cura.ScrollableTextArea
{ {
id: exampleData
anchors anchors
{ {
top: headerText.bottom top: headerText.bottom
@ -80,72 +88,68 @@ UM.Dialog
right: parent.right right: parent.right
} }
text: manager.getExampleData() textArea.text: manager.getExampleData()
readOnly: true textArea.readOnly: true
textFormat: TextEdit.PlainText
} }
} }
Column Column // Radio buttons for agree and disagree
{ {
id: radioButtonsRow id: radioButtonsRow
width: parent.width anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: buttonRow.top anchors.bottom: buttonRow.top
anchors.bottomMargin: UM.Theme.getSize("default_margin").height anchors.bottomMargin: UM.Theme.getSize("default_margin").height
ExclusiveGroup { id: group } Cura.RadioButton
RadioButton
{ {
id: dontSendButton id: dontSendButton
text: catalog.i18nc("@text:window", "I don't want to send this data") text: catalog.i18nc("@text:window", "I don't want to send this data")
exclusiveGroup: group
onClicked: onClicked:
{ {
baseDialog.allowSendData = !checked; baseDialog.allowSendData = !checked
} }
} }
RadioButton Cura.RadioButton
{ {
id: allowSendButton id: allowSendButton
text: catalog.i18nc("@text:window", "Allow sending this data to Ultimaker and help us improve Cura") text: catalog.i18nc("@text:window", "Allow sending this data to Ultimaker and help us improve Cura")
exclusiveGroup: group
onClicked: onClicked:
{ {
baseDialog.allowSendData = checked; baseDialog.allowSendData = checked
} }
} }
} }
Item Item // Bottom buttons
{ {
id: buttonRow id: buttonRow
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: parent.width anchors.left: parent.left
anchors.bottomMargin: UM.Theme.getSize("default_margin").height anchors.right: parent.right
UM.I18nCatalog { id: catalog; name: "cura" } height: childrenRect.height
Button Cura.PrimaryButton
{ {
anchors.right: parent.right anchors.right: parent.right
text: catalog.i18nc("@action:button", "OK") text: catalog.i18nc("@action:button", "OK")
onClicked: onClicked:
{ {
baseDialog.accepted() manager.setSendSliceInfo(allowSendData)
baseDialog.hide() baseDialog.hide()
} }
} }
Button Cura.SecondaryButton
{ {
anchors.left: parent.left anchors.left: parent.left
text: catalog.i18nc("@action:button", "Cancel") text: catalog.i18nc("@action:button", "Cancel")
onClicked: onClicked:
{ {
baseDialog.rejected()
baseDialog.hide() baseDialog.hide()
} }
} }
} }
}
} }

View file

@ -62,7 +62,7 @@ class SliceInfo(QObject, Extension):
def showMoreInfoDialog(self): def showMoreInfoDialog(self):
if self._more_info_dialog is None: if self._more_info_dialog is None:
self._more_info_dialog = self._createDialog("MoreInfoWindow.qml") self._more_info_dialog = self._createDialog("MoreInfoWindow.qml")
self._more_info_dialog.open() self._more_info_dialog.show()
def _createDialog(self, qml_name): def _createDialog(self, qml_name):
Logger.log("d", "Creating dialog [%s]", qml_name) Logger.log("d", "Creating dialog [%s]", qml_name)

View file

@ -21,6 +21,7 @@ ScrollView
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
textFormat: TextEdit.PlainText textFormat: TextEdit.PlainText
renderType: Text.NativeRendering renderType: Text.NativeRendering
selectByMouse: true
background: Rectangle // Border background: Rectangle // Border
{ {