Bug 360020

Summary: color inconsistencies combining defaults with program colors
Product: [Applications] trojita Reporter: Hohyeis <hohyeis>
Component: Desktop GUIAssignee: Trojita default assignee <trojita-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: All   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Looks reasonable to me
Message window
color file for qt5ct
Main window with message

Description Hohyeis 2016-03-03 10:27:06 UTC
There are color inconsistencies because of how trojita uses inherited default colors. 
Some colors are default according to user settings and others are set by the application.
The combination can be difficult or impossible to read.

This is especially visible when the user color scheme has dark background colors and light foreground colors.

A way to fix this is to only use the default foreground colors in combination with default background colors.  If Trojita uses its own background color, it should also specify a foreground color and not use the default.

Reproducible: Always

Steps to Reproduce:
Use a  user color scheme with dark background colors and light foreground colors.
Comment 1 Jan Kundrát 2016-03-03 11:06:03 UTC
We try to do this, so what you're seeing is apparently something which escaped our attention.

Could you please describe what exactly goes wrong, preferably with screenshots, and reopen this bug?
Comment 2 Thomas Lübking 2016-03-03 11:29:11 UTC
=> screenshot, please.
Comment 3 Jan Kundrát 2016-03-03 11:34:28 UTC
Created attachment 97650 [details]
Looks reasonable to me

FYI, this is what I get (breeze-dark for both the icon theme and the color theme).

The [+] in the TagListWidget is clearly wrong (I only noticed when I went looking).

The icons suck and the link colors are wrong, but these colors come from the respective themes.
Comment 4 Thomas Lübking 2016-03-03 11:36:41 UTC
Comment on attachment 97650 [details]
Looks reasonable to me

Tag "+" and general tagwidget thing is fixed in the header commit series (patch that removes the fugly qss abuse ;-)
Comment 5 Thomas Lübking 2016-03-03 11:37:50 UTC
PS: oc. i wanted to see a screenshot from Hohyeis, illustrating *his* concern ;-)
Comment 6 Hohyeis 2016-03-03 11:55:00 UTC
Created attachment 97651 [details]
Message window
Comment 7 Hohyeis 2016-03-03 11:56:47 UTC
The Trojita I have is version 0.6 using Qt5.5.
Comment 8 Hohyeis 2016-03-03 11:58:52 UTC
I see the problem in the message pane of the aggregate main window -- not in the independent message window.
The values From, To, and Tags fields all have a poor combination of background and foreground colors.
Comment 9 Hohyeis 2016-03-03 12:09:23 UTC
In Jan's screen capture, there are also problems.
The highlighted subject line and the "+" sign by Tags.
Comment 10 Thomas Lübking 2016-03-03 12:18:26 UTC
The tagwidget is addressed.

The problem seems to be about the link colors, but what strikes me odd is that the base color in the message tree seems to be black, while it's apparently white on the filter line and the message view itself it seems to be white, where the partwidget is black again.

Do you use KDE and its overly complex color schemes?
Can you please export and attach yours in case?
Comment 11 Hohyeis 2016-03-03 12:57:28 UTC
I use XFCE. I do not use KDE.
The theme was made with qt5ct, if I recall correctly.
I will attache the color theme from ~/.config/qt5ct/colors
Comment 12 Hohyeis 2016-03-03 12:59:40 UTC
Created attachment 97652 [details]
color file for qt5ct
Comment 13 Thomas Lübking 2016-03-03 13:13:25 UTC
Base should be black

> I use XFCE.
While the scrot looks like fusion, can you please check whether
    QT_STYLE_OVERRIDE=Fusion trojita
exposes the same issue (I worry Gtk to intervene here)
Comment 14 Hohyeis 2016-03-03 13:24:03 UTC
With QT_STYLE_OVERRIDE=Fusion , Trojita displays the same.
Comment 15 Jan Kundrát 2016-03-03 14:44:44 UTC
> while it's apparently white on the filter line and the message view itself it seems to
> be white, where the partwidget is black again.

That's how my build (latest git, Qt 5.6 from Nov?, Plasma5 from Feb) behaves when I change the color theme at runtime through Plasma's systemsettings. The backgrounds are correct after I quit and restart Trojita.

Hohyeis, could you please confirm that whether these white backgrounds happen all the time, even after Trojita's restart, or whether this is just at the time you switch the theme?
Comment 16 Hohyeis 2016-03-03 14:52:30 UTC
They happen when I Trojita restarts -- even when the theme is not changed during a run of Trojita.
I may be able to build Qt and Trojita myself and see whether the error reproduces.
Currently, I'm using the build which is in Manjaro/community.
Comment 17 Thomas Lübking 2016-03-03 15:11:48 UTC
Let's see whether it's the xfce QPA plugin:

QT_STYLE_OVERRIDE=Fusion XDG_CURRENT_DESKTOP= DESKTOP_SESSION= trojita
Comment 18 Hohyeis 2016-03-03 18:43:10 UTC
Unsetting variables XDG_CURRENT_DESKTOP DESKTOP_SESSION had no visible effect.
Comment 19 Jan Kundrát 2016-03-04 00:59:54 UTC
Could you please double-check that you quit the application through (menu) IMAP -> Exit instead of just closing the window? There's code for minimizing to systray and IPC, and Trojita will refuse to start more than one instance at a time.

In other words, please check the output of e.g. `ps auxww | grep trojita` to make sure that there's no Trojita left running.
Comment 20 Hohyeis 2016-03-04 09:29:14 UTC
I have now verified with 'ps' that Trojita is not running before restarting.
Comment 21 Hohyeis 2016-03-04 09:58:44 UTC
I have now built Trojita from the Git repository code with the binary distribution of Qt5.6RC from the Qt project.
It looks the same.
Comment 22 Thomas Lübking 2016-03-04 10:02:35 UTC
It will be the custom palette calls.

a) EmbeddedWebView:
    // Redmine#3, the QWebView uses black text color when rendering stuff on dark background
    QPalette palette = QApplication::palette();
    if (palette.background().color().lightness() < 50) {
        QStyle *style = QStyleFactory::create(QStringLiteral("windows"));
        Q_ASSERT(style);
        palette = style->standardPalette();
        setPalette(palette);
    }

and b) MessageView
   QPalette pal = palette();
   pal.setColor(backgroundRole(), palette().color(QPalette::Active, QPalette::Base));
   pal.setColor(foregroundRole(), palette().color(QPalette::Active, QPalette::Text));
   setPalette(pal);

If (a) is the trigger, that's kinda our problem (and we've css to define colors of all elements in the message)
(b) would imply that qt5ct uses the style hooks to alter the palette for each widget during polishment - and that would be terrible behavor and a bug in the qt5ct platform theme.

@Hohyeis
ready do compile some patches?
Comment 23 Thomas Lübking 2016-03-04 10:02:54 UTC
Disregard my last question ;-)
Comment 24 Jan Kundrát 2016-03-04 17:51:04 UTC
I've uploaded some patches which appear to address everything that I was able to see, I think. Please take a look at the patch series which ends at https://gerrit.vesnicky.cesnet.cz/r/634/ ; there's a button "Download" at the right top which shows you a command for checking out these changes into your local git tree.
Comment 25 Jan Kundrát 2016-03-05 17:05:40 UTC
Git commit 4557439352a85ac9ff9abbaf52cdb0e23fb9d156 by Jan Kundrát.
Committed on 05/03/2016 at 16:17.
Pushed by gerrit into branch 'master'.

Use Qt5's features for QLineEdit actions

Our LineEdit started as a class offering a clear button at the right
edge even on styles where this is not available. A feature like this
however got added to Qt in version 5.2, so it makes sense to start using
it instead.

This change makes it possible to deprecate the QSS usage, and therefore
fixes the style issues on (some) dark themes or dynamic palette changes.

The Qt's features do not work on QToolButton level, but on a QAction
level. This means that we have to open the QMenu manually.

The copyright info change reflects the fact that the history code was
contributed by Thomas in 2013. I'm leaving Glad in that file because he
still started doing this button UI thingy.

Change-Id: I818da0646a0fe6ed6c346c81e70ac6d2ffa0c9fd

M  +32   -69   src/Gui/LineEdit.cpp
M  +0    -6    src/Gui/LineEdit.h
M  +8    -18   src/Gui/MessageListWidget.cpp
M  +1    -1    src/Gui/MessageListWidget.h

http://commits.kde.org/trojita/4557439352a85ac9ff9abbaf52cdb0e23fb9d156
Comment 26 Jan Kundrát 2016-03-05 17:05:40 UTC
Git commit db916b2a18990cb487195462ff6ab991f20ad6b5 by Jan Kundrát.
Committed on 05/03/2016 at 16:17.
Pushed by gerrit into branch 'master'.

MessageView: Specify color roles without a QPalette detour

By specifying just the desired color roles instead of going through the
QPalette and doing that thing with colors, it seems that dynamic scheme
changes are now supported.

Change-Id: I0ab8fc0935fa91f67056cca5ecfee56424ce7e62

M  +4    -4    src/Gui/MessageView.cpp

http://commits.kde.org/trojita/db916b2a18990cb487195462ff6ab991f20ad6b5
Comment 27 Jan Kundrát 2016-03-05 17:05:40 UTC
Git commit 0107f850027ee5c190b710dff68c6767b271be55 by Jan Kundrát.
Committed on 05/03/2016 at 16:17.
Pushed by gerrit into branch 'master'.

Rely on systemwide palette for QWebView

This works well enough on this particular machine (a random snapshot of
Qt 5.6), so I'm optimistic that it might even work just fine all the way
back to Qt 5.2.

Change-Id: I894701c56f9e42118b516f9262ccab86f2136908

M  +0    -9    src/Gui/EmbeddedWebView.cpp

http://commits.kde.org/trojita/0107f850027ee5c190b710dff68c6767b271be55
Comment 28 Jan Kundrát 2016-03-08 08:24:44 UTC
Git commit 53ddfe7ebfe235ec8b0cf5823c81bbe41cda143c by Jan Kundrát.
Committed on 07/03/2016 at 14:32.
Pushed by gerrit into branch 'master'.

Use synthetic CSS for specifying colors of the "web" content

The usual story -- if the current color theme is dark and the QWebView
is showing an HTML message, Bad Stuff™ happens quite easily.

By going through a custom CSS stylesheet, we achieve more or less
consistent results as far as I can see -- including various HTML e-mails
that I have in my test collection. There are of course also e-mails
where it goes horribly wrong, so the real question is "should we try to
emulate dark theme on HTML content, or should we always use white
background in order to "better accommodate all content"?

Thomas was kind enough to add a heuristic which tries to arrive to font
colors which are usable on both dark and bright backgrounds, but as
usually -- it's just a heuristic, and it will break on certain inputs.

The alternative is to always and unconditionally force black-on-white. I
could do that pretty easily.

Change-Id: Iabdf9b0d97448b070fa7aa1ca4302cc6b2c8b77f

M  +27   -0    src/Gui/EmbeddedWebView.cpp
M  +1    -0    src/Gui/EmbeddedWebView.h
M  +1    -4    src/Gui/SimplePartWidget.cpp

http://commits.kde.org/trojita/53ddfe7ebfe235ec8b0cf5823c81bbe41cda143c
Comment 29 Jan Kundrát 2016-03-08 08:24:44 UTC
Git commit 6a65385a96221a285c9fe9e52d70bf5541071c36 by Jan Kundrát.
Committed on 07/03/2016 at 14:59.
Pushed by gerrit into branch 'master'.

HTML: Support selecting custom color schemes

...because one cannot please everybody, so let's add a funny button for
this. Oh well.
Change-Id: I51b380df4c93fb4e6eef175aaed99eaf742f8cba

M  +54   -16   src/Gui/EmbeddedWebView.cpp
M  +15   -0    src/Gui/EmbeddedWebView.h
M  +14   -0    src/Gui/SimplePartWidget.cpp

http://commits.kde.org/trojita/6a65385a96221a285c9fe9e52d70bf5541071c36
Comment 30 Hohyeis 2016-03-08 10:40:40 UTC
Created attachment 97760 [details]
Main window with message

The colors of background and text look alright now.  User theme colors are used.