mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support translations in replies / pinned.
This commit is contained in:
parent
f55d9fb82b
commit
3ac86adf10
16 changed files with 246 additions and 84 deletions
|
@ -915,7 +915,6 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
const auto historyDisplayedEmpty = _history->isDisplayedEmpty()
|
const auto historyDisplayedEmpty = _history->isDisplayedEmpty()
|
||||||
&& (!_migrated || _migrated->isDisplayedEmpty());
|
&& (!_migrated || _migrated->isDisplayedEmpty());
|
||||||
const auto translatedTo = _history->translatedTo();
|
|
||||||
if (_botAbout && !_botAbout->info->text.isEmpty() && _botAbout->height > 0) {
|
if (_botAbout && !_botAbout->info->text.isEmpty() && _botAbout->height > 0) {
|
||||||
const auto st = context.st;
|
const auto st = context.st;
|
||||||
const auto stm = &st->messageStyle(false, false);
|
const auto stm = &st->messageStyle(false, false);
|
||||||
|
@ -969,7 +968,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
if (_pinnedItem) {
|
if (_pinnedItem) {
|
||||||
_translateTracker->add(_pinnedItem, translatedTo);
|
_translateTracker->add(_pinnedItem);
|
||||||
}
|
}
|
||||||
_translateTracker->finishBunch();
|
_translateTracker->finishBunch();
|
||||||
if (readTill && _widget->markingMessagesRead()) {
|
if (readTill && _widget->markingMessagesRead()) {
|
||||||
|
@ -985,7 +984,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
not_null<Element*> view,
|
not_null<Element*> view,
|
||||||
int top,
|
int top,
|
||||||
int height) {
|
int height) {
|
||||||
_translateTracker->add(view, translatedTo);
|
_translateTracker->add(view);
|
||||||
const auto item = view->data();
|
const auto item = view->data();
|
||||||
const auto isSponsored = item->isSponsored();
|
const auto isSponsored = item->isSponsored();
|
||||||
const auto isUnread = !item->out()
|
const auto isUnread = !item->out()
|
||||||
|
|
|
@ -480,6 +480,7 @@ SlidingBar::SlidingBar(
|
||||||
, _shadow(parent) {
|
, _shadow(parent) {
|
||||||
setup(parent);
|
setup(parent);
|
||||||
_wrapped.hide(anim::type::instant);
|
_wrapped.hide(anim::type::instant);
|
||||||
|
_shadow.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingBar::setup(not_null<Ui::RpWidget*> parent) {
|
void SlidingBar::setup(not_null<Ui::RpWidget*> parent) {
|
||||||
|
@ -497,10 +498,13 @@ void SlidingBar::setup(not_null<Ui::RpWidget*> parent) {
|
||||||
st::lineWidth);
|
st::lineWidth);
|
||||||
}, _shadow.lifetime());
|
}, _shadow.lifetime());
|
||||||
|
|
||||||
_wrapped.shownValue(
|
_shadow.showOn(rpl::combine(
|
||||||
) | rpl::start_with_next([=](bool shown) {
|
_wrapped.shownValue(),
|
||||||
_shadow.setVisible(shown);
|
_wrapped.heightValue(),
|
||||||
}, _shadow.lifetime());
|
rpl::mappers::_1 && rpl::mappers::_2 > 0
|
||||||
|
) | rpl::filter([=](bool shown) {
|
||||||
|
return (shown == _shadow.isHidden());
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingBar::toggleContent(bool visible) {
|
void SlidingBar::toggleContent(bool visible) {
|
||||||
|
@ -516,14 +520,13 @@ void SlidingBar::raise() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingBar::setVisible(bool visible) {
|
void SlidingBar::setVisible(bool visible) {
|
||||||
if (_shown == visible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_shown = visible;
|
_shown = visible;
|
||||||
if (!_shown) {
|
if (!_shown) {
|
||||||
_wrapped.hide(anim::type::instant);
|
_wrapped.hide(anim::type::instant);
|
||||||
} else if (_contentShown) {
|
} else if (_contentShown) {
|
||||||
_wrapped.show(anim::type::instant);
|
_wrapped.show(anim::type::instant);
|
||||||
|
} else if (!_wrapped.isHidden() && !_wrapped.animating()) {
|
||||||
|
_wrapped.hide(anim::type::instant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_message.h"
|
#include "history/view/history_view_message.h"
|
||||||
#include "history/view/history_view_service_message.h"
|
#include "history/view/history_view_service_message.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
|
#include "history/view/history_view_translate_tracker.h"
|
||||||
#include "history/view/history_view_quick_action.h"
|
#include "history/view/history_view_quick_action.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -83,6 +84,11 @@ constexpr auto kPreloadedScreensCountFull
|
||||||
= kPreloadedScreensCount + 1 + kPreloadedScreensCount;
|
= kPreloadedScreensCount + 1 + kPreloadedScreensCount;
|
||||||
constexpr auto kClearUserpicsAfter = 50;
|
constexpr auto kClearUserpicsAfter = 50;
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<TranslateTracker> MaybeTranslateTracker(
|
||||||
|
History *history) {
|
||||||
|
return history ? std::make_unique<TranslateTracker>(history) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ListWidget::MouseState::MouseState() : pointState(PointState::Outside) {
|
ListWidget::MouseState::MouseState() : pointState(PointState::Outside) {
|
||||||
|
@ -297,6 +303,7 @@ ListWidget::ListWidget(
|
||||||
this,
|
this,
|
||||||
[=](QRect updated) { update(updated); },
|
[=](QRect updated) { update(updated); },
|
||||||
controller->cachedReactionIconFactory().createMethod()))
|
controller->cachedReactionIconFactory().createMethod()))
|
||||||
|
, _translateTracker(MaybeTranslateTracker(_delegate->listTranslateHistory()))
|
||||||
, _scrollDateCheck([this] { scrollDateCheck(); })
|
, _scrollDateCheck([this] { scrollDateCheck(); })
|
||||||
, _applyUpdatedScrollState([this] { applyUpdatedScrollState(); })
|
, _applyUpdatedScrollState([this] { applyUpdatedScrollState(); })
|
||||||
, _selectEnabled(_delegate->listAllowsMultiSelect())
|
, _selectEnabled(_delegate->listAllowsMultiSelect())
|
||||||
|
@ -359,6 +366,15 @@ ListWidget::ListWidget(
|
||||||
maybeMarkReactionsRead(update.item);
|
maybeMarkReactionsRead(update.item);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
if (const auto history = _delegate->listTranslateHistory()) {
|
||||||
|
session().changes().historyUpdates(
|
||||||
|
history,
|
||||||
|
Data::HistoryUpdate::Flag::TranslatedTo
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
update();
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
session().data().itemVisibilityQueries(
|
session().data().itemVisibilityQueries(
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
const Data::Session::ItemVisibilityQuery &query) {
|
const Data::Session::ItemVisibilityQuery &query) {
|
||||||
|
@ -2025,9 +2041,16 @@ void ListWidget::paintEvent(QPaintEvent *e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_translateTracker) {
|
||||||
|
_translateTracker->startBunch();
|
||||||
|
}
|
||||||
auto readTill = (HistoryItem*)nullptr;
|
auto readTill = (HistoryItem*)nullptr;
|
||||||
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
|
if (_translateTracker) {
|
||||||
|
_delegate->listAddTranslatedItems(_translateTracker.get());
|
||||||
|
_translateTracker->finishBunch();
|
||||||
|
}
|
||||||
if (readTill && markingMessagesRead()) {
|
if (readTill && markingMessagesRead()) {
|
||||||
_delegate->listMarkReadTill(readTill);
|
_delegate->listMarkReadTill(readTill);
|
||||||
}
|
}
|
||||||
|
@ -2076,6 +2099,9 @@ void ListWidget::paintEvent(QPaintEvent *e) {
|
||||||
context.selection = itemRenderSelection(view);
|
context.selection = itemRenderSelection(view);
|
||||||
view->draw(p, context);
|
view->draw(p, context);
|
||||||
}
|
}
|
||||||
|
if (_translateTracker) {
|
||||||
|
_translateTracker->add(view);
|
||||||
|
}
|
||||||
const auto isSponsored = item->isSponsored();
|
const auto isSponsored = item->isSponsored();
|
||||||
const auto isUnread = _delegate->listElementShownUnread(view)
|
const auto isUnread = _delegate->listElementShownUnread(view)
|
||||||
&& item->isRegular();
|
&& item->isRegular();
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace HistoryView {
|
||||||
struct TextState;
|
struct TextState;
|
||||||
struct StateRequest;
|
struct StateRequest;
|
||||||
class EmojiInteractions;
|
class EmojiInteractions;
|
||||||
|
class TranslateTracker;
|
||||||
enum class CursorState : char;
|
enum class CursorState : char;
|
||||||
enum class PointState : char;
|
enum class PointState : char;
|
||||||
enum class Context : char;
|
enum class Context : char;
|
||||||
|
@ -142,6 +143,9 @@ public:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) = 0;
|
const Ui::ChatPaintContext &context) = 0;
|
||||||
virtual QString listElementAuthorRank(not_null<const Element*> view) = 0;
|
virtual QString listElementAuthorRank(not_null<const Element*> view) = 0;
|
||||||
|
virtual History *listTranslateHistory() = 0;
|
||||||
|
virtual void listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SelectionData {
|
struct SelectionData {
|
||||||
|
@ -644,6 +648,8 @@ private:
|
||||||
rpl::variable<HistoryItem*> _reactionsItem;
|
rpl::variable<HistoryItem*> _reactionsItem;
|
||||||
bool _useCornerReaction = false;
|
bool _useCornerReaction = false;
|
||||||
|
|
||||||
|
std::unique_ptr<TranslateTracker> _translateTracker;
|
||||||
|
|
||||||
int _minHeight = 0;
|
int _minHeight = 0;
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_pinned_section.h"
|
#include "history/view/history_view_pinned_section.h"
|
||||||
|
|
||||||
#include "history/view/history_view_top_bar_widget.h"
|
#include "history/view/history_view_top_bar_widget.h"
|
||||||
|
#include "history/view/history_view_translate_bar.h"
|
||||||
#include "history/view/history_view_list_widget.h"
|
#include "history/view/history_view_list_widget.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
|
@ -100,6 +101,7 @@ PinnedWidget::PinnedWidget(
|
||||||
: nullptr)
|
: nullptr)
|
||||||
, _topBar(this, controller)
|
, _topBar(this, controller)
|
||||||
, _topBarShadow(this)
|
, _topBarShadow(this)
|
||||||
|
, _translateBar(std::make_unique<TranslateBar>(this, controller, _history))
|
||||||
, _scroll(std::make_unique<Ui::ScrollArea>(
|
, _scroll(std::make_unique<Ui::ScrollArea>(
|
||||||
this,
|
this,
|
||||||
controller->chatStyle()->value(lifetime(), st::historyScroll),
|
controller->chatStyle()->value(lifetime(), st::historyScroll),
|
||||||
|
@ -150,6 +152,7 @@ PinnedWidget::PinnedWidget(
|
||||||
clearSelected();
|
clearSelected();
|
||||||
}, _topBar->lifetime());
|
}, _topBar->lifetime());
|
||||||
|
|
||||||
|
_translateBar->raise();
|
||||||
_topBarShadow->raise();
|
_topBarShadow->raise();
|
||||||
controller->adaptive().value(
|
controller->adaptive().value(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
@ -168,6 +171,7 @@ PinnedWidget::PinnedWidget(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
setupClearButton();
|
setupClearButton();
|
||||||
|
setupTranslateBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
PinnedWidget::~PinnedWidget() = default;
|
PinnedWidget::~PinnedWidget() = default;
|
||||||
|
@ -195,6 +199,29 @@ void PinnedWidget::setupClearButton() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PinnedWidget::setupTranslateBar() {
|
||||||
|
controller()->adaptive().oneColumnValue(
|
||||||
|
) | rpl::start_with_next([=, raw = _translateBar.get()](bool one) {
|
||||||
|
raw->setShadowGeometryPostprocess([=](QRect geometry) {
|
||||||
|
if (!one) {
|
||||||
|
geometry.setLeft(geometry.left() + st::lineWidth);
|
||||||
|
}
|
||||||
|
return geometry;
|
||||||
|
});
|
||||||
|
}, _translateBar->lifetime());
|
||||||
|
|
||||||
|
_translateBarHeight = 0;
|
||||||
|
_translateBar->heightValue(
|
||||||
|
) | rpl::start_with_next([=](int height) {
|
||||||
|
if (const auto delta = height - _translateBarHeight) {
|
||||||
|
_translateBarHeight = height;
|
||||||
|
setGeometryWithTopMoved(geometry(), delta);
|
||||||
|
}
|
||||||
|
}, _translateBar->lifetime());
|
||||||
|
|
||||||
|
_translateBar->finishAnimating();
|
||||||
|
}
|
||||||
|
|
||||||
void PinnedWidget::cornerButtonsShowAtPosition(
|
void PinnedWidget::cornerButtonsShowAtPosition(
|
||||||
Data::MessagePosition position) {
|
Data::MessagePosition position) {
|
||||||
showAtPosition(position);
|
showAtPosition(position);
|
||||||
|
@ -261,6 +288,7 @@ QPixmap PinnedWidget::grabForShowAnimation(const Window::SectionSlideParams &par
|
||||||
if (params.withTopBarShadow) _topBarShadow->hide();
|
if (params.withTopBarShadow) _topBarShadow->hide();
|
||||||
auto result = Ui::GrabWidget(this);
|
auto result = Ui::GrabWidget(this);
|
||||||
if (params.withTopBarShadow) _topBarShadow->show();
|
if (params.withTopBarShadow) _topBarShadow->show();
|
||||||
|
_translateBar->hide();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,8 +398,11 @@ void PinnedWidget::updateControlsGeometry() {
|
||||||
_clearButton->resizeToWidth(width());
|
_clearButton->resizeToWidth(width());
|
||||||
_clearButton->move(0, bottom);
|
_clearButton->move(0, bottom);
|
||||||
const auto controlsHeight = 0;
|
const auto controlsHeight = 0;
|
||||||
const auto scrollY = _topBar->height();
|
auto top = _topBar->height();
|
||||||
const auto scrollHeight = bottom - scrollY - controlsHeight;
|
_translateBar->move(0, top);
|
||||||
|
_translateBar->resizeToWidth(contentWidth);
|
||||||
|
top += _translateBarHeight;
|
||||||
|
const auto scrollHeight = bottom - top - controlsHeight;
|
||||||
const auto scrollSize = QSize(contentWidth, scrollHeight);
|
const auto scrollSize = QSize(contentWidth, scrollHeight);
|
||||||
if (_scroll->size() != scrollSize) {
|
if (_scroll->size() != scrollSize) {
|
||||||
_skipScrollEvent = true;
|
_skipScrollEvent = true;
|
||||||
|
@ -379,7 +410,7 @@ void PinnedWidget::updateControlsGeometry() {
|
||||||
_inner->resizeToWidth(scrollSize.width(), _scroll->height());
|
_inner->resizeToWidth(scrollSize.width(), _scroll->height());
|
||||||
_skipScrollEvent = false;
|
_skipScrollEvent = false;
|
||||||
}
|
}
|
||||||
_scroll->move(0, scrollY);
|
_scroll->move(0, top);
|
||||||
if (!_scroll->isHidden()) {
|
if (!_scroll->isHidden()) {
|
||||||
if (newScrollTop) {
|
if (newScrollTop) {
|
||||||
_scroll->scrollToY(*newScrollTop);
|
_scroll->scrollToY(*newScrollTop);
|
||||||
|
@ -429,6 +460,7 @@ void PinnedWidget::showAnimatedHook(
|
||||||
void PinnedWidget::showFinishedHook() {
|
void PinnedWidget::showFinishedHook() {
|
||||||
_topBar->setAnimatingMode(false);
|
_topBar->setAnimatingMode(false);
|
||||||
_inner->showFinished();
|
_inner->showFinished();
|
||||||
|
_translateBar->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PinnedWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
bool PinnedWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
|
@ -630,6 +662,14 @@ QString PinnedWidget::listElementAuthorRank(not_null<const Element*> view) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
History *PinnedWidget::listTranslateHistory() {
|
||||||
|
return _history;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PinnedWidget::listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) {
|
||||||
|
}
|
||||||
|
|
||||||
void PinnedWidget::confirmDeleteSelected() {
|
void PinnedWidget::confirmDeleteSelected() {
|
||||||
ConfirmDeleteSelectedItems(_inner);
|
ConfirmDeleteSelectedItems(_inner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace HistoryView {
|
||||||
class Element;
|
class Element;
|
||||||
class TopBarWidget;
|
class TopBarWidget;
|
||||||
class PinnedMemento;
|
class PinnedMemento;
|
||||||
|
class TranslateBar;
|
||||||
|
|
||||||
class PinnedWidget final
|
class PinnedWidget final
|
||||||
: public Window::SectionWidget
|
: public Window::SectionWidget
|
||||||
|
@ -126,6 +127,9 @@ public:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
History *listTranslateHistory() override;
|
||||||
|
void listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
@ -158,6 +162,7 @@ private:
|
||||||
FullMsgId originId = {});
|
FullMsgId originId = {});
|
||||||
|
|
||||||
void setupClearButton();
|
void setupClearButton();
|
||||||
|
void setupTranslateBar();
|
||||||
|
|
||||||
void confirmDeleteSelected();
|
void confirmDeleteSelected();
|
||||||
void confirmForwardSelected();
|
void confirmForwardSelected();
|
||||||
|
@ -175,6 +180,9 @@ private:
|
||||||
object_ptr<TopBarWidget> _topBar;
|
object_ptr<TopBarWidget> _topBar;
|
||||||
object_ptr<Ui::PlainShadow> _topBarShadow;
|
object_ptr<Ui::PlainShadow> _topBarShadow;
|
||||||
|
|
||||||
|
std::unique_ptr<TranslateBar> _translateBar;
|
||||||
|
int _translateBarHeight = 0;
|
||||||
|
|
||||||
bool _skipScrollEvent = false;
|
bool _skipScrollEvent = false;
|
||||||
std::unique_ptr<Ui::ScrollArea> _scroll;
|
std::unique_ptr<Ui::ScrollArea> _scroll;
|
||||||
std::unique_ptr<Ui::FlatButton> _clearButton;
|
std::unique_ptr<Ui::FlatButton> _clearButton;
|
||||||
|
|
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_service_message.h"
|
#include "history/view/history_view_service_message.h"
|
||||||
#include "history/view/history_view_pinned_tracker.h"
|
#include "history/view/history_view_pinned_tracker.h"
|
||||||
#include "history/view/history_view_pinned_section.h"
|
#include "history/view/history_view_pinned_section.h"
|
||||||
|
#include "history/view/history_view_translate_bar.h"
|
||||||
|
#include "history/view/history_view_translate_tracker.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_drag_area.h"
|
#include "history/history_drag_area.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
|
@ -241,14 +243,15 @@ RepliesWidget::RepliesWidget(
|
||||||
[=](not_null<DocumentData*> emoji) { listShowPremiumToast(emoji); },
|
[=](not_null<DocumentData*> emoji) { listShowPremiumToast(emoji); },
|
||||||
ComposeControls::Mode::Normal,
|
ComposeControls::Mode::Normal,
|
||||||
SendMenu::Type::SilentOnly))
|
SendMenu::Type::SilentOnly))
|
||||||
|
, _translateBar(std::make_unique<TranslateBar>(this, controller, history))
|
||||||
, _scroll(std::make_unique<Ui::ScrollArea>(
|
, _scroll(std::make_unique<Ui::ScrollArea>(
|
||||||
this,
|
this,
|
||||||
controller->chatStyle()->value(lifetime(), st::historyScroll),
|
controller->chatStyle()->value(lifetime(), st::historyScroll),
|
||||||
false))
|
false))
|
||||||
, _cornerButtons(
|
, _cornerButtons(
|
||||||
_scroll.get(),
|
_scroll.get(),
|
||||||
controller->chatStyle(),
|
controller->chatStyle(),
|
||||||
static_cast<HistoryView::CornerButtonsDelegate*>(this)) {
|
static_cast<HistoryView::CornerButtonsDelegate*>(this)) {
|
||||||
controller->chatStyle()->paletteChanged(
|
controller->chatStyle()->paletteChanged(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
_scroll->updateBars();
|
_scroll->updateBars();
|
||||||
|
@ -265,6 +268,7 @@ RepliesWidget::RepliesWidget(
|
||||||
setupRoot();
|
setupRoot();
|
||||||
setupRootView();
|
setupRootView();
|
||||||
setupShortcuts();
|
setupShortcuts();
|
||||||
|
setupTranslateBar();
|
||||||
|
|
||||||
_history->peer->updateFull();
|
_history->peer->updateFull();
|
||||||
|
|
||||||
|
@ -406,8 +410,9 @@ RepliesWidget::~RepliesWidget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::orderWidgets() {
|
void RepliesWidget::orderWidgets() {
|
||||||
if (_topBar) {
|
_translateBar->raise();
|
||||||
_topBar->raise();
|
if (_topicReopenBar) {
|
||||||
|
_topicReopenBar->bar().raise();
|
||||||
}
|
}
|
||||||
if (_rootView) {
|
if (_rootView) {
|
||||||
_rootView->raise();
|
_rootView->raise();
|
||||||
|
@ -415,8 +420,8 @@ void RepliesWidget::orderWidgets() {
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->raise();
|
_pinnedBar->raise();
|
||||||
}
|
}
|
||||||
if (_topicReopenBar) {
|
if (_topBar) {
|
||||||
_topicReopenBar->bar().raise();
|
_topBar->raise();
|
||||||
}
|
}
|
||||||
_topBarShadow->raise();
|
_topBarShadow->raise();
|
||||||
_composeControls->raisePanels();
|
_composeControls->raisePanels();
|
||||||
|
@ -453,8 +458,12 @@ void RepliesWidget::setupRootView() {
|
||||||
_rootId,
|
_rootId,
|
||||||
[bar = _rootView.get()] { bar->customEmojiRepaint(); }),
|
[bar = _rootView.get()] { bar->customEmojiRepaint(); }),
|
||||||
_rootVisible.value()
|
_rootVisible.value()
|
||||||
) | rpl::map([=](Ui::MessageBarContent &&content, bool shown) {
|
) | rpl::map([=](Ui::MessageBarContent &&content, bool show) {
|
||||||
return shown ? std::move(content) : Ui::MessageBarContent();
|
const auto shown = !content.title.isEmpty() && !content.text.empty();
|
||||||
|
_shownPinnedItem = shown
|
||||||
|
? _history->owner().message(_history->peer->id, _rootId)
|
||||||
|
: nullptr;
|
||||||
|
return show ? std::move(content) : Ui::MessageBarContent();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
controller()->adaptive().oneColumnValue(
|
controller()->adaptive().oneColumnValue(
|
||||||
|
@ -585,6 +594,7 @@ void RepliesWidget::setTopic(Data::ForumTopic *topic) {
|
||||||
refreshTopBarActiveChat();
|
refreshTopBarActiveChat();
|
||||||
if (_topic) {
|
if (_topic) {
|
||||||
if (_rootView) {
|
if (_rootView) {
|
||||||
|
_shownPinnedItem = nullptr;
|
||||||
_rootView = nullptr;
|
_rootView = nullptr;
|
||||||
_rootViewHeight = 0;
|
_rootViewHeight = 0;
|
||||||
}
|
}
|
||||||
|
@ -1510,6 +1520,29 @@ void RepliesWidget::checkLastPinnedClickedIdReset(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RepliesWidget::setupTranslateBar() {
|
||||||
|
controller()->adaptive().oneColumnValue(
|
||||||
|
) | rpl::start_with_next([=, raw = _translateBar.get()](bool one) {
|
||||||
|
raw->setShadowGeometryPostprocess([=](QRect geometry) {
|
||||||
|
if (!one) {
|
||||||
|
geometry.setLeft(geometry.left() + st::lineWidth);
|
||||||
|
}
|
||||||
|
return geometry;
|
||||||
|
});
|
||||||
|
}, _translateBar->lifetime());
|
||||||
|
|
||||||
|
_translateBarHeight = 0;
|
||||||
|
_translateBar->heightValue(
|
||||||
|
) | rpl::start_with_next([=](int height) {
|
||||||
|
if (const auto delta = height - _translateBarHeight) {
|
||||||
|
_translateBarHeight = height;
|
||||||
|
setGeometryWithTopMoved(geometry(), delta);
|
||||||
|
}
|
||||||
|
}, _translateBar->lifetime());
|
||||||
|
|
||||||
|
_translateBar->finishAnimating();
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::setupPinnedTracker() {
|
void RepliesWidget::setupPinnedTracker() {
|
||||||
Expects(_topic != nullptr);
|
Expects(_topic != nullptr);
|
||||||
|
|
||||||
|
@ -1563,6 +1596,7 @@ void RepliesWidget::checkPinnedBarState() {
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->setContent(rpl::single(Ui::MessageBarContent()));
|
_pinnedBar->setContent(rpl::single(Ui::MessageBarContent()));
|
||||||
_pinnedTracker->reset();
|
_pinnedTracker->reset();
|
||||||
|
_shownPinnedItem = nullptr;
|
||||||
_hidingPinnedBar = base::take(_pinnedBar);
|
_hidingPinnedBar = base::take(_pinnedBar);
|
||||||
const auto raw = _hidingPinnedBar.get();
|
const auto raw = _hidingPinnedBar.get();
|
||||||
base::call_delayed(st::defaultMessageBar.duration, this, [=] {
|
base::call_delayed(st::defaultMessageBar.duration, this, [=] {
|
||||||
|
@ -1614,7 +1648,12 @@ void RepliesWidget::checkPinnedBarState() {
|
||||||
std::move(pinnedRefreshed),
|
std::move(pinnedRefreshed),
|
||||||
std::move(markupRefreshed),
|
std::move(markupRefreshed),
|
||||||
_rootVisible.value()
|
_rootVisible.value()
|
||||||
) | rpl::map([](Ui::MessageBarContent &&content, auto, auto, bool show) {
|
) | rpl::map([=](Ui::MessageBarContent &&content, auto, auto, bool show) {
|
||||||
|
const auto shown = !content.title.isEmpty() && !content.text.empty();
|
||||||
|
_shownPinnedItem = shown
|
||||||
|
? _history->owner().message(
|
||||||
|
_pinnedTracker->currentMessageId().message)
|
||||||
|
: nullptr;
|
||||||
return (show || content.count > 1)
|
return (show || content.count > 1)
|
||||||
? std::move(content)
|
? std::move(content)
|
||||||
: Ui::MessageBarContent();
|
: Ui::MessageBarContent();
|
||||||
|
@ -1896,6 +1935,7 @@ QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams &pa
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->hide();
|
_pinnedBar->hide();
|
||||||
}
|
}
|
||||||
|
_translateBar->hide();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2125,22 +2165,24 @@ void RepliesWidget::updateControlsGeometry() {
|
||||||
if (_rootView) {
|
if (_rootView) {
|
||||||
_rootView->resizeToWidth(contentWidth);
|
_rootView->resizeToWidth(contentWidth);
|
||||||
}
|
}
|
||||||
|
auto top = _topBar->height() + _rootViewHeight;
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->move(0, _topBar->height());
|
_pinnedBar->move(0, top);
|
||||||
_pinnedBar->resizeToWidth(contentWidth);
|
_pinnedBar->resizeToWidth(contentWidth);
|
||||||
|
top += _pinnedBarHeight;
|
||||||
}
|
}
|
||||||
|
if (_topicReopenBar) {
|
||||||
|
_topicReopenBar->bar().move(0, top);
|
||||||
|
top += _topicReopenBar->bar().height();
|
||||||
|
}
|
||||||
|
_translateBar->move(0, top);
|
||||||
|
_translateBar->resizeToWidth(contentWidth);
|
||||||
|
top += _translateBarHeight;
|
||||||
|
|
||||||
const auto bottom = height();
|
const auto bottom = height();
|
||||||
const auto controlsHeight = _joinGroup
|
const auto controlsHeight = _joinGroup
|
||||||
? _joinGroup->height()
|
? _joinGroup->height()
|
||||||
: _composeControls->heightCurrent();
|
: _composeControls->heightCurrent();
|
||||||
auto top = _topBar->height()
|
|
||||||
+ _rootViewHeight
|
|
||||||
+ _pinnedBarHeight;
|
|
||||||
if (_topicReopenBar) {
|
|
||||||
_topicReopenBar->bar().move(0, top);
|
|
||||||
top += _topicReopenBar->bar().height();
|
|
||||||
}
|
|
||||||
const auto scrollHeight = bottom - top - controlsHeight;
|
const auto scrollHeight = bottom - top - controlsHeight;
|
||||||
const auto scrollSize = QSize(contentWidth, scrollHeight);
|
const auto scrollSize = QSize(contentWidth, scrollHeight);
|
||||||
if (_scroll->size() != scrollSize) {
|
if (_scroll->size() != scrollSize) {
|
||||||
|
@ -2250,11 +2292,6 @@ void RepliesWidget::setPinnedVisibility(bool shown) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shown) {
|
|
||||||
_rootView->show();
|
|
||||||
} else {
|
|
||||||
_rootView->hide();
|
|
||||||
}
|
|
||||||
_rootVisible = shown;
|
_rootVisible = shown;
|
||||||
if (!_rootViewInited) {
|
if (!_rootViewInited) {
|
||||||
_rootView->finishAnimating();
|
_rootView->finishAnimating();
|
||||||
|
@ -2293,6 +2330,10 @@ void RepliesWidget::showFinishedHook() {
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->show();
|
_pinnedBar->show();
|
||||||
}
|
}
|
||||||
|
_translateBar->show();
|
||||||
|
if (_topicReopenBar) {
|
||||||
|
_topicReopenBar->bar().show();
|
||||||
|
}
|
||||||
|
|
||||||
// We should setup the drag area only after
|
// We should setup the drag area only after
|
||||||
// the section animation is finished,
|
// the section animation is finished,
|
||||||
|
@ -2536,6 +2577,17 @@ QString RepliesWidget::listElementAuthorRank(not_null<const Element*> view) {
|
||||||
: QString();
|
: QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
History *RepliesWidget::listTranslateHistory() {
|
||||||
|
return _history;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RepliesWidget::listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) {
|
||||||
|
if (_shownPinnedItem) {
|
||||||
|
tracker->add(_shownPinnedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::setupEmptyPainter() {
|
void RepliesWidget::setupEmptyPainter() {
|
||||||
Expects(_topic != nullptr);
|
Expects(_topic != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ class StickerToast;
|
||||||
class TopicReopenBar;
|
class TopicReopenBar;
|
||||||
class EmptyPainter;
|
class EmptyPainter;
|
||||||
class PinnedTracker;
|
class PinnedTracker;
|
||||||
|
class TranslateBar;
|
||||||
|
|
||||||
class RepliesWidget final
|
class RepliesWidget final
|
||||||
: public Window::SectionWidget
|
: public Window::SectionWidget
|
||||||
|
@ -170,6 +171,9 @@ public:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
History *listTranslateHistory() override;
|
||||||
|
void listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
@ -217,9 +221,9 @@ private:
|
||||||
void setTopic(Data::ForumTopic *topic);
|
void setTopic(Data::ForumTopic *topic);
|
||||||
void setupDragArea();
|
void setupDragArea();
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
|
void setupTranslateBar();
|
||||||
|
|
||||||
void searchInTopic();
|
void searchInTopic();
|
||||||
void scrollDownAnimationFinish();
|
|
||||||
void updatePinnedVisibility();
|
void updatePinnedVisibility();
|
||||||
|
|
||||||
void confirmDeleteSelected();
|
void confirmDeleteSelected();
|
||||||
|
@ -332,12 +336,16 @@ private:
|
||||||
bool _skipScrollEvent = false;
|
bool _skipScrollEvent = false;
|
||||||
bool _synteticScrollEvent = false;
|
bool _synteticScrollEvent = false;
|
||||||
|
|
||||||
|
std::unique_ptr<TranslateBar> _translateBar;
|
||||||
|
int _translateBarHeight = 0;
|
||||||
|
|
||||||
std::unique_ptr<PinnedTracker> _pinnedTracker;
|
std::unique_ptr<PinnedTracker> _pinnedTracker;
|
||||||
std::unique_ptr<Ui::PinnedBar> _pinnedBar;
|
std::unique_ptr<Ui::PinnedBar> _pinnedBar;
|
||||||
std::unique_ptr<Ui::PinnedBar> _hidingPinnedBar;
|
std::unique_ptr<Ui::PinnedBar> _hidingPinnedBar;
|
||||||
int _pinnedBarHeight = 0;
|
int _pinnedBarHeight = 0;
|
||||||
FullMsgId _pinnedClickedId;
|
FullMsgId _pinnedClickedId;
|
||||||
std::optional<FullMsgId> _minPinnedId;
|
std::optional<FullMsgId> _minPinnedId;
|
||||||
|
HistoryItem *_shownPinnedItem = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<Ui::PinnedBar> _rootView;
|
std::unique_ptr<Ui::PinnedBar> _rootView;
|
||||||
int _rootViewHeight = 0;
|
int _rootViewHeight = 0;
|
||||||
|
|
|
@ -1325,6 +1325,14 @@ QString ScheduledWidget::listElementAuthorRank(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
History *ScheduledWidget::listTranslateHistory() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScheduledWidget::listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) {
|
||||||
|
}
|
||||||
|
|
||||||
void ScheduledWidget::confirmSendNowSelected() {
|
void ScheduledWidget::confirmSendNowSelected() {
|
||||||
ConfirmSendNowSelectedItems(_inner);
|
ConfirmSendNowSelectedItems(_inner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,9 @@ public:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
History *listTranslateHistory() override;
|
||||||
|
void listAddTranslatedItems(
|
||||||
|
not_null<TranslateTracker*> tracker) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
|
|
@ -237,18 +237,19 @@ TranslateBar::TranslateBar(
|
||||||
_wrap.hide(anim::type::instant);
|
_wrap.hide(anim::type::instant);
|
||||||
_shadow->hide();
|
_shadow->hide();
|
||||||
|
|
||||||
|
_shadow->showOn(rpl::combine(
|
||||||
|
_wrap.shownValue(),
|
||||||
|
_wrap.heightValue(),
|
||||||
|
rpl::mappers::_1 && rpl::mappers::_2 > 0
|
||||||
|
) | rpl::filter([=](bool shown) {
|
||||||
|
return (shown == _shadow->isHidden());
|
||||||
|
}));
|
||||||
|
|
||||||
setup(history);
|
setup(history);
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslateBar::~TranslateBar() = default;
|
TranslateBar::~TranslateBar() = default;
|
||||||
|
|
||||||
void TranslateBar::updateControlsGeometry(QRect wrapGeometry) {
|
|
||||||
const auto hidden = _wrap.isHidden() || !wrapGeometry.height();
|
|
||||||
if (_shadow->isHidden() != hidden) {
|
|
||||||
_shadow->setVisible(!hidden);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TranslateBar::setShadowGeometryPostprocess(
|
void TranslateBar::setShadowGeometryPostprocess(
|
||||||
Fn<QRect(QRect)> postprocess) {
|
Fn<QRect(QRect)> postprocess) {
|
||||||
_shadowGeometryPostprocess = std::move(postprocess);
|
_shadowGeometryPostprocess = std::move(postprocess);
|
||||||
|
@ -270,7 +271,6 @@ 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);
|
|
||||||
}, _wrap.lifetime());
|
}, _wrap.lifetime());
|
||||||
|
|
||||||
const auto translateTo = [=](LanguageId id) {
|
const auto translateTo = [=](LanguageId id) {
|
||||||
|
@ -563,7 +563,8 @@ void TranslateBar::show() {
|
||||||
_forceHidden = false;
|
_forceHidden = false;
|
||||||
if (_shouldBeShown) {
|
if (_shouldBeShown) {
|
||||||
_wrap.show(anim::type::instant);
|
_wrap.show(anim::type::instant);
|
||||||
_shadow->show();
|
} else if (!_wrap.isHidden() && !_wrap.animating()) {
|
||||||
|
_wrap.hide(anim::type::instant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +574,6 @@ void TranslateBar::hide() {
|
||||||
}
|
}
|
||||||
_forceHidden = true;
|
_forceHidden = true;
|
||||||
_wrap.hide(anim::type::instant);
|
_wrap.hide(anim::type::instant);
|
||||||
_shadow->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateBar::raise() {
|
void TranslateBar::raise() {
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
private:
|
private:
|
||||||
void setup(not_null<History*> history);
|
void setup(not_null<History*> history);
|
||||||
void updateShadowGeometry(QRect wrapGeometry);
|
void updateShadowGeometry(QRect wrapGeometry);
|
||||||
void updateControlsGeometry(QRect wrapGeometry);
|
|
||||||
[[nodiscard]] base::unique_qptr<Ui::PopupMenu> createMenu(
|
[[nodiscard]] base::unique_qptr<Ui::PopupMenu> createMenu(
|
||||||
not_null<Ui::IconButton*> button);
|
not_null<Ui::IconButton*> button);
|
||||||
void showMenu(base::unique_qptr<Ui::PopupMenu> menu);
|
void showMenu(base::unique_qptr<Ui::PopupMenu> menu);
|
||||||
|
|
|
@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "spellcheck/spellcheck_types.h"
|
|
||||||
#include "spellcheck/platform/platform_language.h"
|
#include "spellcheck/platform/platform_language.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -32,11 +31,6 @@ constexpr auto kRequestCountLimit = 20;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct TranslateTracker::ItemForRecognize {
|
|
||||||
uint64 generation = 0;
|
|
||||||
MaybeLanguageId id;
|
|
||||||
};
|
|
||||||
|
|
||||||
TranslateTracker::TranslateTracker(not_null<History*> history)
|
TranslateTracker::TranslateTracker(not_null<History*> history)
|
||||||
: _history(history)
|
: _history(history)
|
||||||
, _limit(kEnoughForRecognition) {
|
, _limit(kEnoughForRecognition) {
|
||||||
|
@ -85,29 +79,25 @@ bool TranslateTracker::enoughForRecognition() const {
|
||||||
|
|
||||||
void TranslateTracker::startBunch() {
|
void TranslateTracker::startBunch() {
|
||||||
_addedInBunch = 0;
|
_addedInBunch = 0;
|
||||||
|
_bunchTranslatedTo = _history->translatedTo();
|
||||||
++_generation;
|
++_generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateTracker::add(
|
void TranslateTracker::add(not_null<Element*> view) {
|
||||||
not_null<Element*> view,
|
|
||||||
LanguageId translatedTo) {
|
|
||||||
const auto item = view->data();
|
const auto item = view->data();
|
||||||
const auto only = view->isOnlyEmojiAndSpaces();
|
const auto only = view->isOnlyEmojiAndSpaces();
|
||||||
if (only != OnlyEmojiAndSpaces::Unknown) {
|
if (only != OnlyEmojiAndSpaces::Unknown) {
|
||||||
item->cacheOnlyEmojiAndSpaces(only == OnlyEmojiAndSpaces::Yes);
|
item->cacheOnlyEmojiAndSpaces(only == OnlyEmojiAndSpaces::Yes);
|
||||||
}
|
}
|
||||||
add(item, translatedTo, false);
|
add(item, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TranslateTracker::add(not_null<HistoryItem*> item) {
|
||||||
|
add(item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateTracker::add(
|
void TranslateTracker::add(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
LanguageId translatedTo) {
|
|
||||||
add(item, translatedTo, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TranslateTracker::add(
|
|
||||||
not_null<HistoryItem*> item,
|
|
||||||
LanguageId translatedTo,
|
|
||||||
bool skipDependencies) {
|
bool skipDependencies) {
|
||||||
Expects(_addedInBunch >= 0);
|
Expects(_addedInBunch >= 0);
|
||||||
|
|
||||||
|
@ -117,15 +107,26 @@ void TranslateTracker::add(
|
||||||
|| item->isOnlyEmojiAndSpaces()) {
|
|| item->isOnlyEmojiAndSpaces()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item->translationShowRequiresCheck(translatedTo)) {
|
if (item->translationShowRequiresCheck(_bunchTranslatedTo)) {
|
||||||
_switchTranslations[item] = translatedTo;
|
_switchTranslations[item] = _bunchTranslatedTo;
|
||||||
}
|
}
|
||||||
if (!skipDependencies) {
|
if (!skipDependencies) {
|
||||||
if (const auto reply = item->Get<HistoryMessageReply>()) {
|
if (const auto reply = item->Get<HistoryMessageReply>()) {
|
||||||
if (const auto to = reply->replyToMsg.get()) {
|
if (const auto to = reply->replyToMsg.get()) {
|
||||||
add(to, translatedTo, true);
|
add(to, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0 // I hope this is not needed, although I'm not sure.
|
||||||
|
if (item->groupId()) {
|
||||||
|
if (const auto group = _history->owner().groups().find(item)) {
|
||||||
|
for (const auto &other : group->items) {
|
||||||
|
if (other != item) {
|
||||||
|
add(other, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
const auto id = item->fullId();
|
const auto id = item->fullId();
|
||||||
const auto i = _itemsForRecognize.find(id);
|
const auto i = _itemsForRecognize.find(id);
|
||||||
|
@ -162,7 +163,6 @@ void TranslateTracker::finishBunch() {
|
||||||
checkRecognized();
|
checkRecognized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requestSome();
|
|
||||||
if (!_switchTranslations.empty()) {
|
if (!_switchTranslations.empty()) {
|
||||||
auto switching = base::take(_switchTranslations);
|
auto switching = base::take(_switchTranslations);
|
||||||
for (const auto &[item, id] : switching) {
|
for (const auto &[item, id] : switching) {
|
||||||
|
@ -171,6 +171,7 @@ void TranslateTracker::finishBunch() {
|
||||||
_switchTranslations = std::move(switching);
|
_switchTranslations = std::move(switching);
|
||||||
_switchTranslations.clear();
|
_switchTranslations.clear();
|
||||||
}
|
}
|
||||||
|
requestSome();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateTracker::cancelToRequest() {
|
void TranslateTracker::cancelToRequest() {
|
||||||
|
|
|
@ -7,9 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "spellcheck/spellcheck_types.h"
|
||||||
|
|
||||||
class History;
|
class History;
|
||||||
class HistoryItem;
|
class HistoryItem;
|
||||||
struct LanguageId;
|
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
|
@ -22,24 +23,24 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool enoughForRecognition() const;
|
[[nodiscard]] bool enoughForRecognition() const;
|
||||||
void startBunch();
|
void startBunch();
|
||||||
void add(not_null<Element*> view, LanguageId translatedTo);
|
void add(not_null<Element*> view);
|
||||||
void add(not_null<HistoryItem*> item, LanguageId translatedTo);
|
void add(not_null<HistoryItem*> item);
|
||||||
void finishBunch();
|
void finishBunch();
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<bool> trackingLanguage() const;
|
[[nodiscard]] rpl::producer<bool> trackingLanguage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using MaybeLanguageId = std::variant<QString, LanguageId>;
|
using MaybeLanguageId = std::variant<QString, LanguageId>;
|
||||||
struct ItemForRecognize;
|
struct ItemForRecognize {
|
||||||
|
uint64 generation = 0;
|
||||||
|
MaybeLanguageId id;
|
||||||
|
};
|
||||||
struct ItemToRequest {
|
struct ItemToRequest {
|
||||||
int length = 0;
|
int length = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void add(
|
void add(not_null<HistoryItem*> item, bool skipDependencies);
|
||||||
not_null<HistoryItem*> item,
|
|
||||||
LanguageId translatedTo,
|
|
||||||
bool skipDependencies);
|
|
||||||
void recognizeCollected();
|
void recognizeCollected();
|
||||||
void trackSkipLanguages();
|
void trackSkipLanguages();
|
||||||
void checkRecognized();
|
void checkRecognized();
|
||||||
|
@ -58,6 +59,7 @@ private:
|
||||||
rpl::variable<bool> _trackingLanguage = false;
|
rpl::variable<bool> _trackingLanguage = false;
|
||||||
base::flat_map<FullMsgId, ItemForRecognize> _itemsForRecognize;
|
base::flat_map<FullMsgId, ItemForRecognize> _itemsForRecognize;
|
||||||
uint64 _generation = 0;
|
uint64 _generation = 0;
|
||||||
|
LanguageId _bunchTranslatedTo;
|
||||||
int _limit = 0;
|
int _limit = 0;
|
||||||
int _addedInBunch = -1;
|
int _addedInBunch = -1;
|
||||||
bool _allLoaded = false;
|
bool _allLoaded = false;
|
||||||
|
|
|
@ -759,7 +759,10 @@ void GroupedMedia::unloadHeavyPart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupedMedia::parentTextUpdated() {
|
void GroupedMedia::parentTextUpdated() {
|
||||||
history()->owner().requestViewResize(_parent);
|
if (_parent->media() == this) {
|
||||||
|
refreshCaption();
|
||||||
|
history()->owner().requestViewResize(_parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupedMedia::needsBubble() const {
|
bool GroupedMedia::needsBubble() const {
|
||||||
|
|
|
@ -28,6 +28,14 @@ PinnedBar::PinnedBar(
|
||||||
_wrap.hide(anim::type::instant);
|
_wrap.hide(anim::type::instant);
|
||||||
_shadow->hide();
|
_shadow->hide();
|
||||||
|
|
||||||
|
_shadow->showOn(rpl::combine(
|
||||||
|
_wrap.shownValue(),
|
||||||
|
_wrap.heightValue(),
|
||||||
|
rpl::mappers::_1 && rpl::mappers::_2 > 0
|
||||||
|
) | rpl::filter([=](bool shown) {
|
||||||
|
return (shown == _shadow->isHidden());
|
||||||
|
}));
|
||||||
|
|
||||||
_wrap.entity()->paintRequest(
|
_wrap.entity()->paintRequest(
|
||||||
) | rpl::start_with_next([=](QRect clip) {
|
) | rpl::start_with_next([=](QRect clip) {
|
||||||
QPainter(_wrap.entity()).fillRect(clip, st::historyPinnedBg);
|
QPainter(_wrap.entity()).fillRect(clip, st::historyPinnedBg);
|
||||||
|
@ -121,10 +129,6 @@ void PinnedBar::setRightButton(object_ptr<Ui::RpWidget> button) {
|
||||||
|
|
||||||
void PinnedBar::updateControlsGeometry(QRect wrapGeometry) {
|
void PinnedBar::updateControlsGeometry(QRect wrapGeometry) {
|
||||||
_bar->widget()->resizeToWidth(wrapGeometry.width());
|
_bar->widget()->resizeToWidth(wrapGeometry.width());
|
||||||
const auto hidden = _wrap.isHidden() || !wrapGeometry.height();
|
|
||||||
if (_shadow->isHidden() != hidden) {
|
|
||||||
_shadow->setVisible(!hidden);
|
|
||||||
}
|
|
||||||
if (_right.button) {
|
if (_right.button) {
|
||||||
_right.button->moveToRight(0, 0);
|
_right.button->moveToRight(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +212,8 @@ void PinnedBar::show() {
|
||||||
_forceHidden = false;
|
_forceHidden = false;
|
||||||
if (_shouldBeShown) {
|
if (_shouldBeShown) {
|
||||||
_wrap.show(anim::type::instant);
|
_wrap.show(anim::type::instant);
|
||||||
_shadow->show();
|
} else if (!_wrap.isHidden() && !_wrap.animating()) {
|
||||||
|
_wrap.hide(anim::type::instant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +223,6 @@ void PinnedBar::hide() {
|
||||||
}
|
}
|
||||||
_forceHidden = true;
|
_forceHidden = true;
|
||||||
_wrap.hide(anim::type::instant);
|
_wrap.hide(anim::type::instant);
|
||||||
_shadow->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PinnedBar::raise() {
|
void PinnedBar::raise() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue