mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Change volume by wheel events on volume icon.
This commit is contained in:
parent
07dfe88d62
commit
c153cdc70e
3 changed files with 23 additions and 3 deletions
|
@ -57,6 +57,10 @@ void VolumeController::setIsVertical(bool vertical) {
|
|||
_slider->setAlwaysDisplayMarker(vertical);
|
||||
}
|
||||
|
||||
void VolumeController::outerWheelEvent(not_null<QWheelEvent*> e) {
|
||||
QGuiApplication::sendEvent(_slider.data(), e);
|
||||
}
|
||||
|
||||
void VolumeController::resizeEvent(QResizeEvent *e) {
|
||||
_slider->setGeometry(rect());
|
||||
}
|
||||
|
@ -78,7 +82,8 @@ void VolumeController::applyVolumeChange(float64 volume) {
|
|||
|
||||
void PrepareVolumeDropdown(
|
||||
not_null<Dropdown*> dropdown,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
not_null<Window::SessionController*> controller,
|
||||
rpl::producer<not_null<QWheelEvent*>> outerWheelEvents) {
|
||||
const auto volume = Ui::CreateChild<VolumeController>(
|
||||
dropdown.get(),
|
||||
controller);
|
||||
|
@ -98,6 +103,12 @@ void PrepareVolumeDropdown(
|
|||
- ((st::mediaPlayerVolumeSize.width()
|
||||
- st::mediaPlayerPanelPlayback.width) / 2)));
|
||||
}, volume->lifetime());
|
||||
|
||||
std::move(
|
||||
outerWheelEvents
|
||||
) | rpl::start_with_next([=](not_null<QWheelEvent*> e) {
|
||||
volume->outerWheelEvent(e);
|
||||
}, volume->lifetime());
|
||||
}
|
||||
|
||||
} // namespace Media::Player
|
||||
|
|
|
@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/rp_widget.h"
|
||||
#include "base/object_ptr.h"
|
||||
|
||||
class QWheelEvent;
|
||||
|
||||
namespace Ui {
|
||||
class MediaSlider;
|
||||
} // namespace Ui
|
||||
|
@ -29,6 +31,7 @@ public:
|
|||
not_null<Window::SessionController*> controller);
|
||||
|
||||
void setIsVertical(bool vertical);
|
||||
void outerWheelEvent(not_null<QWheelEvent*> e);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
@ -43,6 +46,7 @@ private:
|
|||
|
||||
void PrepareVolumeDropdown(
|
||||
not_null<Dropdown*> dropdown,
|
||||
not_null<Window::SessionController*> controller);
|
||||
not_null<Window::SessionController*> controller,
|
||||
rpl::producer<not_null<QWheelEvent*>> outerWheelEvents);
|
||||
|
||||
} // namespace Media::Player
|
||||
|
|
|
@ -515,7 +515,12 @@ Widget::Widget(
|
|||
handleSongUpdate(state);
|
||||
}, lifetime());
|
||||
|
||||
PrepareVolumeDropdown(_volume.get(), controller);
|
||||
PrepareVolumeDropdown(_volume.get(), controller, _volumeToggle->events(
|
||||
) | rpl::filter([=](not_null<QEvent*> e) {
|
||||
return (e->type() == QEvent::Wheel);
|
||||
}) | rpl::map([=](not_null<QEvent*> e) {
|
||||
return not_null{ static_cast<QWheelEvent*>(e.get()) };
|
||||
}));
|
||||
_volumeToggle->installEventFilter(_volume.get());
|
||||
_volume->events(
|
||||
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue