mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -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
|
import os
|
||||||
from typing import TYPE_CHECKING, Optional
|
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.Qt.ListModel import ListModel
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
@ -11,6 +11,7 @@ from UM.Resources import Resources
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyQt5.QtCore import QObject
|
from PyQt5.QtCore import QObject
|
||||||
|
|
||||||
|
|
||||||
class WelcomePagesModel(ListModel):
|
class WelcomePagesModel(ListModel):
|
||||||
|
|
||||||
IdRole = Qt.UserRole + 1 # Page ID
|
IdRole = Qt.UserRole + 1 # Page ID
|
||||||
|
|
|
@ -23,6 +23,9 @@ Item
|
||||||
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
||||||
property var selectedItem: networkPrinterListView.model[networkPrinterListView.currentIndex]
|
property var selectedItem: networkPrinterListView.model[networkPrinterListView.currentIndex]
|
||||||
|
|
||||||
|
signal refreshButtonClicked()
|
||||||
|
signal addByIpButtonClicked()
|
||||||
|
|
||||||
ScrollView
|
ScrollView
|
||||||
{
|
{
|
||||||
id: networkPrinterScrollView
|
id: networkPrinterScrollView
|
||||||
|
@ -87,6 +90,7 @@ Item
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: catalog.i18nc("@label", "Refresh")
|
text: catalog.i18nc("@label", "Refresh")
|
||||||
height: UM.Theme.getSize("message_action_button").height
|
height: UM.Theme.getSize("message_action_button").height
|
||||||
|
onClicked: base.refreshButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.SecondaryButton
|
Cura.SecondaryButton
|
||||||
|
@ -97,6 +101,7 @@ Item
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: catalog.i18nc("@label", "Add printer by IP")
|
text: catalog.i18nc("@label", "Add printer by IP")
|
||||||
height: UM.Theme.getSize("message_action_button").height
|
height: UM.Theme.getSize("message_action_button").height
|
||||||
|
onClicked: base.addByIpButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
|
|
|
@ -223,7 +223,7 @@ Item
|
||||||
text: catalog.i18nc("@button", "Back")
|
text: catalog.i18nc("@button", "Back")
|
||||||
width: 140
|
width: 140
|
||||||
fixedWidthMode: true
|
fixedWidthMode: true
|
||||||
onClicked: base.showPreviousPage()
|
onClicked: base.gotoPage("add_printer_by_selection")
|
||||||
|
|
||||||
enabled: true
|
enabled: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,16 @@ Item
|
||||||
id: networkPrinterScrollView
|
id: networkPrinterScrollView
|
||||||
|
|
||||||
maxItemCountAtOnce: 6 // show at max 6 items at once, otherwise you need to scroll.
|
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 showNextPage()
|
||||||
signal showPreviousPage()
|
signal showPreviousPage()
|
||||||
signal passLastPage() // Emitted when there is no more page to show
|
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:
|
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:
|
onVisibleChanged:
|
||||||
{
|
{
|
||||||
if (visible)
|
if (visible)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue