mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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(
|
_wrap.geometryValue(
|
||||||
) | rpl::start_with_next([=](QRect rect) {
|
) | rpl::start_with_next([=](QRect rect) {
|
||||||
updateShadowGeometry(rect);
|
updateShadowGeometry(rect);
|
||||||
updateControlsGeometry(rect);
|
updateControlsGeometry(rect);
|
||||||
}, _wrap.lifetime());
|
}, _wrap.lifetime());
|
||||||
|
|
||||||
const auto button = static_cast<Ui::FlatButton*>(_wrap.entity());
|
const auto button = static_cast<Ui::FlatButton*>(_wrap.entity());
|
||||||
button->setClickedCallback([=] {
|
const auto translateTo = [=](LanguageId id) {
|
||||||
const auto to = history->translatedTo()
|
history->translateTo(id);
|
||||||
? LanguageId()
|
|
||||||
: Core::App().settings().translateTo();
|
|
||||||
history->translateTo(to);
|
|
||||||
if (const auto migrated = history->migrateFrom()) {
|
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>(
|
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
button,
|
button,
|
||||||
st::historyTranslateLabel);
|
st::historyTranslateLabel);
|
||||||
|
|
|
@ -270,6 +270,7 @@ private:
|
||||||
void addViewDiscussion();
|
void addViewDiscussion();
|
||||||
void addToggleTopicClosed();
|
void addToggleTopicClosed();
|
||||||
void addExportChat();
|
void addExportChat();
|
||||||
|
void addTranslate();
|
||||||
void addReport();
|
void addReport();
|
||||||
void addNewContact();
|
void addNewContact();
|
||||||
void addShareContact();
|
void addShareContact();
|
||||||
|
@ -776,6 +777,23 @@ void Filler::addExportChat() {
|
||||||
&st::menuIconExport);
|
&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() {
|
void Filler::addReport() {
|
||||||
const auto chat = _peer->asChat();
|
const auto chat = _peer->asChat();
|
||||||
const auto channel = _peer->asChannel();
|
const auto channel = _peer->asChannel();
|
||||||
|
@ -1174,6 +1192,7 @@ void Filler::fillHistoryActions() {
|
||||||
addThemeEdit();
|
addThemeEdit();
|
||||||
addViewDiscussion();
|
addViewDiscussion();
|
||||||
addExportChat();
|
addExportChat();
|
||||||
|
addTranslate();
|
||||||
addReport();
|
addReport();
|
||||||
addClearHistory();
|
addClearHistory();
|
||||||
addDeleteChat();
|
addDeleteChat();
|
||||||
|
|
Loading…
Add table
Reference in a new issue