mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 00:36:53 +00:00
Pause video while caption is expanded.
This commit is contained in:
parent
75dc7e6e81
commit
21fa3264e3
@ -68,13 +68,17 @@ void CaptionFullView::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
void CaptionFullView::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
_close();
|
||||
if (const auto onstack = _close) {
|
||||
onstack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CaptionFullView::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
_close();
|
||||
if (const auto onstack = _close) {
|
||||
onstack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,10 +345,11 @@ Controller::~Controller() {
|
||||
}
|
||||
|
||||
void Controller::updateContentFaded() {
|
||||
if (_contentFaded == _replyActive) {
|
||||
const auto faded = _replyActive || _captionFullView || _captionExpanded;
|
||||
if (_contentFaded == faded) {
|
||||
return;
|
||||
}
|
||||
_contentFaded = _replyActive;
|
||||
_contentFaded = faded;
|
||||
_contentFadeAnimation.start(
|
||||
[=] { _delegate->storiesRepaint(); },
|
||||
_contentFaded ? 0. : 1.,
|
||||
@ -570,16 +571,24 @@ TextWithEntities Controller::captionText() const {
|
||||
return _captionText;
|
||||
}
|
||||
|
||||
void Controller::setCaptionExpanded(bool expanded) {
|
||||
if (_captionExpanded == expanded) {
|
||||
return;
|
||||
}
|
||||
_captionExpanded = expanded;
|
||||
updateContentFaded();
|
||||
}
|
||||
|
||||
void Controller::showFullCaption() {
|
||||
if (_captionText.empty()) {
|
||||
return;
|
||||
}
|
||||
togglePaused(true);
|
||||
_captionFullView = std::make_unique<CaptionFullView>(
|
||||
wrap(),
|
||||
&_delegate->storiesShow()->session(),
|
||||
_captionText,
|
||||
[=] { togglePaused(false); });
|
||||
[=] { _captionFullView = nullptr; updateContentFaded(); });
|
||||
updateContentFaded();
|
||||
}
|
||||
|
||||
std::shared_ptr<ChatHelpers::Show> Controller::uiShow() const {
|
||||
@ -796,6 +805,9 @@ void Controller::show(
|
||||
|
||||
_captionText = story->caption();
|
||||
_captionFullView = nullptr;
|
||||
_captionExpanded = false;
|
||||
_contentFaded = false;
|
||||
_contentFadeAnimation.stop();
|
||||
const auto document = story->document();
|
||||
_header->show({
|
||||
.user = user,
|
||||
@ -942,6 +954,8 @@ void Controller::updatePlayingAllowed() {
|
||||
&& _windowActive
|
||||
&& !_paused
|
||||
&& !_replyActive
|
||||
&& !_captionFullView
|
||||
&& !_captionExpanded
|
||||
&& !_layerShown
|
||||
&& !_menuShown);
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ public:
|
||||
[[nodiscard]] bool closeByClickAt(QPoint position) const;
|
||||
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||
[[nodiscard]] TextWithEntities captionText() const;
|
||||
void setCaptionExpanded(bool expanded);
|
||||
void showFullCaption();
|
||||
|
||||
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow() const;
|
||||
@ -241,6 +242,7 @@ private:
|
||||
Ui::Animations::Simple _contentFadeAnimation;
|
||||
bool _contentFaded = false;
|
||||
|
||||
bool _captionExpanded = false;
|
||||
bool _windowActive = false;
|
||||
bool _replyFocused = false;
|
||||
bool _replyActive = false;
|
||||
|
@ -123,6 +123,10 @@ TextWithEntities View::captionText() const {
|
||||
return _controller->captionText();
|
||||
}
|
||||
|
||||
void View::setCaptionExpanded(bool expanded) {
|
||||
_controller->setCaptionExpanded(expanded);
|
||||
}
|
||||
|
||||
void View::showFullCaption() {
|
||||
_controller->showFullCaption();
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
[[nodiscard]] SiblingView sibling(SiblingType type) const;
|
||||
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||
[[nodiscard]] TextWithEntities captionText() const;
|
||||
void setCaptionExpanded(bool expanded);
|
||||
void showFullCaption();
|
||||
|
||||
void updatePlayback(const Player::TrackState &state);
|
||||
|
@ -486,6 +486,10 @@ OverlayWidget::OverlayWidget()
|
||||
return base::EventFilterResult::Cancel;
|
||||
} else if (type == QEvent::ThemeChange && Platform::IsLinux()) {
|
||||
_window->setWindowIcon(Window::CreateIcon(_session));
|
||||
} else if (type == QEvent::FocusOut) {
|
||||
if (const auto popup = QApplication::activePopupWidget()) {
|
||||
int a = popup->x();
|
||||
}
|
||||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
@ -1384,8 +1388,9 @@ void OverlayWidget::refreshCaptionGeometry() {
|
||||
_captionFitsIfExpanded = _stories
|
||||
&& (wantedHeight <= maxExpandedHeight);
|
||||
_captionShownFull = (wantedHeight <= maxCollapsedHeight);
|
||||
if (_captionShownFull) {
|
||||
if (_captionShownFull && _captionExpanded && _stories) {
|
||||
_captionExpanded = false;
|
||||
_stories->setCaptionExpanded(false);
|
||||
}
|
||||
_captionRect = QRect(
|
||||
(width() - captionWidth) / 2,
|
||||
@ -3120,7 +3125,7 @@ void OverlayWidget::setCursor(style::cursor cursor) {
|
||||
}
|
||||
|
||||
void OverlayWidget::setFocus() {
|
||||
_widget->setFocus();
|
||||
_body->setFocus();
|
||||
}
|
||||
|
||||
bool OverlayWidget::takeFocusFrom(not_null<QWidget*> window) const {
|
||||
@ -5570,10 +5575,12 @@ ClickHandlerPtr OverlayWidget::ensureCaptionExpandLink() {
|
||||
return;
|
||||
} else if (_captionExpanded) {
|
||||
_captionExpanded = false;
|
||||
_stories->setCaptionExpanded(false);
|
||||
refreshCaptionGeometry();
|
||||
update();
|
||||
} else if (_captionFitsIfExpanded) {
|
||||
_captionExpanded = true;
|
||||
_stories->setCaptionExpanded(true);
|
||||
refreshCaptionGeometry();
|
||||
update();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user