mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Highlight quotes in replies to file albums.
This commit is contained in:
parent
0dbb195106
commit
10022a3c6d
4 changed files with 32 additions and 22 deletions
|
@ -538,6 +538,7 @@ ItemPreview Media::toGroupPreview(
|
|||
auto videoCount = 0;
|
||||
auto audioCount = 0;
|
||||
auto fileCount = 0;
|
||||
auto manyCaptions = false;
|
||||
for (const auto &item : items) {
|
||||
if (const auto media = item->media()) {
|
||||
if (media->photo()) {
|
||||
|
@ -571,12 +572,12 @@ ItemPreview Media::toGroupPreview(
|
|||
if (result.text.text.isEmpty()) {
|
||||
result.text = original;
|
||||
} else {
|
||||
result.text = {};
|
||||
manyCaptions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.text.text.isEmpty()) {
|
||||
if (manyCaptions || result.text.text.isEmpty()) {
|
||||
const auto mediaCount = photoCount + videoCount;
|
||||
auto genericText = (photoCount && videoCount)
|
||||
? tr::lng_in_dlg_media_count(tr::now, lt_count, mediaCount)
|
||||
|
|
|
@ -621,6 +621,9 @@ void Element::paintHighlight(
|
|||
Painter &p,
|
||||
const PaintContext &context,
|
||||
int geometryHeight) const {
|
||||
if (context.highlight.opacity == 0.) {
|
||||
return;
|
||||
}
|
||||
const auto top = marginTop();
|
||||
const auto bottom = marginBottom();
|
||||
const auto fill = qMin(top, bottom);
|
||||
|
@ -636,12 +639,8 @@ void Element::paintCustomHighlight(
|
|||
int y,
|
||||
int height,
|
||||
not_null<const HistoryItem*> item) const {
|
||||
const auto opacity = context.highlight.opacity;
|
||||
if (opacity == 0.) {
|
||||
return;
|
||||
}
|
||||
const auto o = p.opacity();
|
||||
p.setOpacity(o * opacity);
|
||||
p.setOpacity(o * context.highlight.opacity);
|
||||
p.fillRect(0, y, width(), height, context.st->msgSelectOverlay());
|
||||
p.setOpacity(o);
|
||||
}
|
||||
|
|
|
@ -1397,6 +1397,8 @@ void Document::drawGrouped(
|
|||
float64 highlightOpacity,
|
||||
not_null<uint64*> cacheKey,
|
||||
not_null<QPixmap*> cache) const {
|
||||
const auto maybeMediaHighlight = context.highlightPathCache
|
||||
&& context.highlightPathCache->isEmpty();
|
||||
p.translate(geometry.topLeft());
|
||||
draw(
|
||||
p,
|
||||
|
@ -1404,6 +1406,10 @@ void Document::drawGrouped(
|
|||
geometry.width(),
|
||||
LayoutMode::Grouped,
|
||||
rounding);
|
||||
if (maybeMediaHighlight
|
||||
&& !context.highlightPathCache->isEmpty()) {
|
||||
context.highlightPathCache->translate(geometry.topLeft());
|
||||
}
|
||||
p.translate(-geometry.topLeft());
|
||||
}
|
||||
|
||||
|
|
|
@ -286,6 +286,9 @@ void GroupedMedia::drawHighlight(
|
|||
Painter &p,
|
||||
const PaintContext &context,
|
||||
int top) const {
|
||||
if (context.highlight.opacity == 0.) {
|
||||
return;
|
||||
}
|
||||
auto selection = context.highlight.range;
|
||||
if (_mode != Mode::Column) {
|
||||
if (!selection.empty() && !IsSubGroupSelection(selection)) {
|
||||
|
@ -305,9 +308,15 @@ void GroupedMedia::drawHighlight(
|
|||
const auto &part = _parts[i];
|
||||
const auto rect = part.geometry.translated(0, skip);
|
||||
const auto full = (!i && empty)
|
||||
|| (subpart && IsGroupItemSelection(selection, i));
|
||||
auto copy = context;
|
||||
|| (subpart && IsGroupItemSelection(selection, i))
|
||||
|| (!subpart
|
||||
&& !selection.empty()
|
||||
&& (selection.from < part.content->fullSelectionLength()));
|
||||
if (!subpart) {
|
||||
selection = part.content->skipSelection(selection);
|
||||
}
|
||||
if (full) {
|
||||
auto copy = context;
|
||||
copy.highlight.range = {};
|
||||
_parent->paintCustomHighlight(
|
||||
p,
|
||||
|
@ -315,18 +324,7 @@ void GroupedMedia::drawHighlight(
|
|||
rect.y(),
|
||||
rect.height(),
|
||||
part.item);
|
||||
} else if (!selection.empty()) {
|
||||
copy.highlight.range = selection;
|
||||
selection = part.content->skipSelection(selection);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
_parent->paintCustomHighlight(
|
||||
p,
|
||||
copy,
|
||||
rect.y(),
|
||||
rect.height(),
|
||||
part.item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,10 +342,10 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
|
|||
const auto rounding = inWebPage
|
||||
? Ui::BubbleRounding{ kSmall, kSmall, kSmall, kSmall }
|
||||
: adjustedBubbleRoundingWithCaption(_caption);
|
||||
const auto highlight = context.highlight.range;
|
||||
auto highlight = context.highlight.range;
|
||||
for (auto i = 0, count = int(_parts.size()); i != count; ++i) {
|
||||
const auto &part = _parts[i];
|
||||
const auto partContext = context.withSelection(fullSelection
|
||||
auto partContext = context.withSelection(fullSelection
|
||||
? FullSelection
|
||||
: textSelection
|
||||
? selection
|
||||
|
@ -359,9 +357,15 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
|
|||
const auto highlightOpacity = highlighted
|
||||
? context.highlight.opacity
|
||||
: 0.;
|
||||
partContext.highlight.range = highlighted
|
||||
? TextSelection()
|
||||
: highlight;
|
||||
if (textSelection) {
|
||||
selection = part.content->skipSelection(selection);
|
||||
}
|
||||
if (!highlighted) {
|
||||
highlight = part.content->skipSelection(highlight);
|
||||
}
|
||||
if (!part.cache.isNull()) {
|
||||
wasCache = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue