@@ -255,6 +255,7 @@ def Populate(self, filter=""):
255
255
256
256
# create spinner
257
257
widget = QComboBox ()
258
+ widget .setSizeAdjustPolicy (QComboBox .AdjustToMinimumContentsLengthWithIcon )
258
259
259
260
# Get values
260
261
value_list = param ["values" ]
@@ -275,6 +276,12 @@ def Populate(self, filter=""):
275
276
"value" : profile .info .description
276
277
})
277
278
279
+ # Add test button
280
+ extraWidget = QPushButton ()
281
+ extraWidget .setToolTip (_ ("Search Profiles" ))
282
+ extraWidget .setIcon (QIcon (":/icons/Humanity/mimes/16/video-x-generic.svg" ))
283
+ extraWidget .clicked .connect (functools .partial (self .btnBrowseProfiles_clicked , widget ))
284
+
278
285
# Overwrite value list (for audio device list dropdown)
279
286
if param ["setting" ] == "playback-audio-device" :
280
287
value_list = []
@@ -339,8 +346,8 @@ def Populate(self, filter=""):
339
346
# Add normal values
340
347
box_index = 0
341
348
for value_item in value_list :
342
- k = value_item [ "name" ]
343
- v = value_item [ "value" ]
349
+ k = value_item . get ( "name" )
350
+ v = value_item . get ( "value" )
344
351
i = value_item .get ("icon" , None )
345
352
346
353
# Translate dropdown item (if needed)
@@ -550,6 +557,54 @@ def dropdown_index_changed(self, widget, param, index):
550
557
# Check for restart
551
558
self .check_for_restart (param )
552
559
560
+ def btnBrowseProfiles_clicked (self , widget ):
561
+ """Search profile button clicked"""
562
+ # Get current selection profile object
563
+ profile_description = widget .currentData ()
564
+
565
+ # Find matching profile path
566
+ matching_profile_path = None
567
+ for profile_folder in [info .USER_PROFILES_PATH , info .PROFILES_PATH ]:
568
+ for file in reversed (sorted (os .listdir (profile_folder ))):
569
+ # Load Profile and append description
570
+ matching_profile_path = os .path .join (profile_folder , file )
571
+ if os .path .isdir (matching_profile_path ):
572
+ continue
573
+ profile = openshot .Profile (matching_profile_path )
574
+ if profile .info .description == profile_description :
575
+ break
576
+
577
+ # Load matching profile
578
+ current_profile = openshot .Profile (matching_profile_path )
579
+
580
+ # Show dialog (init to current selection)
581
+ from windows .profile import Profile
582
+ log .debug ("Showing profile dialog" )
583
+ win = Profile (current_profile .Key ())
584
+ # Run the dialog event loop - blocking interaction on this window during this time
585
+ result = win .exec_ ()
586
+
587
+ profile = win .selected_profile
588
+ if result == QDialog .Accepted and profile :
589
+
590
+ # select the project's current profile
591
+ profile_index = self .getVideoProfileIndex (widget , profile )
592
+ if profile_index != - 1 :
593
+ # Re-select project profile (if found in list)
594
+ widget .setCurrentIndex (profile_index )
595
+ else :
596
+ # Previous profile not in list, so
597
+ # default to first profile in list
598
+ widget .setCurrentIndex (0 )
599
+
600
+ def getVideoProfileIndex (self , widget , profile ):
601
+ """Get the index of a profile name or profile key (-1 if not found)"""
602
+ for index in range (widget .count ()):
603
+ combo_profile_description = widget .itemData (index )
604
+ if profile .info .description == combo_profile_description :
605
+ return index
606
+ return - 1
607
+
553
608
def testHardwareDecode (self , widget , param , btn ):
554
609
"""Test specific settings for hardware decode"""
555
610
all_decoders = param .get ("values" , [])
0 commit comments