mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-21 21:29:41 +08:00
76 lines
3.9 KiB
Python
76 lines
3.9 KiB
Python
# Copyright (c) 2019 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
import os
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
from PyQt5.QtCore import QUrl, Qt, pyqtSlot
|
|
|
|
from UM.Qt.ListModel import ListModel
|
|
from UM.Resources import Resources
|
|
|
|
if TYPE_CHECKING:
|
|
from PyQt5.QtCore import QObject
|
|
|
|
|
|
class WelcomePagesModel(ListModel):
|
|
|
|
IdRole = Qt.UserRole + 1 # Page ID
|
|
PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file
|
|
NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to
|
|
|
|
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
|
super().__init__(parent)
|
|
|
|
self.addRoleName(self.IdRole, "id")
|
|
self.addRoleName(self.PageUrlRole, "page_url")
|
|
self.addRoleName(self.NextPageIdRole, "next_page_id")
|
|
|
|
self._pages = []
|
|
|
|
def initialize(self) -> None:
|
|
from cura.CuraApplication import CuraApplication
|
|
# Add default welcome pages
|
|
self._pages.append({"id": "welcome",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"WelcomeContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "user_agreement",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"UserAgreementContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "whats_new",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"WhatsNewContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "data_collections",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"DataCollectionsContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "add_printer_by_selection",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"AddPrinterBySelectionContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "add_printer_by_ip",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"AddPrinterByIpContent.qml"))),
|
|
})
|
|
self._pages.append({"id": "cloud",
|
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
|
os.path.join("WelcomePages",
|
|
"CloudContent.qml"))),
|
|
})
|
|
|
|
self.setItems(self._pages)
|
|
|
|
|
|
def addPage(self):
|
|
pass
|
|
|
|
__all__ = ["WelcomePagesModel"]
|