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,9 +411,11 @@ 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()) {
|
||||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
w->showMediaPreview(
|
||||||
_pack[_previewShown]);
|
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||||
|
_pack[_previewShown]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,9 +474,11 @@ 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()) {
|
||||||
Data::FileOriginStickerSet(_setId, _setAccess),
|
w->showMediaPreview(
|
||||||
_pack[_previewShown]);
|
Data::FileOriginStickerSet(_setId, _setAccess),
|
||||||
|
_pack[_previewShown]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1030,9 +1030,11 @@ 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()) {
|
||||||
(*_srows)[_down].document->stickerSetOrigin(),
|
w->showMediaPreview(
|
||||||
(*_srows)[_down].document);
|
(*_srows)[_down].document->stickerSetOrigin(),
|
||||||
|
(*_srows)[_down].document);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1050,10 +1052,12 @@ 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()) {
|
||||||
(*_srows)[_down].document->stickerSetOrigin(),
|
w->showMediaPreview(
|
||||||
(*_srows)[_down].document);
|
(*_srows)[_down].document->stickerSetOrigin(),
|
||||||
_previewShown = true;
|
(*_srows)[_down].document);
|
||||||
|
_previewShown = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -985,14 +985,16 @@ 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 previewDocument = layout->getPreviewDocument()) {
|
if (const auto w = App::wnd()) {
|
||||||
Ui::showMediaPreview(
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Data::FileOriginSavedGifs(),
|
w->showMediaPreview(
|
||||||
previewDocument);
|
Data::FileOriginSavedGifs(),
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
previewDocument);
|
||||||
Ui::showMediaPreview(
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Data::FileOrigin(),
|
w->showMediaPreview(
|
||||||
previewPhoto);
|
Data::FileOrigin(),
|
||||||
|
previewPhoto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,16 +1011,18 @@ 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 previewDocument = layout->getPreviewDocument()) {
|
if (const auto w = App::wnd()) {
|
||||||
Ui::showMediaPreview(
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Data::FileOriginSavedGifs(),
|
w->showMediaPreview(
|
||||||
previewDocument);
|
Data::FileOriginSavedGifs(),
|
||||||
_previewShown = true;
|
previewDocument);
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
_previewShown = true;
|
||||||
Ui::showMediaPreview(
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
Data::FileOrigin(),
|
w->showMediaPreview(
|
||||||
previewPhoto);
|
Data::FileOrigin(),
|
||||||
_previewShown = true;
|
previewPhoto);
|
||||||
|
_previewShown = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,8 +2632,10 @@ 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()) {
|
||||||
_previewShown = true;
|
w->showMediaPreview(document->stickerSetOrigin(), document);
|
||||||
|
_previewShown = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 previewDocument = layout->getPreviewDocument()) {
|
if (const auto w = App::wnd()) {
|
||||||
Ui::showMediaPreview(
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
Data::FileOrigin(),
|
w->showMediaPreview(
|
||||||
previewDocument);
|
Data::FileOrigin(),
|
||||||
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
|
previewDocument);
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
} 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;
|
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 previewDocument = layout->getPreviewDocument()) {
|
if (const auto w = App::wnd()) {
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewDocument);
|
if (const auto previewDocument = layout->getPreviewDocument()) {
|
||||||
_previewShown = true;
|
w->showMediaPreview(Data::FileOrigin(), previewDocument);
|
||||||
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
_previewShown = true;
|
||||||
Ui::showMediaPreview(Data::FileOrigin(), previewPhoto);
|
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
|
||||||
_previewShown = true;
|
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
|
||||||
|
_previewShown = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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