On Mon, 15 Sep 2014 06:55:47 -0700 (PDT) "Edward K. Ream" <edream...@gmail.com> wrote:
> There seems to be *no* way to check the validity of a Qt style sheet. > This is a severe annoyance. Comparing w.styleSheet() to the value > passed to w.setStyleSheet() looks like a completely useless test. It > won't detect, for example, missing semicolons, bad selector values or > much of anything else. Googling shows no other solutions. It wasn't intended to test correctness of the stylesheet, just that the intended stylesheet had been successfully applied - so probably more paranoia the useful. > Important: tracing reveals that Leo only sets the stylesheet for the > so-called master widget, the widget returned by > ssm.get_master_widget. That's an important implicit invariant that > simplifies matters. Well... as mentioned previously, applying the full style-sheet to the top level widget is fast enough when you're doing it from Settings -> Reload Styles after editing various settings, but it's slow when you want a more instant response, i.e. the Ctrl-mouse wheel font re-sizing. For that reason I think the font re-sizing(*) code applies the stylesheet to the body widget. This seems to not cause problems, if a more general change is later made and applied with Settings -> Reload Styles... hmm, I was going to it would harmless replace the setting on the body widget, but I guess it doesn't... yes, test's confirm that changing style settings no longer affect the body widget after dynamic font-size zooming. So the short term fix would be to stop the font-resizing code applying the stylesheet to the body widget and have it apply it to the same target as Settings -> Reload Styles, we can address any slow responsiveness problem later. (*) the mechanism used for the dynamic font resizing is general, I don't remember the details, but it can dynamically in/decrease any numeric style parameter - border widths etc. etc. My use case is distraction free writing - I make the font a little larger and turn off other gui elements, but now the text is too wide, so I want to dynamically increase the border sizes as well. The code looks like this: from PyQt4 import QtGui def do_padding(c, deltas): for n,i in enumerate(['padding-top-body', 'padding-left-body', 'padding-bottom-body', 'padding-right-body']): c._style_deltas[i] += deltas[n] # c.frame.top.setStyleSheets() ss = g.expand_css_constants(c, c.active_stylesheet) c.frame.body.bodyCtrl.widget.setStyleSheet(ss) return @g.command("borders-narrow") def borders_narrow(kw): do_padding(kw['c'], [0, 40, 0, 40]) @g.command("borders-wide") def borders_wide(kw): do_padding(kw['c'], [0, -40, 0, -40]) @g.command("borders-tall") def borders_tall(kw): do_padding(kw['c'], [-40, 0, -40, 0]) @g.command("borders-short") def borders_short(kw): do_padding(kw['c'], [40, 0, 40, 0] > Now that all these details have been resolved, I have hopes of > completing the project today. The only remaining task: transition to > fully-parametrized stylesheets. And the hierarchical menu under Settings to guide users to the right part of myLeoSettings.leo which copies on demand the needed pieces of setting tree from leoSettings.leo if they're not already in myLeoSettings.leo, probably using the same mechanism that Settings -> Personal Settings already uses to copy the @enabled-plugins node to a new myLeoSettings.leo when needed. Cheers -Terry > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.