Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the explore button on the SaveDefinitionDialog #62

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/QuiltiX/quiltix.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,15 @@ def fix_geo(self, item, emit=True):


class SaveDefinitionDialog(QDialog):

signal_saved_def = QtCore.Signal(object)

def __init__(self, node, mx_library_doc, parent):
super(SaveDefinitionDialog, self).__init__(parent)
self.node = node
self.mx_library_doc = mx_library_doc
self.setup_definition_dict()
self.setup_ui()

def build_category(self, mx_def):
category_string = 'NODE_' + mx_def.getNodeString() + '_VERSION_' + mx_def.getVersionString()
for input in mx_def.getActiveInputs():
Expand All @@ -781,13 +787,6 @@ def setup_definition_dict(self):
self.nodegroups.add(mx_def.getNodeGroup())
self.nodegroups = sorted(self.nodegroups, key=lambda x: x.lower())

def __init__(self, node, mx_library_doc, parent):
super(SaveDefinitionDialog, self).__init__(parent)
self.node = node
self.mx_library_doc = mx_library_doc
self.setup_definition_dict()
self.setup_ui()

def category_exists(self, mx_def):
return self.build_category(mx_def) in self.categories

Expand All @@ -800,13 +799,15 @@ def setup_ui(self):
self.l_category = QLabel("Category:")
self.e_category = QLineEdit(self.node.NODE_NAME)
self.l_path = QLabel("Save Path: ")
path = os.path.join(os.environ["USERPROFILE"], "custom_mtlx_defs", self.node.NODE_NAME+ ".mtlx")
path = os.path.join(os.path.expanduser("~"), "custom_mtlx_defs", self.node.NODE_NAME + ".mtlx")
self.e_path = QLineEdit(path)
self.b_path = QPushButton("...")
self.bb_main = QDialogButtonBox()
self.bb_main.addButton("Save", QDialogButtonBox.AcceptRole)
self.bb_main.addButton("Cancel", QDialogButtonBox.RejectRole)

self.b_path.pressed.connect(self.explore_save_path_triggered)

self.bb_main.accepted.connect(self.on_accepted)
self.bb_main.rejected.connect(self.reject)

Expand All @@ -825,10 +826,19 @@ def setup_ui(self):
self.lo_main.addWidget(self.bb_main, 4, 2, 1, 2)
self.e_category.setFocus()

def explore_save_path_triggered(self):
start_path = self.e_path.text()
path = QFileDialog.getSaveFileName(self, "Output MaterialX Definition path", start_path, "MaterialX Definition (*.mtlx)")[0]

if not path:
return

self.e_path.setText(path)

def sizeHint(self):
return QtCore.QSize(580, 175)

def on_accepted(self):
def on_accepted(self):

# get nodegroup from e_nodegroup QComboBox
nodegroup = self.e_nodegroup.currentText()
Expand Down