mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow replace media by paste in replies/scheduled.
This commit is contained in:
parent
3a8237f03a
commit
58f735e19b
4 changed files with 40 additions and 25 deletions
|
@ -1157,6 +1157,22 @@ void ComposeControls::setMimeDataHook(MimeDataHook hook) {
|
||||||
_field->setMimeDataHook(std::move(hook));
|
_field->setMimeDataHook(std::move(hook));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ComposeControls::confirmMediaEdit(Ui::PreparedList &list) {
|
||||||
|
if (!isEditingMessage()) {
|
||||||
|
return false;
|
||||||
|
} else if (_canReplaceMedia) {
|
||||||
|
EditCaptionBox::StartMediaReplace(
|
||||||
|
_window,
|
||||||
|
_editingId,
|
||||||
|
std::move(list),
|
||||||
|
_field->getTextWithTags(),
|
||||||
|
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
||||||
|
} else {
|
||||||
|
_window->showToast({ tr::lng_edit_caption_attach(tr::now) });
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<FileChosen> ComposeControls::fileChosen() const {
|
rpl::producer<FileChosen> ComposeControls::fileChosen() const {
|
||||||
return _fileChosen.events();
|
return _fileChosen.events();
|
||||||
}
|
}
|
||||||
|
@ -1431,23 +1447,17 @@ void ComposeControls::init() {
|
||||||
_voiceRecordBar->requestToSendWithOptions(options);
|
_voiceRecordBar->requestToSendWithOptions(options);
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
{
|
_header->editMsgId(
|
||||||
const auto lastMsgId = _wrap->lifetime().make_state<FullMsgId>();
|
) | rpl::start_with_next([=](const auto &id) {
|
||||||
|
_editingId = id;
|
||||||
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
_header->editMsgId(
|
session().data().itemRemoved(
|
||||||
) | rpl::filter([=](const auto &id) {
|
) | rpl::filter([=](not_null<const HistoryItem*> item) {
|
||||||
return !!id;
|
return (_editingId == item->fullId());
|
||||||
}) | rpl::start_with_next([=](const auto &id) {
|
}) | rpl::start_with_next([=] {
|
||||||
*lastMsgId = id;
|
cancelEditMessage();
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
session().data().itemRemoved(
|
|
||||||
) | rpl::filter([=](not_null<const HistoryItem*> item) {
|
|
||||||
return item->id && ((*lastMsgId) == item->fullId());
|
|
||||||
}) | rpl::start_with_next([=] {
|
|
||||||
cancelEditMessage();
|
|
||||||
}, _wrap->lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
_window->materializeLocalDraftsRequests(
|
_window->materializeLocalDraftsRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
@ -1921,7 +1931,7 @@ void ComposeControls::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||||
InvokeQueued(_autocomplete.get(), [=] { updateStickersByEmoji(); });
|
InvokeQueued(_autocomplete.get(), [=] { updateStickersByEmoji(); });
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
updateSendButtonType();
|
updateSendButtonType();
|
||||||
updateReplaceMediaButton(editingId);
|
updateReplaceMediaButton();
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateControlsGeometry(_wrap->size());
|
updateControlsGeometry(_wrap->size());
|
||||||
});
|
});
|
||||||
|
@ -2588,7 +2598,7 @@ void ComposeControls::editMessage(not_null<HistoryItem*> item) {
|
||||||
if (_photoEditMedia) {
|
if (_photoEditMedia) {
|
||||||
_photoEditMedia->wanted(Data::PhotoSize::Large, item->fullId());
|
_photoEditMedia->wanted(Data::PhotoSize::Large, item->fullId());
|
||||||
}
|
}
|
||||||
if (updateReplaceMediaButton(item->fullId())) {
|
if (updateReplaceMediaButton()) {
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateControlsGeometry(_wrap->size());
|
updateControlsGeometry(_wrap->size());
|
||||||
}
|
}
|
||||||
|
@ -2598,7 +2608,7 @@ void ComposeControls::editMessage(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComposeControls::updateReplaceMediaButton(FullMsgId id) {
|
bool ComposeControls::updateReplaceMediaButton() {
|
||||||
if (!_canReplaceMedia) {
|
if (!_canReplaceMedia) {
|
||||||
const auto result = (_replaceMedia != nullptr);
|
const auto result = (_replaceMedia != nullptr);
|
||||||
_replaceMedia = nullptr;
|
_replaceMedia = nullptr;
|
||||||
|
@ -2612,7 +2622,7 @@ bool ComposeControls::updateReplaceMediaButton(FullMsgId id) {
|
||||||
_replaceMedia->setClickedCallback([=] {
|
_replaceMedia->setClickedCallback([=] {
|
||||||
EditCaptionBox::StartMediaReplace(
|
EditCaptionBox::StartMediaReplace(
|
||||||
_window,
|
_window,
|
||||||
id,
|
_editingId,
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,6 +55,7 @@ class EmojiButton;
|
||||||
class SendAsButton;
|
class SendAsButton;
|
||||||
class SilentToggle;
|
class SilentToggle;
|
||||||
class DropdownMenu;
|
class DropdownMenu;
|
||||||
|
struct PreparedList;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
|
@ -143,6 +144,7 @@ public:
|
||||||
not_null<const QMimeData*> data,
|
not_null<const QMimeData*> data,
|
||||||
Ui::InputField::MimeAction action)>;
|
Ui::InputField::MimeAction action)>;
|
||||||
void setMimeDataHook(MimeDataHook hook);
|
void setMimeDataHook(MimeDataHook hook);
|
||||||
|
bool confirmMediaEdit(Ui::PreparedList &list);
|
||||||
|
|
||||||
bool pushTabbedSelectorToThirdSection(
|
bool pushTabbedSelectorToThirdSection(
|
||||||
not_null<Data::Thread*> thread,
|
not_null<Data::Thread*> thread,
|
||||||
|
@ -228,7 +230,7 @@ private:
|
||||||
void updateWrappingVisibility();
|
void updateWrappingVisibility();
|
||||||
void updateControlsVisibility();
|
void updateControlsVisibility();
|
||||||
void updateControlsGeometry(QSize size);
|
void updateControlsGeometry(QSize size);
|
||||||
bool updateReplaceMediaButton(FullMsgId id);
|
bool updateReplaceMediaButton();
|
||||||
void updateOuterGeometry(QRect rect);
|
void updateOuterGeometry(QRect rect);
|
||||||
void paintBackground(QRect clip);
|
void paintBackground(QRect clip);
|
||||||
|
|
||||||
|
@ -236,8 +238,6 @@ private:
|
||||||
[[nodiscard]] SendMenu::Type sendMenuType() const;
|
[[nodiscard]] SendMenu::Type sendMenuType() const;
|
||||||
[[nodiscard]] SendMenu::Type sendButtonMenuType() const;
|
[[nodiscard]] SendMenu::Type sendButtonMenuType() const;
|
||||||
|
|
||||||
void sendSilent();
|
|
||||||
void sendScheduled();
|
|
||||||
[[nodiscard]] auto sendContentRequests(
|
[[nodiscard]] auto sendContentRequests(
|
||||||
SendRequestType requestType = SendRequestType::Text) const;
|
SendRequestType requestType = SendRequestType::Text) const;
|
||||||
|
|
||||||
|
@ -358,6 +358,7 @@ private:
|
||||||
bool _isInlineBot = false;
|
bool _isInlineBot = false;
|
||||||
bool _botCommandShown = false;
|
bool _botCommandShown = false;
|
||||||
|
|
||||||
|
FullMsgId _editingId;
|
||||||
std::shared_ptr<Data::PhotoMedia> _photoEditMedia;
|
std::shared_ptr<Data::PhotoMedia> _photoEditMedia;
|
||||||
bool _canReplaceMedia = false;
|
bool _canReplaceMedia = false;
|
||||||
|
|
||||||
|
|
|
@ -937,7 +937,9 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
bool RepliesWidget::confirmSendingFiles(
|
bool RepliesWidget::confirmSendingFiles(
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
const QString &insertTextOnCancel) {
|
const QString &insertTextOnCancel) {
|
||||||
if (showSendingFilesError(list)) {
|
if (_composeControls->confirmMediaEdit(list)) {
|
||||||
|
return true;
|
||||||
|
} else if (showSendingFilesError(list)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,7 +402,9 @@ bool ScheduledWidget::confirmSendingFiles(
|
||||||
bool ScheduledWidget::confirmSendingFiles(
|
bool ScheduledWidget::confirmSendingFiles(
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
const QString &insertTextOnCancel) {
|
const QString &insertTextOnCancel) {
|
||||||
if (showSendingFilesError(list)) {
|
if (_composeControls->confirmMediaEdit(list)) {
|
||||||
|
return true;
|
||||||
|
} else if (showSendingFilesError(list)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue