From 5c6ddf9cb37659d38c9f9b0f0281656c4015e71a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 30 Nov 2020 20:27:21 +0300 Subject: [PATCH] Disabled mouse events for mute button when state is inactive. --- ui/widgets/call_mute_button.cpp | 15 +++++++++++++++ ui/widgets/call_mute_button.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/ui/widgets/call_mute_button.cpp b/ui/widgets/call_mute_button.cpp index d03f154..69b9cc2 100644 --- a/ui/widgets/call_mute_button.cpp +++ b/ui/widgets/call_mute_button.cpp @@ -285,6 +285,7 @@ void CallMuteButton::init() { // State type. const auto previousType = lifetime().make_state(_state.current().type); + setEnableMouse(false); const auto glowColor = [=](CallMuteButtonType type) { if (IsInactive(type)) { @@ -302,6 +303,10 @@ void CallMuteButton::init() { const auto previous = *previousType; *previousType = type; + if (IsInactive(type) && !IsInactive(previous)) { + setEnableMouse(false); + } + const auto crossFrom = IsMuted(previous) ? 0. : 1.; const auto crossTo = IsMuted(type) ? 0. : 1.; @@ -347,6 +352,12 @@ void CallMuteButton::init() { } overridesColors(previous, type, value); + + if (value == to) { + if (!IsInactive(type) && IsInactive(previous)) { + setEnableMouse(true); + } + } }; _switchAnimation.stop(); @@ -462,6 +473,10 @@ void CallMuteButton::lower() { _blobs->lower(); } +void CallMuteButton::setEnableMouse(bool value) { + _content.setAttribute(Qt::WA_TransparentForMouseEvents, !value); +} + void CallMuteButton::overridesColors( CallMuteButtonType fromType, CallMuteButtonType toType, diff --git a/ui/widgets/call_mute_button.h b/ui/widgets/call_mute_button.h index 8f12d9a..69b5946 100644 --- a/ui/widgets/call_mute_button.h +++ b/ui/widgets/call_mute_button.h @@ -67,6 +67,8 @@ private: CallMuteButtonType toType, float64 progress); + void setEnableMouse(bool value); + rpl::variable _state; float _level = 0.; float64 _crossLineProgress = 0.;