mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Slightly refactored display of media preview.
- Removed showMediaPreview from facades.
This commit is contained in:
parent
da6baeb1a7
commit
7c98f64cdb
9 changed files with 71 additions and 70 deletions
|
@ -411,9 +411,11 @@ void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
|||
int index = stickerFromGlobalPos(e->globalPos());
|
||||
if (index >= 0 && index < _pack.size() && index != _previewShown) {
|
||||
_previewShown = index;
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||
_pack[_previewShown]);
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||
_pack[_previewShown]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,9 +474,11 @@ void StickerSetBox::Inner::showPreview() {
|
|||
int index = stickerFromGlobalPos(QCursor::pos());
|
||||
if (index >= 0 && index < _pack.size()) {
|
||||
_previewShown = index;
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||
_pack[_previewShown]);
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||
_pack[_previewShown]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1030,9 +1030,11 @@ void FieldAutocompleteInner::selectByMouse(QPoint globalPosition) {
|
|||
if (_down >= 0 && _sel >= 0 && _down != _sel) {
|
||||
_down = _sel;
|
||||
if (_down >= 0 && _down < _srows->size()) {
|
||||
Ui::showMediaPreview(
|
||||
(*_srows)[_down].document->stickerSetOrigin(),
|
||||
(*_srows)[_down].document);
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(
|
||||
(*_srows)[_down].document->stickerSetOrigin(),
|
||||
(*_srows)[_down].document);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1050,10 +1052,12 @@ void FieldAutocompleteInner::onParentGeometryChanged() {
|
|||
|
||||
void FieldAutocompleteInner::showPreview() {
|
||||
if (_down >= 0 && _down < _srows->size()) {
|
||||
Ui::showMediaPreview(
|
||||
(*_srows)[_down].document->stickerSetOrigin(),
|
||||
(*_srows)[_down].document);
|
||||
_previewShown = true;
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(
|
||||
(*_srows)[_down].document->stickerSetOrigin(),
|
||||
(*_srows)[_down].document);
|
||||
_previewShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -985,14 +985,16 @@ void GifsListWidget::updateSelected() {
|
|||
_pressed = _selected;
|
||||
if (row >= 0 && col >= 0) {
|
||||
auto layout = _rows[row].items[col];
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOriginSavedGifs(),
|
||||
previewDocument);
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewPhoto);
|
||||
if (const auto w = App::wnd()) {
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOriginSavedGifs(),
|
||||
previewDocument);
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewPhoto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1009,16 +1011,18 @@ void GifsListWidget::showPreview() {
|
|||
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
||||
if (row < _rows.size() && col < _rows[row].items.size()) {
|
||||
auto layout = _rows[row].items[col];
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOriginSavedGifs(),
|
||||
previewDocument);
|
||||
_previewShown = true;
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewPhoto);
|
||||
_previewShown = true;
|
||||
if (const auto w = App::wnd()) {
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOriginSavedGifs(),
|
||||
previewDocument);
|
||||
_previewShown = true;
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewPhoto);
|
||||
_previewShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2617,7 +2617,9 @@ void StickersListWidget::setSelected(OverState newSelected) {
|
|||
const auto &set = sets[sticker->section];
|
||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
Ui::showMediaPreview(document->stickerSetOrigin(), document);
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(document->stickerSetOrigin(), document);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2630,8 +2632,10 @@ void StickersListWidget::showPreview() {
|
|||
const auto &set = sets[sticker->section];
|
||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
Ui::showMediaPreview(document->stickerSetOrigin(), document);
|
||||
_previewShown = true;
|
||||
if (const auto w = App::wnd()) {
|
||||
w->showMediaPreview(document->stickerSetOrigin(), document);
|
||||
_previewShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,20 +192,6 @@ void showBox(
|
|||
|
||||
} // namespace internal
|
||||
|
||||
void showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> document) {
|
||||
if (auto w = App::wnd()) {
|
||||
w->ui_showMediaPreview(origin, document);
|
||||
}
|
||||
}
|
||||
|
||||
void showMediaPreview(Data::FileOrigin origin, not_null<PhotoData*> photo) {
|
||||
if (auto w = App::wnd()) {
|
||||
w->ui_showMediaPreview(origin, photo);
|
||||
}
|
||||
}
|
||||
|
||||
void hideLayer(anim::type animated) {
|
||||
if (auto w = App::wnd()) {
|
||||
w->ui_showBox(
|
||||
|
|
|
@ -97,11 +97,6 @@ void showBox(
|
|||
|
||||
} // namespace internal
|
||||
|
||||
void showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> document);
|
||||
void showMediaPreview(Data::FileOrigin origin, not_null<PhotoData*> photo);
|
||||
|
||||
template <typename BoxType>
|
||||
QPointer<BoxType> show(
|
||||
object_ptr<BoxType> content,
|
||||
|
|
|
@ -683,12 +683,14 @@ void Inner::updateSelected() {
|
|||
_pressed = _selected;
|
||||
if (row >= 0 && col >= 0) {
|
||||
auto layout = _rows.at(row).items.at(col);
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
Ui::showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewDocument);
|
||||
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||
if (const auto w = App::wnd()) {
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
w->showMediaPreview(
|
||||
Data::FileOrigin(),
|
||||
previewDocument);
|
||||
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -708,12 +710,14 @@ void Inner::showPreview() {
|
|||
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
||||
if (row < _rows.size() && col < _rows.at(row).items.size()) {
|
||||
auto layout = _rows.at(row).items.at(col);
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
Ui::showMediaPreview(Data::FileOrigin(), previewDocument);
|
||||
_previewShown = true;
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||
_previewShown = true;
|
||||
if (const auto w = App::wnd()) {
|
||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||
w->showMediaPreview(Data::FileOrigin(), previewDocument);
|
||||
_previewShown = true;
|
||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||
_previewShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ bool MainWindow::ui_isLayerShown() {
|
|||
return _layer != nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::ui_showMediaPreview(
|
||||
void MainWindow::showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> document) {
|
||||
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) {
|
||||
|
@ -398,7 +398,7 @@ void MainWindow::ui_showMediaPreview(
|
|||
_mediaPreview->showPreview(origin, document);
|
||||
}
|
||||
|
||||
void MainWindow::ui_showMediaPreview(
|
||||
void MainWindow::showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<PhotoData*> photo) {
|
||||
if (!photo) {
|
||||
|
|
|
@ -109,12 +109,13 @@ public:
|
|||
void ui_hideSettingsAndLayer(anim::type animated);
|
||||
void ui_removeLayerBlackout();
|
||||
bool ui_isLayerShown();
|
||||
void ui_showMediaPreview(
|
||||
void showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> document);
|
||||
void ui_showMediaPreview(
|
||||
void showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
not_null<PhotoData*> photo);
|
||||
void hideMediaPreview();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *o, QEvent *e) override;
|
||||
|
@ -152,7 +153,6 @@ private:
|
|||
void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) override;
|
||||
|
||||
void hideMediaPreview();
|
||||
void ensureLayerCreated();
|
||||
void destroyLayer();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue