Add Qt 6 support

Tested only on Linux so far
This commit is contained in:
Ilya Fedin 2021-10-19 17:00:21 +04:00 committed by John Preston
parent ea10cf5758
commit 847c01d605
154 changed files with 382 additions and 339 deletions

View file

@ -1197,7 +1197,7 @@ else()
) )
endif() endif()
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION OR DESKTOP_APP_QT6)
remove_target_sources(Telegram ${src_loc} remove_target_sources(Telegram ${src_loc}
platform/linux/linux_wayland_integration.cpp platform/linux/linux_wayland_integration.cpp
) )
@ -1289,10 +1289,16 @@ elseif (APPLE)
endif() endif()
else() else()
if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
if (NOT DESKTOP_APP_QT6)
target_link_libraries(Telegram
PRIVATE
desktop-app::external_statusnotifieritem
desktop-app::external_dbusmenu_qt
)
endif()
target_link_libraries(Telegram target_link_libraries(Telegram
PRIVATE PRIVATE
desktop-app::external_statusnotifieritem
desktop-app::external_dbusmenu_qt
desktop-app::external_glibmm desktop-app::external_glibmm
desktop-app::external_glib desktop-app::external_glib
) )
@ -1309,8 +1315,14 @@ else()
target_link_libraries(Telegram target_link_libraries(Telegram
PRIVATE PRIVATE
desktop-app::lib_waylandshells desktop-app::lib_waylandshells
desktop-app::external_kwayland
) )
if (NOT DESKTOP_APP_QT6)
target_link_libraries(Telegram
PRIVATE
desktop-app::external_kwayland
)
endif()
endif() endif()
endif() endif()

View file

@ -26,7 +26,7 @@ BlockedPeers::Slice TLToSlice(
Data::Session &owner) { Data::Session &owner) {
const auto create = [&](int count, const QVector<MTPPeerBlocked> &list) { const auto create = [&](int count, const QVector<MTPPeerBlocked> &list) {
auto slice = BlockedPeers::Slice(); auto slice = BlockedPeers::Slice();
slice.total = std::max(count, list.size()); slice.total = std::max(count, int(list.size()));
slice.list.reserve(list.size()); slice.list.reserve(list.size());
for (const auto &contact : list) { for (const auto &contact : list) {
contact.match([&](const MTPDpeerBlocked &data) { contact.match([&](const MTPDpeerBlocked &data) {

View file

@ -212,7 +212,7 @@ void SendExistingPhoto(
} }
bool SendDice(Api::MessageToSend &message) { bool SendDice(Api::MessageToSend &message) {
const auto full = message.textWithTags.text.midRef(0).trimmed(); const auto full = QStringView(message.textWithTags.text).trimmed();
auto length = 0; auto length = 0;
if (!Ui::Emoji::Find(full.data(), full.data() + full.size(), &length) if (!Ui::Emoji::Find(full.data(), full.data() + full.size(), &length)
|| length != full.size()) { || length != full.size()) {

View file

@ -159,7 +159,7 @@ struct State {
auto &entry = context->cache(item); auto &entry = context->cache(item);
entry.requestId = 0; entry.requestId = 0;
auto peers = std::vector<PeerId>(); auto peers = std::vector<PeerId>();
peers.reserve(std::max(result.v.size(), 1)); peers.reserve(std::max(int(result.v.size()), 1));
for (const auto &id : result.v) { for (const auto &id : result.v) {
peers.push_back(UserId(id)); peers.push_back(UserId(id));
} }

View file

@ -478,7 +478,7 @@ void ApiWrap::sendMessageFail(
link))); link)));
} else if (error.type().startsWith(qstr("SLOWMODE_WAIT_"))) { } else if (error.type().startsWith(qstr("SLOWMODE_WAIT_"))) {
const auto chop = qstr("SLOWMODE_WAIT_").size(); const auto chop = qstr("SLOWMODE_WAIT_").size();
const auto left = error.type().midRef(chop).toInt(); const auto left = base::StringViewMid(error.type(), chop).toInt();
if (const auto channel = peer->asChannel()) { if (const auto channel = peer->asChannel()) {
const auto seconds = channel->slowmodeSeconds(); const auto seconds = channel->slowmodeSeconds();
if (seconds >= left) { if (seconds >= left) {
@ -3263,7 +3263,7 @@ void ApiWrap::requestMessageAfterDate(
// So we request a message with offset_date = desired_date - 1 and add_offset = -1. // So we request a message with offset_date = desired_date - 1 and add_offset = -1.
// This should give us the first message with date >= desired_date. // This should give us the first message with date >= desired_date.
const auto offsetId = 0; const auto offsetId = 0;
const auto offsetDate = static_cast<int>(base::QDateToDateTime(date).toTime_t()) - 1; const auto offsetDate = static_cast<int>(date.startOfDay().toSecsSinceEpoch()) - 1;
const auto addOffset = -1; const auto addOffset = -1;
const auto limit = 1; const auto limit = 1;
const auto maxId = 0; const auto maxId = 0;

View file

@ -74,7 +74,7 @@ void HostInput::correctValue(
QString newText; QString newText;
int newCursor = nowCursor; int newCursor = nowCursor;
newText.reserve(now.size()); newText.reserve(now.size());
for (auto i = 0, l = now.size(); i < l; ++i) { for (auto i = 0, l = int(now.size()); i < l; ++i) {
if (now[i] == ',') { if (now[i] == ',') {
newText.append('.'); newText.append('.');
} else { } else {
@ -120,7 +120,7 @@ void Base64UrlInput::correctValue(
QString newText; QString newText;
newText.reserve(now.size()); newText.reserve(now.size());
auto newPos = nowCursor; auto newPos = nowCursor;
for (auto i = 0, l = now.size(); i < l; ++i) { for (auto i = 0, l = int(now.size()); i < l; ++i) {
const auto ch = now[i]; const auto ch = now[i];
if ((ch >= '0' && ch <= '9') if ((ch >= '0' && ch <= '9')
|| (ch >= 'a' && ch <= 'z') || (ch >= 'a' && ch <= 'z')
@ -537,8 +537,8 @@ void ProxyRow::showMenu() {
_deleteClicks.fire({}); _deleteClicks.fire({});
}); });
} }
const auto parentTopLeft = window()->mapToGlobal({ 0, 0 }); const auto parentTopLeft = window()->mapToGlobal(QPoint());
const auto buttonTopLeft = _menuToggle->mapToGlobal({ 0, 0 }); const auto buttonTopLeft = _menuToggle->mapToGlobal(QPoint());
const auto parent = QRect(parentTopLeft, window()->size()); const auto parent = QRect(parentTopLeft, window()->size());
const auto button = QRect(buttonTopLeft, _menuToggle->size()); const auto button = QRect(buttonTopLeft, _menuToggle->size());
const auto bottom = button.y() const auto bottom = button.y()

View file

@ -39,11 +39,6 @@ using DictState = BlobState;
using QueryCallback = Fn<void(const QString &)>; using QueryCallback = Fn<void(const QString &)>;
constexpr auto kMaxQueryLength = 15; constexpr auto kMaxQueryLength = 15;
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
#define OLD_QT
using QStringView = QString;
#endif
class Inner : public Ui::RpWidget { class Inner : public Ui::RpWidget {
public: public:
Inner( Inner(

View file

@ -478,7 +478,7 @@ void Rows::showMenu(int index) {
} }
} }
const auto toggle = menuToggleArea(row); const auto toggle = menuToggleArea(row);
const auto parentTopLeft = window()->mapToGlobal({ 0, 0 }); const auto parentTopLeft = window()->mapToGlobal(QPoint());
const auto buttonTopLeft = mapToGlobal(toggle.topLeft()); const auto buttonTopLeft = mapToGlobal(toggle.topLeft());
const auto parent = QRect(parentTopLeft, window()->size()); const auto parent = QRect(parentTopLeft, window()->size());
const auto button = QRect(buttonTopLeft, toggle.size()); const auto button = QRect(buttonTopLeft, toggle.size());

View file

@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_passport.h" #include "styles/style_passport.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "base/qt_adapters.h"
namespace { namespace {
@ -525,7 +526,7 @@ void PasscodeBox::setPasswordFail(
const MTP::Error &error) { const MTP::Error &error) {
const auto prefix = qstr("EMAIL_UNCONFIRMED_"); const auto prefix = qstr("EMAIL_UNCONFIRMED_");
if (error.type().startsWith(prefix)) { if (error.type().startsWith(prefix)) {
const auto codeLength = error.type().midRef(prefix.size()).toInt(); const auto codeLength = base::StringViewMid(error.type(), prefix.size()).toInt();
closeReplacedBy(); closeReplacedBy();
_setRequest = 0; _setRequest = 0;

View file

@ -1240,7 +1240,7 @@ int PeerListContent::resizeGetHeight(int newWidth) {
return belowTop + _belowHeight; return belowTop + _belowHeight;
} }
void PeerListContent::enterEventHook(QEvent *e) { void PeerListContent::enterEventHook(QEnterEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }

View file

@ -622,7 +622,7 @@ protected:
int visibleBottom) override; int visibleBottom) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;

View file

@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h" #include "data/data_user.h"
#include "core/core_cloud_password.h" #include "core/core_cloud_password.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/qt_adapters.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "api/api_cloud_password.h" #include "api/api_cloud_password.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -710,7 +709,7 @@ void EditRestrictedBox::showRestrictUntil() {
highlighted, highlighted,
[this](const QDate &date) { [this](const QDate &date) {
setRestrictUntil( setRestrictUntil(
static_cast<int>(base::QDateToDateTime(date).toTime_t())); static_cast<int>(date.startOfDay().toSecsSinceEpoch()));
}), }),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
_restrictUntilBox->setMaxDate( _restrictUntilBox->setMaxDate(

View file

@ -72,7 +72,7 @@ protected:
int visibleBottom) override; int visibleBottom) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
@ -906,7 +906,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
void ShareBox::Inner::enterEventHook(QEvent *e) { void ShareBox::Inner::enterEventHook(QEnterEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }

View file

@ -404,7 +404,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
auto p = StickersPack(); auto p = StickersPack();
p.reserve(stickers.size()); p.reserve(stickers.size());
for (auto j = 0, c = stickers.size(); j != c; ++j) { for (auto j = 0, c = int(stickers.size()); j != c; ++j) {
auto doc = _controller->session().data().document(stickers[j].v); auto doc = _controller->session().data().document(stickers[j].v);
if (!doc || !doc->sticker()) continue; if (!doc || !doc->sticker()) continue;
@ -532,7 +532,7 @@ void StickerSetBox::Inner::installDone(
auto &order = isMasks auto &order = isMasks
? stickers.maskSetsOrderRef() ? stickers.maskSetsOrderRef()
: stickers.setsOrderRef(); : stickers.setsOrderRef();
const auto insertAtIndex = 0, currentIndex = order.indexOf(_setId); const auto insertAtIndex = 0, currentIndex = int(order.indexOf(_setId));
if (currentIndex != insertAtIndex) { if (currentIndex != insertAtIndex) {
if (currentIndex > 0) { if (currentIndex > 0) {
order.removeAt(currentIndex); order.removeAt(currentIndex);

View file

@ -50,7 +50,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_calls.h" #include "styles/style_calls.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <QtCore/QTimer> #include <QtCore/QTimer>

View file

@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "webrtc/webrtc_video_track.h" #include "webrtc/webrtc_video_track.h"
#include "styles/style_calls.h" #include "styles/style_calls.h"
#include <QtGui/QOpenGLShader> #include <QOpenGLShader>
#include <QtGui/QOpenGLBuffer> #include <QOpenGLBuffer>
namespace Calls { namespace Calls {
namespace { namespace {

View file

@ -55,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_calls.h" #include "styles/style_calls.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <QtGui/QScreen> #include <QtGui/QScreen>

View file

@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_calls.h" #include "styles/style_calls.h"
#include <QtGui/QtEvents> #include <QtGui/QtEvents>
#include <QtGui/QOpenGLShader> #include <QOpenGLShader>
namespace Calls::Group { namespace Calls::Group {
namespace { namespace {

View file

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h" #include "data/data_peer.h"
#include "styles/style_calls.h" #include "styles/style_calls.h"
#include <QtGui/QOpenGLShader> #include <QOpenGLShader>
namespace Calls::Group { namespace Calls::Group {
namespace { namespace {

View file

@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_image.h" #include "ui/gl/gl_image.h"
#include <QtGui/QOpenGLBuffer> #include <QOpenGLBuffer>
#include <QtGui/QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
namespace Webrtc { namespace Webrtc {
struct FrameWithInfo; struct FrameWithInfo;

View file

@ -160,7 +160,7 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) {
} }
} }
void BotKeyboard::enterEventHook(QEvent *e) { void BotKeyboard::enterEventHook(QEnterEvent *e) {
_lastMousePos = QCursor::pos(); _lastMousePos = QCursor::pos();
updateSelected(); updateSelected();
} }

View file

@ -74,7 +74,7 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:

View file

@ -132,7 +132,7 @@ void CreateCacheFilePath() {
} }
list.push_back(entry); list.push_back(entry);
} }
result.maxKeyLength = std::max(result.maxKeyLength, key.size()); result.maxKeyLength = std::max(result.maxKeyLength, int(key.size()));
} }
result.version = version; result.version = version;
return result; return result;

View file

@ -166,7 +166,7 @@ void EmojiColorPicker::showEmoji(EmojiPtr emoji) {
_ignoreShow = false; _ignoreShow = false;
_variants.resize(emoji->variantsCount() + 1); _variants.resize(emoji->variantsCount() + 1);
for (auto i = 0, size = _variants.size(); i != size; ++i) { for (auto i = 0, size = int(_variants.size()); i != size; ++i) {
_variants[i] = emoji->variant(i); _variants[i] = emoji->variant(i);
} }
@ -219,7 +219,7 @@ void EmojiColorPicker::paintEvent(QPaintEvent *e) {
p.fillRect(x, st::emojiPanMargins.top() + st::emojiColorsPadding, st::emojiColorsSep, inner.height() - st::emojiColorsPadding * 2, st::emojiColorsSepColor); p.fillRect(x, st::emojiPanMargins.top() + st::emojiColorsPadding, st::emojiColorsSep, inner.height() - st::emojiColorsPadding * 2, st::emojiColorsSepColor);
if (_variants.isEmpty()) return; if (_variants.isEmpty()) return;
for (auto i = 0, count = _variants.size(); i != count; ++i) { for (auto i = 0, count = int(_variants.size()); i != count; ++i) {
drawVariant(p, i); drawVariant(p, i);
} }
} }

View file

@ -495,7 +495,7 @@ void SuggestionsWidget::triggerRow(const Row &row) const {
_triggered.fire(row.emoji->text()); _triggered.fire(row.emoji->text());
} }
void SuggestionsWidget::enterEventHook(QEvent *e) { void SuggestionsWidget::enterEventHook(QEnterEvent *e) {
if (!inner().contains(mapToInner(QCursor::pos()))) { if (!inner().contains(mapToInner(QCursor::pos()))) {
clearMouseSelection(); clearMouseSelection();
} }

View file

@ -50,7 +50,7 @@ private:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void scrollByWheelEvent(not_null<QWheelEvent*> e); void scrollByWheelEvent(not_null<QWheelEvent*> e);

View file

@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "base/qt_adapters.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
@ -84,7 +85,7 @@ private:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
@ -257,19 +258,19 @@ void FieldAutocomplete::showFiltered(
query = query.toLower(); query = query.toLower();
auto type = Type::Stickers; auto type = Type::Stickers;
auto plainQuery = query.midRef(0); auto plainQuery = QStringView(query);
switch (query.at(0).unicode()) { switch (query.at(0).unicode()) {
case '@': case '@':
type = Type::Mentions; type = Type::Mentions;
plainQuery = query.midRef(1); plainQuery = base::StringViewMid(query, 1);
break; break;
case '#': case '#':
type = Type::Hashtags; type = Type::Hashtags;
plainQuery = query.midRef(1); plainQuery = base::StringViewMid(query, 1);
break; break;
case '/': case '/':
type = Type::BotCommands; type = Type::BotCommands;
plainQuery = query.midRef(1); plainQuery = base::StringViewMid(query, 1);
break; break;
} }
bool resetScroll = (_type != type || _filter != plainQuery); bool resetScroll = (_type != type || _filter != plainQuery);
@ -1202,7 +1203,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) {
} }
} }
void FieldAutocomplete::Inner::enterEventHook(QEvent *e) { void FieldAutocomplete::Inner::enterEventHook(QEnterEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }

View file

@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "base/qt_adapters.h"
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
#include <QtCore/QStack> #include <QtCore/QStack>
@ -93,7 +94,7 @@ QString FieldTagMimeProcessor::tagFromMimeTag(const QString &mimeTag) {
const auto userId = _controller->session().userId(); const auto userId = _controller->session().userId();
auto match = QRegularExpression(":(\\d+)$").match(mimeTag); auto match = QRegularExpression(":(\\d+)$").match(mimeTag);
if (!match.hasMatch() if (!match.hasMatch()
|| match.capturedRef(1).toULongLong() != userId.bare) { || match.capturedView(1).toULongLong() != userId.bare) {
return QString(); return QString();
} }
return mimeTag.mid(0, mimeTag.size() - match.capturedLength()); return mimeTag.mid(0, mimeTag.size() - match.capturedLength());
@ -380,7 +381,7 @@ InlineBotQuery ParseInlineBotQuery(
< inlineUsernameStart + inlineUsernameLength)) { < inlineUsernameStart + inlineUsernameLength)) {
return InlineBotQuery(); return InlineBotQuery();
} }
auto username = text.midRef(inlineUsernameStart, inlineUsernameLength); auto username = base::StringViewMid(text, inlineUsernameStart, inlineUsernameLength);
if (username != result.username) { if (username != result.username) {
result.username = username.toString(); result.username = username.toString();
if (const auto peer = session->data().peerByUsername(result.username)) { if (const auto peer = session->data().peerByUsername(result.username)) {
@ -661,7 +662,7 @@ void MessageLinksParser::parse() {
} }
} }
const auto range = LinkRange { const auto range = LinkRange {
domainOffset, int(domainOffset),
static_cast<int>(p - start - domainOffset), static_cast<int>(p - start - domainOffset),
QString() QString()
}; };
@ -685,8 +686,8 @@ void MessageLinksParser::apply(
const auto current = _list.current(); const auto current = _list.current();
const auto computeLink = [&](const LinkRange &range) { const auto computeLink = [&](const LinkRange &range) {
return range.custom.isEmpty() return range.custom.isEmpty()
? text.midRef(range.start, range.length) ? base::StringViewMid(text, range.start, range.length)
: range.custom.midRef(0); : QStringView(range.custom);
}; };
const auto changed = [&] { const auto changed = [&] {
if (current.size() != count) { if (current.size() != count) {

View file

@ -184,7 +184,7 @@ void AddExceptions() {
return word.utf16(); return word.utf16();
}) | ranges::views::filter([](const auto &word) { }) | ranges::views::filter([](const auto &word) {
return !(Platform::Spellchecker::IsWordInDictionary(word) return !(Platform::Spellchecker::IsWordInDictionary(word)
|| Spellchecker::IsWordSkippable(&word)); || Spellchecker::IsWordSkippable(word));
}) | ranges::to_vector; }) | ranges::to_vector;
ranges::for_each(exceptions, Platform::Spellchecker::AddWord); ranges::for_each(exceptions, Platform::Spellchecker::AddWord);

View file

@ -207,7 +207,7 @@ void TabbedPanel::moveByBottom() {
updateContentHeight(); updateContentHeight();
} }
void TabbedPanel::enterEventHook(QEvent *e) { void TabbedPanel::enterEventHook(QEnterEvent *e) {
Core::App().registerLeaveSubscription(this); Core::App().registerLeaveSubscription(this);
showAnimated(); showAnimated();
} }

View file

@ -58,7 +58,7 @@ public:
~TabbedPanel(); ~TabbedPanel();
protected: protected:
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void otherEnter(); void otherEnter();
void otherLeave(); void otherLeave();

View file

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/ui_integration.h" #include "core/ui_integration.h"
#include "chat_helpers/emoji_keywords.h" #include "chat_helpers/emoji_keywords.h"
#include "chat_helpers/stickers_emoji_image_loader.h" #include "chat_helpers/stickers_emoji_image_loader.h"
#include "base/qt_adapters.h"
#include "base/platform/base_platform_url_scheme.h" #include "base/platform/base_platform_url_scheme.h"
#include "base/platform/base_platform_last_input.h" #include "base/platform/base_platform_last_input.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
@ -83,7 +84,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/share_box.h" #include "boxes/share_box.h"
#include "app.h" #include "app.h"
#include <QtWidgets/QDesktopWidget>
#include <QtCore/QMimeDatabase> #include <QtCore/QMimeDatabase>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QScreen> #include <QtGui/QScreen>
@ -830,7 +830,7 @@ bool Application::openCustomUrl(
|| passcodeLocked()) { || passcodeLocked()) {
return false; return false;
} }
const auto command = urlTrimmed.midRef(protocol.size(), 8192); const auto command = base::StringViewMid(urlTrimmed, protocol.size(), 8192);
const auto controller = _window ? _window->sessionController() : nullptr; const auto controller = _window ? _window->sessionController() : nullptr;
using namespace qthelp; using namespace qthelp;

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "storage/storage_domain.h" #include "storage/storage_domain.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "base/qt_adapters.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -194,7 +195,7 @@ void Changelogs::addBetaLog(int changeVersion, const char *changes) {
static const auto simple = u"\n- "_q; static const auto simple = u"\n- "_q;
static const auto separator = QString::fromUtf8("\n\xE2\x80\xA2 "); static const auto separator = QString::fromUtf8("\n\xE2\x80\xA2 ");
auto result = QString::fromUtf8(changes).trimmed(); auto result = QString::fromUtf8(changes).trimmed();
if (result.startsWith(simple.midRef(1))) { if (result.startsWith(base::StringViewMid(simple, 1))) {
result = separator.mid(1) + result.mid(simple.size() - 1); result = separator.mid(1) + result.mid(simple.size() - 1);
} }
return result.replace(simple, separator); return result.replace(simple, separator);

View file

@ -288,6 +288,7 @@ void Launcher::init() {
QApplication::setApplicationName(qsl("TelegramDesktop")); QApplication::setApplicationName(qsl("TelegramDesktop"));
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// fallback session management is useless for tdesktop since it doesn't have // fallback session management is useless for tdesktop since it doesn't have
// any "are you sure you want to close this window?" dialogs // any "are you sure you want to close this window?" dialogs
// but it produces bugs like https://github.com/telegramdesktop/tdesktop/issues/5022 // but it produces bugs like https://github.com/telegramdesktop/tdesktop/issues/5022
@ -295,6 +296,7 @@ void Launcher::init() {
// and https://github.com/telegramdesktop/tdesktop/issues/948 // and https://github.com/telegramdesktop/tdesktop/issues/948
// more info: https://doc.qt.io/qt-5/qguiapplication.html#isFallbackSessionManagementEnabled // more info: https://doc.qt.io/qt-5/qguiapplication.html#isFallbackSessionManagementEnabled
QApplication::setFallbackSessionManagementEnabled(false); QApplication::setFallbackSessionManagementEnabled(false);
#endif // Qt < 6.0.0
initHook(); initHook();
} }
@ -402,7 +404,7 @@ void Launcher::prepareSettings() {
if (!path.isEmpty()) { if (!path.isEmpty()) {
auto info = QFileInfo(path); auto info = QFileInfo(path);
if (info.isSymLink()) { if (info.isSymLink()) {
info = info.symLinkTarget(); info = QFileInfo(info.symLinkTarget());
} }
if (info.exists()) { if (info.exists()) {
const auto dir = info.absoluteDir().absolutePath(); const auto dir = info.absoluteDir().absolutePath();

View file

@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "history/history.h" #include "history/history.h"
#include "base/qt_adapters.h"
#include "apiwrap.h" #include "apiwrap.h"
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
@ -100,7 +101,7 @@ bool SetLanguage(
Window::SessionController *controller, Window::SessionController *controller,
const Match &match, const Match &match,
const QVariant &context) { const QVariant &context) {
if (match->capturedRef(1).isEmpty()) { if (match->capturedView(1).isEmpty()) {
ShowLanguagesBox(); ShowLanguagesBox();
} else { } else {
const auto languageId = match->captured(2); const auto languageId = match->captured(2);
@ -688,7 +689,7 @@ QString TryConvertUrlToLocal(QString url) {
auto matchOptions = RegExOption::CaseInsensitive; auto matchOptions = RegExOption::CaseInsensitive;
auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions); auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions);
if (telegramMeMatch) { if (telegramMeMatch) {
auto query = telegramMeMatch->capturedRef(5); auto query = telegramMeMatch->capturedView(5);
if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) { if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2)); return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2));
} else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) { } else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
@ -746,7 +747,7 @@ bool InternalPassportLink(const QString &url) {
if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
return false; return false;
} }
const auto command = urlTrimmed.midRef(qstr("tg://").size()); const auto command = base::StringViewMid(urlTrimmed, qstr("tg://").size());
using namespace qthelp; using namespace qthelp;
const auto matchOptions = RegExOption::CaseInsensitive; const auto matchOptions = RegExOption::CaseInsensitive;

View file

@ -265,7 +265,10 @@ void Sandbox::socketReading() {
} }
_localSocketReadData.append(_localSocket.readAll()); _localSocketReadData.append(_localSocket.readAll());
if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) { if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) {
uint64 pid = _localSocketReadData.midRef(4, _localSocketReadData.length() - 5).toULongLong(); uint64 pid = base::StringViewMid(
_localSocketReadData,
4,
_localSocketReadData.length() - 5).toULongLong();
if (pid != kEmptyPidForCommandResponse) { if (pid != kEmptyPidForCommandResponse) {
psActivateProcess(pid); psActivateProcess(pid);
} }
@ -388,7 +391,7 @@ void Sandbox::readClients() {
QString cmds(QString::fromLatin1(i->second)); QString cmds(QString::fromLatin1(i->second));
int32 from = 0, l = cmds.length(); int32 from = 0, l = cmds.length();
for (int32 to = cmds.indexOf(QChar(';'), from); to >= from; to = (from < l) ? cmds.indexOf(QChar(';'), from) : -1) { for (int32 to = cmds.indexOf(QChar(';'), from); to >= from; to = (from < l) ? cmds.indexOf(QChar(';'), from) : -1) {
QStringRef cmd(&cmds, from, to - from); auto cmd = base::StringViewMid(cmds, from, to - from);
if (cmd.startsWith(qsl("CMD:"))) { if (cmd.startsWith(qsl("CMD:"))) {
execExternal(cmds.mid(from + 4, to - from - 4)); execExternal(cmds.mid(from + 4, to - from - 4));
const auto response = qsl("RES:%1;").arg(QApplication::applicationPid()).toLatin1(); const auto response = qsl("RES:%1;").arg(QApplication::applicationPid()).toLatin1();
@ -409,7 +412,7 @@ void Sandbox::readClients() {
const auto response = qsl("RES:%1;").arg(responsePid).toLatin1(); const auto response = qsl("RES:%1;").arg(responsePid).toLatin1();
i->first->write(response.data(), response.size()); i->first->write(response.data(), response.size());
} else { } else {
LOG(("Sandbox Error: unknown command %1 passed in local socket").arg(QString(cmd.constData(), cmd.length()))); LOG(("Sandbox Error: unknown command %1 passed in local socket").arg(cmd.toString()));
} }
from = to + 1; from = to + 1;
} }
@ -571,7 +574,7 @@ void Sandbox::processPostponedCalls(int level) {
bool Sandbox::nativeEventFilter( bool Sandbox::nativeEventFilter(
const QByteArray &eventType, const QByteArray &eventType,
void *message, void *message,
long *result) { base::NativeEventResult *result) {
registerEnterFromEventLoop(); registerEnterFromEventLoop();
return false; return false;
} }

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
#include "mtproto/mtproto_proxy_data.h" #include "mtproto/mtproto_proxy_data.h"
#include "base/qt_adapters.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtNetwork/QLocalServer> #include <QtNetwork/QLocalServer>
@ -85,7 +86,7 @@ private:
bool nativeEventFilter( bool nativeEventFilter(
const QByteArray &eventType, const QByteArray &eventType,
void *message, void *message,
long *result) override; base::NativeEventResult *result) override;
void processPostponedCalls(int level); void processPostponedCalls(int level);
void singleInstanceChecked(); void singleInstanceChecked();
void launchApplication(); void launchApplication();

View file

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "base/parse_helper.h" #include "base/parse_helper.h"
#include <QtWidgets/QShortcut> #include <QShortcut>
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject> #include <QtCore/QJsonObject>
#include <QtCore/QJsonArray> #include <QtCore/QJsonArray>

View file

@ -582,7 +582,7 @@ bool ParseCommonMap(
if ((*version).isString()) { if ((*version).isString()) {
const auto string = (*version).toString(); const auto string = (*version).toString();
if (const auto index = string.indexOf(':'); index > 0) { if (const auto index = string.indexOf(':'); index > 0) {
return string.midRef(0, index).toULongLong(); return base::StringViewMid(string, 0, index).toULongLong();
} }
return string.toULongLong(); return string.toULongLong();
} else if ((*version).isDouble()) { } else if ((*version).isDouble()) {
@ -1014,7 +1014,7 @@ auto MtpChecker::parseText(const QByteArray &text) const
return false; return false;
} }
bestLocation.username = full.mid(start + 1, post - start - 1); bestLocation.username = full.mid(start + 1, post - start - 1);
bestLocation.postId = full.midRef(post + 1).toInt(); bestLocation.postId = base::StringViewMid(full, post + 1).toInt();
if (bestLocation.username.isEmpty() || !bestLocation.postId) { if (bestLocation.username.isEmpty() || !bestLocation.postId) {
LOG(("Update Error: MTP entry '%1' is bad for version %2." LOG(("Update Error: MTP entry '%1' is bad for version %2."
).arg(full ).arg(full

View file

@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "countries/countries_instance.h" #include "countries/countries_instance.h"
#include "base/qt_adapters.h"
namespace Countries { namespace Countries {
namespace { namespace {
@ -328,11 +330,11 @@ FormatResult CountriesInstance::format(FormatArgs args) {
if (phoneNumber.startsWith(callingCode.callingCode)) { if (phoneNumber.startsWith(callingCode.callingCode)) {
const auto codeSize = callingCode.callingCode.size(); const auto codeSize = callingCode.callingCode.size();
for (const auto &prefix : callingCode.prefixes) { for (const auto &prefix : callingCode.prefixes) {
if (prefix.startsWith(phoneNumber.midRef(codeSize))) { if (prefix.startsWith(base::StringViewMid(phoneNumber, codeSize))) {
isPrefix = true; isPrefix = true;
} }
if ((codeSize + prefix.size()) > bestLength && if ((codeSize + prefix.size()) > bestLength &&
phoneNumber.midRef(codeSize).startsWith(prefix)) { base::StringViewMid(phoneNumber, codeSize).startsWith(prefix)) {
bestCountryPtr = &country; bestCountryPtr = &country;
bestCallingCodePtr = &callingCode; bestCallingCodePtr = &callingCode;
bestLength = codeSize + prefix.size(); bestLength = codeSize + prefix.size();

View file

@ -988,7 +988,7 @@ QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform) {
// Write each 0-31 unsigned char as 5 bit to result. // Write each 0-31 unsigned char as 5 bit to result.
// We reserve one extra byte to be able to dereference any of required bytes // We reserve one extra byte to be able to dereference any of required bytes
// as a uint16 without overflowing, even the byte with index "bytesCount - 1". // as a uint16 without overflowing, even the byte with index "bytesCount - 1".
for (auto i = 0, l = waveform.size(); i < l; ++i) { for (auto i = 0, l = int(waveform.size()); i < l; ++i) {
auto byteIndex = (i * 5) / 8; auto byteIndex = (i * 5) / 8;
auto bitShift = (i * 5) % 8; auto bitShift = (i * 5) % 8;
auto value = (static_cast<uint16>(waveform[i]) & 0x1F) << bitShift; auto value = (static_cast<uint16>(waveform[i]) & 0x1F) << bitShift;
@ -1337,7 +1337,7 @@ bool DocumentData::isAudioFile() const {
} }
return false; return false;
} }
const auto left = _mimeString.midRef(prefix.size()).toString(); const auto left = _mimeString.mid(prefix.size());
const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") }; const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") };
return ranges::contains(types, left); return ranges::contains(types, left);
} }

View file

@ -232,7 +232,7 @@ void ResolveDocument(
location.accessDisable(); location.accessDisable();
}); });
const auto path = location.name(); const auto path = location.name();
if (Core::MimeTypeForFile(path).name().startsWith("image/") if (Core::MimeTypeForFile(QFileInfo(path)).name().startsWith("image/")
&& QImageReader(path).canRead()) { && QImageReader(path).canRead()) {
showDocument(); showDocument();
return true; return true;

View file

@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/qt_adapters.h"
namespace Data { namespace Data {
namespace { namespace {
@ -40,7 +39,7 @@ int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) {
return (hours + 1) * 3600 - (now - online); return (hours + 1) * 3600 - (now - online);
} }
const auto nowFull = base::unixtime::parse(now); const auto nowFull = base::unixtime::parse(now);
const auto tomorrow = base::QDateToDateTime(nowFull.date().addDays(1)); const auto tomorrow = nowFull.date().addDays(1).startOfDay();
return std::max(static_cast<TimeId>(nowFull.secsTo(tomorrow)), 0); return std::max(static_cast<TimeId>(nowFull.secsTo(tomorrow)), 0);
} }

View file

@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "base/qt_adapters.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/text/text_entity.h" #include "ui/text/text_entity.h"
@ -27,7 +26,7 @@ QString SiteNameFromUrl(const QString &url) {
if (m.hasMatch()) pretty = pretty.mid(m.capturedLength()); if (m.hasMatch()) pretty = pretty.mid(m.capturedLength());
int32 slash = pretty.indexOf('/'); int32 slash = pretty.indexOf('/');
if (slash > 0) pretty = pretty.mid(0, slash); if (slash > 0) pretty = pretty.mid(0, slash);
QStringList components = pretty.split('.', base::QStringSkipEmptyParts); QStringList components = pretty.split('.', Qt::SkipEmptyParts);
if (components.size() >= 2) { if (components.size() >= 2) {
components = components.mid(components.size() - 2); components = components.mid(components.size() - 2);
return components.at(0).at(0).toUpper() + components.at(0).mid(1) + '.' + components.at(1); return components.at(0).at(0).toUpper() + components.at(0).mid(1) + '.' + components.at(1);

View file

@ -679,7 +679,7 @@ void Stickers::setPackAndEmoji(
auto p = StickersPack(); auto p = StickersPack();
p.reserve(stickers.size()); p.reserve(stickers.size());
for (auto j = 0, c = stickers.size(); j != c; ++j) { for (auto j = 0, c = int(stickers.size()); j != c; ++j) {
auto document = owner().document(stickers[j].v); auto document = owner().document(stickers[j].v);
if (!document || !document->sticker()) continue; if (!document || !document->sticker()) continue;
@ -1302,7 +1302,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
set->stickers = pack; set->stickers = pack;
set->emoji.clear(); set->emoji.clear();
auto &v = d.vpacks().v; auto &v = d.vpacks().v;
for (auto i = 0, l = v.size(); i != l; ++i) { for (auto i = 0, l = int(v.size()); i != l; ++i) {
if (v[i].type() != mtpc_stickerPack) continue; if (v[i].type() != mtpc_stickerPack) continue;
auto &pack = v[i].c_stickerPack(); auto &pack = v[i].c_stickerPack();
@ -1312,7 +1312,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
StickersPack p; StickersPack p;
p.reserve(stickers.size()); p.reserve(stickers.size());
for (auto j = 0, c = stickers.size(); j != c; ++j) { for (auto j = 0, c = int(stickers.size()); j != c; ++j) {
auto doc = owner().document(stickers[j].v); auto doc = owner().document(stickers[j].v);
if (!doc || !doc->sticker()) continue; if (!doc || !doc->sticker()) continue;

View file

@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include "base/qt_adapters.h"
namespace Dialogs { namespace Dialogs {
namespace { namespace {
@ -1619,7 +1620,7 @@ void InnerWidget::updateDialogRow(
} }
} }
void InnerWidget::enterEventHook(QEvent *e) { void InnerWidget::enterEventHook(QEnterEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
@ -1844,7 +1845,7 @@ void InnerWidget::applyFilterUpdate(QString newFilter, bool force) {
} }
} }
void InnerWidget::onHashtagFilterUpdate(QStringRef newFilter) { void InnerWidget::onHashtagFilterUpdate(QStringView newFilter) {
if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInChat) { if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInChat) {
_hashtagFilter = QString(); _hashtagFilter = QString();
if (!_hashtagResults.empty()) { if (!_hashtagResults.empty()) {
@ -1863,7 +1864,7 @@ void InnerWidget::onHashtagFilterUpdate(QStringRef newFilter) {
if (!recent.isEmpty()) { if (!recent.isEmpty()) {
_hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit)); _hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit));
for (const auto &tag : recent) { for (const auto &tag : recent) {
if (tag.first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) if (tag.first.startsWith(base::StringViewMid(_hashtagFilter, 1), Qt::CaseInsensitive)
&& tag.first.size() + 1 != newFilter.size()) { && tag.first.size() + 1 != newFilter.size()) {
_hashtagResults.push_back(std::make_unique<HashtagResult>(tag.first)); _hashtagResults.push_back(std::make_unique<HashtagResult>(tag.first));
if (_hashtagResults.size() == kHashtagResultsLimit) break; if (_hashtagResults.size() == kHashtagResultsLimit) break;
@ -2291,7 +2292,7 @@ void InnerWidget::searchInChat(Key key, PeerData *from) {
_searchFromPeer = from; _searchFromPeer = from;
if (_searchInChat) { if (_searchInChat) {
_controller->closeFolder(); _controller->closeFolder();
onHashtagFilterUpdate(QStringRef()); onHashtagFilterUpdate(QStringView());
_cancelSearchInChat->show(); _cancelSearchInChat->show();
refreshSearchInChatLabel(); refreshSearchInChatLabel();
} else { } else {

View file

@ -114,7 +114,7 @@ public:
void searchInChat(Key key, PeerData *from); void searchInChat(Key key, PeerData *from);
void applyFilterUpdate(QString newFilter, bool force = false); void applyFilterUpdate(QString newFilter, bool force = false);
void onHashtagFilterUpdate(QStringRef newFilter); void onHashtagFilterUpdate(QStringView newFilter);
PeerData *updateFromParentDrag(QPoint globalPosition); PeerData *updateFromParentDrag(QPoint globalPosition);
@ -148,7 +148,7 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;

View file

@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include "base/qt_adapters.h"
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
@ -1475,12 +1476,12 @@ void Widget::showSearchFrom() {
void Widget::onFilterCursorMoved(int from, int to) { void Widget::onFilterCursorMoved(int from, int to) {
if (to < 0) to = _filter->cursorPosition(); if (to < 0) to = _filter->cursorPosition();
QString t = _filter->getLastText(); QString t = _filter->getLastText();
QStringRef r; QStringView r;
for (int start = to; start > 0;) { for (int start = to; start > 0;) {
--start; --start;
if (t.size() <= start) break; if (t.size() <= start) break;
if (t.at(start) == '#') { if (t.at(start) == '#') {
r = t.midRef(start, to - start); r = base::StringViewMid(t, start, to - start);
break; break;
} }
if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break; if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break;
@ -1495,7 +1496,9 @@ void Widget::onCompleteHashtag(QString tag) {
--start; --start;
if (t.size() <= start) break; if (t.size() <= start) break;
if (t.at(start) == '#') { if (t.at(start) == '#') {
if (cur == start + 1 || t.midRef(start + 1, cur - start - 1) == tag.midRef(0, cur - start - 1)) { if (cur == start + 1
|| base::StringViewMid(t, start + 1, cur - start - 1)
== base::StringViewMid(tag, 0, cur - start - 1)) {
for (; cur < t.size() && cur - start - 1 < tag.size(); ++cur) { for (; cur < t.size() && cur - start - 1 < tag.size(); ++cur) {
if (t.at(cur) != tag.at(cur - start - 1)) break; if (t.at(cur) != tag.at(cur - start - 1)) break;
} }

View file

@ -92,7 +92,7 @@ void Crop::applyTransform(
const auto cropHolder = QRectF(QPointF(), scaledImageSize); const auto cropHolder = QRectF(QPointF(), scaledImageSize);
const auto cropHolderCenter = cropHolder.center(); const auto cropHolderCenter = cropHolder.center();
auto matrix = QMatrix() auto matrix = QTransform()
.translate(cropHolderCenter.x(), cropHolderCenter.y()) .translate(cropHolderCenter.x(), cropHolderCenter.y())
.scale(flipped ? -1 : 1, 1) .scale(flipped ? -1 : 1, 1)
.rotate(angle) .rotate(angle)
@ -151,12 +151,12 @@ void Crop::setCropPaint(QRectF &&rect) {
} }
void Crop::convertCropPaintToOriginal() { void Crop::convertCropPaintToOriginal() {
const auto cropHolder = QMatrix() const auto cropHolder = QTransform()
.scale(_ratio.w, _ratio.h) .scale(_ratio.w, _ratio.h)
.mapRect(QRectF(QPointF(), FlipSizeByRotation(_imageSize, _angle))); .mapRect(QRectF(QPointF(), FlipSizeByRotation(_imageSize, _angle)));
const auto cropHolderCenter = cropHolder.center(); const auto cropHolderCenter = cropHolder.center();
const auto matrix = QMatrix() const auto matrix = QTransform()
.translate(cropHolderCenter.x(), cropHolderCenter.y()) .translate(cropHolderCenter.x(), cropHolderCenter.y())
.rotate(-_angle) .rotate(-_angle)
.scale((_flipped ? -1 : 1) * 1. / _ratio.w, 1. / _ratio.h) .scale((_flipped ? -1 : 1) * 1. / _ratio.w, 1. / _ratio.h)

View file

@ -133,7 +133,7 @@ void Paint::applyTransform(QRect geometry, int angle, bool flipped) {
setGeometry(geometry); setGeometry(geometry);
const auto size = geometry.size(); const auto size = geometry.size();
const auto rotatedImageSize = QMatrix() const auto rotatedImageSize = QTransform()
.rotate(angle) .rotate(angle)
.mapRect(QRect(QPoint(), _imageSize)); .mapRect(QRect(QPoint(), _imageSize));

View file

@ -177,7 +177,7 @@ Utf8String FillLeft(const Utf8String &data, int length, char filler) {
} }
auto result = Utf8String(); auto result = Utf8String();
result.reserve(length); result.reserve(length);
for (auto i = 0, count = length - data.size(); i != count; ++i) { for (auto i = 0, count = length - int(data.size()); i != count; ++i) {
result.append(filler); result.append(filler);
} }
result.append(data); result.append(data);
@ -1806,7 +1806,7 @@ Utf8String FormatDateTime(
if (!date) { if (!date) {
return Utf8String(); return Utf8String();
} }
const auto value = QDateTime::fromTime_t(date); const auto value = QDateTime::fromSecsSinceEpoch(date);
return (QString("%1") + dateSeparator + "%2" + dateSeparator + "%3" return (QString("%1") + dateSeparator + "%2" + dateSeparator + "%3"
+ separator + "%4" + timeSeparator + "%5" + timeSeparator + "%6" + separator + "%4" + timeSeparator + "%5" + timeSeparator + "%6"
).arg(value.date().day(), 2, 10, QChar('0') ).arg(value.date().day(), 2, 10, QChar('0')

View file

@ -736,7 +736,7 @@ void ApiWrap::requestUserpics(
auto startInfo = result.match( auto startInfo = result.match(
[](const MTPDphotos_photos &data) { [](const MTPDphotos_photos &data) {
return Data::UserpicsInfo{ data.vphotos().v.size() }; return Data::UserpicsInfo{ int(data.vphotos().v.size()) };
}, [](const MTPDphotos_photosSlice &data) { }, [](const MTPDphotos_photosSlice &data) {
return Data::UserpicsInfo{ data.vcount().v }; return Data::UserpicsInfo{ data.vcount().v };
}); });
@ -968,7 +968,7 @@ void ApiWrap::requestMessagesCount(int localSplitIndex) {
const auto count = result.match( const auto count = result.match(
[](const MTPDmessages_messages &data) { [](const MTPDmessages_messages &data) {
return data.vmessages().v.size(); return int(data.vmessages().v.size());
}, [](const MTPDmessages_messagesSlice &data) { }, [](const MTPDmessages_messagesSlice &data) {
return data.vcount().v; return data.vcount().v;
}, [](const MTPDmessages_channelMessages &data) { }, [](const MTPDmessages_channelMessages &data) {

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/output/export_output_result.h" #include "export/output/export_output_result.h"
#include "export/output/export_output_stats.h" #include "export/output/export_output_stats.h"
#include "base/qt_adapters.h"
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QDir> #include <QtCore/QDir>
@ -102,10 +103,10 @@ QString File::PrepareRelativePath(
// Not lastIndexOf('.') so that "file.tar.xz" won't be messed up. // Not lastIndexOf('.') so that "file.tar.xz" won't be messed up.
const auto position = suggested.indexOf('.'); const auto position = suggested.indexOf('.');
const auto base = suggested.midRef(0, position).toString(); const auto base = suggested.mid(0, position);
const auto extension = (position >= 0) const auto extension = (position >= 0)
? suggested.midRef(position) ? base::StringViewMid(suggested, position)
: QStringRef(); : QStringView();
const auto relativePart = [&](int attempt) { const auto relativePart = [&](int attempt) {
auto result = base + QString(" (%1)").arg(attempt); auto result = base + QString(" (%1)").arg(attempt);
result.append(extension); result.append(extension);

View file

@ -283,12 +283,12 @@ bool DisplayDate(TimeId date, TimeId previousDate) {
if (!previousDate) { if (!previousDate) {
return true; return true;
} }
return QDateTime::fromTime_t(date).date() return QDateTime::fromSecsSinceEpoch(date).date()
!= QDateTime::fromTime_t(previousDate).date(); != QDateTime::fromSecsSinceEpoch(previousDate).date();
} }
QByteArray FormatDateText(TimeId date) { QByteArray FormatDateText(TimeId date) {
const auto parsed = QDateTime::fromTime_t(date).date(); const auto parsed = QDateTime::fromSecsSinceEpoch(date).date();
const auto month = [](int index) { const auto month = [](int index) {
switch (index) { switch (index) {
case 1: return "January"; case 1: return "January";
@ -314,7 +314,7 @@ QByteArray FormatDateText(TimeId date) {
} }
QByteArray FormatTimeText(TimeId date) { QByteArray FormatTimeText(TimeId date) {
const auto parsed = QDateTime::fromTime_t(date).time(); const auto parsed = QDateTime::fromSecsSinceEpoch(date).time();
return Data::NumberToString(parsed.hour(), 2) return Data::NumberToString(parsed.hour(), 2)
+ ':' + ':'
+ Data::NumberToString(parsed.minute(), 2); + Data::NumberToString(parsed.minute(), 2);
@ -1256,8 +1256,8 @@ bool HtmlWriter::Wrap::messageNeedsWrap(
return true; return true;
} else if (message.viaBotId != previous->viaBotId) { } else if (message.viaBotId != previous->viaBotId) {
return true; return true;
} else if (QDateTime::fromTime_t(previous->date).date() } else if (QDateTime::fromSecsSinceEpoch(previous->date).date()
!= QDateTime::fromTime_t(message.date).date()) { != QDateTime::fromSecsSinceEpoch(message.date).date()) {
return true; return true;
} else if (message.forwarded != previous->forwarded } else if (message.forwarded != previous->forwarded
|| message.showForwardedAsOriginal != previous->showForwardedAsOriginal || message.showForwardedAsOriginal != previous->showForwardedAsOriginal

View file

@ -71,7 +71,7 @@ QByteArray SerializeString(const QByteArray &value) {
QByteArray SerializeDate(TimeId date) { QByteArray SerializeDate(TimeId date) {
return SerializeString( return SerializeString(
QDateTime::fromTime_t(date).toString(Qt::ISODate).toUtf8()); QDateTime::fromSecsSinceEpoch(date).toString(Qt::ISODate).toUtf8());
} }
QByteArray StringAllowEmpty(const Data::Utf8String &data) { QByteArray StringAllowEmpty(const Data::Utf8String &data) {

View file

@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/qt_adapters.h"
#include "styles/style_export.h" #include "styles/style_export.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -219,7 +220,8 @@ void PanelController::showError(const ApiErrorState &error) {
if (error.data.type() == qstr("TAKEOUT_INVALID")) { if (error.data.type() == qstr("TAKEOUT_INVALID")) {
showError(tr::lng_export_invalid(tr::now)); showError(tr::lng_export_invalid(tr::now));
} else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) { } else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) {
const auto seconds = std::max(error.data.type().midRef( const auto seconds = std::max(base::StringViewMid(
error.data.type(),
qstr("TAKEOUT_INIT_DELAY_").size()).toInt(), 1); qstr("TAKEOUT_INIT_DELAY_").size()).toInt(), 1);
const auto now = QDateTime::currentDateTime(); const auto now = QDateTime::currentDateTime();
const auto when = now.addSecs(seconds); const auto when = now.addSecs(seconds);

View file

@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/qt_adapters.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
#include "styles/style_export.h" #include "styles/style_export.h"
@ -479,7 +478,7 @@ void SettingsWidget::editDateLimit(
})); }));
}; };
const auto callback = crl::guard(this, [=](const QDate &date) { const auto callback = crl::guard(this, [=](const QDate &date) {
done(base::unixtime::serialize(base::QDateToDateTime(date))); done(base::unixtime::serialize(date.startOfDay()));
if (const auto weak = shared->data()) { if (const auto weak = shared->data()) {
weak->closeBox(); weak->closeBox();
} }

View file

@ -56,13 +56,10 @@ void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
for (auto i = 0; i != intsCount; ++i) { for (auto i = 0; i != intsCount; ++i) {
udst[i] = qUnpremultiply(usrc[i]); udst[i] = qUnpremultiply(usrc[i]);
} }
#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #else // !LIB_FFMPEG_USE_QT_PRIVATE_API
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->convertFromARGB32PM(udst, usrc, intsCount, layout, nullptr);
#else // Qt >= 5.12
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->storeFromARGB32PM(dst, usrc, 0, intsCount, nullptr, nullptr); layout->storeFromARGB32PM(dst, usrc, 0, intsCount, nullptr, nullptr);
#endif // Qt >= 5.12 #endif // LIB_FFMPEG_USE_QT_PRIVATE_API
} }
void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
@ -73,13 +70,10 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
for (auto i = 0; i != intsCount; ++i) { for (auto i = 0; i != intsCount; ++i) {
udst[i] = qPremultiply(usrc[i]); udst[i] = qPremultiply(usrc[i]);
} }
#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #else // !LIB_FFMPEG_USE_QT_PRIVATE_API
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->convertToARGB32PM(udst, usrc, intsCount, layout, nullptr);
#else // Qt >= 5.12
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->fetchToARGB32PM(udst, src, 0, intsCount, nullptr, nullptr); layout->fetchToARGB32PM(udst, src, 0, intsCount, nullptr, nullptr);
#endif // Qt >= 5.12 #endif // LIB_FFMPEG_USE_QT_PRIVATE_API
} }
} // namespace } // namespace

View file

@ -1464,7 +1464,7 @@ void InnerWidget::mouseReleaseEvent(QMouseEvent *e) {
} }
} }
void InnerWidget::enterEventHook(QEvent *e) { void InnerWidget::enterEventHook(QEnterEvent *e) {
mouseActionUpdate(QCursor::pos()); mouseActionUpdate(QCursor::pos());
return TWidget::enterEventHook(e); return TWidget::enterEventHook(e);
} }

View file

@ -153,7 +153,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;

View file

@ -38,7 +38,7 @@ TextWithEntities PrepareText(const QString &value, const QString &emptyValue) {
result.entities.push_back({ result.entities.push_back({
EntityType::Italic, EntityType::Italic,
0, 0,
emptyValue.size() }); int(emptyValue.size()) });
} }
} else { } else {
TextUtilities::ParseEntities(result, TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands); TextUtilities::ParseEntities(result, TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands);
@ -296,7 +296,7 @@ TextWithEntities GenerateInviteLinkChangeText(
link.entities.push_back({ link.entities.push_back({
EntityType::CustomUrl, EntityType::CustomUrl,
0, 0,
link.text.size(), int(link.text.size()),
InternalInviteLinkUrl(newLink) }); InternalInviteLinkUrl(newLink) });
} }
auto result = tr::lng_admin_log_edited_invite_link(tr::now, lt_link, link, Ui::Text::WithEntities); auto result = tr::lng_admin_log_edited_invite_link(tr::now, lt_link, link, Ui::Text::WithEntities);
@ -350,7 +350,7 @@ auto GenerateParticipantString(
name.entities.push_back({ name.entities.push_back({
EntityType::MentionName, EntityType::MentionName,
0, 0,
name.text.size(), int(name.text.size()),
entityData }); entityData });
} }
auto username = peer->userName(); auto username = peer->userName();
@ -361,7 +361,7 @@ auto GenerateParticipantString(
mention.entities.push_back({ mention.entities.push_back({
EntityType::Mention, EntityType::Mention,
0, 0,
mention.text.size() }); int(mention.text.size()) });
return tr::lng_admin_log_user_with_username( return tr::lng_admin_log_user_with_username(
tr::now, tr::now,
lt_name, lt_name,

View file

@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "core/application.h" #include "core/application.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/qt_adapters.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
namespace { namespace {
@ -2655,10 +2656,10 @@ void History::cacheTopPromotion(
} }
} }
QStringRef History::topPromotionType() const { QStringView History::topPromotionType() const {
return topPromotionAboutShown() return topPromotionAboutShown()
? _topPromotedType.midRef(5) ? base::StringViewMid(_topPromotedType, 5)
: _topPromotedType.midRef(0); : QStringView(_topPromotedType);
} }
bool History::topPromotionAboutShown() const { bool History::topPromotionAboutShown() const {

View file

@ -277,7 +277,7 @@ public:
bool promoted, bool promoted,
const QString &type, const QString &type,
const QString &message); const QString &message);
[[nodiscard]] QStringRef topPromotionType() const; [[nodiscard]] QStringView topPromotionType() const;
[[nodiscard]] QString topPromotionMessage() const; [[nodiscard]] QString topPromotionMessage() const;
[[nodiscard]] bool topPromotionAboutShown() const; [[nodiscard]] bool topPromotionAboutShown() const;
void markTopPromotionAboutShown(); void markTopPromotionAboutShown();

View file

@ -76,6 +76,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "app.h" #include "app.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_window.h" // st::windowMinWidth #include "styles/style_window.h" // st::windowMinWidth
#include "base/qt_adapters.h"
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
@ -866,7 +867,7 @@ bool HistoryInner::eventHook(QEvent *e) {
|| e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchEnd
|| e->type() == QEvent::TouchCancel) { || e->type() == QEvent::TouchCancel) {
QTouchEvent *ev = static_cast<QTouchEvent*>(e); QTouchEvent *ev = static_cast<QTouchEvent*>(e);
if (ev->device()->type() == QTouchDevice::TouchScreen) { if (ev->device()->type() == base::TouchDevice::TouchScreen) {
touchEvent(ev); touchEvent(ev);
return true; return true;
} }
@ -2504,7 +2505,7 @@ void HistoryInner::updateSize() {
} }
} }
void HistoryInner::enterEventHook(QEvent *e) { void HistoryInner::enterEventHook(QEnterEvent *e) {
mouseActionUpdate(QCursor::pos()); mouseActionUpdate(QCursor::pos());
return TWidget::enterEventHook(e); return TWidget::enterEventHook(e);
} }

View file

@ -167,7 +167,7 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;

View file

@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "facades.h" #include "facades.h"
#include "base/qt_adapters.h"
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
@ -136,7 +135,7 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
? Ui::EmptyUserpic::ExternalName() ? Ui::EmptyUserpic::ExternalName()
: name)) { : name)) {
nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions()); nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
const auto parts = name.trimmed().split(' ', base::QStringSkipEmptyParts); const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts);
firstName = parts[0]; firstName = parts[0];
for (const auto &part : parts.mid(1)) { for (const auto &part : parts.mid(1)) {
if (!lastName.isEmpty()) { if (!lastName.isEmpty()) {

View file

@ -120,7 +120,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
result.text = tr::lng_action_add_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody")); result.text = tr::lng_action_add_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody"));
} else { } else {
result.links.push_back(fromLink()); result.links.push_back(fromLink());
for (auto i = 0, l = users.size(); i != l; ++i) { for (auto i = 0, l = int(users.size()); i != l; ++i) {
auto user = history()->owner().user(users[i].v); auto user = history()->owner().user(users[i].v);
result.links.push_back(user->createOpenLink()); result.links.push_back(user->createOpenLink());
@ -641,7 +641,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
} else if (users.isEmpty()) { } else if (users.isEmpty()) {
result.text = tr::lng_action_invite_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody"), lt_chat, chatText); result.text = tr::lng_action_invite_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody"), lt_chat, chatText);
} else { } else {
for (auto i = 0, l = users.size(); i != l; ++i) { for (auto i = 0, l = int(users.size()); i != l; ++i) {
auto user = owner->user(users[i].v); auto user = owner->user(users[i].v);
result.links.push_back(user->createOpenLink()); result.links.push_back(user->createOpenLink());

View file

@ -168,7 +168,7 @@ const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) { [[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
return std::clamp( return std::clamp(
crl::time(1000) * text.text.size() / 14, crl::time(1000) * int(text.text.size()) / 14,
crl::time(1000) * 5, crl::time(1000) * 5,
crl::time(1000) * 8); crl::time(1000) * 8);
} }
@ -1653,7 +1653,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
if (samePeerBot) { if (samePeerBot) {
if (_history) { if (_history) {
TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() }; TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() };
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX }; MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
_history->setLocalDraft(std::make_unique<Data::Draft>( _history->setLocalDraft(std::make_unique<Data::Draft>(
textWithTags, textWithTags,
0, 0,
@ -1674,7 +1674,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
using Section = Dialogs::EntryState::Section; using Section = Dialogs::EntryState::Section;
TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() }; TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() };
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX }; MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
auto draft = std::make_unique<Data::Draft>( auto draft = std::make_unique<Data::Draft>(
textWithTags, textWithTags,
to.currentReplyToId, to.currentReplyToId,
@ -6254,8 +6254,8 @@ void HistoryWidget::editMessage(not_null<HistoryItem*> item) {
const auto editData = PrepareEditText(item); const auto editData = PrepareEditText(item);
const auto cursor = MessageCursor { const auto cursor = MessageCursor {
editData.text.size(), int(editData.text.size()),
editData.text.size(), int(editData.text.size()),
QFIXED_MAX QFIXED_MAX
}; };
const auto previewPage = [&]() -> WebPageData* { const auto previewPage = [&]() -> WebPageData* {
@ -6550,7 +6550,7 @@ void HistoryWidget::updatePreview() {
st::msgNameStyle, st::msgNameStyle,
tr::lng_preview_loading(tr::now), tr::lng_preview_loading(tr::now),
Ui::NameTextOptions()); Ui::NameTextOptions());
auto linkText = _previewLinks.splitRef(' ').at(0).toString(); auto linkText = QStringView(_previewLinks).split(' ').at(0).toString();
_previewDescription.setText( _previewDescription.setText(
st::messageTextStyle, st::messageTextStyle,
TextUtilities::Clean(linkText), TextUtilities::Clean(linkText),

View file

@ -2024,8 +2024,8 @@ void ComposeControls::editMessage(not_null<HistoryItem*> item) {
} }
const auto editData = PrepareEditText(item); const auto editData = PrepareEditText(item);
const auto cursor = MessageCursor{ const auto cursor = MessageCursor{
editData.text.size(), int(editData.text.size()),
editData.text.size(), int(editData.text.size()),
QFIXED_MAX QFIXED_MAX
}; };
const auto previewPage = [&]() -> WebPageData* { const auto previewPage = [&]() -> WebPageData* {
@ -2164,7 +2164,7 @@ void ComposeControls::initWebpageProcess() {
if (ShowWebPagePreview(*previewData)) { if (ShowWebPagePreview(*previewData)) {
if (const auto till = (*previewData)->pendingTill) { if (const auto till = (*previewData)->pendingTill) {
t = tr::lng_preview_loading(tr::now); t = tr::lng_preview_loading(tr::now);
d = (*previewLinks).splitRef(' ').at(0).toString(); d = QStringView(*previewLinks).split(' ').at(0).toString();
const auto timeout = till - base::unixtime::now(); const auto timeout = till - base::unixtime::now();
previewTimer->callOnce( previewTimer->callOnce(

View file

@ -2033,7 +2033,7 @@ void ListWidget::mouseReleaseEvent(QMouseEvent *e) {
} }
} }
void ListWidget::enterEventHook(QEvent *e) { void ListWidget::enterEventHook(QEnterEvent *e) {
mouseActionUpdate(QCursor::pos()); mouseActionUpdate(QCursor::pos());
return TWidget::enterEventHook(e); return TWidget::enterEventHook(e);
} }

View file

@ -277,7 +277,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;

View file

@ -132,7 +132,6 @@ ViewButton::Inner::Inner(
, link(std::make_shared<LambdaClickHandler>([=](ClickContext context) { , link(std::make_shared<LambdaClickHandler>([=](ClickContext context) {
const auto my = context.other.value<ClickHandlerContext>(); const auto my = context.other.value<ClickHandlerContext>();
if (const auto controller = my.sessionWindow.get()) { if (const auto controller = my.sessionWindow.get()) {
const auto &data = controller->session().data();
const auto webpage = media->webpage(); const auto webpage = media->webpage();
if (!webpage) { if (!webpage) {
return; return;

View file

@ -89,7 +89,7 @@ void PaintWaveform(
const auto active = stm->msgWaveformActive; const auto active = stm->msgWaveformActive;
const auto inactive = stm->msgWaveformInactive; const auto inactive = stm->msgWaveformInactive;
const auto wfSize = wf const auto wfSize = wf
? wf->size() ? int(wf->size())
: ::Media::Player::kWaveformSamplesCount; : ::Media::Player::kWaveformSamplesCount;
const auto activeWidth = base::SafeRound(availableWidth * progress); const auto activeWidth = base::SafeRound(availableWidth * progress);

View file

@ -58,7 +58,7 @@ void Invoice::fillFromData(not_null<Data::Invoice*> invoice) {
statusText.entities.push_back({ statusText.entities.push_back({
EntityType::Bold, EntityType::Bold,
0, 0,
statusText.text.size() }); int(statusText.text.size()) });
statusText.text += ' ' + labelText().toUpper(); statusText.text += ' ' + labelText().toUpper();
_status.setMarkedText( _status.setMarkedText(
st::defaultTextStyle, st::defaultTextStyle,

View file

@ -24,10 +24,10 @@ namespace HistoryView {
namespace { namespace {
[[nodiscard]] TimeId TimeFromMatch( [[nodiscard]] TimeId TimeFromMatch(
const QStringRef &hours, QStringView hours,
const QStringRef &minutes1, QStringView minutes1,
const QStringRef &minutes2, QStringView minutes2,
const QStringRef &seconds) { QStringView seconds) {
auto ok1 = true; auto ok1 = true;
auto ok2 = true; auto ok2 = true;
auto ok3 = true; auto ok3 = true;
@ -71,10 +71,10 @@ TextWithEntities AddTimestampLinks(
offset = till; offset = till;
const auto time = TimeFromMatch( const auto time = TimeFromMatch(
m.capturedRef(1), m.capturedView(1),
m.capturedRef(2), m.capturedView(2),
m.capturedRef(3), m.capturedView(3),
m.capturedRef(4)); m.capturedView(4));
if (time < 0 || time > duration) { if (time < 0 || time > duration) {
continue; continue;
} }

View file

@ -1906,7 +1906,7 @@ void ListWidget::validateTrippleClickStartTime() {
} }
} }
void ListWidget::enterEventHook(QEvent *e) { void ListWidget::enterEventHook(QEnterEvent *e) {
mouseActionUpdate(QCursor::pos()); mouseActionUpdate(QCursor::pos());
return RpWidget::enterEventHook(e); return RpWidget::enterEventHook(e);
} }

View file

@ -169,7 +169,7 @@ private:
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void start(); void start();

View file

@ -199,7 +199,7 @@ ClickHandlerPtr ItemBase::getResultPreviewHandler() const {
} }
QString ItemBase::getResultThumbLetter() const { QString ItemBase::getResultThumbLetter() const {
auto parts = _result->_url.splitRef('/'); auto parts = QStringView(_result->_url).split('/');
if (!parts.isEmpty()) { if (!parts.isEmpty()) {
auto domain = parts.at(0); auto domain = parts.at(0);
if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others

View file

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "app.h" #include "app.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
#include "base/qt_adapters.h"
namespace Intro { namespace Intro {
namespace { namespace {
@ -512,7 +513,8 @@ void Widget::resetAccount() {
const auto &type = error.type(); const auto &type = error.type();
if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) { if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) {
const auto seconds = type.midRef( const auto seconds = base::StringViewMid(
type,
qstr("2FA_CONFIRM_WAIT_").size()).toInt(); qstr("2FA_CONFIRM_WAIT_").size()).toInt();
const auto days = (seconds + 59) / 86400; const auto days = (seconds + 59) / 86400;
const auto hours = ((seconds + 59) % 86400) / 3600; const auto hours = ((seconds + 59) % 86400) / 3600;

View file

@ -174,7 +174,11 @@ QByteArray FileParser::ReadFile(const QString &absolutePath, const QString &rela
QByteArray data; QByteArray data;
auto readUtf16Stream = [relativePath, absolutePath](auto &&stream) { auto readUtf16Stream = [relativePath, absolutePath](auto &&stream) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
stream.setEncoding(QStringConverter::Utf16);
#else // Qt >= 6.0.0
stream.setCodec("UTF-16"); stream.setCodec("UTF-16");
#endif // Qt < 6.0.0
auto string = stream.readAll(); auto string = stream.readAll();
if (stream.status() != QTextStream::Ok) { if (stream.status() != QTextStream::Ok) {
LOG(("Lang Error: Could not read UTF-16 data from '%1' ('%2')").arg(relativePath, absolutePath)); LOG(("Lang Error: Could not read UTF-16 data from '%1' ('%2')").arg(relativePath, absolutePath));

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "ui/text/text.h" #include "ui/text/text.h"
#include "base/qt_adapters.h"
namespace Lang { namespace Lang {
namespace { namespace {
@ -911,7 +912,7 @@ int NonZeroPartToInt(QString value) {
} }
} }
return (zeros > 0) return (zeros > 0)
? (zeros < value.size() ? value.midRef(zeros).toInt() : 0) ? (zeros < value.size() ? base::StringViewMid(value, zeros).toInt() : 0)
: (value.isEmpty() ? 0 : value.toInt()); : (value.isEmpty() ? 0 : value.toInt());
} }
@ -1008,11 +1009,11 @@ QString ReplaceTag<QString>::Replace(QString &&original, const QString &replacem
auto result = QString(); auto result = QString();
result.reserve(original.size() + replacement.size() - kTagReplacementSize); result.reserve(original.size() + replacement.size() - kTagReplacementSize);
if (replacementPosition > 0) { if (replacementPosition > 0) {
result.append(original.midRef(0, replacementPosition)); result.append(base::StringViewMid(original, 0, replacementPosition));
} }
result.append(replacement); result.append(replacement);
if (replacementPosition + kTagReplacementSize < original.size()) { if (replacementPosition + kTagReplacementSize < original.size()) {
result.append(original.midRef(replacementPosition + kTagReplacementSize)); result.append(base::StringViewMid(original, replacementPosition + kTagReplacementSize));
} }
return result; return result;
} }

View file

@ -24,7 +24,7 @@ TextWithEntities ReplaceTag<TextWithEntities>::Call(TextWithEntities &&original,
if (originalEntitiesCount != 0 || replacementEntitiesCount != 0) { if (originalEntitiesCount != 0 || replacementEntitiesCount != 0) {
result.entities.reserve(originalEntitiesCount + replacementEntitiesCount); result.entities.reserve(originalEntitiesCount + replacementEntitiesCount);
auto replacementEnd = replacementPosition + replacement.text.size(); auto replacementEnd = replacementPosition + int(replacement.text.size());
auto replacementEntity = replacement.entities.cbegin(); auto replacementEntity = replacement.entities.cbegin();
auto addReplacementEntitiesUntil = [&replacementEntity, &replacement, &result, replacementPosition, replacementEnd](int untilPosition) { auto addReplacementEntitiesUntil = [&replacementEntity, &replacement, &result, replacementPosition, replacementEnd](int untilPosition) {
while (replacementEntity != replacement.entities.cend()) { while (replacementEntity != replacement.entities.cend()) {
@ -52,8 +52,8 @@ TextWithEntities ReplaceTag<TextWithEntities>::Call(TextWithEntities &&original,
if (end > replacementPosition) { if (end > replacementPosition) {
end = end + replacement.text.size() - kTagReplacementSize; end = end + replacement.text.size() - kTagReplacementSize;
} }
offset = std::clamp(offset, 0, result.text.size()); offset = std::clamp(offset, 0, int(result.text.size()));
end = std::clamp(end, 0, result.text.size()); end = std::clamp(end, 0, int(result.text.size()));
// Add all replacement entities that start before the current original entity. // Add all replacement entities that start before the current original entity.
addReplacementEntitiesUntil(offset); addReplacementEntitiesUntil(offset);

View file

@ -165,7 +165,7 @@ private:
QStringList oldlogs = working.entryList(QStringList("log_start*.txt"), QDir::Files); QStringList oldlogs = working.entryList(QStringList("log_start*.txt"), QDir::Files);
for (QStringList::const_iterator i = oldlogs.cbegin(), e = oldlogs.cend(); i != e; ++i) { for (QStringList::const_iterator i = oldlogs.cbegin(), e = oldlogs.cend(); i != e; ++i) {
QString oldlog = cWorkingDir() + *i, oldlogend = i->mid(qstr("log_start").size()); QString oldlog = cWorkingDir() + *i, oldlogend = i->mid(qstr("log_start").size());
if (oldlogend.size() == 1 + qstr(".txt").size() && oldlogend.at(0).isDigit() && oldlogend.midRef(1) == qstr(".txt")) { if (oldlogend.size() == 1 + qstr(".txt").size() && oldlogend.at(0).isDigit() && base::StringViewMid(oldlogend, 1) == qstr(".txt")) {
bool removed = QFile(oldlog).remove(); bool removed = QFile(oldlog).remove();
LOG(("Old start log '%1' found, deleted: %2").arg(*i, Logs::b(removed))); LOG(("Old start log '%1' found, deleted: %2").arg(*i, Logs::b(removed)));
} }

View file

@ -531,8 +531,8 @@ bool MainWidget::shareUrl(
TextWithTags::Tags() TextWithTags::Tags()
}; };
MessageCursor cursor = { MessageCursor cursor = {
url.size() + 1, int(url.size()) + 1,
url.size() + 1 + text.size(), int(url.size()) + 1 + int(text.size()),
QFIXED_MAX QFIXED_MAX
}; };
auto history = peer->owner().history(peer); auto history = peer->owner().history(peer);
@ -558,7 +558,7 @@ bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) {
} }
const auto h = peer->owner().history(peer); const auto h = peer->owner().history(peer);
TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() }; TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() };
MessageCursor cursor = { botAndQuery.size(), botAndQuery.size(), QFIXED_MAX }; MessageCursor cursor = { int(botAndQuery.size()), int(botAndQuery.size()), QFIXED_MAX };
h->setLocalDraft(std::make_unique<Data::Draft>( h->setLocalDraft(std::make_unique<Data::Draft>(
textWithTags, textWithTags,
0, 0,

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QtEndian> #include <QtCore/QtEndian>
#include <QtCore/QBuffer> #include <QtCore/QBuffer>
#include <QtCore/QFile>
namespace Media { namespace Media {
namespace Clip { namespace Clip {

View file

@ -225,7 +225,7 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q
} }
// AV_NUM_DATA_POINTERS defined in AVFrame struct // AV_NUM_DATA_POINTERS defined in AVFrame struct
uint8_t *toData[AV_NUM_DATA_POINTERS] = { to.bits(), nullptr }; uint8_t *toData[AV_NUM_DATA_POINTERS] = { to.bits(), nullptr };
int toLinesize[AV_NUM_DATA_POINTERS] = { to.bytesPerLine(), 0 }; int toLinesize[AV_NUM_DATA_POINTERS] = { int(to.bytesPerLine()), 0 };
sws_scale(_swsContext, _frame->data, _frame->linesize, 0, _frame->height, toData, toLinesize); sws_scale(_swsContext, _frame->data, _frame->linesize, 0, _frame->height, toData, toLinesize);
} }
if (hasAlpha) { if (hasAlpha) {

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
#include <QtCore/QBuffer> #include <QtCore/QBuffer>
#include <QtCore/QFile>
namespace Core { namespace Core {
class FileLocation; class FileLocation;

View file

@ -164,7 +164,7 @@ void Panel::paintEvent(QPaintEvent *e) {
Ui::FillRoundRect(p, shadowedRect, st::menuBg, Ui::MenuCorners, nullptr, parts); Ui::FillRoundRect(p, shadowedRect, st::menuBg, Ui::MenuCorners, nullptr, parts);
} }
void Panel::enterEventHook(QEvent *e) { void Panel::enterEventHook(QEnterEvent *e) {
if (_ignoringEnterEvents || contentTooSmall()) return; if (_ignoringEnterEvents || contentTooSmall()) return;
_hideTimer.cancel(); _hideTimer.cancel();

View file

@ -44,7 +44,7 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:

View file

@ -149,7 +149,7 @@ void VolumeWidget::paintEvent(QPaintEvent *e) {
Ui::FillRoundRect(p, QRect(shadowedRect.x(), -st::roundRadiusSmall, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::roundRadiusSmall), st::menuBg, Ui::MenuCorners, nullptr, parts); Ui::FillRoundRect(p, QRect(shadowedRect.x(), -st::roundRadiusSmall, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::roundRadiusSmall), st::menuBg, Ui::MenuCorners, nullptr, parts);
} }
void VolumeWidget::enterEventHook(QEvent *e) { void VolumeWidget::enterEventHook(QEnterEvent *e) {
_hideTimer.stop(); _hideTimer.stop();
if (_a_appearance.animating()) { if (_a_appearance.animating()) {
onShowStart(); onShowStart();

View file

@ -59,7 +59,7 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEventHook(QEvent *e) override; void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override; void leaveEventHook(QEvent *e) override;
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View file

@ -160,7 +160,7 @@ QImage ConvertFrame(
// AV_NUM_DATA_POINTERS defined in AVFrame struct // AV_NUM_DATA_POINTERS defined in AVFrame struct
uint8_t *data[AV_NUM_DATA_POINTERS] = { storage.bits(), nullptr }; uint8_t *data[AV_NUM_DATA_POINTERS] = { storage.bits(), nullptr };
int linesize[AV_NUM_DATA_POINTERS] = { storage.bytesPerLine(), 0 }; int linesize[AV_NUM_DATA_POINTERS] = { int(storage.bytesPerLine()), 0 };
sws_scale( sws_scale(
stream.swscale.get(), stream.swscale.get(),

View file

@ -55,7 +55,7 @@ static_assert(kDisplaySkipped != kTimeUnknown);
0, 0,
}; };
uint8_t *dstData[AV_NUM_DATA_POINTERS] = { result.bits(), nullptr }; uint8_t *dstData[AV_NUM_DATA_POINTERS] = { result.bits(), nullptr };
int dstLinesize[AV_NUM_DATA_POINTERS] = { result.bytesPerLine(), 0 }; int dstLinesize[AV_NUM_DATA_POINTERS] = { int(result.bytesPerLine()), 0 };
sws_scale( sws_scale(
swscale.get(), swscale.get(),

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/gl/gl_image.h" #include "ui/gl/gl_image.h"
#include "ui/gl/gl_primitives.h" #include "ui/gl/gl_primitives.h"
#include <QtGui/QOpenGLBuffer> #include <QOpenGLBuffer>
namespace Media::View { namespace Media::View {

View file

@ -74,13 +74,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "facades.h" #include "facades.h"
#include "styles/style_media_view.h" #include "styles/style_media_view.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "base/qt_adapters.h"
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#include "platform/mac/touchbar/mac_touchbar_media_view.h" #include "platform/mac/touchbar/mac_touchbar_media_view.h"
#endif // Q_OS_MAC #endif // Q_OS_MAC
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QDesktopWidget>
#include <QtCore/QBuffer> #include <QtCore/QBuffer>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
@ -4430,7 +4430,7 @@ bool OverlayWidget::handleContextMenu(std::optional<QPoint> position) {
} }
bool OverlayWidget::handleTouchEvent(not_null<QTouchEvent*> e) { bool OverlayWidget::handleTouchEvent(not_null<QTouchEvent*> e) {
if (e->device()->type() != QTouchDevice::TouchScreen) { if (e->device()->type() != base::TouchDevice::TouchScreen) {
return false; return false;
} else if (e->type() == QEvent::TouchBegin } else if (e->type() == QEvent::TouchBegin
&& !e->touchPoints().isEmpty() && !e->touchPoints().isEmpty()

View file

@ -33,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include "styles/style_media_view.h" #include "styles/style_media_view.h"
#include "base/qt_adapters.h"
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <QtGui/QScreen> #include <QtGui/QScreen>
@ -51,7 +50,7 @@ constexpr auto kMsInSecond = 1000;
} }
[[nodiscard]] QRect ScreenFromPosition(QPoint point) { [[nodiscard]] QRect ScreenFromPosition(QPoint point) {
const auto screen = base::QScreenNearestTo(point); const auto screen = QGuiApplication::screenAt(point);
const auto use = screen ? screen : QGuiApplication::primaryScreen(); const auto use = screen ? screen : QGuiApplication::primaryScreen();
return use return use
? use->availableGeometry() ? use->availableGeometry()

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/gl/gl_image.h" #include "ui/gl/gl_image.h"
#include "ui/gl/gl_primitives.h" #include "ui/gl/gl_primitives.h"
#include <QtGui/QOpenGLBuffer> #include <QOpenGLBuffer>
namespace Media::View { namespace Media::View {

View file

@ -107,7 +107,7 @@ SerializedRequest DcKeyBinder::prepareRequest(
DcKeyBindState DcKeyBinder::handleResponse(const mtpBuffer &response) { DcKeyBindState DcKeyBinder::handleResponse(const mtpBuffer &response) {
Expects(!response.isEmpty()); Expects(!response.isEmpty());
auto from = response.begin(); auto from = response.data();
const auto end = from + response.size(); const auto end = from + response.size();
auto error = MTPRpcError(); auto error = MTPRpcError();
if (response[0] == mtpc_boolTrue) { if (response[0] == mtpc_boolTrue) {

View file

@ -710,7 +710,7 @@ int64 TlsSocket::read(bytes::span buffer) {
while (_incomingGoodDataLimit) { while (_incomingGoodDataLimit) {
const auto available = std::min( const auto available = std::min(
_incomingGoodDataLimit, _incomingGoodDataLimit,
_incoming.size() - _incomingGoodDataOffset); int(_incoming.size()) - _incomingGoodDataOffset);
if (available <= 0) { if (available <= 0) {
return written; return written;
} }

View file

@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/facade.h" #include "mtproto/facade.h"
#include "mtproto/connection_tcp.h" #include "mtproto/connection_tcp.h"
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "base/qt_adapters.h"
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpression>
@ -754,10 +753,12 @@ bool DcOptions::loadFromFile(const QString &path) {
return false; return false;
} }
QTextStream stream(&f); QTextStream stream(&f);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8"); stream.setCodec("UTF-8");
#endif // Qt < 6.0.0
while (!stream.atEnd()) { while (!stream.atEnd()) {
auto line = stream.readLine(); auto line = stream.readLine();
auto components = line.split(QRegularExpression(R"(\s)"), base::QStringSkipEmptyParts); auto components = line.split(QRegularExpression(R"(\s)"), Qt::SkipEmptyParts);
if (components.isEmpty() || components[0].startsWith('#')) { if (components.isEmpty() || components[0].startsWith('#')) {
continue; continue;
} }
@ -816,7 +817,9 @@ bool DcOptions::writeToFile(const QString &path) const {
return false; return false;
} }
QTextStream stream(&f); QTextStream stream(&f);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8"); stream.setCodec("UTF-8");
#endif // Qt < 6.0.0
ReadLocker lock(this); ReadLocker lock(this);
for (const auto &item : _data) { for (const auto &item : _data) {

Some files were not shown because too many files have changed in this diff Show more