mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Apply auto-translation from French? for test.
This commit is contained in:
parent
eb81c33308
commit
9583007769
5 changed files with 30 additions and 3 deletions
|
@ -734,6 +734,13 @@ bool PeerData::canExportChatHistory() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PeerData::autoTranslation() const {
|
||||||
|
if (const auto channel = asChannel()) {
|
||||||
|
return channel->autoTranslation();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool PeerData::setAbout(const QString &newAbout) {
|
bool PeerData::setAbout(const QString &newAbout) {
|
||||||
if (_about == newAbout) {
|
if (_about == newAbout) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -396,6 +396,7 @@ public:
|
||||||
[[nodiscard]] bool canManageGifts() const;
|
[[nodiscard]] bool canManageGifts() const;
|
||||||
[[nodiscard]] bool canTransferGifts() const;
|
[[nodiscard]] bool canTransferGifts() const;
|
||||||
[[nodiscard]] bool canExportChatHistory() const;
|
[[nodiscard]] bool canExportChatHistory() const;
|
||||||
|
[[nodiscard]] bool autoTranslation() const;
|
||||||
|
|
||||||
// Returns true if about text was changed.
|
// Returns true if about text was changed.
|
||||||
bool setAbout(const QString &newAbout);
|
bool setAbout(const QString &newAbout);
|
||||||
|
|
|
@ -7557,6 +7557,10 @@ void HistoryWidget::checkLastPinnedClickedIdReset(
|
||||||
void HistoryWidget::setupTranslateBar() {
|
void HistoryWidget::setupTranslateBar() {
|
||||||
Expects(_history != nullptr);
|
Expects(_history != nullptr);
|
||||||
|
|
||||||
|
if (_history->peer->autoTranslation()) {
|
||||||
|
_history->translateTo(Core::App().settings().translateTo());
|
||||||
|
}
|
||||||
|
|
||||||
_translateBar = std::make_unique<HistoryView::TranslateBar>(
|
_translateBar = std::make_unique<HistoryView::TranslateBar>(
|
||||||
this,
|
this,
|
||||||
controller(),
|
controller(),
|
||||||
|
|
|
@ -372,6 +372,7 @@ void TranslateBar::setup(not_null<History*> history) {
|
||||||
const auto&,
|
const auto&,
|
||||||
const auto&) {
|
const auto&) {
|
||||||
using Flag = PeerData::TranslationFlag;
|
using Flag = PeerData::TranslationFlag;
|
||||||
|
//const auto autotranslation = history->peer->autoTranslation();
|
||||||
return (history->peer->translationFlag() != Flag::Enabled)
|
return (history->peer->translationFlag() != Flag::Enabled)
|
||||||
? rpl::single(QString())
|
? rpl::single(QString())
|
||||||
: history->translatedTo()
|
: history->translatedTo()
|
||||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_flags.h"
|
||||||
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
@ -57,10 +59,22 @@ void TranslateTracker::setup() {
|
||||||
Core::App().settings().translateChatEnabledValue(),
|
Core::App().settings().translateChatEnabledValue(),
|
||||||
_1 && _2);
|
_1 && _2);
|
||||||
|
|
||||||
_trackingLanguage.value(
|
const auto channel = peer->asChannel();
|
||||||
) | rpl::start_with_next([=](bool tracking) {
|
auto autoTranslationValue = (channel
|
||||||
|
? channel->flagsValue()
|
||||||
|
: rpl::single(Data::Flags<ChannelDataFlags>::Change({}, {}))
|
||||||
|
) | rpl::map([=](Data::Flags<ChannelDataFlags>::Change data) {
|
||||||
|
return (data.value & ChannelDataFlag::AutoTranslation);
|
||||||
|
}) | rpl::distinct_until_changed();
|
||||||
|
rpl::combine(
|
||||||
|
_trackingLanguage.value(),
|
||||||
|
std::move(autoTranslationValue)
|
||||||
|
) | rpl::start_with_next([=](bool tracking, bool autotranslation) {
|
||||||
_trackingLifetime.destroy();
|
_trackingLifetime.destroy();
|
||||||
if (tracking) {
|
if (autotranslation) {
|
||||||
|
_history->translateOfferFrom({ QLocale::French });
|
||||||
|
AssertIsDebug();
|
||||||
|
} else if (tracking) {
|
||||||
recognizeCollected();
|
recognizeCollected();
|
||||||
trackSkipLanguages();
|
trackSkipLanguages();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue