Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new pull request by comparing changes across two branches #745

Merged
merged 21 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c70482d
Qt 6.8.0-rc1 -> 6.8.0
ilya-fedin Oct 8, 2024
b0ecb2c
Update patches and lib_ui
ilya-fedin Oct 8, 2024
88703ba
Toggle fullscreen by double click in media viewe title area
ilya-fedin Oct 10, 2024
828ecab
Don't show user badge in star stats rows.
john-preston Oct 10, 2024
1038baf
Allow timestamp links under spoilers.
john-preston Oct 10, 2024
3cb33f0
Custom "Copy ID" for peer ID context menu.
john-preston Oct 10, 2024
af728e8
Unify channel links and usernames clicks.
john-preston Oct 10, 2024
388325a
Set dpi awareness in the manifest.
john-preston Oct 10, 2024
ac7b2e0
Keyboard navigation in closed topics.
john-preston Oct 10, 2024
2d20e7a
Add keyboard navigation to chat preview.
john-preston Oct 10, 2024
6a69447
Fixed non focused window when process credits payment from web view bot.
23rd Oct 7, 2024
86fa98d
Fixed position of mini stars in header if gift box.
23rd Oct 7, 2024
a32a9aa
Added experimental option to disable floating reactions strip.
23rd Oct 8, 2024
9557f0c
Improved quality of profile photo in share QR box.
23rd Oct 8, 2024
8d9d7c4
Added ability to remove background from QR in share QR box.
23rd Oct 8, 2024
44aa2ae
Added ability to change font size in share QR box.
23rd Oct 8, 2024
73b63aa
Fixed update of width for username label in profile section.
23rd Oct 8, 2024
e57742e
Don't show non-working wallpaper button.
john-preston Oct 10, 2024
fdf826b
Improve gifts layout a bit.
john-preston Oct 10, 2024
6812e17
Improve star gift size in the box.
john-preston Oct 10, 2024
394ef13
Fix code block language change.
john-preston Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_username_app_not_found" = "Bot application not found.";
"lng_username_link" = "This link opens a chat with you:";
"lng_username_copied" = "Link copied to clipboard.";
"lng_username_text_copied" = "Username copied to clipboard.";

"lng_usernames_edit" = "click to edit";
"lng_usernames_active" = "active";
Expand Down Expand Up @@ -487,6 +488,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_collectible_phone_info" = "This phone number was bought on **Fragment** on {date} for {price}";
"lng_collectible_phone_copy" = "Copy Phone Number";
"lng_collectible_learn_more" = "Learn More";
"lng_collectible_phone_copied" = "Phone number copied to clipboard.";

"lng_settings_section_info" = "Info";

Expand Down Expand Up @@ -5629,6 +5631,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_qr_box_quality1" = "Normal";
"lng_qr_box_quality2" = "High";
"lng_qr_box_quality3" = "Very High";
"lng_qr_box_transparent_background" = "Transparent Background";
"lng_qr_box_font_size" = "Font size";

// Wnd specific

Expand Down
2 changes: 2 additions & 0 deletions Telegram/Resources/winrc/Telegram.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>
Expand Down
5 changes: 3 additions & 2 deletions Telegram/SourceFiles/boxes/peer_list_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,14 @@ int PeerListRow::paintNameIconGetWidth(
int availableWidth,
int outerWidth,
bool selected) {
if (special()
if (_skipPeerBadge
|| special()
|| !_savedMessagesStatus.isEmpty()
|| _isRepliesMessagesChat
|| _isVerifyCodesChat) {
return 0;
}
return _bagde.drawGetWidth(
return _badge.drawGetWidth(
p,
QRect(
nameLeft,
Expand Down
7 changes: 6 additions & 1 deletion Telegram/SourceFiles/boxes/peer_list_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ class PeerListRow {
return _nameFirstLetters;
}

void setSkipPeerBadge(bool skip) {
_skipPeerBadge = skip;
}

virtual void lazyInitialize(const style::PeerListItem &st);
virtual void paintStatusText(
Painter &p,
Expand Down Expand Up @@ -291,7 +295,7 @@ class PeerListRow {
std::unique_ptr<Ui::RoundImageCheckbox> _checkbox;
Ui::Text::String _name;
Ui::Text::String _status;
Ui::PeerBadge _bagde;
Ui::PeerBadge _badge;
StatusType _statusType = StatusType::Online;
crl::time _statusValidTill = 0;
base::flat_set<QChar> _nameFirstLetters;
Expand All @@ -303,6 +307,7 @@ class PeerListRow {
bool _isSearchResult : 1 = false;
bool _isRepliesMessagesChat : 1 = false;
bool _isVerifyCodesChat : 1 = false;
bool _skipPeerBadge : 1 = false;

};

Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/boxes/star_gift_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ void GiftBox(
stUser.photoSize * 2);
content->sizeValue(
) | rpl::start_with_next([=](const QSize &size) {
widget->moveToLeft(stUser.photoSize / 2, 0);
widget->moveToLeft((size.width() - widget->width()) / 2, 0);
const auto starsRect = Rect(widget->size());
stars->setPosition(starsRect.topLeft());
stars->setSize(starsRect.size());
Expand Down
9 changes: 8 additions & 1 deletion Telegram/SourceFiles/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,14 @@ bool Application::openCustomUrl(
|| passcodeLocked()) {
return false;
}
const auto command = base::StringViewMid(urlTrimmed, protocol.size(), 8192);
static const auto kTagExp = QRegularExpression(
u"^\\~[a-zA-Z0-9_\\-]+\\~:"_q);
auto skip = protocol.size();
const auto match = kTagExp.match(base::StringViewMid(urlTrimmed, skip));
if (match.hasMatch()) {
skip += match.capturedLength();
}
const auto command = base::StringViewMid(urlTrimmed, skip, 8192);
const auto my = context.value<ClickHandlerContext>();
const auto controller = my.sessionWindow.get()
? my.sessionWindow.get()
Expand Down
40 changes: 38 additions & 2 deletions Telegram/SourceFiles/core/local_url_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,9 @@ bool CopyPeerId(
Window::SessionController *controller,
const Match &match,
const QVariant &context) {
TextUtilities::SetClipboardText(TextForMimeData{ match->captured(1) });
TextUtilities::SetClipboardText({ match->captured(1) });
if (controller) {
controller->showToast(tr::lng_text_copied(tr::now));
controller->showToast(u"ID copied to clipboard."_q);
}
return true;
}
Expand Down Expand Up @@ -926,6 +926,34 @@ bool ShowCollectibleUsername(
return true;
}

bool CopyUsernameLink(
Window::SessionController *controller,
const Match &match,
const QVariant &context) {
if (!controller) {
return false;
}
const auto username = match->captured(1);
TextUtilities::SetClipboardText({
controller->session().createInternalLinkFull(username)
});
controller->showToast(tr::lng_username_copied(tr::now));
return true;
}

bool CopyUsername(
Window::SessionController *controller,
const Match &match,
const QVariant &context) {
if (!controller) {
return false;
}
const auto username = match->captured(1);
TextUtilities::SetClipboardText({ '@' + username });
controller->showToast(tr::lng_username_text_copied(tr::now));
return true;
}

bool ShowStarsExamples(
Window::SessionController *controller,
const Match &match,
Expand Down Expand Up @@ -1391,6 +1419,14 @@ const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
u"^collectible_username/([a-zA-Z0-9\\-\\_\\.]+)@([0-9]+)$"_q,
ShowCollectibleUsername,
},
{
u"^username_link/([a-zA-Z0-9\\-\\_\\.]+)@([0-9]+)$"_q,
CopyUsernameLink,
},
{
u"^username_regular/([a-zA-Z0-9\\-\\_\\.]+)@([0-9]+)$"_q,
CopyUsername,
},
{
u"^stars_examples$"_q,
ShowStarsExamples,
Expand Down
10 changes: 10 additions & 0 deletions Telegram/SourceFiles/history/view/history_view_chat_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ void Item::setupHistory() {
using Type = Ui::ElasticScroll::OverscrollType;
_scroll->setOverscrollTypes(Type::Real, Type::Real);

_inner->scrollKeyEvents(
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
_scroll->keyPressEvent(e);
}, lifetime());

_scroll->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
if (e->type() == QEvent::MouseButtonDblClick) {
const auto button = static_cast<QMouseEvent*>(e.get())->button();
Expand All @@ -504,6 +509,10 @@ void Item::setupHistory() {
_inner->refreshViewer();

_inner->setAttribute(Qt::WA_TransparentForMouseEvents);

crl::on_main(this, [=] {
_inner->setFocus();
});
}

void Item::paintEvent(QPaintEvent *e) {
Expand Down Expand Up @@ -532,6 +541,7 @@ bool Item::listScrollTo(int top, bool syntetic) {
}

void Item::listCancelRequest() {
_actions.fire({ .cancel = true });
}

void Item::listDeleteRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace HistoryView {

struct ChatPreviewAction {
FullMsgId openItemId;
bool cancel = false;
bool openInfo = false;
bool markRead = false;
bool markUnread = false;
Expand Down
23 changes: 19 additions & 4 deletions Telegram/SourceFiles/history/view/history_view_list_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,11 @@ auto ListWidget::countScrollState() const -> ScrollTopState {
}

void ListWidget::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Back) {
const auto key = e->key();
const auto hasModifiers = (Qt::NoModifier !=
(e->modifiers()
& ~(Qt::KeypadModifier | Qt::GroupSwitchModifier)));
if (key == Qt::Key_Escape || key == Qt::Key_Back) {
if (hasSelectedText() || hasSelectedItems()) {
cancelSelection();
} else {
Expand All @@ -2616,22 +2620,33 @@ void ListWidget::keyPressEvent(QKeyEvent *e) {
&& !hasCopyRestrictionForSelected()) {
TextUtilities::SetClipboardText(getSelectedText());
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E
} else if (key == Qt::Key_E
&& e->modifiers().testFlag(Qt::ControlModifier)
&& !showCopyRestriction()
&& !hasCopyRestrictionForSelected()) {
TextUtilities::SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
#endif // Q_OS_MAC
} else if (e == QKeySequence::Delete || e->key() == Qt::Key_Backspace) {
} else if (e == QKeySequence::Delete || key == Qt::Key_Backspace) {
_delegate->listDeleteRequest();
} else if (!hasModifiers
&& ((key == Qt::Key_Up)
|| (key == Qt::Key_Down)
|| (key == Qt::Key_PageUp)
|| (key == Qt::Key_PageDown))) {
_scrollKeyEvents.fire(std::move(e));
} else if (!(e->modifiers() & ~Qt::ShiftModifier)
&& e->key() != Qt::Key_Shift) {
&& key != Qt::Key_Shift) {
_delegate->listTryProcessKeyInput(e);
} else {
e->ignore();
}
}

auto ListWidget::scrollKeyEvents() const
-> rpl::producer<not_null<QKeyEvent*>> {
return _scrollKeyEvents.events();
}

void ListWidget::mouseDoubleClickEvent(QMouseEvent *e) {
mouseActionStart(e->globalPos(), e->button());
trySwitchToWordSelection();
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/history/view/history_view_list_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ class ListWidget final
const TextState &reactionState) const;
void toggleFavoriteReaction(not_null<Element*> view) const;


[[nodiscard]] auto scrollKeyEvents() const
-> rpl::producer<not_null<QKeyEvent*>>;

// ElementDelegate interface.
Context elementContext() override;
bool elementUnderCursor(not_null<const Element*> view) override;
Expand Down Expand Up @@ -851,6 +855,7 @@ class ListWidget final
rpl::event_stream<ReplyToMessageRequest> _requestedToReplyToMessage;
rpl::event_stream<FullMsgId> _requestedToReadMessage;
rpl::event_stream<FullMsgId> _requestedToShowMessage;
rpl::event_stream<not_null<QKeyEvent*>> _scrollKeyEvents;

rpl::lifetime _viewerLifetime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,9 @@ void RepliesWidget::setupComposeControls() {
}
}, lifetime());

_composeControls->scrollKeyEvents(
rpl::merge(
_composeControls->scrollKeyEvents(),
_inner->scrollKeyEvents()
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
_scroll->keyPressEvent(e);
}, lifetime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ void ScheduledWidget::setupComposeControls() {
}
}, lifetime());

_composeControls->scrollKeyEvents(
rpl::merge(
_composeControls->scrollKeyEvents(),
_inner->scrollKeyEvents()
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
_scroll->keyPressEvent(e);
}, lifetime());
Expand Down
10 changes: 8 additions & 2 deletions Telegram/SourceFiles/history/view/media/history_view_media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,23 @@ TextWithEntities AddTimestampLinks(
}

auto &entities = text.entities;
const auto i = ranges::lower_bound(
auto i = ranges::lower_bound(
entities,
from,
std::less<>(),
&EntityInText::offset);
while (i != entities.end()
&& i->offset() < till
&& i->type() == EntityType::Spoiler) {
++i;
}
if (i != entities.end() && i->offset() < till) {
continue;
}

const auto intersects = [&](const EntityInText &entity) {
return entity.offset() + entity.length() > from;
return (entity.offset() + entity.length() > from)
&& (entity.type() != EntityType::Spoiler);
};
auto j = std::make_reverse_iterator(i);
const auto e = std::make_reverse_iterator(entities.begin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ TextWithEntities ThemeDocumentBox::subtitle() {
}

rpl::producer<QString> ThemeDocumentBox::button() {
if (_parent->data()->out()) {
if (_parent->data()->out() || _parent->history()->peer->isChannel()) {
return {};
}
return rpl::conditional(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For license and copyright information please follow this link:
#include "core/click_handler_types.h"
#include "main/main_session.h"
#include "base/event_filter.h"
#include "base/options.h"
#include "styles/style_chat.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_menu_icons.h"
Expand Down Expand Up @@ -59,8 +60,15 @@ constexpr auto kRefreshListDelay = crl::time(100);
return CountMaxSizeWithMargins(st::reactionCornerShadow);
}

base::options::toggle OptionDisableFloatReactions({
.id = kOptionDisableFloatReactions,
.name = "Disable floating reactions strip",
});

} // namespace

const char kOptionDisableFloatReactions[] = "disable-float-reactions";

Button::Button(
Fn<void(QRect)> update,
ButtonParameters parameters,
Expand Down Expand Up @@ -445,6 +453,11 @@ void Manager::showButtonDelayed() {

void Manager::applyList(const Data::PossibleItemReactionsRef &reactions) {
using Button = Strip::AddedButton;
if (OptionDisableFloatReactions.value()) {
_strip.applyList({}, Button::None);
_tagsStrip = {};
return;
}
_strip.applyList(
reactions.recent,
(/*reactions.customAllowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Session;

namespace HistoryView::Reactions {

extern const char kOptionDisableFloatReactions[];

enum class ExpandDirection {
Up,
Down,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor) {
}, [&](const GiftTypeStars &data) {
_price.setMarkedText(
st::semiboldTextStyle,
_delegate->star().append(QString::number(data.stars)),
_delegate->star().append(' ' + QString::number(data.stars)),
kMarkupTextOptions,
_delegate->textContext());
_userpic = !data.userpic
Expand Down Expand Up @@ -284,6 +284,10 @@ void GiftButton::paintEvent(QPaintEvent *e) {
const auto twidth = font->width(text);
const auto pos = position + QPoint(singlew - twidth, font->height);
p.save();
const auto rubberOut = _extend.top();
const auto inner = rect().marginsRemoved(_extend);
p.setClipRect(inner.marginsAdded(
{ rubberOut, rubberOut, rubberOut, rubberOut }));
p.translate(pos);
p.rotate(45.);
p.translate(-pos);
Expand Down
Loading
Loading