mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-23 01:27:15 +02:00
Replaced QTimer with base::Timer in OverlayWidget.
This commit is contained in:
parent
eb42a77eb7
commit
b6f17e1cea
2 changed files with 18 additions and 22 deletions
|
@ -322,8 +322,7 @@ OverlayWidget::OverlayWidget()
|
|||
, _radial([=](crl::time now) { return radialAnimationCallback(now); })
|
||||
, _lastAction(-st::mediaviewDeltaFromLastAction, -st::mediaviewDeltaFromLastAction)
|
||||
, _stateAnimation([=](crl::time now) { return stateAnimationCallback(now); })
|
||||
, _dropdown(this, st::mediaviewDropdownMenu)
|
||||
, _dropdownShowTimer(this) {
|
||||
, _dropdown(this, st::mediaviewDropdownMenu) {
|
||||
Lang::Updated(
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshLang();
|
||||
|
@ -410,23 +409,19 @@ OverlayWidget::OverlayWidget()
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
_saveMsgUpdater.setSingleShot(true);
|
||||
connect(&_saveMsgUpdater, SIGNAL(timeout()), this, SLOT(updateImage()));
|
||||
_saveMsgUpdater.setCallback([=] { updateImage(); });
|
||||
|
||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
_touchTimer.setSingleShot(true);
|
||||
connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
|
||||
_touchTimer.setCallback([=] { onTouchTimer(); });
|
||||
|
||||
_controlsHideTimer.setSingleShot(true);
|
||||
connect(&_controlsHideTimer, SIGNAL(timeout()), this, SLOT(onHideControls()));
|
||||
_controlsHideTimer.setCallback([=] { onHideControls(); });
|
||||
|
||||
_docDownload->addClickHandler([=] { onDownload(); });
|
||||
_docSaveAs->addClickHandler([=] { onSaveAs(); });
|
||||
_docCancel->addClickHandler([=] { onSaveCancel(); });
|
||||
|
||||
_dropdown->setHiddenCallback([this] { dropdownHidden(); });
|
||||
_dropdownShowTimer->setSingleShot(true);
|
||||
connect(_dropdownShowTimer, SIGNAL(timeout()), this, SLOT(onDropdown()));
|
||||
_dropdownShowTimer.setCallback([=] { onDropdown(); });
|
||||
}
|
||||
|
||||
void OverlayWidget::refreshLang() {
|
||||
|
@ -1240,7 +1235,7 @@ void OverlayWidget::close() {
|
|||
|
||||
void OverlayWidget::activateControls() {
|
||||
if (!_menu && !_mousePressed) {
|
||||
_controlsHideTimer.start(int(st::mediaviewWaitHide));
|
||||
_controlsHideTimer.callOnce(st::mediaviewWaitHide);
|
||||
}
|
||||
if (_fullScreenVideo) {
|
||||
if (_streamed) {
|
||||
|
@ -3113,7 +3108,7 @@ void OverlayWidget::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
if (!_blurred) {
|
||||
auto nextFrame = (dt < st::mediaviewSaveMsgShowing || hidingDt >= 0) ? int(AnimationTimerDelta) : (st::mediaviewSaveMsgShowing + st::mediaviewSaveMsgShown + 1 - dt);
|
||||
_saveMsgUpdater.start(nextFrame);
|
||||
_saveMsgUpdater.callOnce(nextFrame);
|
||||
}
|
||||
} else {
|
||||
_saveMsgStarted = 0;
|
||||
|
@ -3968,9 +3963,9 @@ bool OverlayWidget::updateOverState(OverState newState) {
|
|||
bool result = true;
|
||||
if (_over != newState) {
|
||||
if (newState == OverMore && !_ignoringDropdown) {
|
||||
_dropdownShowTimer->start(0);
|
||||
_dropdownShowTimer.callOnce(0);
|
||||
} else {
|
||||
_dropdownShowTimer->stop();
|
||||
_dropdownShowTimer.cancel();
|
||||
}
|
||||
updateOverRect(_over);
|
||||
updateOverRect(newState);
|
||||
|
@ -4163,7 +4158,7 @@ void OverlayWidget::touchEvent(QTouchEvent *e) {
|
|||
switch (e->type()) {
|
||||
case QEvent::TouchBegin: {
|
||||
if (_touchPress || e->touchPoints().isEmpty()) return;
|
||||
_touchTimer.start(QApplication::startDragTime());
|
||||
_touchTimer.callOnce(QApplication::startDragTime());
|
||||
_touchPress = true;
|
||||
_touchMove = _touchRightButton = false;
|
||||
_touchStart = e->touchPoints().cbegin()->screenPos().toPoint();
|
||||
|
@ -4203,14 +4198,14 @@ void OverlayWidget::touchEvent(QTouchEvent *e) {
|
|||
}
|
||||
}
|
||||
if (weak) {
|
||||
_touchTimer.stop();
|
||||
_touchTimer.cancel();
|
||||
_touchPress = _touchMove = _touchRightButton = false;
|
||||
}
|
||||
} break;
|
||||
|
||||
case QEvent::TouchCancel: {
|
||||
_touchPress = false;
|
||||
_touchTimer.stop();
|
||||
_touchTimer.cancel();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -4315,7 +4310,7 @@ void OverlayWidget::setVisibleHook(bool visible) {
|
|||
_preloadPhotos.clear();
|
||||
_preloadDocuments.clear();
|
||||
if (_menu) _menu->hideMenu(true);
|
||||
_controlsHideTimer.stop();
|
||||
_controlsHideTimer.cancel();
|
||||
_controlsState = ControlsShown;
|
||||
_controlsOpacity = anim::value(1, 1);
|
||||
_groupThumbs = nullptr;
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
@ -493,13 +494,13 @@ private:
|
|||
};
|
||||
ControlsState _controlsState = ControlsShown;
|
||||
crl::time _controlsAnimStarted = 0;
|
||||
QTimer _controlsHideTimer;
|
||||
base::Timer _controlsHideTimer;
|
||||
anim::value _controlsOpacity;
|
||||
bool _mousePressed = false;
|
||||
|
||||
Ui::PopupMenu *_menu = nullptr;
|
||||
object_ptr<Ui::DropdownMenu> _dropdown;
|
||||
object_ptr<QTimer> _dropdownShowTimer;
|
||||
base::Timer _dropdownShowTimer;
|
||||
|
||||
struct ActionData {
|
||||
QString text;
|
||||
|
@ -512,7 +513,7 @@ private:
|
|||
bool _touchPress = false;
|
||||
bool _touchMove = false;
|
||||
bool _touchRightButton = false;
|
||||
QTimer _touchTimer;
|
||||
base::Timer _touchTimer;
|
||||
QPoint _touchStart;
|
||||
QPoint _accumScroll;
|
||||
|
||||
|
@ -520,7 +521,7 @@ private:
|
|||
crl::time _saveMsgStarted = 0;
|
||||
anim::value _saveMsgOpacity;
|
||||
QRect _saveMsg;
|
||||
QTimer _saveMsgUpdater;
|
||||
base::Timer _saveMsgUpdater;
|
||||
Ui::Text::String _saveMsgText;
|
||||
SavePhotoVideo _savePhotoVideoWhenLoaded = SavePhotoVideo::None;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue