Skip to content

Commit

Permalink
Merge pull request OpenShot#2255 from DylanC/blender_locate
Browse files Browse the repository at this point in the history
Locate Blender executable via File Manager
  • Loading branch information
DylanC authored Oct 24, 2018
2 parents 7156ad0 + 5b6fd84 commit b299864
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/settings/_default.settings
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
{
"value": "blender",
"title": "Blender Command (path)",
"type": "text",
"type": "browse",
"category": "General",
"setting": "blender_command"
},
{
"value": "inkscape",
"title": "Advanced Title Editor (path)",
"type": "text",
"type": "browse",
"category": "General",
"setting": "title_editor"
},
Expand Down
16 changes: 16 additions & 0 deletions src/windows/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __init__(self):

# Create Label
widget = None
extraWidget = None
label = QLabel()
label.setText(_(param["title"]))
label.setToolTip(_(param["title"]))
Expand Down Expand Up @@ -167,6 +168,14 @@ def __init__(self):
widget.setText(_(param["value"]))
widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))

elif param["type"] == "browse":
# create QLineEdit
widget = QLineEdit()
widget.setText(_(param["value"]))
widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))
extraWidget = QPushButton("Browse")
extraWidget.clicked.connect(functools.partial(self.selectExecutable, widget, param))

elif param["type"] == "bool":
# create spinner
widget = QCheckBox()
Expand Down Expand Up @@ -238,6 +247,7 @@ def __init__(self):
layout_hbox = QHBoxLayout()
layout_hbox.addWidget(label)
layout_hbox.addWidget(widget)
layout_hbox.addWidget(extraWidget)

# Add widget to layout
tabWidget.layout().addLayout(layout_hbox)
Expand All @@ -248,6 +258,12 @@ def __init__(self):
# Add stretch to bottom of layout
tabWidget.layout().addStretch()

def selectExecutable(self, widget, param):
fileName = QFileDialog.getOpenFileName(self,"Select executable file", QDir.rootPath(),"All Files (*)")
if fileName:
self.s.set(param["setting"], fileName)
widget.setText(fileName)

def check_for_restart(self, param):
"""Check if the app needs to restart"""
if "restart" in param and param["restart"]:
Expand Down

0 comments on commit b299864

Please sign in to comment.