mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed false clicking on Silent post toggle when mouse is outside.
This commit is contained in:
parent
0f70f9e89d
commit
5515988439
2 changed files with 30 additions and 30 deletions
|
@ -31,23 +31,29 @@ SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
|
||||||
|
|
||||||
resize(_st.width, _st.height);
|
resize(_st.width, _st.height);
|
||||||
|
|
||||||
paintRequest(
|
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
|
||||||
auto p = QPainter(this);
|
|
||||||
paintRipple(p, _st.rippleAreaPosition, nullptr);
|
|
||||||
|
|
||||||
//const auto checked = _crossLineAnimation.value(_checked ? 1. : 0.);
|
|
||||||
const auto over = isOver();
|
|
||||||
(_checked
|
|
||||||
? (over
|
|
||||||
? st::historySilentToggleOnOver
|
|
||||||
: st::historySilentToggleOn)
|
|
||||||
: (over
|
|
||||||
? st::historySilentToggle.iconOver
|
|
||||||
: st::historySilentToggle.icon)).paintInCenter(p, rect());
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
clicks(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
setChecked(!_checked);
|
||||||
|
Ui::Tooltip::Show(0, this);
|
||||||
|
_channel->owner().notifySettings().update(_channel, {}, _checked);
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SilentToggle::paintEvent(QPaintEvent *e) {
|
||||||
|
auto p = QPainter(this);
|
||||||
|
paintRipple(p, _st.rippleAreaPosition, nullptr);
|
||||||
|
|
||||||
|
//const auto checked = _crossLineAnimation.value(_checked ? 1. : 0.);
|
||||||
|
const auto over = isOver();
|
||||||
|
(_checked
|
||||||
|
? (over
|
||||||
|
? st::historySilentToggleOnOver
|
||||||
|
: st::historySilentToggleOn)
|
||||||
|
: (over
|
||||||
|
? st::historySilentToggle.iconOver
|
||||||
|
: st::historySilentToggle.icon)).paintInCenter(p, rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
|
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
@ -62,11 +68,12 @@ void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
|
||||||
void SilentToggle::setChecked(bool checked) {
|
void SilentToggle::setChecked(bool checked) {
|
||||||
if (_checked != checked) {
|
if (_checked != checked) {
|
||||||
_checked = checked;
|
_checked = checked;
|
||||||
_crossLineAnimation.start(
|
update();
|
||||||
[=] { update(); },
|
// _crossLineAnimation.start(
|
||||||
_checked ? 0. : 1.,
|
// [=] { update(); },
|
||||||
_checked ? 1. : 0.,
|
// _checked ? 0. : 1.,
|
||||||
kAnimationDuration);
|
// _checked ? 1. : 0.,
|
||||||
|
// kAnimationDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,13 +82,6 @@ void SilentToggle::leaveEventHook(QEvent *e) {
|
||||||
Ui::Tooltip::Hide();
|
Ui::Tooltip::Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SilentToggle::mouseReleaseEvent(QMouseEvent *e) {
|
|
||||||
setChecked(!_checked);
|
|
||||||
RippleButton::mouseReleaseEvent(e);
|
|
||||||
Ui::Tooltip::Show(0, this);
|
|
||||||
_channel->owner().notifySettings().update(_channel, {}, _checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SilentToggle::tooltipText() const {
|
QString SilentToggle::tooltipText() const {
|
||||||
return _checked
|
return _checked
|
||||||
? tr::lng_wont_be_notified(tr::now)
|
? tr::lng_wont_be_notified(tr::now)
|
||||||
|
|
|
@ -29,8 +29,8 @@ public:
|
||||||
bool tooltipWindowActive() const override;
|
bool tooltipWindowActive() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
||||||
void leaveEventHook(QEvent *e) override;
|
void leaveEventHook(QEvent *e) override;
|
||||||
|
|
||||||
QImage prepareRippleMask() const override;
|
QImage prepareRippleMask() const override;
|
||||||
|
@ -42,7 +42,7 @@ private:
|
||||||
not_null<ChannelData*> _channel;
|
not_null<ChannelData*> _channel;
|
||||||
bool _checked = false;
|
bool _checked = false;
|
||||||
|
|
||||||
Animations::Simple _crossLineAnimation;
|
// Animations::Simple _crossLineAnimation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue