mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 21:44:01 -06:00
Move page index logic into WelcomePagesModel
This commit is contained in:
parent
20bd9ea501
commit
418ad73a63
5 changed files with 126 additions and 73 deletions
|
@ -247,7 +247,7 @@ Item
|
|||
text: catalog.i18nc("@button", "Cancel")
|
||||
width: UM.Theme.getSize("action_button").width
|
||||
fixedWidthMode: true
|
||||
onClicked: base.goToPage("add_printer_by_selection")
|
||||
onClicked: base.showPreviousPage()
|
||||
}
|
||||
|
||||
Cura.PrimaryButton
|
||||
|
|
|
@ -14,6 +14,7 @@ Window
|
|||
{
|
||||
UM.I18nCatalog { id: catalog; name: "cura" }
|
||||
|
||||
id: dialog
|
||||
title: catalog.i18nc("@title", "Welcome to Ultimaker Cura")
|
||||
modality: Qt.ApplicationModal
|
||||
flags: Qt.Window | Qt.FramelessWindowHint
|
||||
|
@ -24,14 +25,21 @@ Window
|
|||
|
||||
property int shadowOffset: 1 * screenScaleFactor
|
||||
|
||||
property alias currentStep: stepPanel.currentStep
|
||||
property var model: CuraApplication.getWelcomePagesModel()
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
model.resetState()
|
||||
}
|
||||
}
|
||||
|
||||
WizardPanel
|
||||
{
|
||||
id: stepPanel
|
||||
anchors.fill: parent
|
||||
currentStep: 0
|
||||
model: CuraApplication.getWelcomePagesModel()
|
||||
model: dialog.model
|
||||
}
|
||||
|
||||
// Drop shadow around the panel
|
||||
|
@ -50,7 +58,7 @@ Window
|
|||
// Close this dialog when there's no more page to show
|
||||
Connections
|
||||
{
|
||||
target: stepPanel
|
||||
onPassLastPage: close()
|
||||
target: model
|
||||
onAllFinished: close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,70 +20,21 @@ Item
|
|||
|
||||
clip: true
|
||||
|
||||
property int currentStep: 0
|
||||
property int totalStepCount: (model == null) ? 0 : model.count
|
||||
property real progressValue: (totalStepCount == 0) ? 0 : (currentStep / totalStepCount)
|
||||
|
||||
property var currentItem: (model == null) ? null : model.getItem(currentStep)
|
||||
property var currentItem: (model == null) ? null : model.getItem(model.currentPageIndex)
|
||||
property var model: null
|
||||
|
||||
// Convenience properties
|
||||
property var progressValue: model == null ? 0 : model.currentProgress
|
||||
property string pageUrl: currentItem == null ? null : currentItem.page_url
|
||||
|
||||
signal showNextPage()
|
||||
signal showPreviousPage()
|
||||
signal passLastPage() // Emitted when there is no more page to show
|
||||
signal goToPage(string page_id) // Go to a specific page by the given page_id.
|
||||
|
||||
onShowNextPage:
|
||||
{
|
||||
if (currentStep < totalStepCount - 1)
|
||||
{
|
||||
currentStep++
|
||||
}
|
||||
else
|
||||
{
|
||||
passLastPage()
|
||||
}
|
||||
}
|
||||
|
||||
onShowPreviousPage:
|
||||
{
|
||||
if (currentStep > 0)
|
||||
{
|
||||
currentStep--
|
||||
}
|
||||
}
|
||||
|
||||
onGoToPage:
|
||||
{
|
||||
// find the page index
|
||||
var page_index = -1
|
||||
for (var i = 0; i < base.model.count; i++)
|
||||
{
|
||||
const item = base.model.getItem(i)
|
||||
if (item.id == page_id)
|
||||
{
|
||||
page_index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if (page_index > 0)
|
||||
{
|
||||
currentStep = page_index
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
base.currentStep = 0
|
||||
base.currentItem = base.model.getItem(base.currentStep)
|
||||
}
|
||||
}
|
||||
|
||||
onModelChanged:
|
||||
{
|
||||
base.currentStep = 0
|
||||
}
|
||||
// Call the corresponding functions in the model
|
||||
onShowNextPage: model.goToNextPage()
|
||||
onShowPreviousPage: model.goToPreviousPage()
|
||||
onGoToPage: model.goToPage(page_id)
|
||||
|
||||
Rectangle // Panel background
|
||||
{
|
||||
|
@ -108,13 +59,13 @@ Item
|
|||
id: contentLoader
|
||||
anchors
|
||||
{
|
||||
margins: base.contentMargins
|
||||
margins: UM.Theme.getSize("default_margin").width
|
||||
top: progressBar.bottom
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
source: base.currentItem.page_url
|
||||
source: base.pageUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue