-
Notifications
You must be signed in to change notification settings - Fork 227
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
Audiomixerboard: Auto-reduce size when switching between meter styles #2352
Audiomixerboard: Auto-reduce size when switching between meter styles #2352
Conversation
Something like this explicitly sets a border similar to what it looks like for me for the Bar style, but I'm not sure it would be a good idea as it probabl overrides default operating styles: diff --git a/src/levelmeter.cpp b/src/levelmeter.cpp
index 1244daf3..4658d1b3 100644
--- a/src/levelmeter.cpp
+++ b/src/levelmeter.cpp
@@ -173,6 +173,7 @@ void CLevelMeter::SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType,
if ( bIsClip )
{
pBarMeter->setStyleSheet ( "QProgressBar { border: 2px solid red;"
+ " border-radius: 4px;"
" margin: 1px;"
" padding: 1px;"
" width: 15px;"
@@ -181,7 +182,9 @@ void CLevelMeter::SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType,
}
else
{
- pBarMeter->setStyleSheet ( "QProgressBar { margin: 1px;"
+ pBarMeter->setStyleSheet ( "QProgressBar { border: 2px solid #ccc;"
+ " border-radius: 4px;"
+ " margin: 1px;"
" padding: 1px;"
" width: 15px; }"
"QProgressBar::chunk { background: green; }" ); Also, based on my CSS understanding, I don't know why it would be necessary at all. But maybe Qt is specific or I'm missing some detail. |
I believe that the stylesheet is not reset to a default or that it remembers what the previous setting was, as if it remove all previous set values. Think it needs explicit to be set again when changing.
Round LEDs can be selected in any skin mode. So don't think they should always use the "narrow" style, but think in "Compact" mode it could. |
Small LEDs now seem to work as how I originally would have like to implement it. Nice work @hoffie and thanks for fixing (tested with the build generate from this PR). So at least we have an option to keep the smallest space for the fader when switching between narrow bar and small leds. Other styles still changes the width, but to be honest I would not call that a bug. It is done by "design". |
I suspected something like this, but found contrary information here: https://www.qtcentre.org/threads/38841-How-to-reset-a-stylesheet-to-default?p=178450#post178450 (just a forum thread though, so might be inaccurate). Do you have an idea what to set
Ok, I'll look into it. |
I have seen really odd behaviours sometimes it can be fixed by explicit setting the border option to no. But then I have also seen that, when doing it, is suddenly inherits some style/spacing from other item it is placed in. |
Pardon? Do you mean it's a fix to a bug introduced within the release cycle? That means tagging the new feature with this PR as well, then. |
Hmm, ok. I've moved Round LEDs back to the regular code path. I think I've found the real reason for the size changes: The stacked layout seems to take the width of the widest member. I'm currently looking for ways around that. |
I remember now I that I tried to only "modify" the meterstyle when changing the appearance and not also updating the "skin" style settings. It seems almost not possible to not have a link between them to keep a consistent/view layout. |
Short update: I still think that the QStackedLayout behavior is the issue. I'm currently experimenting with the following:
I think the following is code which only exists due to this exact bug and I don't think it is a nice solution: Edit: Oh and BTW, what I did yesterday was the same category of change. I think it's wrong to do it that way, now that I understand it more deeply. |
caae861
to
f2d392b
Compare
There are two different base meter styles (LED vs. bars) with multiple variants each (regular, slim, round). The base meter styles are implmeneted as widgets and are always part of a QStackedLayout. The selected meter style is shown via setCurrentWidget(). This hides the inactive widget, but the inactive widget is still there and is part of QStackedLayout's size calculations which always uses the maximum size over all widgets, not just the currently visible one. This leads to problems when the currently visible meter widget is narrower than the hidden counterpart. In that case, the QStackedLayout is wider than expected. Technically, the following transitions show this issue: - Select Bar, then Small LEDs, or - Select LEDs, then Narrow Bar However, the latter case already had a workaround (choosing Narrow Bar silently adjusted details of the LED meter as well). The proper fix is using a subclass of QStackedLayout which calculates its sizeHint solely based on the currently visible widget. This fixes the Bar->Small LEDs transition and makes the LEDs->Narrow Bar workaround redundant, which has therefore been removed. Fixes jamulussoftware#2351
f2d392b
to
01b0c3a
Compare
I think I now understand the issue and have a fix which looks proper and seems to work. I've updated the PR along with its description.
Yep, I've added the PR to the existing ChangeLog entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK. On my Pi, I've compiled and compared this commit with its parent commit, and the sizing is more consistent with this PR. When changing meter modes, I only observed any changes in the overall width of a channel when in Compact mode. In other modes, the channel width was determined by the name box, and was not affected by changes to the LED/Bar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like a really nice fix! (Not tested yet.)
How to?? (assets?) |
This one look OK to me! |
Seem working fine to me as well. Nice work! |
Short description of changes
There are two different base meter styles (LED vs. bars) with multiple variants each (regular, slim, round). The base meter styles are implmeneted as widgets and are always part of a
QStackedLayout
. The selected meter style is shown viasetCurrentWidget()
. This hides the inactive widget, but the inactive widget is still there and is part ofQStackedLayout
's size calculations which always uses the maximum size over all widgets, not just the currently visible one.This leads to problems when the currently visible meter widget is narrower than the hidden counterpart. In that case, the
QStackedLayout
is wider than expected.Technically, the following transitions show this issue:
However, the latter case already had a workaround (choosing Narrow Bar silently adjusted details of the LED meter as well).
The proper fix is using a subclass of QStackedLayout which calculates its sizeHint solely based on the currently visible widget.
This fixes the Bar->Small LEDs transition and makes the LEDs->Narrow Bar workaround redundant, which has therefore been removed.
Context: Fixes an issue?
Fixes #2351
Initially reported here: #1688 (comment)
Does this change need documentation? What needs to be documented and how?
No ChangeLog entry as the bug was not part of a release. The PR adds itself to the existing ChangeLog entry.
CHANGELOG:SKIP
Status of this Pull Request
Ready for testing/review
What is missing until this pull request can be merged?
Checklist