Blast from the past!

On Mon, Apr 6, 2009 at 6:44 PM, Edward K. Ream<[email protected]> wrote:

> Rev 1700 of the trunk adds support for changing the background color
> of the body pane,
> depending on whether the pane has focus or not.  All unit tests pass,
> except for the expected failure.
>
> The following option settings now control the background color of the
> body pane.  The usual settings apply if one or the other of these do
> not exist.
>
> �...@string selected-background-color
> �...@string unselected-background-color
>
> **Important**: the new code provides a template for intermixing Leo-
> style settings with Qt stylesheets.  The trick is that we can set a
> stylesheet of the body pane that just specifies the background color,
> and we can get the color from a normal Leo-style setting, as shown
> above.  Here is the code::
>
> badFocusColors = []
>
> def onFocusIn (self):
>    self.onFocusHelper(self.selectedBackgroundColor)
>
> def onFocusOut (self):
>    self.onFocusHelper(self.unselectedBackgroundColor)
>
> def onFocusHelper(self,name):
>
>    if QtGui.QColor(name).isValid():
>        s = 'QTextEdit#richTextEdit { background-color: %s; }' % name
>        self.widget.widget.setStyleSheet(s)
>    elif name not in self.badFocusColors:
>        self.badFocusColors.append(name)
>        g.es_print('invalid body background color: %s' %
> (name),color='blue')
>
> The selectedBackgroundColor and unselectedBackgroundColor ivars come
> from the settings.

Perhaps this code should be removed?

Rationale for this suggestion -

I made some googling on stylesheets, and noted we can achieve similar
functionality with

QTreeWidget:focus {
  background-color: #fdf5f5; /* Leo's traditional tree color */
}

(i.e. we can use :focus mode selector to apply stylesheets without
writing any code).

This approach is undoubtedly simpler and faster (everything happens in
behind-the-scenes fast C++ code).

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to