Removed redundant record methods from SendButton.

This commit is contained in:
23rd 2020-10-04 18:25:03 +03:00 committed by John Preston
parent 3e4866d3b7
commit e7454e3849
2 changed files with 0 additions and 61 deletions

View File

@ -66,15 +66,6 @@ void SendButton::finishAnimating() {
update();
}
void SendButton::mouseMoveEvent(QMouseEvent *e) {
AbstractButton::mouseMoveEvent(e);
if (_recording) {
if (_recordUpdateCallback) {
_recordUpdateCallback(e->globalPos());
}
}
}
void SendButton::requestPaintRecord(float64 progress) {
if (_type == Type::Record) {
_recordProgress = progress;
@ -189,27 +180,6 @@ void SendButton::paintSlowmode(Painter &p) {
style::al_center);
}
void SendButton::onStateChanged(State was, StateChangeSource source) {
RippleButton::onStateChanged(was, source);
auto down = (state() & StateFlag::Down);
if ((was & StateFlag::Down) != down) {
if (down) {
if (_type == Type::Record) {
_recording = true;
if (_recordStartCallback) {
_recordStartCallback();
}
}
} else if (_recording) {
_recording = false;
if (_recordStopCallback) {
_recordStopCallback(_recordActive);
}
}
}
}
bool SendButton::isSlowmode() const {
return (_slowmodeDelay > 0);
}
@ -248,11 +218,4 @@ QPoint SendButton::prepareRippleStartPosition() const {
return real - QPoint((width() - size) / 2, y);
}
void SendButton::recordAnimationCallback() {
update();
if (_recordAnimationCallback) {
_recordAnimationCallback();
}
}
} // namespace Ui

View File

@ -29,35 +29,18 @@ public:
return _type;
}
void setType(Type state);
void setRecordActive(bool recordActive);
void setSlowmodeDelay(int seconds);
void finishAnimating();
void setRecordStartCallback(Fn<void()> callback) {
_recordStartCallback = std::move(callback);
}
void setRecordUpdateCallback(Fn<void(QPoint globalPos)> callback) {
_recordUpdateCallback = std::move(callback);
}
void setRecordStopCallback(Fn<void(bool active)> callback) {
_recordStopCallback = std::move(callback);
}
void setRecordAnimationCallback(Fn<void()> callback) {
_recordAnimationCallback = std::move(callback);
}
void requestPaintRecord(float64 progress);
protected:
void mouseMoveEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void onStateChanged(State was, StateChangeSource source) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
void recordAnimationCallback();
[[nodiscard]] QPixmap grabContent();
[[nodiscard]] bool isSlowmode() const;
@ -70,19 +53,12 @@ private:
Type _type = Type::Send;
Type _afterSlowmodeType = Type::Send;
bool _recordActive = false;
QPixmap _contentFrom, _contentTo;
Ui::Animations::Simple _a_typeChanged;
float64 _recordProgress = 0.;
bool _recording = false;
Fn<void()> _recordStartCallback;
Fn<void(bool active)> _recordStopCallback;
Fn<void(QPoint globalPos)> _recordUpdateCallback;
Fn<void()> _recordAnimationCallback;
int _slowmodeDelay = 0;
QString _slowmodeDelayText;