mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Move page index logic into WelcomePagesModel
This commit is contained in:
parent
d52f9600b1
commit
92d95a1c00
7 changed files with 122 additions and 62 deletions
|
|
@ -145,7 +145,7 @@ Item
|
|||
const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem
|
||||
Cura.MachineManager.addMachine(localPrinterItem.id)
|
||||
|
||||
base.goToPage("machine_actions")
|
||||
base.showNextPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ Item
|
|||
text: catalog.i18nc("@button", "Cancel")
|
||||
width: UM.Theme.getSize("action_button").width
|
||||
fixedWidthMode: true
|
||||
onClicked: base.goToPage("add_network_or_local_printer")
|
||||
onClicked: base.showPreviousPage()
|
||||
}
|
||||
|
||||
Cura.PrimaryButton
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ Item
|
|||
{
|
||||
if (visible)
|
||||
{
|
||||
// Reset the action to start from the beginning when it is shown.
|
||||
currentActionIndex = 0
|
||||
if (!hasActions)
|
||||
{
|
||||
|
|
@ -48,7 +49,7 @@ Item
|
|||
anchors.topMargin: UM.Theme.getSize("welcome_pages_default_margin").height
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: currentActionItem.title
|
||||
text: currentActionItem == null ? "" : currentActionItem.title
|
||||
color: UM.Theme.getColor("primary_button")
|
||||
font: UM.Theme.getFont("large_bold")
|
||||
renderType: Text.NativeRendering
|
||||
|
|
|
|||
|
|
@ -21,70 +21,30 @@ Item
|
|||
property int stepBarHeight: 12
|
||||
property int contentMargins: 1
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
// Call the corresponding functions in the model
|
||||
onShowNextPage: model.goToNextPage()
|
||||
onShowPreviousPage: model.goToPreviousPage()
|
||||
onGoToPage: model.goToPage(page_id)
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
base.currentStep = 0
|
||||
base.currentItem = base.model.getItem(base.currentStep)
|
||||
model.resetState()
|
||||
}
|
||||
}
|
||||
|
||||
onModelChanged:
|
||||
{
|
||||
base.currentStep = 0
|
||||
}
|
||||
onModelChanged: model.resetState()
|
||||
|
||||
// Panel background
|
||||
Rectangle
|
||||
|
|
@ -137,6 +97,6 @@ Item
|
|||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
source: base.currentItem.page_url
|
||||
source: base.pageUrl
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,12 @@ import UM 1.3 as UM
|
|||
import Cura 1.1 as Cura
|
||||
|
||||
|
||||
//
|
||||
// This is a no-frame dialog that shows the welcome process.
|
||||
//
|
||||
Window
|
||||
{
|
||||
id: dialog
|
||||
UM.I18nCatalog { id: catalog; name: "cura" }
|
||||
|
||||
title: catalog.i18nc("@title", "Welcome to Ultimaker Cura")
|
||||
|
|
@ -21,19 +25,18 @@ Window
|
|||
height: 600 // TODO
|
||||
color: "transparent"
|
||||
|
||||
property alias currentStep: stepPanel.currentStep
|
||||
property var model: CuraApplication.getWelcomePagesModel()
|
||||
|
||||
StepPanel
|
||||
{
|
||||
id: stepPanel
|
||||
currentStep: 0
|
||||
model: CuraApplication.getWelcomePagesModel()
|
||||
model: dialog.model
|
||||
}
|
||||
|
||||
// Close this dialog when there's no more page to show
|
||||
Connections
|
||||
{
|
||||
target: stepPanel
|
||||
onPassLastPage: close()
|
||||
target: model
|
||||
onAllFinished: close()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue