mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add video story saved toast to viewer.
This commit is contained in:
parent
3d795f2f67
commit
1d5b57c39c
4 changed files with 69 additions and 31 deletions
|
@ -2502,6 +2502,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_mediaview_title" = "Media viewer";
|
"lng_mediaview_title" = "Media viewer";
|
||||||
"lng_mediaview_saved_to" = "Image was saved to your {downloads} folder";
|
"lng_mediaview_saved_to" = "Image was saved to your {downloads} folder";
|
||||||
"lng_mediaview_saved_images_to" = "Images were saved to your {downloads} folder";
|
"lng_mediaview_saved_images_to" = "Images were saved to your {downloads} folder";
|
||||||
|
"lng_mediaview_video_saved_to" = "Video file was saved to your {downloads} folder";
|
||||||
"lng_mediaview_downloads" = "Downloads";
|
"lng_mediaview_downloads" = "Downloads";
|
||||||
"lng_mediaview_playback_speed" = "Playback speed: {speed}";
|
"lng_mediaview_playback_speed" = "Playback speed: {speed}";
|
||||||
"lng_mediaview_rotate_video" = "Rotate video";
|
"lng_mediaview_rotate_video" = "Rotate video";
|
||||||
|
|
|
@ -444,20 +444,8 @@ OverlayWidget::OverlayWidget()
|
||||||
? Core::App().settings().videoVolume()
|
? Core::App().settings().videoVolume()
|
||||||
: Core::Settings::kDefaultVolume;
|
: Core::Settings::kDefaultVolume;
|
||||||
|
|
||||||
const auto text = tr::lng_mediaview_saved_to(
|
|
||||||
tr::now,
|
|
||||||
lt_downloads,
|
|
||||||
Ui::Text::Link(
|
|
||||||
tr::lng_mediaview_downloads(tr::now),
|
|
||||||
"internal:show_saved_message"),
|
|
||||||
Ui::Text::WithEntities);
|
|
||||||
_saveMsgText.setMarkedText(st::mediaviewSaveMsgStyle, text);
|
|
||||||
_saveMsg = QRect(0, 0, _saveMsgText.maxWidth() + st::mediaviewSaveMsgPadding.left() + st::mediaviewSaveMsgPadding.right(), st::mediaviewSaveMsgStyle.font->height + st::mediaviewSaveMsgPadding.top() + st::mediaviewSaveMsgPadding.bottom());
|
|
||||||
_saveMsgImage = QImage(
|
|
||||||
_saveMsg.size() * cIntRetinaFactor(),
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
_saveMsgTimer.setCallback([=, delay = st::mediaviewSaveMsgHiding] {
|
_saveMsgTimer.setCallback([=, delay = st::mediaviewSaveMsgHiding] {
|
||||||
_saveMsgAnimation.start([=] { updateImage(); }, 1., 0., delay);
|
_saveMsgAnimation.start([=] { updateSaveMsg(); }, 1., 0., delay);
|
||||||
});
|
});
|
||||||
|
|
||||||
_docRectImage = QImage(
|
_docRectImage = QImage(
|
||||||
|
@ -663,6 +651,40 @@ OverlayWidget::OverlayWidget()
|
||||||
orderWidgets();
|
orderWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverlayWidget::showSaveMsgToast(const QString &path, auto phrase) {
|
||||||
|
showSaveMsgToastWith(path, phrase(
|
||||||
|
tr::now,
|
||||||
|
lt_downloads,
|
||||||
|
Ui::Text::Link(
|
||||||
|
tr::lng_mediaview_downloads(tr::now),
|
||||||
|
"internal:show_saved_message"),
|
||||||
|
Ui::Text::WithEntities));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OverlayWidget::showSaveMsgToastWith(
|
||||||
|
const QString &path,
|
||||||
|
const TextWithEntities &text) {
|
||||||
|
_saveMsgFilename = path;
|
||||||
|
_saveMsgText.setMarkedText(st::mediaviewSaveMsgStyle, text);
|
||||||
|
const auto w = _saveMsgText.maxWidth()
|
||||||
|
+ st::mediaviewSaveMsgPadding.left()
|
||||||
|
+ st::mediaviewSaveMsgPadding.right();
|
||||||
|
const auto h = st::mediaviewSaveMsgStyle.font->height
|
||||||
|
+ st::mediaviewSaveMsgPadding.top()
|
||||||
|
+ st::mediaviewSaveMsgPadding.bottom();
|
||||||
|
_saveMsg = QRect((width() - w) / 2, (height() - h) / 2, w, h);
|
||||||
|
const auto toIn = 1.;
|
||||||
|
const auto callback = [=](float64 value) {
|
||||||
|
updateSaveMsg();
|
||||||
|
if (!_saveMsgAnimation.animating()) {
|
||||||
|
_saveMsgTimer.callOnce(st::mediaviewSaveMsgShown);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const auto duration = st::mediaviewSaveMsgShowing;
|
||||||
|
_saveMsgAnimation.start(callback, 0., 1., duration);
|
||||||
|
updateSaveMsg();
|
||||||
|
}
|
||||||
|
|
||||||
void OverlayWidget::orderWidgets() {
|
void OverlayWidget::orderWidgets() {
|
||||||
_helper->orderWidgets();
|
_helper->orderWidgets();
|
||||||
}
|
}
|
||||||
|
@ -1104,6 +1126,13 @@ void OverlayWidget::documentUpdated(not_null<DocumentData*> document) {
|
||||||
: 0;
|
: 0;
|
||||||
_streamed->controls->setLoadingProgress(ready, _document->size);
|
_streamed->controls->setLoadingProgress(ready, _document->size);
|
||||||
}
|
}
|
||||||
|
if (_stories
|
||||||
|
&& !_documentLoadingTo.isEmpty()
|
||||||
|
&& _document->location(true).isEmpty()) {
|
||||||
|
showSaveMsgToast(
|
||||||
|
base::take(_documentLoadingTo),
|
||||||
|
tr::lng_mediaview_video_saved_to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::changingMsgId(FullMsgId newId, MsgId oldId) {
|
void OverlayWidget::changingMsgId(FullMsgId newId, MsgId oldId) {
|
||||||
|
@ -1995,6 +2024,7 @@ void OverlayWidget::assignMediaPointer(DocumentData *document) {
|
||||||
} else {
|
} else {
|
||||||
_documentMedia = nullptr;
|
_documentMedia = nullptr;
|
||||||
}
|
}
|
||||||
|
_documentLoadingTo = QString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2002,6 +2032,7 @@ void OverlayWidget::assignMediaPointer(not_null<PhotoData*> photo) {
|
||||||
_savePhotoVideoWhenLoaded = SavePhotoVideo::None;
|
_savePhotoVideoWhenLoaded = SavePhotoVideo::None;
|
||||||
_document = nullptr;
|
_document = nullptr;
|
||||||
_documentMedia = nullptr;
|
_documentMedia = nullptr;
|
||||||
|
_documentLoadingTo = QString();
|
||||||
if (_photo != photo) {
|
if (_photo != photo) {
|
||||||
_photo = photo;
|
_photo = photo;
|
||||||
_photoMedia = _photo->createMediaView();
|
_photoMedia = _photo->createMediaView();
|
||||||
|
@ -2349,6 +2380,9 @@ void OverlayWidget::downloadMedia() {
|
||||||
}, toName, manager.computeNextStartDate());
|
}, toName, manager.computeNextStartDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_stories && !toName.isEmpty()) {
|
||||||
|
showSaveMsgToast(toName, tr::lng_mediaview_video_saved_to);
|
||||||
|
}
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
} else {
|
} else {
|
||||||
if (_document->filepath(true).isEmpty()
|
if (_document->filepath(true).isEmpty()
|
||||||
|
@ -2357,7 +2391,15 @@ void OverlayWidget::downloadMedia() {
|
||||||
_message ? _message->fullId() : FullMsgId(),
|
_message ? _message->fullId() : FullMsgId(),
|
||||||
_document,
|
_document,
|
||||||
DocumentSaveClickHandler::Mode::ToFile);
|
DocumentSaveClickHandler::Mode::ToFile);
|
||||||
updateControls();
|
_documentLoadingTo = _document->loadingFilePath();
|
||||||
|
if (_stories && _documentLoadingTo.isEmpty()) {
|
||||||
|
toName = _document->filepath(true);
|
||||||
|
if (!toName.isEmpty()) {
|
||||||
|
showSaveMsgToast(
|
||||||
|
toName,
|
||||||
|
tr::lng_mediaview_video_saved_to);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_saveVisible = contentCanBeSaved();
|
_saveVisible = contentCanBeSaved();
|
||||||
update(_saveNavOver);
|
update(_saveNavOver);
|
||||||
|
@ -2393,19 +2435,9 @@ void OverlayWidget::downloadMedia() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!toName.isEmpty()) {
|
if (!toName.isEmpty()) {
|
||||||
_saveMsgFilename = toName;
|
showSaveMsgToast(toName, (_stories && _document)
|
||||||
const auto toIn = 1.;
|
? tr::lng_mediaview_video_saved_to
|
||||||
_saveMsgAnimation.start(
|
: tr::lng_mediaview_saved_to);
|
||||||
[=](float64 value) {
|
|
||||||
updateImage();
|
|
||||||
if (value == toIn) {
|
|
||||||
_saveMsgTimer.callOnce(st::mediaviewSaveMsgShown);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
0.,
|
|
||||||
toIn,
|
|
||||||
st::mediaviewSaveMsgShowing);
|
|
||||||
updateImage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5879,7 +5911,7 @@ void OverlayWidget::handleTouchTimer() {
|
||||||
_touchRightButton = true;
|
_touchRightButton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::updateImage() {
|
void OverlayWidget::updateSaveMsg() {
|
||||||
update(_saveMsg);
|
update(_saveMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,12 @@ private:
|
||||||
void showDropdown();
|
void showDropdown();
|
||||||
void handleTouchTimer();
|
void handleTouchTimer();
|
||||||
void handleDocumentClick();
|
void handleDocumentClick();
|
||||||
void updateImage();
|
|
||||||
|
void showSaveMsgToast(const QString &path, auto phrase);
|
||||||
|
void showSaveMsgToastWith(
|
||||||
|
const QString &path,
|
||||||
|
const TextWithEntities &text);
|
||||||
|
void updateSaveMsg();
|
||||||
|
|
||||||
void clearBeforeHide();
|
void clearBeforeHide();
|
||||||
void clearAfterHide();
|
void clearAfterHide();
|
||||||
|
@ -533,6 +538,7 @@ private:
|
||||||
rpl::lifetime _sessionLifetime;
|
rpl::lifetime _sessionLifetime;
|
||||||
PhotoData *_photo = nullptr;
|
PhotoData *_photo = nullptr;
|
||||||
DocumentData *_document = nullptr;
|
DocumentData *_document = nullptr;
|
||||||
|
QString _documentLoadingTo;
|
||||||
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
||||||
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
||||||
base::flat_set<std::shared_ptr<Data::PhotoMedia>> _preloadPhotos;
|
base::flat_set<std::shared_ptr<Data::PhotoMedia>> _preloadPhotos;
|
||||||
|
@ -689,7 +695,6 @@ private:
|
||||||
|
|
||||||
QString _saveMsgFilename;
|
QString _saveMsgFilename;
|
||||||
QRect _saveMsg;
|
QRect _saveMsg;
|
||||||
QImage _saveMsgImage;
|
|
||||||
Ui::Text::String _saveMsgText;
|
Ui::Text::String _saveMsgText;
|
||||||
SavePhotoVideo _savePhotoVideoWhenLoaded = SavePhotoVideo::None;
|
SavePhotoVideo _savePhotoVideoWhenLoaded = SavePhotoVideo::None;
|
||||||
// _saveMsgAnimation -> _saveMsgTimer -> _saveMsgAnimation.
|
// _saveMsgAnimation -> _saveMsgTimer -> _saveMsgAnimation.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ed00cd28098e1b04979e7b2dd3a582b7a8a6713a
|
Subproject commit 08f80548668df2737905365b254624055642b937
|
Loading…
Add table
Reference in a new issue