View Single Post
Old 01-20-2021, 11:45 AM   #284
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,223
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
First of all, thank you so much for continuous help, it is really appreciated.

Quote:
Originally Posted by chaley View Post
Case 1 is templates.py/TemplateBox. It seems that you were forced to reimplement textbox_changed so you could call safe_format with your new functions. To avoid that I could add two parameters to init
Code:
all_functions=None, builtin_functions=None
This would do 2 things: eliminate the requirement that you override textbox_changed and make your template functions visible in the template dialog. The difference between the two arguments is how the functions are labeled in the template reference box. I suspect that you would add your functions to both the standard builtins and all_funcs, making your functions appear as builtin.
That would really eleminate the need to re-implement the text_changed() method and and make the TemplateDialog re-usable.


Quote:
Originally Posted by chaley View Post
Case 2 is ConditionsEval, which reimplements the entire dialog. I think you were forced to this for the same reason as case 1, and because you wanted to add the widgets for datatype, comparison, condition value, icon, and tooltip. To get around adding the widgets I could add several empty label/QBoxLayout pairs to the base TemplateDialog that are normally invisible, named user_label_N and user_layout_N where N is 1-6. You would use these to add your own fields to TemplateDialog. This would both get rid of a lot of the semi-duplicated code and add the template reference.
I wonder if it is possible to add an additional nested layout instead, right above the font row, something like this

Code:
self.user_layout = QGridLayout()
self.gridLayout.addLayout(self.user_layout, row, col, 2, 1)
The self.user_layout can be used to add variable number of extra widgets. I think this might offer more flexibility when adding things in the future. For example, yesterday I added and additional checkbox that makes chain condition evaluation optional when showing the plugin menu. On the other hand, it might be difficult to keep the alignment of the labels in line with the parent layout.

I can already do something similar by adding to self.verticalLayout as in the attached screen. But it is at the bottom of dialog. Would be better If I have access right above the font row.

Edit: After thinking about it more, I think would should stick the the first point for now, which would make the template dialog re-usable for both cases. Something does not feel right about altering the template dialog that much to accommodate the plugin.

I will only be re-implementing the textbox and the template_value in the ConditionsEval. The rest I can inherit if you make the first change.
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	800
Size:	30.3 KB
ID:	184838  

Last edited by capink; 01-20-2021 at 12:18 PM.
capink is offline   Reply With Quote