Treat Button/ToolButton labels as plaintext
ClosedPublic

Authored by fvogt on Jul 13 2017, 1:07 PM.

Details

Summary

The label text gets treated as RichText/StyledText, which is required
to display mnemonics underlined. Therefore it is necessary to manually
HTML escape the label text, which unfortunately breaks mnemonics as
escaped HTML contains ampersands.
This commit fixes that by introducing a custom function to stylize
mnemonics in HTML escaped text.

Test Plan

Ran a modified knotificationdbustest with "<h1>&&a&ction</h1>" and
"actio&n2" as actions. Result: http://i.imgur.com/xHifDBu.png

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
fvogt created this revision.Jul 13 2017, 1:07 PM
Restricted Application added projects: Plasma, Frameworks. · View Herald TranscriptJul 13 2017, 1:07 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
broulik edited edge metadata.EditedJul 13 2017, 1:10 PM

+1

(for others reading this: Explicitly turning it into StyledText prevents Qt's AutoText from deciding to use PlainText in some cases which will then again look broken. Note that StyledText uses a basic string parser so it's nowhere near as heavy as RichText and should be fine)

Also note that QtQuick Controls Desktop style does not support HTML styling, so while this is a behavior change, I think it's fine and people shouldn't be using HTML formatting in buttons anyway.

src/declarativeimports/plasmastyle/ToolButtonStyle.qml
100

Text.StyledText

fvogt updated this revision to Diff 16649.Jul 13 2017, 1:12 PM

Fix typo in ToolButtonStyle

fvogt marked an inline comment as done.Jul 13 2017, 1:13 PM
fvogt added inline comments.
src/declarativeimports/plasmastyle/ToolButtonStyle.qml
100

I think the priority queue in my brain is somehow backwards

davidedmundson accepted this revision.Jul 25 2017, 2:00 PM
This revision is now accepted and ready to land.Jul 25 2017, 2:00 PM
This revision was automatically updated to reflect the committed changes.
fvogt marked an inline comment as done.