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

Make the theme not affect the virtual console widgets #1603

Open
Binary-Vanguard-12138 opened this issue Aug 4, 2024 · 3 comments
Open

Make the theme not affect the virtual console widgets #1603

Binary-Vanguard-12138 opened this issue Aug 4, 2024 · 3 comments

Comments

@Binary-Vanguard-12138
Copy link
Contributor

We need to change the theme so it never interferes with the virtual console
Because currently the theme file overrides the virtual console widgets and makes them look horrible.

image

The reason we need to fix this is because the user needs to be able to change the colours of things on the virtual console.

@Binary-Vanguard-12138
Copy link
Contributor Author

Binary-Vanguard-12138 commented Aug 4, 2024

Hi, @mcallegari
To solve this issue, I'm trying to update the code as follows.
(This is just an example. VCSlider widget top label)

The VCSlider top label is defined like this. (vcslider.cpp)

m_topLabel = new QLabel(this);
m_topLabel->setAlignment(Qt::AlignHCenter);
layout()->addWidget(m_topLabel);

This works as follows.

image

I will update like this.

m_topLabel = new QLabel;
m_topLabel->setAlignment(Qt::AlignHCenter);
// Now the label is a top-level widget with no parent style sheet
m_topLabel->setAttribute(Qt::WA_NoSystemBackground);
m_topLabel->setAttribute(Qt::WA_TranslucentBackground);
m_topLabel->setPalette(QPalette());
m_topLabel->setStyleSheet("QLabel { color: palette(text); }");
m_topLabel->setParent(this); // Reparent the label to this widget
layout()->addWidget(m_topLabel);

The result as follows.

image

If we follow this, we have to check & update all of the VC widgets.

What do you think?

Without applying a theme, VCSlider top label font looks too light.(light gray color)
image

But the above code makes the font color black.

@mcallegari
Copy link
Owner

mcallegari commented Aug 18, 2024

This is a quite complicated topic, since there are many variables involved:

  • style sheets
  • OS-style base colors
  • user-defined VC colors
  • enable/disable states

What I found so far:
OS colors can be retrieved via palette() like this:

m_topLabel->setStyleSheet(QString("QLabel{ background: %1; color: %2; }")
                                     .arg(m_topLabel->palette().window().color().name())
                                     .arg(m_topLabel->palette().windowText().color().name()));

however this doesn't consider enable/disable state and probably ignores user-defined colors.

VC items can be customized via style

VCSlider QLabel {
  color: black;
  background: red;
}
VCSlider QLabel:disabled {
  color: gray;
}

But again, this ignores user-defined colors.
There is no easy solution to this.
I am still investigating

@yestalgia
Copy link
Contributor

I've tried a bunch of ways to exclude the VC widgets from the QSS file (by manually selecting all the qWidgets excluding the vc widgets for each style) but it's super painful.

For now - my plan is to do what @mcallegari has suggested and theme the widgets individually.

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

No branches or pull requests

3 participants