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