mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
WIP: Add gotoPage
This commit is contained in:
parent
53ea944da1
commit
cc35eb0195
5 changed files with 42 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from PyQt5.QtCore import QUrl, Qt
|
||||
from PyQt5.QtCore import QUrl, Qt, pyqtSlot
|
||||
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Resources import Resources
|
||||
|
@ -11,6 +11,7 @@ from UM.Resources import Resources
|
|||
if TYPE_CHECKING:
|
||||
from PyQt5.QtCore import QObject
|
||||
|
||||
|
||||
class WelcomePagesModel(ListModel):
|
||||
|
||||
IdRole = Qt.UserRole + 1 # Page ID
|
||||
|
|
|
@ -23,6 +23,9 @@ Item
|
|||
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
||||
property var selectedItem: networkPrinterListView.model[networkPrinterListView.currentIndex]
|
||||
|
||||
signal refreshButtonClicked()
|
||||
signal addByIpButtonClicked()
|
||||
|
||||
ScrollView
|
||||
{
|
||||
id: networkPrinterScrollView
|
||||
|
@ -87,6 +90,7 @@ Item
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: catalog.i18nc("@label", "Refresh")
|
||||
height: UM.Theme.getSize("message_action_button").height
|
||||
onClicked: base.refreshButtonClicked()
|
||||
}
|
||||
|
||||
Cura.SecondaryButton
|
||||
|
@ -97,6 +101,7 @@ Item
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: catalog.i18nc("@label", "Add printer by IP")
|
||||
height: UM.Theme.getSize("message_action_button").height
|
||||
onClicked: base.addByIpButtonClicked()
|
||||
}
|
||||
|
||||
Item
|
||||
|
|
|
@ -223,7 +223,7 @@ Item
|
|||
text: catalog.i18nc("@button", "Back")
|
||||
width: 140
|
||||
fixedWidthMode: true
|
||||
onClicked: base.showPreviousPage()
|
||||
onClicked: base.gotoPage("add_printer_by_selection")
|
||||
|
||||
enabled: true
|
||||
}
|
||||
|
|
|
@ -58,6 +58,16 @@ Item
|
|||
id: networkPrinterScrollView
|
||||
|
||||
maxItemCountAtOnce: 6 // show at max 6 items at once, otherwise you need to scroll.
|
||||
|
||||
onRefreshButtonClicked:
|
||||
{
|
||||
// TODO: implement refresh
|
||||
}
|
||||
|
||||
onAddByIpButtonClicked:
|
||||
{
|
||||
base.gotoPage("add_printer_by_ip")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ Item
|
|||
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:
|
||||
{
|
||||
|
@ -53,6 +54,29 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Error: cannot find page with page_id = [", page_id, "]")
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (visible)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue