There are two parts to this post:
===== 1. Having settings take effect immediately.
In the previous thread I said, "allowing settings to take effect
immediately would be a major project". On second thought, this should be
easy!
Indeed, any class that calls c.config.getWhatever can "register" a
configuration updater just by appending an updater method of the class to a
global list, say g.app.configUpdaters. When Leo saves a configuration
file, it will call all the methods on this list, in no particular order and
then update all widgets.
A simple prototype while demonstrate the updating of widgets. I don't
expect major problems...
===== 2. Simplifying Qt style sheets.
In the last thread, Terry said the following:
QQQ
I think we can shoot for the best of both worlds here. The template system
can provide a tree of simple Leo settings for all the simple
design elements (colors, fonts, font sizes, border widths, etc.) If you
want a gradient fill that changes when you hover over a widget,
*then* you'd need to hack the stylesheet yourself, but for the core stuff,
a simple user editable tree (Leo outline) of settings should be
possible.
QQQ
If I understand Terry's general idea, it is that we can break the daunting
task of creating Qt stylesheets into simpler pieces, which then either get
composed into a single stylesheet or get passed individually to particular
widgets.
Imo, we should go further. Newbie users should not need to know about Qt
selectors such as::
TreeWidget QLineEdit { /* Headline edit widgets */
or worse::
QTextEdit#richTextEdit[vim_state~="vim_normal"]
Instead, Leo should provide these selectors automagically. The idea is to
define a new @settings type, say @style::
@style <simplified-leo-selector>
<< simplified stylesheet in the body >>
For example, instead of::
QTreeWidget QLineEdit { /* Headline edit widgets */
background-color: pink;
selection-color: white;
selection-background-color: blue;
}
The user would see and use::
@style edit-headline
# A comment explaining what the edit-headline selector means,
# and typical values, perhaps with a link to the relevant Qt doc page.
background-color: pink
# I also tried red and salmon
selection-color: white
selection-background-color: blue
Leo's configuration code would do the following with @style nodes:
1. Associate a full-blown Qt selector with the simplified selector in the
@style node, with a warning if no such association is known.
The association will be given by a dict. The entry for this case will be:
'edit-headline': 'QTreeWidget QLineEdit'.
2. Munge the the body as follows:
- Lines starting with # are comment lines. No need for error-prone c-style
block comments.
- A trailing semicolon will be added to lines if needed.
- All non-comment lines wrapped in { and }.
===== Summary
1. Registering updaters is straightforward. To find the needed updaters,
I'll just search for c.config.get ;-)
2. There will be several dozen @style nodes, corresponding to the various
selectors in @data qt-gui-plugin-style-sheet in leoSettings.leo. As usual,
more specific simplified selectors will "inherit" more general selectors,
because everything will turn into a real Qt stylesheet eventually.
3. @style nodes would be natural "targets" of a configuration menu.
I expect that all of this can be done in a day or so. This project should
help newbies a lot. It should be done for the next release.
Your comments please. While waiting for your comments, I'll play with the
prototype mentioned above.
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.