mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +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_yes" = "Remove";
|
||||
|
||||
"lng_photo_editor_menu_delete" = "Delete";
|
||||
"lng_photo_editor_menu_flip" = "Flip";
|
||||
"lng_photo_editor_menu_duplicate" = "Duplicate";
|
||||
|
||||
// Wnd specific
|
||||
|
||||
"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->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())) {
|
||||
s->removeItem(this);
|
||||
}
|
||||
});
|
||||
_menu->addAction(tr::lng_photo_editor_menu_flip(tr::now), [=] {
|
||||
setFlip(!flipped());
|
||||
});
|
||||
|
||||
_menu->popup(event->screenPos());
|
||||
}
|
||||
|
@ -233,4 +236,18 @@ ItemBase::HandleType ItemBase::handleType(const QPointF &pos) const {
|
|||
: HandleType::None;
|
||||
}
|
||||
|
||||
bool ItemBase::flipped() const {
|
||||
return _flipped;
|
||||
}
|
||||
|
||||
void ItemBase::setFlip(bool value) {
|
||||
if (_flipped != value) {
|
||||
performFlip();
|
||||
_flipped = value;
|
||||
}
|
||||
}
|
||||
|
||||
void ItemBase::performFlip() {
|
||||
}
|
||||
|
||||
} // namespace Editor
|
||||
|
|
|
@ -47,6 +47,9 @@ public:
|
|||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override;
|
||||
int type() const override;
|
||||
|
||||
bool flipped() const;
|
||||
void setFlip(bool value);
|
||||
protected:
|
||||
enum HandleType {
|
||||
None,
|
||||
|
@ -66,6 +69,7 @@ protected:
|
|||
float64 verticalSize() const;
|
||||
void setAspectRatio(float64 aspectRatio);
|
||||
|
||||
virtual void performFlip();
|
||||
private:
|
||||
HandleType handleType(const QPointF &pos) const;
|
||||
QRectF rightHandleRect() const;
|
||||
|
@ -88,6 +92,8 @@ private:
|
|||
float64 _aspectRatio = 1.0;
|
||||
HandleType _handle = HandleType::None;
|
||||
|
||||
bool _flipped = false;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
|
|
@ -97,4 +97,8 @@ int ItemSticker::type() const {
|
|||
return Type;
|
||||
}
|
||||
|
||||
void ItemSticker::performFlip() {
|
||||
_pixmap = _pixmap.transformed(QTransform().scale(-1, 1));
|
||||
}
|
||||
|
||||
} // namespace Editor
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
QWidget *widget) override;
|
||||
MTPInputDocument sticker() const;
|
||||
int type() const override;
|
||||
protected:
|
||||
void performFlip() override;
|
||||
private:
|
||||
const not_null<DocumentData*> _document;
|
||||
const std::shared_ptr<Data::DocumentMedia> _mediaView;
|
||||
|
|
Loading…
Add table
Reference in a new issue