mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added translate ability to context menu.
This commit is contained in:
parent
921d2239c7
commit
6db7840fa7
7 changed files with 54 additions and 0 deletions
BIN
Telegram/Resources/icons/menu/translate.png
Normal file
BIN
Telegram/Resources/icons/menu/translate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 604 B |
BIN
Telegram/Resources/icons/menu/translate@2x.png
Normal file
BIN
Telegram/Resources/icons/menu/translate@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/menu/translate@3x.png
Normal file
BIN
Telegram/Resources/icons/menu/translate@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -2258,6 +2258,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_context_delete_from_disk" = "Delete from disk";
|
"lng_context_delete_from_disk" = "Delete from disk";
|
||||||
"lng_context_delete_all_files" = "Delete all files";
|
"lng_context_delete_all_files" = "Delete all files";
|
||||||
"lng_context_save_custom_sound" = "Save for notifications";
|
"lng_context_save_custom_sound" = "Save for notifications";
|
||||||
|
"lng_context_translate" = "Translate";
|
||||||
|
"lng_context_translate_selected" = "Translate Selected Text";
|
||||||
|
|
||||||
"lng_context_animated_emoji" = "This message contains emoji from **{name} pack**.";
|
"lng_context_animated_emoji" = "This message contains emoji from **{name} pack**.";
|
||||||
"lng_context_animated_emoji_many#one" = "This message contains emoji from **{count} pack**.";
|
"lng_context_animated_emoji_many#one" = "This message contains emoji from **{count} pack**.";
|
||||||
|
|
|
@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/report_messages_box.h"
|
#include "boxes/report_messages_box.h"
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
|
#include "boxes/translate_box.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/emoji_interactions.h"
|
#include "chat_helpers/emoji_interactions.h"
|
||||||
#include "history/history_widget.h"
|
#include "history/history_widget.h"
|
||||||
|
@ -2267,6 +2268,13 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
: tr::lng_context_copy_selected(tr::now)),
|
: tr::lng_context_copy_selected(tr::now)),
|
||||||
[=] { copySelectedText(); },
|
[=] { copySelectedText(); },
|
||||||
&st::menuIconCopy);
|
&st::menuIconCopy);
|
||||||
|
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
||||||
|
_controller->show(Box(
|
||||||
|
Ui::TranslateBox,
|
||||||
|
item->history()->peer,
|
||||||
|
MsgId(),
|
||||||
|
getSelectedText().rich));
|
||||||
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
addItemActions(item, item);
|
addItemActions(item, item);
|
||||||
if (!selectedState.count) {
|
if (!selectedState.count) {
|
||||||
|
@ -2358,6 +2366,13 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
[=] { copySelectedText(); },
|
[=] { copySelectedText(); },
|
||||||
&st::menuIconCopy);
|
&st::menuIconCopy);
|
||||||
}
|
}
|
||||||
|
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
||||||
|
_controller->show(Box(
|
||||||
|
Ui::TranslateBox,
|
||||||
|
item->history()->peer,
|
||||||
|
MsgId(),
|
||||||
|
getSelectedText().rich));
|
||||||
|
}, &st::menuIconTranslate);
|
||||||
addItemActions(item, item);
|
addItemActions(item, item);
|
||||||
} else {
|
} else {
|
||||||
addItemActions(item, albumPartItem);
|
addItemActions(item, albumPartItem);
|
||||||
|
@ -2415,6 +2430,18 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
copyContextText(itemId);
|
copyContextText(itemId);
|
||||||
}, &st::menuIconCopy);
|
}, &st::menuIconCopy);
|
||||||
}
|
}
|
||||||
|
if (!item->isService()
|
||||||
|
&& view
|
||||||
|
&& actionText.isEmpty()
|
||||||
|
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||||
|
_menu->addAction(tr::lng_context_translate(tr::now), [=] {
|
||||||
|
_controller->show(Box(
|
||||||
|
Ui::TranslateBox,
|
||||||
|
item->history()->peer,
|
||||||
|
item->fullId().msg,
|
||||||
|
item->originalText()));
|
||||||
|
}, &st::menuIconTranslate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!actionText.isEmpty() && !hasCopyRestriction(item)) {
|
if (!actionText.isEmpty() && !hasCopyRestriction(item)) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/report_messages_box.h"
|
#include "boxes/report_messages_box.h"
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
#include "boxes/stickers_box.h"
|
#include "boxes/stickers_box.h"
|
||||||
|
#include "boxes/translate_box.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
@ -1004,6 +1005,18 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
}
|
}
|
||||||
}, &st::menuIconCopy);
|
}, &st::menuIconCopy);
|
||||||
}
|
}
|
||||||
|
if (request.overSelection) {
|
||||||
|
const auto owner = &view->history()->owner();
|
||||||
|
result->addAction(tr::lng_context_translate_selected(tr::now), [=] {
|
||||||
|
if (const auto item = owner->message(itemId)) {
|
||||||
|
list->controller()->show(Box(
|
||||||
|
Ui::TranslateBox,
|
||||||
|
item->history()->peer,
|
||||||
|
MsgId(),
|
||||||
|
list->getSelectedText().rich));
|
||||||
|
}
|
||||||
|
}, &st::menuIconTranslate);
|
||||||
|
}
|
||||||
|
|
||||||
AddTopMessageActions(result, request, list);
|
AddTopMessageActions(result, request, list);
|
||||||
if (lnkPhoto && request.selectedItems.empty()) {
|
if (lnkPhoto && request.selectedItems.empty()) {
|
||||||
|
@ -1038,6 +1051,17 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
}
|
}
|
||||||
}, &st::menuIconCopy);
|
}, &st::menuIconCopy);
|
||||||
}
|
}
|
||||||
|
if (!link && (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||||
|
result->addAction(tr::lng_context_translate(tr::now), [=] {
|
||||||
|
if (const auto item = owner->message(itemId)) {
|
||||||
|
list->controller()->show(Box(
|
||||||
|
Ui::TranslateBox,
|
||||||
|
item->history()->peer,
|
||||||
|
item->fullId().msg,
|
||||||
|
item->originalText()));
|
||||||
|
}
|
||||||
|
}, &st::menuIconTranslate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!view || !list->hasCopyRestriction(view->data())) {
|
if (!view || !list->hasCopyRestriction(view->data())) {
|
||||||
|
|
|
@ -92,6 +92,7 @@ menuIconSearch: icon {{ "menu/search", menuIconColor }};
|
||||||
menuIconStartStream: icon {{ "menu/start_stream", menuIconColor }};
|
menuIconStartStream: icon {{ "menu/start_stream", menuIconColor }};
|
||||||
menuIconStartStreamWith: icon {{ "menu/start_stream_with", menuIconColor }};
|
menuIconStartStreamWith: icon {{ "menu/start_stream_with", menuIconColor }};
|
||||||
menuIconVideoChat: icon {{ "menu/video_chat", menuIconColor }};
|
menuIconVideoChat: icon {{ "menu/video_chat", menuIconColor }};
|
||||||
|
menuIconTranslate: icon {{ "menu/translate", menuIconColor }};
|
||||||
|
|
||||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||||
|
|
Loading…
Add table
Reference in a new issue