mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added ability to fast change forward options with right click on panel.
This commit is contained in:
parent
830fb3ccc2
commit
f457a9d109
3 changed files with 59 additions and 27 deletions
|
@ -6195,7 +6195,11 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
|
|||
crl::guard(_list, [=] { cancelEdit(); }));
|
||||
} else if (_inReplyEditForward) {
|
||||
if (isReadyToForward) {
|
||||
_forwardPanel->editOptions(controller()->uiShow());
|
||||
if (e->button() != Qt::LeftButton) {
|
||||
_forwardPanel->editToNextOption();
|
||||
} else {
|
||||
_forwardPanel->editOptions(controller()->uiShow());
|
||||
}
|
||||
} else {
|
||||
controller()->showPeerHistory(
|
||||
_peer,
|
||||
|
|
|
@ -36,6 +36,31 @@ constexpr auto kUnknownVersion = -1;
|
|||
constexpr auto kNameWithCaptionsVersion = -2;
|
||||
constexpr auto kNameNoCaptionsVersion = -3;
|
||||
|
||||
[[nodiscard]] bool HasCaptions(const HistoryItemsList &list) {
|
||||
for (const auto &item : list) {
|
||||
if (const auto media = item->media()) {
|
||||
if (!item->originalText().text.isEmpty()
|
||||
&& media->allowsEditCaption()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool HasOnlyForcedForwardedInfo(const HistoryItemsList &list) {
|
||||
for (const auto &item : list) {
|
||||
if (const auto media = item->media()) {
|
||||
if (!media->forceForwardedInfo()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ForwardPanel::ForwardPanel(Fn<void()> repaint)
|
||||
|
@ -224,32 +249,10 @@ void ForwardPanel::editOptions(std::shared_ptr<ChatHelpers::Show> show) {
|
|||
const auto now = _data.options;
|
||||
const auto count = _data.items.size();
|
||||
const auto dropNames = (now != Options::PreserveInfo);
|
||||
const auto hasCaptions = [&] {
|
||||
for (const auto item : _data.items) {
|
||||
if (const auto media = item->media()) {
|
||||
if (!item->originalText().text.isEmpty()
|
||||
&& media->allowsEditCaption()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
const auto hasOnlyForcedForwardedInfo = [&] {
|
||||
if (hasCaptions) {
|
||||
return false;
|
||||
}
|
||||
for (const auto item : _data.items) {
|
||||
if (const auto media = item->media()) {
|
||||
if (!media->forceForwardedInfo()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
const auto hasCaptions = HasCaptions(_data.items);
|
||||
const auto hasOnlyForcedForwardedInfo = hasCaptions
|
||||
? false
|
||||
: HasOnlyForcedForwardedInfo(_data.items);
|
||||
const auto dropCaptions = (now == Options::NoNamesAndCaptions);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto changeRecipient = crl::guard(this, [=] {
|
||||
|
@ -299,6 +302,30 @@ void ForwardPanel::editOptions(std::shared_ptr<ChatHelpers::Show> show) {
|
|||
changeRecipient));
|
||||
}
|
||||
|
||||
void ForwardPanel::editToNextOption() {
|
||||
using Options = Data::ForwardOptions;
|
||||
const auto hasCaptions = HasCaptions(_data.items);
|
||||
const auto hasOnlyForcedForwardedInfo = hasCaptions
|
||||
? false
|
||||
: HasOnlyForcedForwardedInfo(_data.items);
|
||||
if (hasOnlyForcedForwardedInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto now = _data.options;
|
||||
const auto next = (now == Options::PreserveInfo)
|
||||
? Options::NoSenderNames
|
||||
: ((now == Options::NoSenderNames) && hasCaptions)
|
||||
? Options::NoNamesAndCaptions
|
||||
: Options::PreserveInfo;
|
||||
|
||||
_to->owningHistory()->setForwardDraft(_to->topicRootId(), {
|
||||
.ids = _to->owner().itemsToIds(_data.items),
|
||||
.options = next,
|
||||
});
|
||||
_repaint();
|
||||
}
|
||||
|
||||
void ForwardPanel::paint(
|
||||
Painter &p,
|
||||
int x,
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
[[nodiscard]] rpl::producer<> itemsUpdated() const;
|
||||
|
||||
void editOptions(std::shared_ptr<ChatHelpers::Show> show);
|
||||
void editToNextOption();
|
||||
|
||||
[[nodiscard]] const HistoryItemsList &items() const;
|
||||
[[nodiscard]] bool empty() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue