Skip to content

Commit 736919d

Browse files
committed
Add a new link widget to our preprocessing effect dialog, so we can give further instructions/link to users who want to download the object detector dependencies.
1 parent d720565 commit 736919d

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/classes/effect_init.py

+6
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@
150150
],
151151

152152
"Object Detector": [
153+
{
154+
"value": "https://github.com/OpenShot/openshot-qt/wiki/Object-Detection-Effect-(dependencies)",
155+
"title": "Click here for instructions and dependencies...",
156+
"type": "link",
157+
"setting": "model-instructions"
158+
},
153159
{
154160
"value": os.path.join(YOLO_PATH,"yolov3.weights"),
155161
"title": "Model Weights",

src/windows/process_effect.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import time
3030
import json
3131
import functools
32+
import webbrowser
3233

3334
from PyQt5.QtCore import *
3435
from PyQt5.QtGui import QBrush
@@ -93,6 +94,12 @@ def __init__(self, clip_id, effect_name, effect_params):
9394
label.setText(_(param["title"]))
9495
label.setToolTip(_(param["title"]))
9596

97+
if param["type"] == "link":
98+
# create a clickable link
99+
label.setText('<a href="%s" style="color: #FFFFFF">%s</a>' % (param["value"], param["title"]))
100+
label.setTextInteractionFlags(Qt.TextBrowserInteraction)
101+
label.linkActivated.connect(functools.partial(self.link_activated, widget, param))
102+
96103
if param["type"] == "spinner":
97104
# create QDoubleSpinBox
98105
widget = QDoubleSpinBox()
@@ -178,13 +185,17 @@ def __init__(self, clip_id, effect_name, effect_params):
178185
widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param))
179186

180187
# Add Label and Widget to the form
181-
if (widget and label):
188+
if widget and label:
182189
# Add minimum size
183190
label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
184191
widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
185192

186193
# Create HBoxLayout for each field
187-
self.scrollAreaWidgetContents.layout().insertRow(row_count - 1, label, widget)
194+
self.scrollAreaWidgetContents.layout().insertRow(row_count, label, widget)
195+
196+
elif not widget and label:
197+
label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
198+
self.scrollAreaWidgetContents.layout().insertRow(row_count, label)
188199

189200
row_count += 1
190201

@@ -203,6 +214,10 @@ def __init__(self, clip_id, effect_name, effect_params):
203214
self.cancel_clip_processing = False
204215
self.effect = None
205216

217+
def link_activated(self, widget, param, value):
218+
"""Link activated"""
219+
webbrowser.open(value, new=1)
220+
206221
def spinner_value_changed(self, widget, param, value):
207222
"""Spinner value change callback"""
208223
self.context[param["setting"]] = value
@@ -256,7 +271,7 @@ def rect_select_clicked(self, widget, param):
256271
bottomRight = win.videoPreview.regionBottomRightHandle
257272
viewPortSize = win.viewport_rect
258273
curr_frame_size = win.videoPreview.curr_frame_size
259-
274+
260275
x1 = topLeft.x() / curr_frame_size.width()
261276
y1 = topLeft.y() / curr_frame_size.height()
262277
x2 = bottomRight.x() / curr_frame_size.width()

src/windows/ui/process-effect.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>410</width>
10-
<height>250</height>
10+
<height>270</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">

0 commit comments

Comments
 (0)