mcallegari / qlcplus

Q Light Controller Plus (QLC+) is a free and cross-platform software to control DMX or analog lighting systems like moving heads, dimmers, scanners etc. This project is a fork of the great QLC project written by Heikki Junnila that aims to continue the QLC development and to introduce new features.
Apache License 2.0
1.02k stars 360 forks source link

Make the theme not affect the virtual console widgets #1603

Open Binary-Vanguard-12138 opened 3 months ago

Binary-Vanguard-12138 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

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 commented 3 months ago

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.