Bug 320342 - notes plasmoid doesn't visually change the text color on a plasma theme change
Summary: notes plasmoid doesn't visually change the text color on a plasma theme change
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Plasma
Component: widget-notes (show other bugs)
Version: 4.10.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-27 10:04 UTC by Wolfgang Bauer
Modified: 2013-06-25 20:02 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.10.5


Attachments
Androbit notes when using ButtonTextColor (182.12 KB, image/png)
2013-06-20 09:42 UTC, Wolfgang Bauer
Details
Androbit notes when using TextColor (273.66 KB, image/png)
2013-06-20 09:44 UTC, Wolfgang Bauer
Details
Slim Glow notes when using ButtonTextColor (257.80 KB, image/png)
2013-06-20 09:45 UTC, Wolfgang Bauer
Details
Slim Glow notes when using TextColor (218.88 KB, image/png)
2013-06-20 09:46 UTC, Wolfgang Bauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bauer 2013-05-27 10:04:38 UTC
By default, "Use theme color" is set for a notes plasmoid, so the text color is taken from the current plasma theme.
But when you change the plasma theme, the text color doesn't adapt to the new one, only the cursor changes its color.
You have to restart plasma for the change to take effect on the notes plasmoid.

Reproducible: Always

Steps to Reproduce:
1. create a note plasmoid with some text
2. check that setting "Use theme color" is set
3. change plasma theme to one with a different text color
Actual Results:  
Text stays in the same color, cursor does change the color though

Expected Results:  
Text has the new color

To fix this, in the slot themeChanged() the following should be done instead of calling update():

        QTextCursor oldCursor = m_noteEditor->textCursor();
        m_noteEditor->selectAll();
        m_noteEditor->setTextColor(m_textColor);
        m_noteEditor->setTextCursor(oldCursor);

Like it is done in configChanged().
Comment 1 Anne-Marie Mahfouf 2013-05-29 07:23:23 UTC
Hi, for me the cursor is always the theme color even with your patch. When I switch from Air to Oxygen theme the cursor becomes white. I had tried to fix this in the past but it's still broken somehow.

The lines you add are for changing the whole text color, not the cursor color.
Comment 2 Wolfgang Bauer 2013-05-29 08:50:28 UTC
Yes. The cursor behaves correctly. But the text color doesn't change although it's set to use the color from the plasma theme. If you restart plasma it does change.
Comment 3 Anne-Marie Mahfouf 2013-05-29 18:37:31 UTC
Hi, sorry, I got mixed up, I thought this was about the cursor color.

The patch only works for me if I also change the first line from
m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor);
to 
m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);

The patch is therefore:
diff --git a/applets/notes/notes.cpp b/applets/notes/notes.cpp
index 5c2ed70..0b6092c 100644
--- a/applets/notes/notes.cpp
+++ b/applets/notes/notes.cpp
@@ -356,8 +356,11 @@ void Notes::saveState(KConfigGroup &cg) const
 void Notes::themeChanged()
 {
     if (m_useThemeColor) {
-        m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor);
-        update();
+        m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
+        QTextCursor oldCursor = m_noteEditor->textCursor();
+        m_noteEditor->selectAll();
+        m_noteEditor->setTextColor(m_textColor);
+        m_noteEditor->setTextCursor(oldCursor);
     }
 }

also in configChanged, in line 192
        m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor);
should be
        m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
Comment 4 Anne-Marie Mahfouf 2013-05-29 18:58:28 UTC
https://git.reviewboard.kde.org/r/110716/

Feel free to comment Wolfgang!
Comment 5 Wolfgang Bauer 2013-05-29 21:02:00 UTC
(In reply to comment #3)
> The patch only works for me if I also change the first line from
> m_textColor =
> Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor);
> to 
> m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
It does work with ButtonTextColor as well, it just may have an unexpected result with certain themes which have different TextColor and ButtonTextColor.

And of course this should be used consistent everywhere in the applet. I just now discovered that in configAccepted(), line 526 TextColor is used, in the other 2 places (configChanged() and themeChanged()) TextButtonColor, so this has been another bug...

Well, I guess using TextColor instead of TextButtonColor would be more correct semantically.

So, IMHO the patch in reviewboard seems to be 100% ok now.

Thanks for the fast response! :-)
Comment 6 Hrvoje Senjan 2013-05-29 21:05:59 UTC
AFAICS, exactly cause of a similar issue was ButtonColour chosen instead of TextColour (at least git log says so)
Comment 7 Anne-Marie Mahfouf 2013-05-31 09:05:34 UTC
It won't make it to 4.10.4 as nobody reviews it :(
Comment 8 Wolfgang Bauer 2013-06-20 09:42:45 UTC
Created attachment 80658 [details]
Androbit notes when using ButtonTextColor

Regarding TextColor vs. TextButtonColor:
I have now compared those 2 with all the themes I have installed.

For most it doesn't matter (the text colors are the same), but there were 2 exceptions:
- Androbit: Notes are not readable when using TextButtonColor (black on black), but fine when using TextColor (white on black); Androbit is a bit special as it brings it's own background theme for the notes which can't be changed AFAIK.
- Slow Glim: here it is the other way round, TextButtonColor results in black on yellow, TextColor in white on yellow (hardly readable). But this would be fixed by the patch I have ready for bug#320350, I will put that up on reviewboard today.

See also attached screenshots.

So all in all, TextColor would indeed be the better choice IMHO (especially for Androbit where you can't change the background color).
Comment 9 Wolfgang Bauer 2013-06-20 09:44:08 UTC
Created attachment 80659 [details]
Androbit notes when using TextColor
Comment 10 Wolfgang Bauer 2013-06-20 09:45:19 UTC
Created attachment 80660 [details]
Slim Glow notes when using ButtonTextColor
Comment 11 Wolfgang Bauer 2013-06-20 09:46:01 UTC
Created attachment 80661 [details]
Slim Glow notes when using TextColor
Comment 12 Wolfgang Bauer 2013-06-25 18:41:43 UTC
Git commit ec261d923cc5773430b93d0248b1e9642eb4db26 by Wolfgang Bauer.
Committed on 25/06/2013 at 18:34.
Pushed by wbauer into branch 'KDE/4.10'.

Visually change the text color when plasma theme changes

Patch by Anne-Marie Mahfouf

For theme text color, the code was Plasma::Theme::ButtonTextColor
instead of Plasma::Theme::TextColor in 2 places. When the theme changes,
make the text change color.
FIXED-IN: 4.10.5
REVIEW: 110716

M  +6    -3    applets/notes/notes.cpp

http://commits.kde.org/kdeplasma-addons/ec261d923cc5773430b93d0248b1e9642eb4db26
Comment 13 Wolfgang Bauer 2013-06-25 19:37:12 UTC
Git commit 07c290bd345891aaad83f3acce652bd2aab97477 by Wolfgang Bauer.
Committed on 25/06/2013 at 19:34.
Pushed by wbauer into branch 'master'.

Visually change the text color when plasma theme changes

Patch by Anne-Marie Mahfouf

For theme text color, the code was Plasma::Theme::ButtonTextColor
instead of Plasma::Theme::TextColor in 2 places. When the theme changes,
make the text change color.
REVIEW: 110716

M  +6    -3    applets/notes/notes.cpp

http://commits.kde.org/kdeplasma-addons/07c290bd345891aaad83f3acce652bd2aab97477
Comment 14 Wolfgang Bauer 2013-06-25 20:02:46 UTC
I took the liberty to commit this because I wanted to make sure it ends up in 4.10.5. I hope you don't mind.

Thanks again!