Fixed volume percents painting in volume menu item in group calls.
This commit is contained in:
parent
e9864bcf5b
commit
71ee981371
|
@ -25,6 +25,10 @@ constexpr auto kSpeakerThreshold = {
|
||||||
50.0f / kMaxVolumePercent,
|
50.0f / kMaxVolumePercent,
|
||||||
150.0f / kMaxVolumePercent };
|
150.0f / kMaxVolumePercent };
|
||||||
|
|
||||||
|
QString VolumeString(int volumePercent) {
|
||||||
|
return u"%1%"_q.arg(volumePercent);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MenuVolumeItem::MenuVolumeItem(
|
MenuVolumeItem::MenuVolumeItem(
|
||||||
|
@ -61,14 +65,13 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
const auto geometry = QRect(QPoint(), size);
|
const auto geometry = QRect(QPoint(), size);
|
||||||
_itemRect = geometry - _st.itemPadding;
|
_itemRect = geometry - _st.itemPadding;
|
||||||
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
||||||
_volumeRect = _speakerRect.translated(
|
|
||||||
_stCross.icon.width() + st::groupCallMenuVolumeSkip,
|
|
||||||
0);
|
|
||||||
_arcPosition = _speakerRect.center()
|
_arcPosition = _speakerRect.center()
|
||||||
+ QPoint(0, st::groupCallMenuSpeakerArcsSkip);
|
+ QPoint(0, st::groupCallMenuSpeakerArcsSkip);
|
||||||
|
|
||||||
_slider->setGeometry(_itemRect
|
_slider->setGeometry(_itemRect
|
||||||
- style::margins(0, contentHeight() / 2, 0, 0));
|
- style::margins(0, contentHeight() / 2, 0, 0));
|
||||||
|
|
||||||
|
computeVolumeRect();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
setCloudVolume(startVolume);
|
setCloudVolume(startVolume);
|
||||||
|
@ -92,7 +95,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
muteProgress);
|
muteProgress);
|
||||||
p.setPen(mutePen);
|
p.setPen(mutePen);
|
||||||
p.setFont(_st.itemStyle.font);
|
p.setFont(_st.itemStyle.font);
|
||||||
p.drawText(_volumeRect, u"%1%"_q.arg(volume), style::al_center);
|
p.drawText(_volumeRect, VolumeString(volume), style::al_left);
|
||||||
|
|
||||||
_crossLineMute->paint(
|
_crossLineMute->paint(
|
||||||
p,
|
p,
|
||||||
|
@ -121,6 +124,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
||||||
}
|
}
|
||||||
|
computeVolumeRect();
|
||||||
update(_volumeRect);
|
update(_volumeRect);
|
||||||
_arcs->setValue(value);
|
_arcs->setValue(value);
|
||||||
});
|
});
|
||||||
|
@ -182,6 +186,7 @@ void MenuVolumeItem::initArcsAnimation() {
|
||||||
_arcsAnimation.init([=](crl::time now) {
|
_arcsAnimation.init([=](crl::time now) {
|
||||||
_arcs->update(now);
|
_arcs->update(now);
|
||||||
update(_speakerRect);
|
update(_speakerRect);
|
||||||
|
computeVolumeRect();
|
||||||
});
|
});
|
||||||
|
|
||||||
_arcs->startUpdateRequests(
|
_arcs->startUpdateRequests(
|
||||||
|
@ -197,6 +202,19 @@ void MenuVolumeItem::initArcsAnimation() {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuVolumeItem::computeVolumeRect() {
|
||||||
|
const auto was = _volumeRect;
|
||||||
|
_volumeRect = QRect(
|
||||||
|
_arcPosition.x() + st::groupCallMenuVolumeSkip + _arcs->width(),
|
||||||
|
_speakerRect.y(),
|
||||||
|
_st.itemStyle.font->width(VolumeString(kMaxVolumePercent)),
|
||||||
|
_speakerRect.height());
|
||||||
|
if (was != _volumeRect) {
|
||||||
|
// Clear the previous text rendering.
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QColor MenuVolumeItem::unmuteColor() const {
|
QColor MenuVolumeItem::unmuteColor() const {
|
||||||
return (isSelected()
|
return (isSelected()
|
||||||
? _st.itemFgOver
|
? _st.itemFgOver
|
||||||
|
|
|
@ -53,6 +53,8 @@ private:
|
||||||
void setCloudVolume(int volume);
|
void setCloudVolume(int volume);
|
||||||
void setSliderVolume(int volume);
|
void setSliderVolume(int volume);
|
||||||
|
|
||||||
|
void computeVolumeRect();
|
||||||
|
|
||||||
QColor unmuteColor() const;
|
QColor unmuteColor() const;
|
||||||
QColor muteColor() const;
|
QColor muteColor() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue