Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QLabel links not styled #139

Closed
goanpeca opened this issue Apr 26, 2019 · 4 comments · Fixed by #156
Closed

QLabel links not styled #139

goanpeca opened this issue Apr 26, 2019 · 4 comments · Fixed by #156

Comments

@goanpeca
Copy link
Collaborator

goanpeca commented Apr 26, 2019

Screen Shot 2019-04-25 at 20 02 59

Not possible via QSS but this provides a fix,

app = QCoreAppilcation.instance()
palette = app.palette()
palette.setColor(QPalette.Normal, QPalette.Link, Qt.red)
app.setPalette(palette)

Although if we want to support hover changes, (or even visited...) we need to provide custom QLabel to handle that programmatically.

Something naive like (assumes the user has added <a style="text-decoration:none;">...:

class QLabelLinks(QLabel):

    def __init__(self, *args, **kwargs):
        super(QLabelLinks, self).__init__( *args, **kwargs)

        self.linkHovered.connect(self._update_hover_html_link_style)

    def _update_hover_html_link_style(self, url):
        link = 'text-decoration:none;'
        link_hovered = 'text-decoration:underline;'
        self._url = url

        if url:
            QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
            new_text, old_text = link_hovered, link
        else:
            new_text, old_text = link, link_hovered
            QApplication.restoreOverrideCursor()

        text = self.text()
        new_text = text.replace(old_text, new_text)

        self.setText(new_text)
@dpizetta
Copy link
Collaborator

Do you mean that this class should be distributed with Qdark? What about keeping this class on the "user" app?

@goanpeca
Copy link
Collaborator Author

Hmm maybe ? Do not know or have a known issues section with tips like how to fix it. However I do think that the palette fix should be implemented. Either by running a helper function or similar.

@dpizetta
Copy link
Collaborator

dpizetta commented May 5, 2019

We should create a known-issues in docs? I will propose to use Sphinx to generate docs. I'll create a new issue about it.

@goanpeca
Copy link
Collaborator Author

goanpeca commented May 5, 2019

Sure, I think that would be sweet :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants