mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Show "Translate" in three-dot if bar was hidden.
This commit is contained in:
parent
be71139515
commit
19e43cfd1d
2 changed files with 36 additions and 7 deletions
|
@ -83,20 +83,30 @@ void TranslateBar::setup(not_null<History*> history) {
|
|||
_wrap.geometryValue(
|
||||
) | rpl::start_with_next([=](QRect rect) {
|
||||
updateShadowGeometry(rect);
|
||||
updateControlsGeometry(rect);
|
||||
updateControlsGeometry(rect);
|
||||
}, _wrap.lifetime());
|
||||
|
||||
const auto button = static_cast<Ui::FlatButton*>(_wrap.entity());
|
||||
button->setClickedCallback([=] {
|
||||
const auto to = history->translatedTo()
|
||||
? LanguageId()
|
||||
: Core::App().settings().translateTo();
|
||||
history->translateTo(to);
|
||||
const auto translateTo = [=](LanguageId id) {
|
||||
history->translateTo(id);
|
||||
if (const auto migrated = history->migrateFrom()) {
|
||||
migrated->translateTo(to);
|
||||
migrated->translateTo(id);
|
||||
}
|
||||
};
|
||||
button->setClickedCallback([=] {
|
||||
translateTo(history->translatedTo()
|
||||
? LanguageId()
|
||||
: Core::App().settings().translateTo());
|
||||
});
|
||||
|
||||
Core::App().settings().translateToValue(
|
||||
) | rpl::filter([=](LanguageId should) {
|
||||
const auto now = history->translatedTo();
|
||||
return now && (now != should);
|
||||
}) | rpl::start_with_next([=](LanguageId should) {
|
||||
translateTo(should);
|
||||
}, _wrap.lifetime());
|
||||
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
st::historyTranslateLabel);
|
||||
|
|
|
@ -270,6 +270,7 @@ private:
|
|||
void addViewDiscussion();
|
||||
void addToggleTopicClosed();
|
||||
void addExportChat();
|
||||
void addTranslate();
|
||||
void addReport();
|
||||
void addNewContact();
|
||||
void addShareContact();
|
||||
|
@ -776,6 +777,23 @@ void Filler::addExportChat() {
|
|||
&st::menuIconExport);
|
||||
}
|
||||
|
||||
void Filler::addTranslate() {
|
||||
if (_peer->translationFlag() != PeerData::TranslationFlag::Disabled
|
||||
|| !_peer->session().premium()
|
||||
|| !Core::App().settings().translateChatEnabled()) {
|
||||
return;
|
||||
}
|
||||
const auto history = _peer->owner().historyLoaded(_peer);
|
||||
if (!history
|
||||
|| !history->translateOfferedFrom()
|
||||
|| history->translatedTo()) {
|
||||
return;
|
||||
}
|
||||
_addAction(tr::lng_context_translate(tr::now), [=] {
|
||||
history->peer->saveTranslationDisabled(false);
|
||||
}, &st::menuIconTranslate);
|
||||
}
|
||||
|
||||
void Filler::addReport() {
|
||||
const auto chat = _peer->asChat();
|
||||
const auto channel = _peer->asChannel();
|
||||
|
@ -1174,6 +1192,7 @@ void Filler::fillHistoryActions() {
|
|||
addThemeEdit();
|
||||
addViewDiscussion();
|
||||
addExportChat();
|
||||
addTranslate();
|
||||
addReport();
|
||||
addClearHistory();
|
||||
addDeleteChat();
|
||||
|
|
Loading…
Add table
Reference in a new issue