Removed Q_OBJECT from InnerDropdown.
This commit is contained in:
parent
093e3129ab
commit
897bea2baf
2 changed files with 14 additions and 21 deletions
|
|
@ -20,11 +20,9 @@ InnerDropdown::InnerDropdown(
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _roundRect(ImageRoundRadius::Small, _st.bg)
|
, _roundRect(ImageRoundRadius::Small, _st.bg)
|
||||||
|
, _hideTimer([=] { hideAnimated(); })
|
||||||
, _scroll(this, _st.scroll) {
|
, _scroll(this, _st.scroll) {
|
||||||
_hideTimer.setSingleShot(true);
|
connect(_scroll, &ScrollArea::scrolled, [=] { scrolled(); });
|
||||||
connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(onHideAnimated()));
|
|
||||||
|
|
||||||
connect(_scroll, SIGNAL(scrolled()), this, SLOT(onScroll()));
|
|
||||||
|
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
|
|
@ -89,11 +87,11 @@ void InnerDropdown::resizeEvent(QResizeEvent *e) {
|
||||||
_scroll->setGeometry(rect().marginsRemoved(_st.padding).marginsRemoved(_st.scrollMargin));
|
_scroll->setGeometry(rect().marginsRemoved(_st.padding).marginsRemoved(_st.scrollMargin));
|
||||||
if (auto widget = static_cast<TWidget*>(_scroll->widget())) {
|
if (auto widget = static_cast<TWidget*>(_scroll->widget())) {
|
||||||
widget->resizeToWidth(_scroll->width());
|
widget->resizeToWidth(_scroll->width());
|
||||||
onScroll();
|
scrolled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerDropdown::onScroll() {
|
void InnerDropdown::scrolled() {
|
||||||
if (auto widget = static_cast<TWidget*>(_scroll->widget())) {
|
if (auto widget = static_cast<TWidget*>(_scroll->widget())) {
|
||||||
int visibleTop = _scroll->scrollTop();
|
int visibleTop = _scroll->scrollTop();
|
||||||
int visibleBottom = visibleTop + _scroll->height();
|
int visibleBottom = visibleTop + _scroll->height();
|
||||||
|
|
@ -140,7 +138,7 @@ void InnerDropdown::leaveEventHook(QEvent *e) {
|
||||||
if (_a_show.animating() || _a_opacity.animating()) {
|
if (_a_show.animating() || _a_opacity.animating()) {
|
||||||
hideAnimated();
|
hideAnimated();
|
||||||
} else {
|
} else {
|
||||||
_hideTimer.start(300);
|
_hideTimer.callOnce(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RpWidget::leaveEventHook(e);
|
return RpWidget::leaveEventHook(e);
|
||||||
|
|
@ -157,7 +155,7 @@ void InnerDropdown::otherLeave() {
|
||||||
if (_a_show.animating() || _a_opacity.animating()) {
|
if (_a_show.animating() || _a_opacity.animating()) {
|
||||||
hideAnimated();
|
hideAnimated();
|
||||||
} else {
|
} else {
|
||||||
_hideTimer.start(0);
|
_hideTimer.callOnce(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +170,7 @@ void InnerDropdown::showAnimated(PanelAnimation::Origin origin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerDropdown::showAnimated() {
|
void InnerDropdown::showAnimated() {
|
||||||
_hideTimer.stop();
|
_hideTimer.cancel();
|
||||||
showStarted();
|
showStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +181,7 @@ void InnerDropdown::hideAnimated(HideOption option) {
|
||||||
}
|
}
|
||||||
if (_hiding) return;
|
if (_hiding) return;
|
||||||
|
|
||||||
_hideTimer.stop();
|
_hideTimer.cancel();
|
||||||
startOpacityAnimation(true);
|
startOpacityAnimation(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,7 +201,7 @@ void InnerDropdown::finishAnimating() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerDropdown::showFast() {
|
void InnerDropdown::showFast() {
|
||||||
_hideTimer.stop();
|
_hideTimer.cancel();
|
||||||
finishAnimating();
|
finishAnimating();
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
showChildren();
|
showChildren();
|
||||||
|
|
@ -215,7 +213,7 @@ void InnerDropdown::showFast() {
|
||||||
void InnerDropdown::hideFast() {
|
void InnerDropdown::hideFast() {
|
||||||
if (isHidden()) return;
|
if (isHidden()) return;
|
||||||
|
|
||||||
_hideTimer.stop();
|
_hideTimer.cancel();
|
||||||
finishAnimating();
|
finishAnimating();
|
||||||
_hiding = false;
|
_hiding = false;
|
||||||
hideFinished();
|
hideFinished();
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,13 @@
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/panel_animation.h"
|
#include "ui/effects/panel_animation.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
#include "base/timer.h"
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
|
|
||||||
class InnerDropdown : public RpWidget {
|
class InnerDropdown : public RpWidget {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InnerDropdown(QWidget *parent, const style::InnerDropdown &st = st::defaultInnerDropdown);
|
InnerDropdown(QWidget *parent, const style::InnerDropdown &st = st::defaultInnerDropdown);
|
||||||
|
|
@ -81,11 +79,6 @@ protected:
|
||||||
|
|
||||||
int resizeGetHeight(int newWidth) override;
|
int resizeGetHeight(int newWidth) override;
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onHideAnimated() {
|
|
||||||
hideAnimated();
|
|
||||||
}
|
|
||||||
void onScroll();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<RpWidget> doSetOwnedWidget(object_ptr<RpWidget> widget);
|
QPointer<RpWidget> doSetOwnedWidget(object_ptr<RpWidget> widget);
|
||||||
|
|
@ -103,6 +96,8 @@ private:
|
||||||
|
|
||||||
void updateHeight();
|
void updateHeight();
|
||||||
|
|
||||||
|
void scrolled();
|
||||||
|
|
||||||
const style::InnerDropdown &_st;
|
const style::InnerDropdown &_st;
|
||||||
|
|
||||||
RoundRect _roundRect;
|
RoundRect _roundRect;
|
||||||
|
|
@ -115,7 +110,7 @@ private:
|
||||||
QPixmap _cache;
|
QPixmap _cache;
|
||||||
Animations::Simple _a_opacity;
|
Animations::Simple _a_opacity;
|
||||||
|
|
||||||
QTimer _hideTimer;
|
base::Timer _hideTimer;
|
||||||
bool _ignoreShowEvents = false;
|
bool _ignoreShowEvents = false;
|
||||||
Fn<void()> _showStartCallback;
|
Fn<void()> _showStartCallback;
|
||||||
Fn<void()> _hideStartCallback;
|
Fn<void()> _hideStartCallback;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue