mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added ability to open photo editor in EditCaptionBox with left-click.
This commit is contained in:
parent
e926e5f882
commit
22213a71c1
2 changed files with 24 additions and 4 deletions
|
@ -54,6 +54,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/controls/emoji_button.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "confirm_box.h"
|
||||
#include "apiwrap.h"
|
||||
|
@ -405,7 +406,8 @@ EditCaptionBox::EditCaptionBox(
|
|||
closeBox();
|
||||
}, lifetime());
|
||||
|
||||
AddPhotoEditorMenu(this, [=, _controller = controller] {
|
||||
_photoEditorOpens.events(
|
||||
) | rpl::start_with_next([=, controller = _controller] {
|
||||
const auto previewWidth = st::sendMediaPreviewSize;
|
||||
if (!_preparedList.files.empty()) {
|
||||
Editor::OpenWithPreparedFile(
|
||||
|
@ -444,7 +446,7 @@ EditCaptionBox::EditCaptionBox(
|
|||
std::move(callback)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
EditCaptionBox::~EditCaptionBox() = default;
|
||||
|
@ -637,6 +639,7 @@ void EditCaptionBox::updateEditPreview() {
|
|||
|
||||
const auto showCheckbox = _photo && (_albumType == Ui::AlbumType::None);
|
||||
_wayWrap->toggle(showCheckbox, anim::type::instant);
|
||||
_photoEditorButton->setVisible(_photo);
|
||||
|
||||
if (!_doc) {
|
||||
_thumb = App::pixmapFromImageInPlace(
|
||||
|
@ -727,6 +730,15 @@ void EditCaptionBox::createEditMediaButton() {
|
|||
st::historyAttach.ripple.hideDuration,
|
||||
this,
|
||||
buttonCallback));
|
||||
|
||||
_photoEditorButton = base::make_unique_q<Ui::AbstractButton>(this);
|
||||
_photoEditorButton->clicks(
|
||||
) | rpl::to_empty | rpl::start_to_stream(
|
||||
_photoEditorOpens,
|
||||
_photoEditorButton->lifetime());
|
||||
|
||||
_photoEditorButton->raise();
|
||||
_editMedia->raise();
|
||||
}
|
||||
|
||||
void EditCaptionBox::prepare() {
|
||||
|
@ -1052,6 +1064,9 @@ void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
|||
_wayWrap->moveToLeft(
|
||||
st::boxPhotoPadding.left(),
|
||||
st::boxPhotoPadding.top() + _thumbh);
|
||||
|
||||
_photoEditorButton->resize(_thumbw, _thumbh);
|
||||
_photoEditorButton->moveToLeft(_thumbx, st::boxPhotoPadding.top());
|
||||
}
|
||||
|
||||
_field->resize(st::sendMediaPreviewSize, _field->height());
|
||||
|
@ -1144,8 +1159,10 @@ void EditCaptionBox::setName(QString nameString, qint64 size) {
|
|||
}
|
||||
|
||||
void EditCaptionBox::keyPressEvent(QKeyEvent *e) {
|
||||
if ((e->key() == Qt::Key_E || e->key() == Qt::Key_O)
|
||||
&& e->modifiers() == Qt::ControlModifier) {
|
||||
const auto ctrl = e->modifiers().testFlag(Qt::ControlModifier);
|
||||
if ((e->key() == Qt::Key_E) && ctrl) {
|
||||
_photoEditorOpens.fire({});
|
||||
} else if ((e->key() == Qt::Key_O) && ctrl) {
|
||||
_editMediaClicks.fire({});
|
||||
} else {
|
||||
e->ignore();
|
||||
|
|
|
@ -29,6 +29,7 @@ class DocumentMedia;
|
|||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class AbstractButton;
|
||||
class InputField;
|
||||
class EmojiButton;
|
||||
class IconButton;
|
||||
|
@ -122,6 +123,7 @@ private:
|
|||
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
|
||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||
base::unique_qptr<QObject> _emojiFilter;
|
||||
base::unique_qptr<Ui::AbstractButton> _photoEditorButton;
|
||||
|
||||
int _thumbx = 0;
|
||||
int _thumbw = 0;
|
||||
|
@ -146,6 +148,7 @@ private:
|
|||
bool _isAllowedEditMedia = false;
|
||||
bool _asFile = false;
|
||||
rpl::event_stream<> _editMediaClicks;
|
||||
rpl::event_stream<> _photoEditorOpens;
|
||||
|
||||
QString _error;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue