Remove Q_OBJECT from VolumeWidget.

This commit is contained in:
John Preston 2021-11-18 20:11:39 +04:00
parent f4a6be2ed9
commit a2bf1544df
2 changed files with 28 additions and 34 deletions

View file

@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/continuous_sliders.h" #include "ui/widgets/continuous_sliders.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "base/object_ptr.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -81,16 +80,12 @@ VolumeWidget::VolumeWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: RpWidget(parent) : RpWidget(parent)
, _controller(this, controller) { , _controller(this, controller)
, _hideTimer([=] { startHide(); })
, _showTimer([=] { startShow(); }) {
hide(); hide();
_controller->setIsVertical(true); _controller->setIsVertical(true);
_hideTimer.setSingleShot(true);
connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(onHideStart()));
_showTimer.setSingleShot(true);
connect(&_showTimer, SIGNAL(timeout()), this, SLOT(onShowStart()));
macWindowDeactivateEvents( macWindowDeactivateEvents(
) | rpl::filter([=] { ) | rpl::filter([=] {
return !isHidden(); return !isHidden();
@ -150,44 +145,44 @@ void VolumeWidget::paintEvent(QPaintEvent *e) {
} }
void VolumeWidget::enterEventHook(QEnterEvent *e) { void VolumeWidget::enterEventHook(QEnterEvent *e) {
_hideTimer.stop(); _hideTimer.cancel();
if (_a_appearance.animating()) { if (_a_appearance.animating()) {
onShowStart(); startShow();
} else { } else {
_showTimer.start(0); _showTimer.callOnce(0);
} }
return RpWidget::enterEventHook(e); return RpWidget::enterEventHook(e);
} }
void VolumeWidget::leaveEventHook(QEvent *e) { void VolumeWidget::leaveEventHook(QEvent *e) {
_showTimer.stop(); _showTimer.cancel();
if (_a_appearance.animating()) { if (_a_appearance.animating()) {
onHideStart(); startHide();
} else { } else {
_hideTimer.start(300); _hideTimer.callOnce(300);
} }
return RpWidget::leaveEventHook(e); return RpWidget::leaveEventHook(e);
} }
void VolumeWidget::otherEnter() { void VolumeWidget::otherEnter() {
_hideTimer.stop(); _hideTimer.cancel();
if (_a_appearance.animating()) { if (_a_appearance.animating()) {
onShowStart(); startShow();
} else { } else {
_showTimer.start(0); _showTimer.callOnce(0);
} }
} }
void VolumeWidget::otherLeave() { void VolumeWidget::otherLeave() {
_showTimer.stop(); _showTimer.cancel();
if (_a_appearance.animating()) { if (_a_appearance.animating()) {
onHideStart(); startHide();
} else { } else {
_hideTimer.start(0); _hideTimer.callOnce(0);
} }
} }
void VolumeWidget::onShowStart() { void VolumeWidget::startShow() {
if (isHidden()) { if (isHidden()) {
show(); show();
} else if (!_hiding) { } else if (!_hiding) {
@ -197,8 +192,10 @@ void VolumeWidget::onShowStart() {
startAnimation(); startAnimation();
} }
void VolumeWidget::onHideStart() { void VolumeWidget::startHide() {
if (_hiding) return; if (_hiding) {
return;
}
_hiding = true; _hiding = true;
startAnimation(); startAnimation();

View file

@ -10,8 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
#include "base/timer.h"
#include <QtCore/QTimer>
namespace Ui { namespace Ui {
class IconButton; class IconButton;
@ -44,9 +43,7 @@ private:
}; };
class VolumeWidget : public Ui::RpWidget { class VolumeWidget final : public Ui::RpWidget {
Q_OBJECT
public: public:
VolumeWidget( VolumeWidget(
QWidget *parent, QWidget *parent,
@ -64,11 +61,10 @@ protected:
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;
private Q_SLOTS:
void onShowStart();
void onHideStart();
private: private:
void startHide();
void startShow();
void otherEnter(); void otherEnter();
void otherLeave(); void otherLeave();
@ -81,10 +77,11 @@ private:
QPixmap _cache; QPixmap _cache;
Ui::Animations::Simple _a_appearance; Ui::Animations::Simple _a_appearance;
QTimer _hideTimer, _showTimer;
object_ptr<VolumeController> _controller; object_ptr<VolumeController> _controller;
base::Timer _hideTimer;
base::Timer _showTimer;
}; };
} // namespace Player } // namespace Player