fix: make `getLinkStyle` work again

Probably slipped through in the refactor: `getLinkStyle` was defined
in to places, was probably meant to live only in `Utils`.

In addition, it expected a `wrapper` expression which wasn't defined.
This commit fixes it by removing the second declaration of that function
and passing a third parameter to the one defined in `Utils`.
This commit is contained in:
Pascal Precht 2021-10-21 11:15:33 +02:00 committed by r4bbit.eth
parent 193b42ed54
commit 59109e1318
3 changed files with 6 additions and 17 deletions

View File

@ -73,7 +73,7 @@ Item {
StyledTextEdit { StyledTextEdit {
id: communityName id: communityName
text: Utils.getLinkStyle(communityBadge.communityName, hoveredLink) text: Utils.getLinkStyle(communityBadge.communityName, hoveredLink, textColor)
height: 18 height: 18
readOnly: true readOnly: true
textFormat: Text.RichText textFormat: Text.RichText
@ -104,7 +104,7 @@ Item {
StyledTextEdit { StyledTextEdit {
id: channelName id: channelName
text: Utils.getLinkStyle(communityBadge.channelName || name, hoveredLink) text: Utils.getLinkStyle(communityBadge.channelName || name, hoveredLink, textColor)
height: 18 height: 18
readOnly: true readOnly: true
textFormat: Text.RichText textFormat: Text.RichText

View File

@ -100,20 +100,9 @@ Item {
} }
} }
function getLinkStyle(link, hoveredLink) {
return `<style type="text/css">` +
`a {` +
`color: ${wrapper.textColor};` +
`text-decoration: none;` +
`}` +
(hoveredLink !== "" ? `a[href="${hoveredLink}"] { text-decoration: underline; }` : "") +
`</style>` +
`<a href="${link}">${link}</a>`
}
StyledTextEdit { StyledTextEdit {
id: communityName id: communityName
text: communityBadge.getLinkStyle(communityBadge.communityName, hoveredLink) text: Utils.getLinkStyle(communityBadge.communityName, hoveredLink, wrapper.textColor)
height: 18 height: 18
readOnly: true readOnly: true
textFormat: Text.RichText textFormat: Text.RichText
@ -146,7 +135,7 @@ Item {
StyledTextEdit { StyledTextEdit {
id: channelName id: channelName
text: communityBadge.getLinkStyle(communityBadge.channelName || wrapper.name, hoveredLink) text: communityBadge.getLinkStyle(communityBadge.channelName || wrapper.name, hoveredLink, wrapper.textColor)
height: 18 height: 18
readOnly: true readOnly: true
textFormat: Text.RichText textFormat: Text.RichText

View File

@ -115,10 +115,10 @@ QtObject {
`</html>` `</html>`
} }
function getLinkStyle(link, hoveredLink) { function getLinkStyle(link, hoveredLink, textColor) {
return `<style type="text/css">` + return `<style type="text/css">` +
`a {` + `a {` +
`color: ${wrapper.textColor};` + `color: ${textColor};` +
`text-decoration: none;` + `text-decoration: none;` +
`}` + `}` +
(hoveredLink !== "" ? `a[href="${hoveredLink}"] { text-decoration: underline; }` : "") + (hoveredLink !== "" ? `a[href="${hoveredLink}"] { text-decoration: underline; }` : "") +