mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Add Qt 6 support
Tested only on Linux so far
This commit is contained in:
parent
ea10cf5758
commit
847c01d605
154 changed files with 382 additions and 339 deletions
|
@ -1197,7 +1197,7 @@ else()
|
|||
)
|
||||
endif()
|
||||
|
||||
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
|
||||
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION OR DESKTOP_APP_QT6)
|
||||
remove_target_sources(Telegram ${src_loc}
|
||||
platform/linux/linux_wayland_integration.cpp
|
||||
)
|
||||
|
@ -1289,10 +1289,16 @@ elseif (APPLE)
|
|||
endif()
|
||||
else()
|
||||
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
|
||||
PRIVATE
|
||||
desktop-app::external_statusnotifieritem
|
||||
desktop-app::external_dbusmenu_qt
|
||||
desktop-app::external_glibmm
|
||||
desktop-app::external_glib
|
||||
)
|
||||
|
@ -1309,8 +1315,14 @@ else()
|
|||
target_link_libraries(Telegram
|
||||
PRIVATE
|
||||
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()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ BlockedPeers::Slice TLToSlice(
|
|||
Data::Session &owner) {
|
||||
const auto create = [&](int count, const QVector<MTPPeerBlocked> &list) {
|
||||
auto slice = BlockedPeers::Slice();
|
||||
slice.total = std::max(count, list.size());
|
||||
slice.total = std::max(count, int(list.size()));
|
||||
slice.list.reserve(list.size());
|
||||
for (const auto &contact : list) {
|
||||
contact.match([&](const MTPDpeerBlocked &data) {
|
||||
|
|
|
@ -212,7 +212,7 @@ void SendExistingPhoto(
|
|||
}
|
||||
|
||||
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;
|
||||
if (!Ui::Emoji::Find(full.data(), full.data() + full.size(), &length)
|
||||
|| length != full.size()) {
|
||||
|
|
|
@ -159,7 +159,7 @@ struct State {
|
|||
auto &entry = context->cache(item);
|
||||
entry.requestId = 0;
|
||||
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) {
|
||||
peers.push_back(UserId(id));
|
||||
}
|
||||
|
|
|
@ -478,7 +478,7 @@ void ApiWrap::sendMessageFail(
|
|||
link)));
|
||||
} else if (error.type().startsWith(qstr("SLOWMODE_WAIT_"))) {
|
||||
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()) {
|
||||
const auto seconds = channel->slowmodeSeconds();
|
||||
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.
|
||||
// This should give us the first message with date >= desired_date.
|
||||
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 limit = 1;
|
||||
const auto maxId = 0;
|
||||
|
|
|
@ -74,7 +74,7 @@ void HostInput::correctValue(
|
|||
QString newText;
|
||||
int newCursor = nowCursor;
|
||||
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] == ',') {
|
||||
newText.append('.');
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ void Base64UrlInput::correctValue(
|
|||
QString newText;
|
||||
newText.reserve(now.size());
|
||||
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];
|
||||
if ((ch >= '0' && ch <= '9')
|
||||
|| (ch >= 'a' && ch <= 'z')
|
||||
|
@ -537,8 +537,8 @@ void ProxyRow::showMenu() {
|
|||
_deleteClicks.fire({});
|
||||
});
|
||||
}
|
||||
const auto parentTopLeft = window()->mapToGlobal({ 0, 0 });
|
||||
const auto buttonTopLeft = _menuToggle->mapToGlobal({ 0, 0 });
|
||||
const auto parentTopLeft = window()->mapToGlobal(QPoint());
|
||||
const auto buttonTopLeft = _menuToggle->mapToGlobal(QPoint());
|
||||
const auto parent = QRect(parentTopLeft, window()->size());
|
||||
const auto button = QRect(buttonTopLeft, _menuToggle->size());
|
||||
const auto bottom = button.y()
|
||||
|
|
|
@ -39,11 +39,6 @@ using DictState = BlobState;
|
|||
using QueryCallback = Fn<void(const QString &)>;
|
||||
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 {
|
||||
public:
|
||||
Inner(
|
||||
|
|
|
@ -478,7 +478,7 @@ void Rows::showMenu(int index) {
|
|||
}
|
||||
}
|
||||
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 parent = QRect(parentTopLeft, window()->size());
|
||||
const auto button = QRect(buttonTopLeft, toggle.size());
|
||||
|
|
|
@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h"
|
||||
#include "styles/style_passport.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -525,7 +526,7 @@ void PasscodeBox::setPasswordFail(
|
|||
const MTP::Error &error) {
|
||||
const auto prefix = qstr("EMAIL_UNCONFIRMED_");
|
||||
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();
|
||||
_setRequest = 0;
|
||||
|
|
|
@ -1240,7 +1240,7 @@ int PeerListContent::resizeGetHeight(int newWidth) {
|
|||
return belowTop + _belowHeight;
|
||||
}
|
||||
|
||||
void PeerListContent::enterEventHook(QEvent *e) {
|
||||
void PeerListContent::enterEventHook(QEnterEvent *e) {
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -622,7 +622,7 @@ protected:
|
|||
int visibleBottom) override;
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
|
|
@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_cloud_password.h"
|
||||
#include "main/main_session.h"
|
||||
|
@ -710,7 +709,7 @@ void EditRestrictedBox::showRestrictUntil() {
|
|||
highlighted,
|
||||
[this](const QDate &date) {
|
||||
setRestrictUntil(
|
||||
static_cast<int>(base::QDateToDateTime(date).toTime_t()));
|
||||
static_cast<int>(date.startOfDay().toSecsSinceEpoch()));
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
_restrictUntilBox->setMaxDate(
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
int visibleBottom) override;
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void mouseMoveEvent(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
|||
|
||||
auto p = StickersPack();
|
||||
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);
|
||||
if (!doc || !doc->sticker()) continue;
|
||||
|
||||
|
@ -532,7 +532,7 @@ void StickerSetBox::Inner::installDone(
|
|||
auto &order = isMasks
|
||||
? stickers.maskSetsOrderRef()
|
||||
: stickers.setsOrderRef();
|
||||
const auto insertAtIndex = 0, currentIndex = order.indexOf(_setId);
|
||||
const auto insertAtIndex = 0, currentIndex = int(order.indexOf(_setId));
|
||||
if (currentIndex != insertAtIndex) {
|
||||
if (currentIndex > 0) {
|
||||
order.removeAt(currentIndex);
|
||||
|
|
|
@ -50,7 +50,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_calls.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtCore/QTimer>
|
||||
|
|
|
@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "webrtc/webrtc_video_track.h"
|
||||
#include "styles/style_calls.h"
|
||||
|
||||
#include <QtGui/QOpenGLShader>
|
||||
#include <QtGui/QOpenGLBuffer>
|
||||
#include <QOpenGLShader>
|
||||
#include <QOpenGLBuffer>
|
||||
|
||||
namespace Calls {
|
||||
namespace {
|
||||
|
|
|
@ -55,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_calls.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QScreen>
|
||||
|
|
|
@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_calls.h"
|
||||
|
||||
#include <QtGui/QtEvents>
|
||||
#include <QtGui/QOpenGLShader>
|
||||
#include <QOpenGLShader>
|
||||
|
||||
namespace Calls::Group {
|
||||
namespace {
|
||||
|
|
|
@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer.h"
|
||||
#include "styles/style_calls.h"
|
||||
|
||||
#include <QtGui/QOpenGLShader>
|
||||
#include <QOpenGLShader>
|
||||
|
||||
namespace Calls::Group {
|
||||
namespace {
|
||||
|
|
|
@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/gl/gl_surface.h"
|
||||
#include "ui/gl/gl_image.h"
|
||||
|
||||
#include <QtGui/QOpenGLBuffer>
|
||||
#include <QtGui/QOpenGLShaderProgram>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
namespace Webrtc {
|
||||
struct FrameWithInfo;
|
||||
|
|
|
@ -160,7 +160,7 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void BotKeyboard::enterEventHook(QEvent *e) {
|
||||
void BotKeyboard::enterEventHook(QEnterEvent *e) {
|
||||
_lastMousePos = QCursor::pos();
|
||||
updateSelected();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -132,7 +132,7 @@ void CreateCacheFilePath() {
|
|||
}
|
||||
list.push_back(entry);
|
||||
}
|
||||
result.maxKeyLength = std::max(result.maxKeyLength, key.size());
|
||||
result.maxKeyLength = std::max(result.maxKeyLength, int(key.size()));
|
||||
}
|
||||
result.version = version;
|
||||
return result;
|
||||
|
|
|
@ -166,7 +166,7 @@ void EmojiColorPicker::showEmoji(EmojiPtr emoji) {
|
|||
_ignoreShow = false;
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -495,7 +495,7 @@ void SuggestionsWidget::triggerRow(const Row &row) const {
|
|||
_triggered.fire(row.emoji->text());
|
||||
}
|
||||
|
||||
void SuggestionsWidget::enterEventHook(QEvent *e) {
|
||||
void SuggestionsWidget::enterEventHook(QEnterEvent *e) {
|
||||
if (!inner().contains(mapToInner(QCursor::pos()))) {
|
||||
clearMouseSelection();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
void scrollByWheelEvent(not_null<QWheelEvent*> e);
|
||||
|
|
|
@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_chat.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
|
@ -84,7 +85,7 @@ private:
|
|||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
@ -257,19 +258,19 @@ void FieldAutocomplete::showFiltered(
|
|||
|
||||
query = query.toLower();
|
||||
auto type = Type::Stickers;
|
||||
auto plainQuery = query.midRef(0);
|
||||
auto plainQuery = QStringView(query);
|
||||
switch (query.at(0).unicode()) {
|
||||
case '@':
|
||||
type = Type::Mentions;
|
||||
plainQuery = query.midRef(1);
|
||||
plainQuery = base::StringViewMid(query, 1);
|
||||
break;
|
||||
case '#':
|
||||
type = Type::Hashtags;
|
||||
plainQuery = query.midRef(1);
|
||||
plainQuery = base::StringViewMid(query, 1);
|
||||
break;
|
||||
case '/':
|
||||
type = Type::BotCommands;
|
||||
plainQuery = query.midRef(1);
|
||||
plainQuery = base::StringViewMid(query, 1);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtCore/QStack>
|
||||
|
@ -93,7 +94,7 @@ QString FieldTagMimeProcessor::tagFromMimeTag(const QString &mimeTag) {
|
|||
const auto userId = _controller->session().userId();
|
||||
auto match = QRegularExpression(":(\\d+)$").match(mimeTag);
|
||||
if (!match.hasMatch()
|
||||
|| match.capturedRef(1).toULongLong() != userId.bare) {
|
||||
|| match.capturedView(1).toULongLong() != userId.bare) {
|
||||
return QString();
|
||||
}
|
||||
return mimeTag.mid(0, mimeTag.size() - match.capturedLength());
|
||||
|
@ -380,7 +381,7 @@ InlineBotQuery ParseInlineBotQuery(
|
|||
< inlineUsernameStart + inlineUsernameLength)) {
|
||||
return InlineBotQuery();
|
||||
}
|
||||
auto username = text.midRef(inlineUsernameStart, inlineUsernameLength);
|
||||
auto username = base::StringViewMid(text, inlineUsernameStart, inlineUsernameLength);
|
||||
if (username != result.username) {
|
||||
result.username = username.toString();
|
||||
if (const auto peer = session->data().peerByUsername(result.username)) {
|
||||
|
@ -661,7 +662,7 @@ void MessageLinksParser::parse() {
|
|||
}
|
||||
}
|
||||
const auto range = LinkRange {
|
||||
domainOffset,
|
||||
int(domainOffset),
|
||||
static_cast<int>(p - start - domainOffset),
|
||||
QString()
|
||||
};
|
||||
|
@ -685,8 +686,8 @@ void MessageLinksParser::apply(
|
|||
const auto current = _list.current();
|
||||
const auto computeLink = [&](const LinkRange &range) {
|
||||
return range.custom.isEmpty()
|
||||
? text.midRef(range.start, range.length)
|
||||
: range.custom.midRef(0);
|
||||
? base::StringViewMid(text, range.start, range.length)
|
||||
: QStringView(range.custom);
|
||||
};
|
||||
const auto changed = [&] {
|
||||
if (current.size() != count) {
|
||||
|
|
|
@ -184,7 +184,7 @@ void AddExceptions() {
|
|||
return word.utf16();
|
||||
}) | ranges::views::filter([](const auto &word) {
|
||||
return !(Platform::Spellchecker::IsWordInDictionary(word)
|
||||
|| Spellchecker::IsWordSkippable(&word));
|
||||
|| Spellchecker::IsWordSkippable(word));
|
||||
}) | ranges::to_vector;
|
||||
|
||||
ranges::for_each(exceptions, Platform::Spellchecker::AddWord);
|
||||
|
|
|
@ -207,7 +207,7 @@ void TabbedPanel::moveByBottom() {
|
|||
updateContentHeight();
|
||||
}
|
||||
|
||||
void TabbedPanel::enterEventHook(QEvent *e) {
|
||||
void TabbedPanel::enterEventHook(QEnterEvent *e) {
|
||||
Core::App().registerLeaveSubscription(this);
|
||||
showAnimated();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
~TabbedPanel();
|
||||
|
||||
protected:
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void otherEnter();
|
||||
void otherLeave();
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/ui_integration.h"
|
||||
#include "chat_helpers/emoji_keywords.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_last_input.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 "app.h"
|
||||
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtCore/QMimeDatabase>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
|
@ -830,7 +830,7 @@ bool Application::openCustomUrl(
|
|||
|| passcodeLocked()) {
|
||||
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;
|
||||
|
||||
using namespace qthelp;
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session.h"
|
||||
#include "storage/storage_domain.h"
|
||||
#include "data/data_session.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "mainwindow.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 separator = QString::fromUtf8("\n\xE2\x80\xA2 ");
|
||||
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);
|
||||
}
|
||||
return result.replace(simple, separator);
|
||||
|
|
|
@ -288,6 +288,7 @@ void Launcher::init() {
|
|||
QApplication::setApplicationName(qsl("TelegramDesktop"));
|
||||
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
|
||||
// any "are you sure you want to close this window?" dialogs
|
||||
// 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
|
||||
// more info: https://doc.qt.io/qt-5/qguiapplication.html#isFallbackSessionManagementEnabled
|
||||
QApplication::setFallbackSessionManagementEnabled(false);
|
||||
#endif // Qt < 6.0.0
|
||||
|
||||
initHook();
|
||||
}
|
||||
|
@ -402,7 +404,7 @@ void Launcher::prepareSettings() {
|
|||
if (!path.isEmpty()) {
|
||||
auto info = QFileInfo(path);
|
||||
if (info.isSymLink()) {
|
||||
info = info.symLinkTarget();
|
||||
info = QFileInfo(info.symLinkTarget());
|
||||
}
|
||||
if (info.exists()) {
|
||||
const auto dir = info.absoluteDir().absolutePath();
|
||||
|
|
|
@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "history/history.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
@ -100,7 +101,7 @@ bool SetLanguage(
|
|||
Window::SessionController *controller,
|
||||
const Match &match,
|
||||
const QVariant &context) {
|
||||
if (match->capturedRef(1).isEmpty()) {
|
||||
if (match->capturedView(1).isEmpty()) {
|
||||
ShowLanguagesBox();
|
||||
} else {
|
||||
const auto languageId = match->captured(2);
|
||||
|
@ -688,7 +689,7 @@ QString TryConvertUrlToLocal(QString url) {
|
|||
auto matchOptions = RegExOption::CaseInsensitive;
|
||||
auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions);
|
||||
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)) {
|
||||
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2));
|
||||
} 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)) {
|
||||
return false;
|
||||
}
|
||||
const auto command = urlTrimmed.midRef(qstr("tg://").size());
|
||||
const auto command = base::StringViewMid(urlTrimmed, qstr("tg://").size());
|
||||
|
||||
using namespace qthelp;
|
||||
const auto matchOptions = RegExOption::CaseInsensitive;
|
||||
|
|
|
@ -265,7 +265,10 @@ void Sandbox::socketReading() {
|
|||
}
|
||||
_localSocketReadData.append(_localSocket.readAll());
|
||||
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) {
|
||||
psActivateProcess(pid);
|
||||
}
|
||||
|
@ -388,7 +391,7 @@ void Sandbox::readClients() {
|
|||
QString cmds(QString::fromLatin1(i->second));
|
||||
int32 from = 0, l = cmds.length();
|
||||
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:"))) {
|
||||
execExternal(cmds.mid(from + 4, to - from - 4));
|
||||
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();
|
||||
i->first->write(response.data(), response.size());
|
||||
} 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;
|
||||
}
|
||||
|
@ -571,7 +574,7 @@ void Sandbox::processPostponedCalls(int level) {
|
|||
bool Sandbox::nativeEventFilter(
|
||||
const QByteArray &eventType,
|
||||
void *message,
|
||||
long *result) {
|
||||
base::NativeEventResult *result) {
|
||||
registerEnterFromEventLoop();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "mtproto/mtproto_proxy_data.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtNetwork/QLocalServer>
|
||||
|
@ -85,7 +86,7 @@ private:
|
|||
bool nativeEventFilter(
|
||||
const QByteArray &eventType,
|
||||
void *message,
|
||||
long *result) override;
|
||||
base::NativeEventResult *result) override;
|
||||
void processPostponedCalls(int level);
|
||||
void singleInstanceChecked();
|
||||
void launchApplication();
|
||||
|
|
|
@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/platform_specific.h"
|
||||
#include "base/parse_helper.h"
|
||||
|
||||
#include <QtWidgets/QShortcut>
|
||||
#include <QShortcut>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
|
|
@ -582,7 +582,7 @@ bool ParseCommonMap(
|
|||
if ((*version).isString()) {
|
||||
const auto string = (*version).toString();
|
||||
if (const auto index = string.indexOf(':'); index > 0) {
|
||||
return string.midRef(0, index).toULongLong();
|
||||
return base::StringViewMid(string, 0, index).toULongLong();
|
||||
}
|
||||
return string.toULongLong();
|
||||
} else if ((*version).isDouble()) {
|
||||
|
@ -1014,7 +1014,7 @@ auto MtpChecker::parseText(const QByteArray &text) const
|
|||
return false;
|
||||
}
|
||||
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) {
|
||||
LOG(("Update Error: MTP entry '%1' is bad for version %2."
|
||||
).arg(full
|
||||
|
|
|
@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "countries/countries_instance.h"
|
||||
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace Countries {
|
||||
namespace {
|
||||
|
||||
|
@ -328,11 +330,11 @@ FormatResult CountriesInstance::format(FormatArgs args) {
|
|||
if (phoneNumber.startsWith(callingCode.callingCode)) {
|
||||
const auto codeSize = callingCode.callingCode.size();
|
||||
for (const auto &prefix : callingCode.prefixes) {
|
||||
if (prefix.startsWith(phoneNumber.midRef(codeSize))) {
|
||||
if (prefix.startsWith(base::StringViewMid(phoneNumber, codeSize))) {
|
||||
isPrefix = true;
|
||||
}
|
||||
if ((codeSize + prefix.size()) > bestLength &&
|
||||
phoneNumber.midRef(codeSize).startsWith(prefix)) {
|
||||
base::StringViewMid(phoneNumber, codeSize).startsWith(prefix)) {
|
||||
bestCountryPtr = &country;
|
||||
bestCallingCodePtr = &callingCode;
|
||||
bestLength = codeSize + prefix.size();
|
||||
|
|
|
@ -988,7 +988,7 @@ QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform) {
|
|||
// 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
|
||||
// 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 bitShift = (i * 5) % 8;
|
||||
auto value = (static_cast<uint16>(waveform[i]) & 0x1F) << bitShift;
|
||||
|
@ -1337,7 +1337,7 @@ bool DocumentData::isAudioFile() const {
|
|||
}
|
||||
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") };
|
||||
return ranges::contains(types, left);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ void ResolveDocument(
|
|||
location.accessDisable();
|
||||
});
|
||||
const auto path = location.name();
|
||||
if (Core::MimeTypeForFile(path).name().startsWith("image/")
|
||||
if (Core::MimeTypeForFile(QFileInfo(path)).name().startsWith("image/")
|
||||
&& QImageReader(path).canRead()) {
|
||||
showDocument();
|
||||
return true;
|
||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace Data {
|
||||
namespace {
|
||||
|
@ -40,7 +39,7 @@ int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) {
|
|||
return (hours + 1) * 3600 - (now - online);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_document.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/text/text_entity.h"
|
||||
|
||||
|
@ -27,7 +26,7 @@ QString SiteNameFromUrl(const QString &url) {
|
|||
if (m.hasMatch()) pretty = pretty.mid(m.capturedLength());
|
||||
int32 slash = pretty.indexOf('/');
|
||||
if (slash > 0) pretty = pretty.mid(0, slash);
|
||||
QStringList components = pretty.split('.', base::QStringSkipEmptyParts);
|
||||
QStringList components = pretty.split('.', Qt::SkipEmptyParts);
|
||||
if (components.size() >= 2) {
|
||||
components = components.mid(components.size() - 2);
|
||||
return components.at(0).at(0).toUpper() + components.at(0).mid(1) + '.' + components.at(1);
|
||||
|
|
|
@ -679,7 +679,7 @@ void Stickers::setPackAndEmoji(
|
|||
|
||||
auto p = StickersPack();
|
||||
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);
|
||||
if (!document || !document->sticker()) continue;
|
||||
|
||||
|
@ -1302,7 +1302,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
|||
set->stickers = pack;
|
||||
set->emoji.clear();
|
||||
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;
|
||||
|
||||
auto &pack = v[i].c_stickerPack();
|
||||
|
@ -1312,7 +1312,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
|||
|
||||
StickersPack p;
|
||||
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);
|
||||
if (!doc || !doc->sticker()) continue;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace Dialogs {
|
||||
namespace {
|
||||
|
@ -1619,7 +1620,7 @@ void InnerWidget::updateDialogRow(
|
|||
}
|
||||
}
|
||||
|
||||
void InnerWidget::enterEventHook(QEvent *e) {
|
||||
void InnerWidget::enterEventHook(QEnterEvent *e) {
|
||||
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) {
|
||||
_hashtagFilter = QString();
|
||||
if (!_hashtagResults.empty()) {
|
||||
|
@ -1863,7 +1864,7 @@ void InnerWidget::onHashtagFilterUpdate(QStringRef newFilter) {
|
|||
if (!recent.isEmpty()) {
|
||||
_hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit));
|
||||
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()) {
|
||||
_hashtagResults.push_back(std::make_unique<HashtagResult>(tag.first));
|
||||
if (_hashtagResults.size() == kHashtagResultsLimit) break;
|
||||
|
@ -2291,7 +2292,7 @@ void InnerWidget::searchInChat(Key key, PeerData *from) {
|
|||
_searchFromPeer = from;
|
||||
if (_searchInChat) {
|
||||
_controller->closeFolder();
|
||||
onHashtagFilterUpdate(QStringRef());
|
||||
onHashtagFilterUpdate(QStringView());
|
||||
_cancelSearchInChat->show();
|
||||
refreshSearchInChatLabel();
|
||||
} else {
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
void searchInChat(Key key, PeerData *from);
|
||||
|
||||
void applyFilterUpdate(QString newFilter, bool force = false);
|
||||
void onHashtagFilterUpdate(QStringRef newFilter);
|
||||
void onHashtagFilterUpdate(QStringView newFilter);
|
||||
|
||||
PeerData *updateFromParentDrag(QPoint globalPosition);
|
||||
|
||||
|
@ -148,7 +148,7 @@ protected:
|
|||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_chat.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtCore/QMimeData>
|
||||
|
||||
|
@ -1475,12 +1476,12 @@ void Widget::showSearchFrom() {
|
|||
void Widget::onFilterCursorMoved(int from, int to) {
|
||||
if (to < 0) to = _filter->cursorPosition();
|
||||
QString t = _filter->getLastText();
|
||||
QStringRef r;
|
||||
QStringView r;
|
||||
for (int start = to; start > 0;) {
|
||||
--start;
|
||||
if (t.size() <= start) break;
|
||||
if (t.at(start) == '#') {
|
||||
r = t.midRef(start, to - start);
|
||||
r = base::StringViewMid(t, start, to - start);
|
||||
break;
|
||||
}
|
||||
if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break;
|
||||
|
@ -1495,7 +1496,9 @@ void Widget::onCompleteHashtag(QString tag) {
|
|||
--start;
|
||||
if (t.size() <= start) break;
|
||||
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) {
|
||||
if (t.at(cur) != tag.at(cur - start - 1)) break;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void Crop::applyTransform(
|
|||
const auto cropHolder = QRectF(QPointF(), scaledImageSize);
|
||||
const auto cropHolderCenter = cropHolder.center();
|
||||
|
||||
auto matrix = QMatrix()
|
||||
auto matrix = QTransform()
|
||||
.translate(cropHolderCenter.x(), cropHolderCenter.y())
|
||||
.scale(flipped ? -1 : 1, 1)
|
||||
.rotate(angle)
|
||||
|
@ -151,12 +151,12 @@ void Crop::setCropPaint(QRectF &&rect) {
|
|||
}
|
||||
|
||||
void Crop::convertCropPaintToOriginal() {
|
||||
const auto cropHolder = QMatrix()
|
||||
const auto cropHolder = QTransform()
|
||||
.scale(_ratio.w, _ratio.h)
|
||||
.mapRect(QRectF(QPointF(), FlipSizeByRotation(_imageSize, _angle)));
|
||||
const auto cropHolderCenter = cropHolder.center();
|
||||
|
||||
const auto matrix = QMatrix()
|
||||
const auto matrix = QTransform()
|
||||
.translate(cropHolderCenter.x(), cropHolderCenter.y())
|
||||
.rotate(-_angle)
|
||||
.scale((_flipped ? -1 : 1) * 1. / _ratio.w, 1. / _ratio.h)
|
||||
|
|
|
@ -133,7 +133,7 @@ void Paint::applyTransform(QRect geometry, int angle, bool flipped) {
|
|||
setGeometry(geometry);
|
||||
const auto size = geometry.size();
|
||||
|
||||
const auto rotatedImageSize = QMatrix()
|
||||
const auto rotatedImageSize = QTransform()
|
||||
.rotate(angle)
|
||||
.mapRect(QRect(QPoint(), _imageSize));
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ Utf8String FillLeft(const Utf8String &data, int length, char filler) {
|
|||
}
|
||||
auto result = Utf8String();
|
||||
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(data);
|
||||
|
@ -1806,7 +1806,7 @@ Utf8String FormatDateTime(
|
|||
if (!date) {
|
||||
return Utf8String();
|
||||
}
|
||||
const auto value = QDateTime::fromTime_t(date);
|
||||
const auto value = QDateTime::fromSecsSinceEpoch(date);
|
||||
return (QString("%1") + dateSeparator + "%2" + dateSeparator + "%3"
|
||||
+ separator + "%4" + timeSeparator + "%5" + timeSeparator + "%6"
|
||||
).arg(value.date().day(), 2, 10, QChar('0')
|
||||
|
|
|
@ -736,7 +736,7 @@ void ApiWrap::requestUserpics(
|
|||
|
||||
auto startInfo = result.match(
|
||||
[](const MTPDphotos_photos &data) {
|
||||
return Data::UserpicsInfo{ data.vphotos().v.size() };
|
||||
return Data::UserpicsInfo{ int(data.vphotos().v.size()) };
|
||||
}, [](const MTPDphotos_photosSlice &data) {
|
||||
return Data::UserpicsInfo{ data.vcount().v };
|
||||
});
|
||||
|
@ -968,7 +968,7 @@ void ApiWrap::requestMessagesCount(int localSplitIndex) {
|
|||
|
||||
const auto count = result.match(
|
||||
[](const MTPDmessages_messages &data) {
|
||||
return data.vmessages().v.size();
|
||||
return int(data.vmessages().v.size());
|
||||
}, [](const MTPDmessages_messagesSlice &data) {
|
||||
return data.vcount().v;
|
||||
}, [](const MTPDmessages_channelMessages &data) {
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "export/output/export_output_result.h"
|
||||
#include "export/output/export_output_stats.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDir>
|
||||
|
@ -102,10 +103,10 @@ QString File::PrepareRelativePath(
|
|||
|
||||
// Not lastIndexOf('.') so that "file.tar.xz" won't be messed up.
|
||||
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)
|
||||
? suggested.midRef(position)
|
||||
: QStringRef();
|
||||
? base::StringViewMid(suggested, position)
|
||||
: QStringView();
|
||||
const auto relativePart = [&](int attempt) {
|
||||
auto result = base + QString(" (%1)").arg(attempt);
|
||||
result.append(extension);
|
||||
|
|
|
@ -283,12 +283,12 @@ bool DisplayDate(TimeId date, TimeId previousDate) {
|
|||
if (!previousDate) {
|
||||
return true;
|
||||
}
|
||||
return QDateTime::fromTime_t(date).date()
|
||||
!= QDateTime::fromTime_t(previousDate).date();
|
||||
return QDateTime::fromSecsSinceEpoch(date).date()
|
||||
!= QDateTime::fromSecsSinceEpoch(previousDate).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) {
|
||||
switch (index) {
|
||||
case 1: return "January";
|
||||
|
@ -314,7 +314,7 @@ QByteArray FormatDateText(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)
|
||||
+ ':'
|
||||
+ Data::NumberToString(parsed.minute(), 2);
|
||||
|
@ -1256,8 +1256,8 @@ bool HtmlWriter::Wrap::messageNeedsWrap(
|
|||
return true;
|
||||
} else if (message.viaBotId != previous->viaBotId) {
|
||||
return true;
|
||||
} else if (QDateTime::fromTime_t(previous->date).date()
|
||||
!= QDateTime::fromTime_t(message.date).date()) {
|
||||
} else if (QDateTime::fromSecsSinceEpoch(previous->date).date()
|
||||
!= QDateTime::fromSecsSinceEpoch(message.date).date()) {
|
||||
return true;
|
||||
} else if (message.forwarded != previous->forwarded
|
||||
|| message.showForwardedAsOriginal != previous->showForwardedAsOriginal
|
||||
|
|
|
@ -71,7 +71,7 @@ QByteArray SerializeString(const QByteArray &value) {
|
|||
|
||||
QByteArray SerializeDate(TimeId date) {
|
||||
return SerializeString(
|
||||
QDateTime::fromTime_t(date).toString(Qt::ISODate).toUtf8());
|
||||
QDateTime::fromSecsSinceEpoch(date).toString(Qt::ISODate).toUtf8());
|
||||
}
|
||||
|
||||
QByteArray StringAllowEmpty(const Data::Utf8String &data) {
|
||||
|
|
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "styles/style_export.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
|
@ -219,7 +220,8 @@ void PanelController::showError(const ApiErrorState &error) {
|
|||
if (error.data.type() == qstr("TAKEOUT_INVALID")) {
|
||||
showError(tr::lng_export_invalid(tr::now));
|
||||
} 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);
|
||||
const auto now = QDateTime::currentDateTime();
|
||||
const auto when = now.addSecs(seconds);
|
||||
|
|
|
@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/platform_specific.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "main/main_session.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_export.h"
|
||||
|
@ -479,7 +478,7 @@ void SettingsWidget::editDateLimit(
|
|||
}));
|
||||
};
|
||||
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()) {
|
||||
weak->closeBox();
|
||||
}
|
||||
|
|
|
@ -56,13 +56,10 @@ void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
|
|||
for (auto i = 0; i != intsCount; ++i) {
|
||||
udst[i] = qUnpremultiply(usrc[i]);
|
||||
}
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
|
||||
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
|
||||
layout->convertFromARGB32PM(udst, usrc, intsCount, layout, nullptr);
|
||||
#else // Qt >= 5.12
|
||||
#else // !LIB_FFMPEG_USE_QT_PRIVATE_API
|
||||
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
|
||||
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) {
|
||||
|
@ -73,13 +70,10 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
|
|||
for (auto i = 0; i != intsCount; ++i) {
|
||||
udst[i] = qPremultiply(usrc[i]);
|
||||
}
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
|
||||
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
|
||||
layout->convertToARGB32PM(udst, usrc, intsCount, layout, nullptr);
|
||||
#else // Qt >= 5.12
|
||||
#else // !LIB_FFMPEG_USE_QT_PRIVATE_API
|
||||
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
|
||||
layout->fetchToARGB32PM(udst, src, 0, intsCount, nullptr, nullptr);
|
||||
#endif // Qt >= 5.12
|
||||
#endif // LIB_FFMPEG_USE_QT_PRIVATE_API
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -1464,7 +1464,7 @@ void InnerWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void InnerWidget::enterEventHook(QEvent *e) {
|
||||
void InnerWidget::enterEventHook(QEnterEvent *e) {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
return TWidget::enterEventHook(e);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ protected:
|
|||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ TextWithEntities PrepareText(const QString &value, const QString &emptyValue) {
|
|||
result.entities.push_back({
|
||||
EntityType::Italic,
|
||||
0,
|
||||
emptyValue.size() });
|
||||
int(emptyValue.size()) });
|
||||
}
|
||||
} else {
|
||||
TextUtilities::ParseEntities(result, TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands);
|
||||
|
@ -296,7 +296,7 @@ TextWithEntities GenerateInviteLinkChangeText(
|
|||
link.entities.push_back({
|
||||
EntityType::CustomUrl,
|
||||
0,
|
||||
link.text.size(),
|
||||
int(link.text.size()),
|
||||
InternalInviteLinkUrl(newLink) });
|
||||
}
|
||||
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({
|
||||
EntityType::MentionName,
|
||||
0,
|
||||
name.text.size(),
|
||||
int(name.text.size()),
|
||||
entityData });
|
||||
}
|
||||
auto username = peer->userName();
|
||||
|
@ -361,7 +361,7 @@ auto GenerateParticipantString(
|
|||
mention.entities.push_back({
|
||||
EntityType::Mention,
|
||||
0,
|
||||
mention.text.size() });
|
||||
int(mention.text.size()) });
|
||||
return tr::lng_admin_log_user_with_username(
|
||||
tr::now,
|
||||
lt_name,
|
||||
|
|
|
@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/crash_reports.h"
|
||||
#include "core/application.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
namespace {
|
||||
|
@ -2655,10 +2656,10 @@ void History::cacheTopPromotion(
|
|||
}
|
||||
}
|
||||
|
||||
QStringRef History::topPromotionType() const {
|
||||
QStringView History::topPromotionType() const {
|
||||
return topPromotionAboutShown()
|
||||
? _topPromotedType.midRef(5)
|
||||
: _topPromotedType.midRef(0);
|
||||
? base::StringViewMid(_topPromotedType, 5)
|
||||
: QStringView(_topPromotedType);
|
||||
}
|
||||
|
||||
bool History::topPromotionAboutShown() const {
|
||||
|
|
|
@ -277,7 +277,7 @@ public:
|
|||
bool promoted,
|
||||
const QString &type,
|
||||
const QString &message);
|
||||
[[nodiscard]] QStringRef topPromotionType() const;
|
||||
[[nodiscard]] QStringView topPromotionType() const;
|
||||
[[nodiscard]] QString topPromotionMessage() const;
|
||||
[[nodiscard]] bool topPromotionAboutShown() const;
|
||||
void markTopPromotionAboutShown();
|
||||
|
|
|
@ -76,6 +76,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "app.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_window.h" // st::windowMinWidth
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
@ -866,7 +867,7 @@ bool HistoryInner::eventHook(QEvent *e) {
|
|||
|| e->type() == QEvent::TouchEnd
|
||||
|| e->type() == QEvent::TouchCancel) {
|
||||
QTouchEvent *ev = static_cast<QTouchEvent*>(e);
|
||||
if (ev->device()->type() == QTouchDevice::TouchScreen) {
|
||||
if (ev->device()->type() == base::TouchDevice::TouchScreen) {
|
||||
touchEvent(ev);
|
||||
return true;
|
||||
}
|
||||
|
@ -2504,7 +2505,7 @@ void HistoryInner::updateSize() {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryInner::enterEventHook(QEvent *e) {
|
||||
void HistoryInner::enterEventHook(QEnterEvent *e) {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
return TWidget::enterEventHook(e);
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ protected:
|
|||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
|
|
@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "facades.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
|
@ -136,7 +135,7 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
|
|||
? Ui::EmptyUserpic::ExternalName()
|
||||
: name)) {
|
||||
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];
|
||||
for (const auto &part : parts.mid(1)) {
|
||||
if (!lastName.isEmpty()) {
|
||||
|
|
|
@ -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"));
|
||||
} else {
|
||||
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);
|
||||
result.links.push_back(user->createOpenLink());
|
||||
|
||||
|
@ -641,7 +641,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
|
|||
} else if (users.isEmpty()) {
|
||||
result.text = tr::lng_action_invite_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody"), lt_chat, chatText);
|
||||
} 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);
|
||||
result.links.push_back(user->createOpenLink());
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
|
|||
|
||||
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
|
||||
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) * 8);
|
||||
}
|
||||
|
@ -1653,7 +1653,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
|
|||
if (samePeerBot) {
|
||||
if (_history) {
|
||||
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>(
|
||||
textWithTags,
|
||||
0,
|
||||
|
@ -1674,7 +1674,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
|
|||
using Section = Dialogs::EntryState::Section;
|
||||
|
||||
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>(
|
||||
textWithTags,
|
||||
to.currentReplyToId,
|
||||
|
@ -6254,8 +6254,8 @@ void HistoryWidget::editMessage(not_null<HistoryItem*> item) {
|
|||
|
||||
const auto editData = PrepareEditText(item);
|
||||
const auto cursor = MessageCursor {
|
||||
editData.text.size(),
|
||||
editData.text.size(),
|
||||
int(editData.text.size()),
|
||||
int(editData.text.size()),
|
||||
QFIXED_MAX
|
||||
};
|
||||
const auto previewPage = [&]() -> WebPageData* {
|
||||
|
@ -6550,7 +6550,7 @@ void HistoryWidget::updatePreview() {
|
|||
st::msgNameStyle,
|
||||
tr::lng_preview_loading(tr::now),
|
||||
Ui::NameTextOptions());
|
||||
auto linkText = _previewLinks.splitRef(' ').at(0).toString();
|
||||
auto linkText = QStringView(_previewLinks).split(' ').at(0).toString();
|
||||
_previewDescription.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(linkText),
|
||||
|
|
|
@ -2024,8 +2024,8 @@ void ComposeControls::editMessage(not_null<HistoryItem*> item) {
|
|||
}
|
||||
const auto editData = PrepareEditText(item);
|
||||
const auto cursor = MessageCursor{
|
||||
editData.text.size(),
|
||||
editData.text.size(),
|
||||
int(editData.text.size()),
|
||||
int(editData.text.size()),
|
||||
QFIXED_MAX
|
||||
};
|
||||
const auto previewPage = [&]() -> WebPageData* {
|
||||
|
@ -2164,7 +2164,7 @@ void ComposeControls::initWebpageProcess() {
|
|||
if (ShowWebPagePreview(*previewData)) {
|
||||
if (const auto till = (*previewData)->pendingTill) {
|
||||
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();
|
||||
previewTimer->callOnce(
|
||||
|
|
|
@ -2033,7 +2033,7 @@ void ListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void ListWidget::enterEventHook(QEvent *e) {
|
||||
void ListWidget::enterEventHook(QEnterEvent *e) {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
return TWidget::enterEventHook(e);
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ protected:
|
|||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
|
|
|
@ -132,7 +132,6 @@ ViewButton::Inner::Inner(
|
|||
, link(std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto controller = my.sessionWindow.get()) {
|
||||
const auto &data = controller->session().data();
|
||||
const auto webpage = media->webpage();
|
||||
if (!webpage) {
|
||||
return;
|
||||
|
|
|
@ -89,7 +89,7 @@ void PaintWaveform(
|
|||
const auto active = stm->msgWaveformActive;
|
||||
const auto inactive = stm->msgWaveformInactive;
|
||||
const auto wfSize = wf
|
||||
? wf->size()
|
||||
? int(wf->size())
|
||||
: ::Media::Player::kWaveformSamplesCount;
|
||||
const auto activeWidth = base::SafeRound(availableWidth * progress);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void Invoice::fillFromData(not_null<Data::Invoice*> invoice) {
|
|||
statusText.entities.push_back({
|
||||
EntityType::Bold,
|
||||
0,
|
||||
statusText.text.size() });
|
||||
int(statusText.text.size()) });
|
||||
statusText.text += ' ' + labelText().toUpper();
|
||||
_status.setMarkedText(
|
||||
st::defaultTextStyle,
|
||||
|
|
|
@ -24,10 +24,10 @@ namespace HistoryView {
|
|||
namespace {
|
||||
|
||||
[[nodiscard]] TimeId TimeFromMatch(
|
||||
const QStringRef &hours,
|
||||
const QStringRef &minutes1,
|
||||
const QStringRef &minutes2,
|
||||
const QStringRef &seconds) {
|
||||
QStringView hours,
|
||||
QStringView minutes1,
|
||||
QStringView minutes2,
|
||||
QStringView seconds) {
|
||||
auto ok1 = true;
|
||||
auto ok2 = true;
|
||||
auto ok3 = true;
|
||||
|
@ -71,10 +71,10 @@ TextWithEntities AddTimestampLinks(
|
|||
offset = till;
|
||||
|
||||
const auto time = TimeFromMatch(
|
||||
m.capturedRef(1),
|
||||
m.capturedRef(2),
|
||||
m.capturedRef(3),
|
||||
m.capturedRef(4));
|
||||
m.capturedView(1),
|
||||
m.capturedView(2),
|
||||
m.capturedView(3),
|
||||
m.capturedView(4));
|
||||
if (time < 0 || time > duration) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1906,7 +1906,7 @@ void ListWidget::validateTrippleClickStartTime() {
|
|||
}
|
||||
}
|
||||
|
||||
void ListWidget::enterEventHook(QEvent *e) {
|
||||
void ListWidget::enterEventHook(QEnterEvent *e) {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
return RpWidget::enterEventHook(e);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ private:
|
|||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
void start();
|
||||
|
|
|
@ -199,7 +199,7 @@ ClickHandlerPtr ItemBase::getResultPreviewHandler() const {
|
|||
}
|
||||
|
||||
QString ItemBase::getResultThumbLetter() const {
|
||||
auto parts = _result->_url.splitRef('/');
|
||||
auto parts = QStringView(_result->_url).split('/');
|
||||
if (!parts.isEmpty()) {
|
||||
auto domain = parts.at(0);
|
||||
if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others
|
||||
|
|
|
@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "app.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_intro.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace Intro {
|
||||
namespace {
|
||||
|
@ -512,7 +513,8 @@ void Widget::resetAccount() {
|
|||
|
||||
const auto &type = error.type();
|
||||
if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) {
|
||||
const auto seconds = type.midRef(
|
||||
const auto seconds = base::StringViewMid(
|
||||
type,
|
||||
qstr("2FA_CONFIRM_WAIT_").size()).toInt();
|
||||
const auto days = (seconds + 59) / 86400;
|
||||
const auto hours = ((seconds + 59) % 86400) / 3600;
|
||||
|
|
|
@ -174,7 +174,11 @@ QByteArray FileParser::ReadFile(const QString &absolutePath, const QString &rela
|
|||
|
||||
QByteArray data;
|
||||
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");
|
||||
#endif // Qt < 6.0.0
|
||||
auto string = stream.readAll();
|
||||
if (stream.status() != QTextStream::Ok) {
|
||||
LOG(("Lang Error: Could not read UTF-16 data from '%1' ('%2')").arg(relativePath, absolutePath));
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/text/text.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
namespace Lang {
|
||||
namespace {
|
||||
|
@ -911,7 +912,7 @@ int NonZeroPartToInt(QString value) {
|
|||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -1008,11 +1009,11 @@ QString ReplaceTag<QString>::Replace(QString &&original, const QString &replacem
|
|||
auto result = QString();
|
||||
result.reserve(original.size() + replacement.size() - kTagReplacementSize);
|
||||
if (replacementPosition > 0) {
|
||||
result.append(original.midRef(0, replacementPosition));
|
||||
result.append(base::StringViewMid(original, 0, replacementPosition));
|
||||
}
|
||||
result.append(replacement);
|
||||
if (replacementPosition + kTagReplacementSize < original.size()) {
|
||||
result.append(original.midRef(replacementPosition + kTagReplacementSize));
|
||||
result.append(base::StringViewMid(original, replacementPosition + kTagReplacementSize));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ TextWithEntities ReplaceTag<TextWithEntities>::Call(TextWithEntities &&original,
|
|||
if (originalEntitiesCount != 0 || replacementEntitiesCount != 0) {
|
||||
result.entities.reserve(originalEntitiesCount + replacementEntitiesCount);
|
||||
|
||||
auto replacementEnd = replacementPosition + replacement.text.size();
|
||||
auto replacementEnd = replacementPosition + int(replacement.text.size());
|
||||
auto replacementEntity = replacement.entities.cbegin();
|
||||
auto addReplacementEntitiesUntil = [&replacementEntity, &replacement, &result, replacementPosition, replacementEnd](int untilPosition) {
|
||||
while (replacementEntity != replacement.entities.cend()) {
|
||||
|
@ -52,8 +52,8 @@ TextWithEntities ReplaceTag<TextWithEntities>::Call(TextWithEntities &&original,
|
|||
if (end > replacementPosition) {
|
||||
end = end + replacement.text.size() - kTagReplacementSize;
|
||||
}
|
||||
offset = std::clamp(offset, 0, result.text.size());
|
||||
end = std::clamp(end, 0, result.text.size());
|
||||
offset = std::clamp(offset, 0, int(result.text.size()));
|
||||
end = std::clamp(end, 0, int(result.text.size()));
|
||||
|
||||
// Add all replacement entities that start before the current original entity.
|
||||
addReplacementEntitiesUntil(offset);
|
||||
|
|
|
@ -165,7 +165,7 @@ private:
|
|||
QStringList oldlogs = working.entryList(QStringList("log_start*.txt"), QDir::Files);
|
||||
for (QStringList::const_iterator i = oldlogs.cbegin(), e = oldlogs.cend(); i != e; ++i) {
|
||||
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();
|
||||
LOG(("Old start log '%1' found, deleted: %2").arg(*i, Logs::b(removed)));
|
||||
}
|
||||
|
|
|
@ -531,8 +531,8 @@ bool MainWidget::shareUrl(
|
|||
TextWithTags::Tags()
|
||||
};
|
||||
MessageCursor cursor = {
|
||||
url.size() + 1,
|
||||
url.size() + 1 + text.size(),
|
||||
int(url.size()) + 1,
|
||||
int(url.size()) + 1 + int(text.size()),
|
||||
QFIXED_MAX
|
||||
};
|
||||
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);
|
||||
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>(
|
||||
textWithTags,
|
||||
0,
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QtCore/QtEndian>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
namespace Media {
|
||||
namespace Clip {
|
||||
|
|
|
@ -225,7 +225,7 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q
|
|||
}
|
||||
// AV_NUM_DATA_POINTERS defined in AVFrame struct
|
||||
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);
|
||||
}
|
||||
if (hasAlpha) {
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
namespace Core {
|
||||
class FileLocation;
|
||||
|
|
|
@ -164,7 +164,7 @@ void Panel::paintEvent(QPaintEvent *e) {
|
|||
Ui::FillRoundRect(p, shadowedRect, st::menuBg, Ui::MenuCorners, nullptr, parts);
|
||||
}
|
||||
|
||||
void Panel::enterEventHook(QEvent *e) {
|
||||
void Panel::enterEventHook(QEnterEvent *e) {
|
||||
if (_ignoringEnterEvents || contentTooSmall()) return;
|
||||
|
||||
_hideTimer.cancel();
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
void VolumeWidget::enterEventHook(QEvent *e) {
|
||||
void VolumeWidget::enterEventHook(QEnterEvent *e) {
|
||||
_hideTimer.stop();
|
||||
if (_a_appearance.animating()) {
|
||||
onShowStart();
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void enterEventHook(QEnterEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||
|
|
|
@ -160,7 +160,7 @@ QImage ConvertFrame(
|
|||
|
||||
// AV_NUM_DATA_POINTERS defined in AVFrame struct
|
||||
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(
|
||||
stream.swscale.get(),
|
||||
|
|
|
@ -55,7 +55,7 @@ static_assert(kDisplaySkipped != kTimeUnknown);
|
|||
0,
|
||||
};
|
||||
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(
|
||||
swscale.get(),
|
||||
|
|
|
@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/gl/gl_image.h"
|
||||
#include "ui/gl/gl_primitives.h"
|
||||
|
||||
#include <QtGui/QOpenGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
|
||||
namespace Media::View {
|
||||
|
||||
|
|
|
@ -74,13 +74,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "facades.h"
|
||||
#include "styles/style_media_view.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "platform/mac/touchbar/mac_touchbar_media_view.h"
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
|
@ -4430,7 +4430,7 @@ bool OverlayWidget::handleContextMenu(std::optional<QPoint> position) {
|
|||
}
|
||||
|
||||
bool OverlayWidget::handleTouchEvent(not_null<QTouchEvent*> e) {
|
||||
if (e->device()->type() != QTouchDevice::TouchScreen) {
|
||||
if (e->device()->type() != base::TouchDevice::TouchScreen) {
|
||||
return false;
|
||||
} else if (e->type() == QEvent::TouchBegin
|
||||
&& !e->touchPoints().isEmpty()
|
||||
|
|
|
@ -33,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_media_view.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QScreen>
|
||||
|
@ -51,7 +50,7 @@ constexpr auto kMsInSecond = 1000;
|
|||
}
|
||||
|
||||
[[nodiscard]] QRect ScreenFromPosition(QPoint point) {
|
||||
const auto screen = base::QScreenNearestTo(point);
|
||||
const auto screen = QGuiApplication::screenAt(point);
|
||||
const auto use = screen ? screen : QGuiApplication::primaryScreen();
|
||||
return use
|
||||
? use->availableGeometry()
|
||||
|
|
|
@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/gl/gl_image.h"
|
||||
#include "ui/gl/gl_primitives.h"
|
||||
|
||||
#include <QtGui/QOpenGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
|
||||
namespace Media::View {
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ SerializedRequest DcKeyBinder::prepareRequest(
|
|||
DcKeyBindState DcKeyBinder::handleResponse(const mtpBuffer &response) {
|
||||
Expects(!response.isEmpty());
|
||||
|
||||
auto from = response.begin();
|
||||
auto from = response.data();
|
||||
const auto end = from + response.size();
|
||||
auto error = MTPRpcError();
|
||||
if (response[0] == mtpc_boolTrue) {
|
||||
|
|
|
@ -710,7 +710,7 @@ int64 TlsSocket::read(bytes::span buffer) {
|
|||
while (_incomingGoodDataLimit) {
|
||||
const auto available = std::min(
|
||||
_incomingGoodDataLimit,
|
||||
_incoming.size() - _incomingGoodDataOffset);
|
||||
int(_incoming.size()) - _incomingGoodDataOffset);
|
||||
if (available <= 0) {
|
||||
return written;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/facade.h"
|
||||
#include "mtproto/connection_tcp.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
@ -754,10 +753,12 @@ bool DcOptions::loadFromFile(const QString &path) {
|
|||
return false;
|
||||
}
|
||||
QTextStream stream(&f);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setCodec("UTF-8");
|
||||
#endif // Qt < 6.0.0
|
||||
while (!stream.atEnd()) {
|
||||
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('#')) {
|
||||
continue;
|
||||
}
|
||||
|
@ -816,7 +817,9 @@ bool DcOptions::writeToFile(const QString &path) const {
|
|||
return false;
|
||||
}
|
||||
QTextStream stream(&f);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setCodec("UTF-8");
|
||||
#endif // Qt < 6.0.0
|
||||
|
||||
ReadLocker lock(this);
|
||||
for (const auto &item : _data) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue