2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 07:25:46 +00:00

Make tabbed selector working in scheduled section.

This commit is contained in:
John Preston
2019-08-16 15:44:20 +03:00
parent 385a7eb00d
commit 3e895d0e85
27 changed files with 341 additions and 250 deletions

View File

@@ -26,20 +26,27 @@ constexpr auto kDelayedHideTimeoutMs = 3000;
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller)
: TabbedPanel(
parent,
controller,
object_ptr<TabbedSelector>(nullptr, controller)) {
not_null<Window::SessionController*> controller,
not_null<TabbedSelector*> selector)
: TabbedPanel(parent, controller, { nullptr }, selector) {
}
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> selector)
: TabbedPanel(parent, controller, std::move(selector), nullptr) {
}
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> ownedSelector,
TabbedSelector *nonOwnedSelector)
: RpWidget(parent)
, _controller(controller)
, _selector(std::move(selector))
, _ownedSelector(std::move(ownedSelector))
, _selector(nonOwnedSelector ? nonOwnedSelector : _ownedSelector.data())
, _heightRatio(st::emojiPanHeightRatio)
, _minContentHeight(st::emojiPanMinHeight)
, _maxContentHeight(st::emojiPanMaxHeight) {
@@ -106,6 +113,14 @@ TabbedPanel::TabbedPanel(
hide();
}
not_null<TabbedSelector*> TabbedPanel::selector() const {
return _selector;
}
bool TabbedPanel::isSelectorStolen() const {
return (_selector->parent() != this);
}
void TabbedPanel::moveBottomRight(int bottom, int right) {
const auto isNew = (_bottom != bottom || _right != right);
_bottom = bottom;
@@ -366,17 +381,6 @@ void TabbedPanel::toggleAnimated() {
}
}
object_ptr<TabbedSelector> TabbedPanel::takeSelector() {
if (!isHidden() && !_hiding) {
startOpacityAnimation(true);
}
return std::move(_selector);
}
QPointer<TabbedSelector> TabbedPanel::getSelector() const {
return _selector.data();
}
void TabbedPanel::hideFinished() {
hide();
_a_show.stop();
@@ -450,6 +454,10 @@ bool TabbedPanel::overlaps(const QRect &globalRect) const {
|| inner.marginsRemoved(QMargins(0, st::buttonRadius, 0, st::buttonRadius)).contains(testRect);
}
TabbedPanel::~TabbedPanel() = default;
TabbedPanel::~TabbedPanel() {
if (!_ownedSelector) {
_controller->takeTabbedSelectorOwnershipFrom(this);
}
}
} // namespace ChatHelpers