mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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(); }));
|
crl::guard(_list, [=] { cancelEdit(); }));
|
||||||
} else if (_inReplyEditForward) {
|
} else if (_inReplyEditForward) {
|
||||||
if (isReadyToForward) {
|
if (isReadyToForward) {
|
||||||
_forwardPanel->editOptions(controller()->uiShow());
|
if (e->button() != Qt::LeftButton) {
|
||||||
|
_forwardPanel->editToNextOption();
|
||||||
|
} else {
|
||||||
|
_forwardPanel->editOptions(controller()->uiShow());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
controller()->showPeerHistory(
|
controller()->showPeerHistory(
|
||||||
_peer,
|
_peer,
|
||||||
|
|
|
@ -36,6 +36,31 @@ constexpr auto kUnknownVersion = -1;
|
||||||
constexpr auto kNameWithCaptionsVersion = -2;
|
constexpr auto kNameWithCaptionsVersion = -2;
|
||||||
constexpr auto kNameNoCaptionsVersion = -3;
|
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
|
} // namespace
|
||||||
|
|
||||||
ForwardPanel::ForwardPanel(Fn<void()> repaint)
|
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 now = _data.options;
|
||||||
const auto count = _data.items.size();
|
const auto count = _data.items.size();
|
||||||
const auto dropNames = (now != Options::PreserveInfo);
|
const auto dropNames = (now != Options::PreserveInfo);
|
||||||
const auto hasCaptions = [&] {
|
const auto hasCaptions = HasCaptions(_data.items);
|
||||||
for (const auto item : _data.items) {
|
const auto hasOnlyForcedForwardedInfo = hasCaptions
|
||||||
if (const auto media = item->media()) {
|
? false
|
||||||
if (!item->originalText().text.isEmpty()
|
: HasOnlyForcedForwardedInfo(_data.items);
|
||||||
&& 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 dropCaptions = (now == Options::NoNamesAndCaptions);
|
const auto dropCaptions = (now == Options::NoNamesAndCaptions);
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
const auto changeRecipient = crl::guard(this, [=] {
|
const auto changeRecipient = crl::guard(this, [=] {
|
||||||
|
@ -299,6 +302,30 @@ void ForwardPanel::editOptions(std::shared_ptr<ChatHelpers::Show> show) {
|
||||||
changeRecipient));
|
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(
|
void ForwardPanel::paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
int x,
|
int x,
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
[[nodiscard]] rpl::producer<> itemsUpdated() const;
|
[[nodiscard]] rpl::producer<> itemsUpdated() const;
|
||||||
|
|
||||||
void editOptions(std::shared_ptr<ChatHelpers::Show> show);
|
void editOptions(std::shared_ptr<ChatHelpers::Show> show);
|
||||||
|
void editToNextOption();
|
||||||
|
|
||||||
[[nodiscard]] const HistoryItemsList &items() const;
|
[[nodiscard]] const HistoryItemsList &items() const;
|
||||||
[[nodiscard]] bool empty() const;
|
[[nodiscard]] bool empty() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue