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