mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to flip items in photo editor.
This commit is contained in:
parent
fde7cef9c8
commit
808c9e3d2c
5 changed files with 34 additions and 1 deletions
|
@ -2767,6 +2767,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_filters_remove_sure" = "This will remove the folder, your chats will not be deleted.";
|
"lng_filters_remove_sure" = "This will remove the folder, your chats will not be deleted.";
|
||||||
"lng_filters_remove_yes" = "Remove";
|
"lng_filters_remove_yes" = "Remove";
|
||||||
|
|
||||||
|
"lng_photo_editor_menu_delete" = "Delete";
|
||||||
|
"lng_photo_editor_menu_flip" = "Flip";
|
||||||
|
"lng_photo_editor_menu_duplicate" = "Duplicate";
|
||||||
|
|
||||||
// Wnd specific
|
// Wnd specific
|
||||||
|
|
||||||
"lng_wnd_choose_program_menu" = "Choose Default Program...";
|
"lng_wnd_choose_program_menu" = "Choose Default Program...";
|
||||||
|
|
|
@ -179,11 +179,14 @@ void ItemBase::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(nullptr);
|
_menu = base::make_unique_q<Ui::PopupMenu>(nullptr);
|
||||||
_menu->addAction(tr::lng_selected_delete(tr::now), [=] {
|
_menu->addAction(tr::lng_photo_editor_menu_delete(tr::now), [=] {
|
||||||
if (const auto s = static_cast<Scene*>(scene())) {
|
if (const auto s = static_cast<Scene*>(scene())) {
|
||||||
s->removeItem(this);
|
s->removeItem(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_menu->addAction(tr::lng_photo_editor_menu_flip(tr::now), [=] {
|
||||||
|
setFlip(!flipped());
|
||||||
|
});
|
||||||
|
|
||||||
_menu->popup(event->screenPos());
|
_menu->popup(event->screenPos());
|
||||||
}
|
}
|
||||||
|
@ -233,4 +236,18 @@ ItemBase::HandleType ItemBase::handleType(const QPointF &pos) const {
|
||||||
: HandleType::None;
|
: HandleType::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ItemBase::flipped() const {
|
||||||
|
return _flipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemBase::setFlip(bool value) {
|
||||||
|
if (_flipped != value) {
|
||||||
|
performFlip();
|
||||||
|
_flipped = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemBase::performFlip() {
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -47,6 +47,9 @@ public:
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget) override;
|
QWidget *widget) override;
|
||||||
int type() const override;
|
int type() const override;
|
||||||
|
|
||||||
|
bool flipped() const;
|
||||||
|
void setFlip(bool value);
|
||||||
protected:
|
protected:
|
||||||
enum HandleType {
|
enum HandleType {
|
||||||
None,
|
None,
|
||||||
|
@ -66,6 +69,7 @@ protected:
|
||||||
float64 verticalSize() const;
|
float64 verticalSize() const;
|
||||||
void setAspectRatio(float64 aspectRatio);
|
void setAspectRatio(float64 aspectRatio);
|
||||||
|
|
||||||
|
virtual void performFlip();
|
||||||
private:
|
private:
|
||||||
HandleType handleType(const QPointF &pos) const;
|
HandleType handleType(const QPointF &pos) const;
|
||||||
QRectF rightHandleRect() const;
|
QRectF rightHandleRect() const;
|
||||||
|
@ -88,6 +92,8 @@ private:
|
||||||
float64 _aspectRatio = 1.0;
|
float64 _aspectRatio = 1.0;
|
||||||
HandleType _handle = HandleType::None;
|
HandleType _handle = HandleType::None;
|
||||||
|
|
||||||
|
bool _flipped = false;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -97,4 +97,8 @@ int ItemSticker::type() const {
|
||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemSticker::performFlip() {
|
||||||
|
_pixmap = _pixmap.transformed(QTransform().scale(-1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
QWidget *widget) override;
|
QWidget *widget) override;
|
||||||
MTPInputDocument sticker() const;
|
MTPInputDocument sticker() const;
|
||||||
int type() const override;
|
int type() const override;
|
||||||
|
protected:
|
||||||
|
void performFlip() override;
|
||||||
private:
|
private:
|
||||||
const not_null<DocumentData*> _document;
|
const not_null<DocumentData*> _document;
|
||||||
const std::shared_ptr<Data::DocumentMedia> _mediaView;
|
const std::shared_ptr<Data::DocumentMedia> _mediaView;
|
||||||
|
|
Loading…
Add table
Reference in a new issue