Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2022-01-03 13:06:19 +0300
committerJaime van Kessel <nallath@gmail.com>2022-01-03 13:06:19 +0300
commit6af2677c5223e0f68cc1221605e0e76ae0e38d63 (patch)
tree286a85098a5515deece951e8e0ce6d6a30861bd1 /plugins/Marketplace
parent3b2be48390abfb465cd85446662cfe253e723507 (diff)
Remove TabManager
Since marketplace itself already needed to be a qObject, there wasn't really a need to have a seperate object for it
Diffstat (limited to 'plugins/Marketplace')
-rw-r--r--plugins/Marketplace/Marketplace.py37
-rw-r--r--plugins/Marketplace/resources/qml/Marketplace.qml4
2 files changed, 18 insertions, 23 deletions
diff --git a/plugins/Marketplace/Marketplace.py b/plugins/Marketplace/Marketplace.py
index 9bc1a2713c..515d9959ed 100644
--- a/plugins/Marketplace/Marketplace.py
+++ b/plugins/Marketplace/Marketplace.py
@@ -20,29 +20,11 @@ class Marketplace(Extension, QObject):
"""
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:
QObject.__init__(self, parent)
Extension.__init__(self)
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._tab_manager = Marketplace.TabManager()
self._package_manager = CuraApplication.getInstance().getPackageManager()
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.checkForUpdates(self._package_manager.local_packages)
+ self._tab_shown: int = 0
+
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)
def MaterialPackageList(self):
if self._material_package_list is None:
@@ -88,10 +83,10 @@ class Marketplace(Extension, QObject):
if plugin_path is None:
plugin_path = os.path.dirname(__file__)
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.
return
- self._tab_manager.setTabShown(0)
+ self.setTabShown(0)
self._window.show()
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.
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)
diff --git a/plugins/Marketplace/resources/qml/Marketplace.qml b/plugins/Marketplace/resources/qml/Marketplace.qml
index 9027a02121..b909c88877 100644
--- a/plugins/Marketplace/resources/qml/Marketplace.qml
+++ b/plugins/Marketplace/resources/qml/Marketplace.qml
@@ -130,11 +130,11 @@ Window
height: UM.Theme.getSize("button_icon").height
spacing: 0
background: Rectangle { color: "transparent" }
- currentIndex: tabManager.tabShown
+ currentIndex: manager.tabShown
onCurrentIndexChanged:
{
- tabManager.tabShown = currentIndex
+ manager.tabShown = currentIndex
searchBar.text = "";
searchBar.visible = currentItem.hasSearch;
content.source = currentItem.sourcePage;