Skip to content

Commit

Permalink
Add export sub-menu
Browse files Browse the repository at this point in the history
CURA-11561
  • Loading branch information
wawanbreton committed Jan 25, 2024
1 parent 0b839f3 commit 7b201fd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions UM/Qt/Bindings/Bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from . import VisibleMessagesModel
from . import Utilities
from . import TableModel
from . import MeshWritersModel

from UM.Settings.Models.SettingDefinitionsModel import SettingDefinitionsModel
from UM.Settings.Models.DefinitionContainersModel import DefinitionContainersModel
Expand Down Expand Up @@ -127,6 +128,9 @@ def register(self):
qmlRegisterType(TableModel.TableModel, "UM", 1, 6, "TableModel")
qmlRegisterType(Window.Window, "UM", 1, 6, "Window")

# Additions after 5.6
qmlRegisterType(MeshWritersModel.MeshWritersModel, "UM", 1, 7, "MeshWritersModel")

@staticmethod
def addRegisterType(class_type: type, qml_import_name: str, major_version: int, minor_version: int, class_name: str) -> None:
qmlRegisterType(class_type, qml_import_name, major_version, minor_version, class_name)
35 changes: 35 additions & 0 deletions UM/Qt/Bindings/MeshWritersModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2024 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.

from typing import List

from PyQt6.QtCore import Qt, pyqtSignal
from PyQt6.QtQml import QQmlEngine

from UM.Application import Application
from UM.OutputDevice.OutputDeviceManager import OutputDeviceManager
from UM.OutputDevice.ProjectOutputDevice import ProjectOutputDevice
from UM.Qt.ListModel import ListModel


class MeshWritersModel(ListModel):
"""A list model providing a list of all registered MeshWriters that can export meshes.
Exposes the following roles:
* mime_type - The associated writable file mime type
* description - The human-readable name of the file format
"""

MimeTypeRole = Qt.ItemDataRole.UserRole + 1
DescriptionRole = Qt.ItemDataRole.UserRole + 2

def __init__(self, parent = None):
super().__init__(parent)
# Ensure that this model doesn't get garbage collected (Now the bound object is destroyed when the wrapper is)
QQmlEngine.setObjectOwnership(self, QQmlEngine.ObjectOwnership.CppOwnership)

self.addRoleName(self.MimeTypeRole, "mime_type")
self.addRoleName(self.DescriptionRole, "description")

self.setItems(Application.getInstance().getMeshFileHandler().getSupportedFileTypesWrite())

0 comments on commit 7b201fd

Please sign in to comment.