mirror of https://github.com/procxx/kepka.git
Slightly refactored display of media preview.
- Removed showMediaPreview from facades.
This commit is contained in:
parent
da6baeb1a7
commit
7c98f64cdb
|
@ -411,12 +411,14 @@ void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
||||||
int index = stickerFromGlobalPos(e->globalPos());
|
int index = stickerFromGlobalPos(e->globalPos());
|
||||||
if (index >= 0 && index < _pack.size() && index != _previewShown) {
|
if (index >= 0 && index < _pack.size() && index != _previewShown) {
|
||||||
_previewShown = index;
|
_previewShown = index;
|
||||||
Ui::showMediaPreview(
|
if (const auto w = App::wnd()) {
|
||||||
|
w->showMediaPreview(
|
||||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||||
_pack[_previewShown]);
|
_pack[_previewShown]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StickerSetBox::Inner::leaveEventHook(QEvent *e) {
|
void StickerSetBox::Inner::leaveEventHook(QEvent *e) {
|
||||||
setSelected(-1);
|
setSelected(-1);
|
||||||
|
@ -472,11 +474,13 @@ void StickerSetBox::Inner::showPreview() {
|
||||||
int index = stickerFromGlobalPos(QCursor::pos());
|
int index = stickerFromGlobalPos(QCursor::pos());
|
||||||
if (index >= 0 && index < _pack.size()) {
|
if (index >= 0 && index < _pack.size()) {
|
||||||
_previewShown = index;
|
_previewShown = index;
|
||||||
Ui::showMediaPreview(
|
if (const auto w = App::wnd()) {
|
||||||
|
w->showMediaPreview(
|
||||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||||
_pack[_previewShown]);
|
_pack[_previewShown]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
not_null<Lottie::MultiPlayer*> StickerSetBox::Inner::getLottiePlayer() {
|
not_null<Lottie::MultiPlayer*> StickerSetBox::Inner::getLottiePlayer() {
|
||||||
if (!_lottiePlayer) {
|
if (!_lottiePlayer) {
|
||||||
|
|
|
@ -1030,13 +1030,15 @@ void FieldAutocompleteInner::selectByMouse(QPoint globalPosition) {
|
||||||
if (_down >= 0 && _sel >= 0 && _down != _sel) {
|
if (_down >= 0 && _sel >= 0 && _down != _sel) {
|
||||||
_down = _sel;
|
_down = _sel;
|
||||||
if (_down >= 0 && _down < _srows->size()) {
|
if (_down >= 0 && _down < _srows->size()) {
|
||||||
Ui::showMediaPreview(
|
if (const auto w = App::wnd()) {
|
||||||
|
w->showMediaPreview(
|
||||||
(*_srows)[_down].document->stickerSetOrigin(),
|
(*_srows)[_down].document->stickerSetOrigin(),
|
||||||
(*_srows)[_down].document);
|
(*_srows)[_down].document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FieldAutocompleteInner::onParentGeometryChanged() {
|
void FieldAutocompleteInner::onParentGeometryChanged() {
|
||||||
const auto globalPosition = QCursor::pos();
|
const auto globalPosition = QCursor::pos();
|
||||||
|
@ -1050,11 +1052,13 @@ void FieldAutocompleteInner::onParentGeometryChanged() {
|
||||||
|
|
||||||
void FieldAutocompleteInner::showPreview() {
|
void FieldAutocompleteInner::showPreview() {
|
||||||
if (_down >= 0 && _down < _srows->size()) {
|
if (_down >= 0 && _down < _srows->size()) {
|
||||||
Ui::showMediaPreview(
|
if (const auto w = App::wnd()) {
|
||||||
|
w->showMediaPreview(
|
||||||
(*_srows)[_down].document->stickerSetOrigin(),
|
(*_srows)[_down].document->stickerSetOrigin(),
|
||||||
(*_srows)[_down].document);
|
(*_srows)[_down].document);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
@ -985,18 +985,20 @@ void GifsListWidget::updateSelected() {
|
||||||
_pressed = _selected;
|
_pressed = _selected;
|
||||||
if (row >= 0 && col >= 0) {
|
if (row >= 0 && col >= 0) {
|
||||||
auto layout = _rows[row].items[col];
|
auto layout = _rows[row].items[col];
|
||||||
|
if (const auto w = App::wnd()) {
|
||||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Ui::showMediaPreview(
|
w->showMediaPreview(
|
||||||
Data::FileOriginSavedGifs(),
|
Data::FileOriginSavedGifs(),
|
||||||
previewDocument);
|
previewDocument);
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Ui::showMediaPreview(
|
w->showMediaPreview(
|
||||||
Data::FileOrigin(),
|
Data::FileOrigin(),
|
||||||
previewPhoto);
|
previewPhoto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ClickHandler::setActive(lnk, lnkhost)) {
|
if (ClickHandler::setActive(lnk, lnkhost)) {
|
||||||
setCursor(lnk ? style::cur_pointer : style::cur_default);
|
setCursor(lnk ? style::cur_pointer : style::cur_default);
|
||||||
}
|
}
|
||||||
|
@ -1009,19 +1011,21 @@ void GifsListWidget::showPreview() {
|
||||||
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
||||||
if (row < _rows.size() && col < _rows[row].items.size()) {
|
if (row < _rows.size() && col < _rows[row].items.size()) {
|
||||||
auto layout = _rows[row].items[col];
|
auto layout = _rows[row].items[col];
|
||||||
|
if (const auto w = App::wnd()) {
|
||||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Ui::showMediaPreview(
|
w->showMediaPreview(
|
||||||
Data::FileOriginSavedGifs(),
|
Data::FileOriginSavedGifs(),
|
||||||
previewDocument);
|
previewDocument);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Ui::showMediaPreview(
|
w->showMediaPreview(
|
||||||
Data::FileOrigin(),
|
Data::FileOrigin(),
|
||||||
previewPhoto);
|
previewPhoto);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GifsListWidget::updateInlineItems() {
|
void GifsListWidget::updateInlineItems() {
|
||||||
auto ms = crl::now();
|
auto ms = crl::now();
|
||||||
|
|
|
@ -2617,7 +2617,9 @@ void StickersListWidget::setSelected(OverState newSelected) {
|
||||||
const auto &set = sets[sticker->section];
|
const auto &set = sets[sticker->section];
|
||||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||||
const auto document = set.stickers[sticker->index].document;
|
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,10 +2632,12 @@ void StickersListWidget::showPreview() {
|
||||||
const auto &set = sets[sticker->section];
|
const auto &set = sets[sticker->section];
|
||||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||||
const auto document = set.stickers[sticker->index].document;
|
const auto document = set.stickers[sticker->index].document;
|
||||||
Ui::showMediaPreview(document->stickerSetOrigin(), document);
|
if (const auto w = App::wnd()) {
|
||||||
|
w->showMediaPreview(document->stickerSetOrigin(), document);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto StickersListWidget::getLottieRenderer()
|
auto StickersListWidget::getLottieRenderer()
|
||||||
-> std::shared_ptr<Lottie::FrameRenderer> {
|
-> std::shared_ptr<Lottie::FrameRenderer> {
|
||||||
|
|
|
@ -192,20 +192,6 @@ void showBox(
|
||||||
|
|
||||||
} // namespace internal
|
} // 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) {
|
void hideLayer(anim::type animated) {
|
||||||
if (auto w = App::wnd()) {
|
if (auto w = App::wnd()) {
|
||||||
w->ui_showBox(
|
w->ui_showBox(
|
||||||
|
|
|
@ -97,11 +97,6 @@ void showBox(
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
void showMediaPreview(
|
|
||||||
Data::FileOrigin origin,
|
|
||||||
not_null<DocumentData*> document);
|
|
||||||
void showMediaPreview(Data::FileOrigin origin, not_null<PhotoData*> photo);
|
|
||||||
|
|
||||||
template <typename BoxType>
|
template <typename BoxType>
|
||||||
QPointer<BoxType> show(
|
QPointer<BoxType> show(
|
||||||
object_ptr<BoxType> content,
|
object_ptr<BoxType> content,
|
||||||
|
|
|
@ -683,12 +683,14 @@ void Inner::updateSelected() {
|
||||||
_pressed = _selected;
|
_pressed = _selected;
|
||||||
if (row >= 0 && col >= 0) {
|
if (row >= 0 && col >= 0) {
|
||||||
auto layout = _rows.at(row).items.at(col);
|
auto layout = _rows.at(row).items.at(col);
|
||||||
|
if (const auto w = App::wnd()) {
|
||||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Ui::showMediaPreview(
|
w->showMediaPreview(
|
||||||
Data::FileOrigin(),
|
Data::FileOrigin(),
|
||||||
previewDocument);
|
previewDocument);
|
||||||
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
|
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,15 +710,17 @@ void Inner::showPreview() {
|
||||||
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
|
||||||
if (row < _rows.size() && col < _rows.at(row).items.size()) {
|
if (row < _rows.size() && col < _rows.at(row).items.size()) {
|
||||||
auto layout = _rows.at(row).items.at(col);
|
auto layout = _rows.at(row).items.at(col);
|
||||||
|
if (const auto w = App::wnd()) {
|
||||||
if (const auto previewDocument = layout->getPreviewDocument()) {
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewDocument);
|
w->showMediaPreview(Data::FileOrigin(), previewDocument);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||||
_previewShown = true;
|
_previewShown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Inner::updateInlineItems() {
|
void Inner::updateInlineItems() {
|
||||||
auto ms = crl::now();
|
auto ms = crl::now();
|
||||||
|
|
|
@ -382,7 +382,7 @@ bool MainWindow::ui_isLayerShown() {
|
||||||
return _layer != nullptr;
|
return _layer != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ui_showMediaPreview(
|
void MainWindow::showMediaPreview(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<DocumentData*> document) {
|
not_null<DocumentData*> document) {
|
||||||
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) {
|
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) {
|
||||||
|
@ -398,7 +398,7 @@ void MainWindow::ui_showMediaPreview(
|
||||||
_mediaPreview->showPreview(origin, document);
|
_mediaPreview->showPreview(origin, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ui_showMediaPreview(
|
void MainWindow::showMediaPreview(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<PhotoData*> photo) {
|
not_null<PhotoData*> photo) {
|
||||||
if (!photo) {
|
if (!photo) {
|
||||||
|
|
|
@ -109,12 +109,13 @@ public:
|
||||||
void ui_hideSettingsAndLayer(anim::type animated);
|
void ui_hideSettingsAndLayer(anim::type animated);
|
||||||
void ui_removeLayerBlackout();
|
void ui_removeLayerBlackout();
|
||||||
bool ui_isLayerShown();
|
bool ui_isLayerShown();
|
||||||
void ui_showMediaPreview(
|
void showMediaPreview(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<DocumentData*> document);
|
not_null<DocumentData*> document);
|
||||||
void ui_showMediaPreview(
|
void showMediaPreview(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<PhotoData*> photo);
|
not_null<PhotoData*> photo);
|
||||||
|
void hideMediaPreview();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *o, QEvent *e) override;
|
bool eventFilter(QObject *o, QEvent *e) override;
|
||||||
|
@ -152,7 +153,6 @@ private:
|
||||||
void handleTrayIconActication(
|
void handleTrayIconActication(
|
||||||
QSystemTrayIcon::ActivationReason reason) override;
|
QSystemTrayIcon::ActivationReason reason) override;
|
||||||
|
|
||||||
void hideMediaPreview();
|
|
||||||
void ensureLayerCreated();
|
void ensureLayerCreated();
|
||||||
void destroyLayer();
|
void destroyLayer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue