qlcplus icon indicating copy to clipboard operation
qlcplus copied to clipboard

Make the theme not affect the virtual console widgets

Open Binary-Vanguard-12138 opened this issue 1 year ago • 3 comments

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 avatar Aug 04 '24 15:08 Binary-Vanguard-12138

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.

Binary-Vanguard-12138 avatar Aug 04 '24 15:08 Binary-Vanguard-12138

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

mcallegari avatar Aug 18 '24 08:08 mcallegari

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.

yestalgia avatar Aug 24 '24 06:08 yestalgia