mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-09-04 02:53:07 +02:00
Merge d953730ea0
into 1dfe68e9f3
This commit is contained in:
commit
2d9e3f090c
8 changed files with 102 additions and 0 deletions
|
@ -7156,3 +7156,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_AboutText1" = "ToS breaking Telegram client based on {api_link}.";
|
||||
"ayu_UpdateAyuGram" = "Update AyuGram";
|
||||
"ayu_UtilityRestartRequired" = "The app will close in 5 seconds.";
|
||||
"ayu_Repeater" = "+1 / Repeater";
|
||||
|
|
|
@ -257,6 +257,7 @@ AyuGramSettings::AyuGramSettings() {
|
|||
showHideMessageInContextMenu = 0;
|
||||
showUserMessagesInContextMenu = 2;
|
||||
showMessageDetailsInContextMenu = 2;
|
||||
showRepeaterInContextMenu = 2;
|
||||
|
||||
showAttachButtonInMessageField = true;
|
||||
showCommandsButtonInMessageField = true;
|
||||
|
@ -473,6 +474,10 @@ void set_showMessageDetailsInContextMenu(int val) {
|
|||
settings->showMessageDetailsInContextMenu = val;
|
||||
}
|
||||
|
||||
void set_showRepeaterInContextMenu(int val) {
|
||||
settings->showRepeaterInContextMenu = val;
|
||||
}
|
||||
|
||||
void set_showAttachButtonInMessageField(bool val) {
|
||||
settings->showAttachButtonInMessageField = val;
|
||||
triggerHistoryUpdate();
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
int showHideMessageInContextMenu;
|
||||
int showUserMessagesInContextMenu;
|
||||
int showMessageDetailsInContextMenu;
|
||||
int showRepeaterInContextMenu;
|
||||
|
||||
bool showAttachButtonInMessageField;
|
||||
bool showCommandsButtonInMessageField;
|
||||
|
@ -175,6 +176,7 @@ void set_showViewsPanelInContextMenu(int val);
|
|||
void set_showHideMessageInContextMenu(int val);
|
||||
void set_showUserMessagesInContextMenu(int val);
|
||||
void set_showMessageDetailsInContextMenu(int val);
|
||||
void set_showRepeaterInContextMenu(int val);
|
||||
|
||||
void set_showAttachButtonInMessageField(bool val);
|
||||
void set_showCommandsButtonInMessageField(bool val);
|
||||
|
@ -245,6 +247,7 @@ inline void to_json(nlohmann::json &nlohmann_json_j, const AyuGramSettings &nloh
|
|||
NLOHMANN_JSON_TO(showHideMessageInContextMenu)
|
||||
NLOHMANN_JSON_TO(showUserMessagesInContextMenu)
|
||||
NLOHMANN_JSON_TO(showMessageDetailsInContextMenu)
|
||||
NLOHMANN_JSON_TO(showRepeaterInContextMenu)
|
||||
NLOHMANN_JSON_TO(showAttachButtonInMessageField)
|
||||
NLOHMANN_JSON_TO(showCommandsButtonInMessageField)
|
||||
NLOHMANN_JSON_TO(showEmojiButtonInMessageField)
|
||||
|
@ -310,6 +313,7 @@ inline void from_json(const nlohmann::json &nlohmann_json_j, AyuGramSettings &nl
|
|||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showHideMessageInContextMenu)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showUserMessagesInContextMenu)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showMessageDetailsInContextMenu)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showRepeaterInContextMenu)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showAttachButtonInMessageField)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showCommandsButtonInMessageField)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showEmojiButtonInMessageField)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/ayu_state.h"
|
||||
#include "ayu/data/messages_storage.h"
|
||||
#include "ayu/features/forward/ayu_forward.h"
|
||||
#include "ayu/ui/context_menu/menu_item_subtext.h"
|
||||
#include "ayu/utils/qt_key_modifiers_extended.h"
|
||||
#include "history/history_item_components.h"
|
||||
|
@ -42,6 +43,10 @@
|
|||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
#include "main/session/send_as_peers.h"
|
||||
#include "api/api_sending.h"
|
||||
#include "history/history_widget.h"
|
||||
|
||||
namespace AyuUi {
|
||||
|
||||
namespace {
|
||||
|
@ -631,6 +636,77 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
|
|||
});
|
||||
}
|
||||
|
||||
void AddRepeaterAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (!needToShowItem(settings->showRepeaterInContextMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item || item->isService() || item->id <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto peer = item->history()->peer;
|
||||
if (!peer->isUser() && !peer->isChat() && !peer->isMegagroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto canRepeat = item->allowsForward() ||
|
||||
(!item->emptyText() && !item->isDeleted()) ||
|
||||
(item->media() && (item->media()->document() || item->media()->photo()));
|
||||
|
||||
if (!canRepeat) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto itemId = item->fullId();
|
||||
const auto history = item->history();
|
||||
const auto session = &history->session();
|
||||
|
||||
menu->addAction(
|
||||
tr::ayu_Repeater(tr::now),
|
||||
[=] {
|
||||
auto sendOptions = Api::SendOptions{
|
||||
.sendAs = session->sendAsPeers().resolveChosen(peer)
|
||||
};
|
||||
|
||||
if (peer->isUser() || peer->isChat()) {
|
||||
sendOptions.sendAs = nullptr;
|
||||
}
|
||||
|
||||
auto action = Api::SendAction(history, sendOptions);
|
||||
action.clearDraft = false;
|
||||
|
||||
if (item->topic()) {
|
||||
action.replyTo = FullReplyTo{
|
||||
.messageId = itemId,
|
||||
.topicRootId = item->topicRootId(),
|
||||
};
|
||||
}
|
||||
|
||||
auto forwardDraft = Data::ForwardDraft{
|
||||
.ids = MessageIdsList(1, itemId),
|
||||
.options = Data::ForwardOptions::PreserveInfo
|
||||
};
|
||||
auto resolved = history->resolveForwardDraft(forwardDraft);
|
||||
const auto needsFullAyuForward = AyuForward::isFullAyuForwardNeeded(item);
|
||||
const auto needsAyuForward = AyuForward::isAyuForwardNeeded(item);
|
||||
|
||||
if (needsFullAyuForward) {
|
||||
crl::async([=] {
|
||||
AyuForward::forwardMessages(session, action, false, resolved);
|
||||
});
|
||||
} else if (needsAyuForward) {
|
||||
crl::async([=] {
|
||||
AyuForward::intelligentForward(session, action, resolved);
|
||||
});
|
||||
} else {
|
||||
session->api().forwardMessages(std::move(resolved), action, [] {});
|
||||
}
|
||||
},
|
||||
&st::menuIconDiscussion);
|
||||
}
|
||||
|
||||
void AddReadUntilAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
|
||||
if (item->isLocal() || item->isService() || item->out() || item->isDeleted()) {
|
||||
return;
|
||||
|
|
|
@ -37,6 +37,7 @@ void AddHistoryAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
|||
void AddHideMessageAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
void AddUserMessagesAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
void AddRepeaterAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
void AddReadUntilAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
void AddBurnAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
|
||||
|
||||
|
|
|
@ -974,6 +974,19 @@ void SetupContextMenuElements(not_null<Ui::VerticalLayout*> container,
|
|||
AyuSettings::set_showMessageDetailsInContextMenu(index);
|
||||
AyuSettings::save();
|
||||
});
|
||||
AddChooseButtonWithIconAndRightText(
|
||||
container,
|
||||
controller,
|
||||
settings->showRepeaterInContextMenu,
|
||||
options,
|
||||
tr::ayu_Repeater(),
|
||||
tr::ayu_SettingsContextMenuTitle(),
|
||||
st::menuIconDiscussion,
|
||||
[=](int index)
|
||||
{
|
||||
AyuSettings::set_showRepeaterInContextMenu(index);
|
||||
AyuSettings::save();
|
||||
});
|
||||
|
||||
AddSkip(container);
|
||||
AddDividerText(container, tr::ayu_SettingsContextMenuDescription());
|
||||
|
|
|
@ -2552,6 +2552,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
AyuUi::AddHideMessageAction(_menu, item);
|
||||
AyuUi::AddUserMessagesAction(_menu, item);
|
||||
AyuUi::AddMessageDetailsAction(_menu, item);
|
||||
AyuUi::AddRepeaterAction(_menu, item);
|
||||
};
|
||||
const auto addPhotoActions = [&](not_null<PhotoData*> photo, HistoryItem *item) {
|
||||
const auto media = photo->activeMediaView();
|
||||
|
|
|
@ -1064,6 +1064,7 @@ void AddMessageActions(
|
|||
AyuUi::AddHideMessageAction(menu, request.item);
|
||||
AyuUi::AddUserMessagesAction(menu, request.item);
|
||||
AyuUi::AddMessageDetailsAction(menu, request.item);
|
||||
AyuUi::AddRepeaterAction(menu, request.item);
|
||||
}
|
||||
|
||||
AddPostLinkAction(menu, request);
|
||||
|
|
Loading…
Add table
Reference in a new issue