mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 16:05:56 +08:00
Remove TabManager
Since marketplace itself already needed to be a qObject, there wasn't really a need to have a seperate object for it
This commit is contained in:
parent
3b2be48390
commit
6af2677c52
@ -20,29 +20,11 @@ class Marketplace(Extension, QObject):
|
|||||||
"""
|
"""
|
||||||
The main managing object for the Marketplace plug-in.
|
The main managing object for the Marketplace plug-in.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class TabManager(QObject):
|
|
||||||
def __init__(self) -> None:
|
|
||||||
super().__init__(parent=CuraApplication.getInstance())
|
|
||||||
self._tab_shown: int = 0
|
|
||||||
|
|
||||||
def getTabShown(self) -> int:
|
|
||||||
return self._tab_shown
|
|
||||||
|
|
||||||
def setTabShown(self, tab_shown: int) -> None:
|
|
||||||
if tab_shown != self._tab_shown:
|
|
||||||
self._tab_shown = tab_shown
|
|
||||||
self.tabShownChanged.emit()
|
|
||||||
|
|
||||||
tabShownChanged = pyqtSignal()
|
|
||||||
tabShown = pyqtProperty(int, fget=getTabShown, fset=setTabShown, notify=tabShownChanged)
|
|
||||||
|
|
||||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||||
QObject.__init__(self, parent)
|
QObject.__init__(self, parent)
|
||||||
Extension.__init__(self)
|
Extension.__init__(self)
|
||||||
self._window: Optional["QObject"] = None # If the window has been loaded yet, it'll be cached in here.
|
self._window: Optional["QObject"] = None # If the window has been loaded yet, it'll be cached in here.
|
||||||
self._plugin_registry: Optional[PluginRegistry] = None
|
self._plugin_registry: Optional[PluginRegistry] = None
|
||||||
self._tab_manager = Marketplace.TabManager()
|
|
||||||
self._package_manager = CuraApplication.getInstance().getPackageManager()
|
self._package_manager = CuraApplication.getInstance().getPackageManager()
|
||||||
|
|
||||||
self._material_package_list: Optional[RemotePackageList] = None
|
self._material_package_list: Optional[RemotePackageList] = None
|
||||||
@ -54,8 +36,21 @@ class Marketplace(Extension, QObject):
|
|||||||
self._local_package_list = LocalPackageList(self)
|
self._local_package_list = LocalPackageList(self)
|
||||||
self._local_package_list.checkForUpdates(self._package_manager.local_packages)
|
self._local_package_list.checkForUpdates(self._package_manager.local_packages)
|
||||||
|
|
||||||
|
self._tab_shown: int = 0
|
||||||
|
|
||||||
qmlRegisterType(RestartManager, "Marketplace", 1, 0, "RestartManager")
|
qmlRegisterType(RestartManager, "Marketplace", 1, 0, "RestartManager")
|
||||||
|
|
||||||
|
def getTabShown(self) -> int:
|
||||||
|
return self._tab_shown
|
||||||
|
|
||||||
|
def setTabShown(self, tab_shown: int) -> None:
|
||||||
|
if tab_shown != self._tab_shown:
|
||||||
|
self._tab_shown = tab_shown
|
||||||
|
self.tabShownChanged.emit()
|
||||||
|
|
||||||
|
tabShownChanged = pyqtSignal()
|
||||||
|
tabShown = pyqtProperty(int, fget=getTabShown, fset=setTabShown, notify=tabShownChanged)
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant=True)
|
@pyqtProperty(QObject, constant=True)
|
||||||
def MaterialPackageList(self):
|
def MaterialPackageList(self):
|
||||||
if self._material_package_list is None:
|
if self._material_package_list is None:
|
||||||
@ -88,10 +83,10 @@ class Marketplace(Extension, QObject):
|
|||||||
if plugin_path is None:
|
if plugin_path is None:
|
||||||
plugin_path = os.path.dirname(__file__)
|
plugin_path = os.path.dirname(__file__)
|
||||||
path = os.path.join(plugin_path, "resources", "qml", "Marketplace.qml")
|
path = os.path.join(plugin_path, "resources", "qml", "Marketplace.qml")
|
||||||
self._window = CuraApplication.getInstance().createQmlComponent(path, {"tabManager": self._tab_manager, "manager": self})
|
self._window = CuraApplication.getInstance().createQmlComponent(path, {"manager": self})
|
||||||
if self._window is None: # Still None? Failed to load the QML then.
|
if self._window is None: # Still None? Failed to load the QML then.
|
||||||
return
|
return
|
||||||
self._tab_manager.setTabShown(0)
|
self.setTabShown(0)
|
||||||
self._window.show()
|
self._window.show()
|
||||||
self._window.requestActivate() # Bring window into focus, if it was already open in the background.
|
self._window.requestActivate() # Bring window into focus, if it was already open in the background.
|
||||||
|
|
||||||
@ -101,4 +96,4 @@ class Marketplace(Extension, QObject):
|
|||||||
Set the tab shown to the remote materials one.
|
Set the tab shown to the remote materials one.
|
||||||
Not implemented in a more generic way because it needs the ability to be called with 'callExtensionMethod'.
|
Not implemented in a more generic way because it needs the ability to be called with 'callExtensionMethod'.
|
||||||
"""
|
"""
|
||||||
self._tab_manager.setTabShown(1)
|
self.setTabShown(1)
|
||||||
|
@ -130,11 +130,11 @@ Window
|
|||||||
height: UM.Theme.getSize("button_icon").height
|
height: UM.Theme.getSize("button_icon").height
|
||||||
spacing: 0
|
spacing: 0
|
||||||
background: Rectangle { color: "transparent" }
|
background: Rectangle { color: "transparent" }
|
||||||
currentIndex: tabManager.tabShown
|
currentIndex: manager.tabShown
|
||||||
|
|
||||||
onCurrentIndexChanged:
|
onCurrentIndexChanged:
|
||||||
{
|
{
|
||||||
tabManager.tabShown = currentIndex
|
manager.tabShown = currentIndex
|
||||||
searchBar.text = "";
|
searchBar.text = "";
|
||||||
searchBar.visible = currentItem.hasSearch;
|
searchBar.visible = currentItem.hasSearch;
|
||||||
content.source = currentItem.sourcePage;
|
content.source = currentItem.sourcePage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user