diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 12b8be525..df487c492 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -81,11 +81,11 @@ constexpr auto kUnreadMentionsFirstRequestLimit = 10; constexpr auto kUnreadMentionsNextRequestLimit = 100; constexpr auto kSharedMediaLimit = 100; constexpr auto kFeedMessagesLimit = 50; -constexpr auto kReadFeaturedSetsTimeout = TimeMs(1000); -constexpr auto kFileLoaderQueueStopTimeout = TimeMs(5000); -constexpr auto kFeedReadTimeout = TimeMs(1000); -constexpr auto kStickersByEmojiInvalidateTimeout = TimeMs(60 * 60 * 1000); -constexpr auto kNotifySettingSaveTimeout = TimeMs(1000); +constexpr auto kReadFeaturedSetsTimeout = crl::time(1000); +constexpr auto kFileLoaderQueueStopTimeout = crl::time(5000); +constexpr auto kFeedReadTimeout = crl::time(1000); +constexpr auto kStickersByEmojiInvalidateTimeout = crl::time(60 * 60 * 1000); +constexpr auto kNotifySettingSaveTimeout = crl::time(1000); using SimpleFileLocationId = Data::SimpleFileLocationId; using DocumentFileLocationId = Data::DocumentFileLocationId; @@ -253,7 +253,7 @@ void ApiWrap::refreshProxyPromotion() { void ApiWrap::getProxyPromotionDelayed(TimeId now, TimeId next) { _proxyPromotionTimer.callOnce(std::min( std::max(next - now, kProxyPromotionMinDelay), - kProxyPromotionInterval) * TimeMs(1000)); + kProxyPromotionInterval) * crl::time(1000)); }; void ApiWrap::proxyPromotionDone(const MTPhelp_ProxyData &proxy) { @@ -296,7 +296,7 @@ void ApiWrap::requestTermsUpdate() { if (_termsUpdateRequestId) { return; } - const auto now = getms(true); + const auto now = crl::now(); if (_termsUpdateSendAt && now < _termsUpdateSendAt) { App::CallDelayed(_termsUpdateSendAt - now, _session, [=] { requestTermsUpdate(); @@ -304,8 +304,8 @@ void ApiWrap::requestTermsUpdate() { return; } - constexpr auto kTermsUpdateTimeoutMin = 10 * TimeMs(1000); - constexpr auto kTermsUpdateTimeoutMax = 86400 * TimeMs(1000); + constexpr auto kTermsUpdateTimeoutMin = 10 * crl::time(1000); + constexpr auto kTermsUpdateTimeoutMax = 86400 * crl::time(1000); _termsUpdateRequestId = request(MTPhelp_GetTermsOfServiceUpdate( )).done([=](const MTPhelp_TermsOfServiceUpdate &result) { @@ -313,8 +313,8 @@ void ApiWrap::requestTermsUpdate() { const auto requestNext = [&](auto &&data) { const auto timeout = (data.vexpires.v - unixtime()); - _termsUpdateSendAt = getms(true) + snap( - timeout * TimeMs(1000), + _termsUpdateSendAt = crl::now() + snap( + timeout * crl::time(1000), kTermsUpdateTimeoutMin, kTermsUpdateTimeoutMax); requestTermsUpdate(); @@ -336,7 +336,7 @@ void ApiWrap::requestTermsUpdate() { } }).fail([=](const RPCError &error) { _termsUpdateRequestId = 0; - _termsUpdateSendAt = getms(true) + kTermsUpdateTimeoutMin; + _termsUpdateSendAt = crl::now() + kTermsUpdateTimeoutMin; requestTermsUpdate(); }).send(); } @@ -1091,7 +1091,7 @@ void ApiWrap::gotUserFull( const auto &d = result.c_userFull(); if (user == _session->user() && !_session->validateSelf(d.vuser)) { - constexpr auto kRequestUserAgainTimeout = TimeMs(10000); + constexpr auto kRequestUserAgainTimeout = crl::time(10000); App::CallDelayed(kRequestUserAgainTimeout, _session, [=] { requestFullPeer(user); }); @@ -2963,7 +2963,7 @@ void ApiWrap::stickersSaveOrder() { } void ApiWrap::updateStickers() { - auto now = getms(true); + auto now = crl::now(); requestStickers(now); requestRecentStickers(now); requestFavedStickers(now); @@ -2991,7 +2991,7 @@ std::vector> *ApiWrap::stickersByEmoji( return true; } const auto received = it->second.received; - const auto now = getms(true); + const auto now = crl::now(); return (received > 0) && (received + kStickersByEmojiInvalidateTimeout) <= now; }(); @@ -3019,7 +3019,7 @@ std::vector> *ApiWrap::stickersByEmoji( } } entry.hash = data.vhash.v; - entry.received = getms(true); + entry.received = crl::now(); _session->data().notifyStickersUpdated(); }).send(); } @@ -3111,7 +3111,7 @@ void ApiWrap::requestStickers(TimeId now) { return; } auto onDone = [this](const MTPmessages_AllStickers &result) { - _session->data().setLastStickersUpdate(getms(true)); + _session->data().setLastStickersUpdate(crl::now()); _stickersUpdateRequest = 0; switch (result.type()) { @@ -3146,7 +3146,7 @@ void ApiWrap::requestRecentStickersWithHash(int32 hash) { MTP_flags(0), MTP_int(hash) )).done([=](const MTPmessages_RecentStickers &result) { - _session->data().setLastRecentStickersUpdate(getms(true)); + _session->data().setLastRecentStickersUpdate(crl::now()); _recentStickersUpdateRequest = 0; switch (result.type()) { @@ -3164,7 +3164,7 @@ void ApiWrap::requestRecentStickersWithHash(int32 hash) { default: Unexpected("Type in ApiWrap::recentStickersDone()"); } }).fail([=](const RPCError &error) { - _session->data().setLastRecentStickersUpdate(getms(true)); + _session->data().setLastRecentStickersUpdate(crl::now()); _recentStickersUpdateRequest = 0; LOG(("App Fail: Failed to get recent stickers!")); @@ -3179,7 +3179,7 @@ void ApiWrap::requestFavedStickers(TimeId now) { _favedStickersUpdateRequest = request(MTPmessages_GetFavedStickers( MTP_int(Local::countFavedStickersHash()) )).done([=](const MTPmessages_FavedStickers &result) { - _session->data().setLastFavedStickersUpdate(getms(true)); + _session->data().setLastFavedStickersUpdate(crl::now()); _favedStickersUpdateRequest = 0; switch (result.type()) { @@ -3196,7 +3196,7 @@ void ApiWrap::requestFavedStickers(TimeId now) { default: Unexpected("Type in ApiWrap::favedStickersDone()"); } }).fail([=](const RPCError &error) { - _session->data().setLastFavedStickersUpdate(getms(true)); + _session->data().setLastFavedStickersUpdate(crl::now()); _favedStickersUpdateRequest = 0; LOG(("App Fail: Failed to get faved stickers!")); @@ -3211,7 +3211,7 @@ void ApiWrap::requestFeaturedStickers(TimeId now) { _featuredStickersUpdateRequest = request(MTPmessages_GetFeaturedStickers( MTP_int(Local::countFeaturedStickersHash()) )).done([=](const MTPmessages_FeaturedStickers &result) { - _session->data().setLastFeaturedStickersUpdate(getms(true)); + _session->data().setLastFeaturedStickersUpdate(crl::now()); _featuredStickersUpdateRequest = 0; switch (result.type()) { @@ -3223,7 +3223,7 @@ void ApiWrap::requestFeaturedStickers(TimeId now) { default: Unexpected("Type in ApiWrap::featuredStickersDone()"); } }).fail([=](const RPCError &error) { - _session->data().setLastFeaturedStickersUpdate(getms(true)); + _session->data().setLastFeaturedStickersUpdate(crl::now()); _featuredStickersUpdateRequest = 0; LOG(("App Fail: Failed to get featured stickers!")); @@ -3238,7 +3238,7 @@ void ApiWrap::requestSavedGifs(TimeId now) { _savedGifsUpdateRequest = request(MTPmessages_GetSavedGifs( MTP_int(Local::countSavedGifsHash()) )).done([=](const MTPmessages_SavedGifs &result) { - _session->data().setLastSavedGifsUpdate(getms(true)); + _session->data().setLastSavedGifsUpdate(crl::now()); _savedGifsUpdateRequest = 0; switch (result.type()) { @@ -3250,7 +3250,7 @@ void ApiWrap::requestSavedGifs(TimeId now) { default: Unexpected("Type in ApiWrap::savedGifsDone()"); } }).fail([=](const RPCError &error) { - _session->data().setLastSavedGifsUpdate(getms(true)); + _session->data().setLastSavedGifsUpdate(crl::now()); _savedGifsUpdateRequest = 0; LOG(("App Fail: Failed to get saved gifs!")); @@ -3722,7 +3722,7 @@ void ApiWrap::addChatParticipants( applyUpdates(result); }).fail([=](const RPCError &error) { ShowAddParticipantsError(error.type(), peer, { 1, user }); - }).afterDelay(TimeMs(5)).send(); + }).afterDelay(crl::time(5)).send(); } } else if (const auto channel = peer->asChannel()) { const auto bot = ranges::find_if(users, [](not_null user) { @@ -3743,7 +3743,7 @@ void ApiWrap::addChatParticipants( requestParticipantsCountDelayed(channel); }).fail([=](const RPCError &error) { ShowAddParticipantsError(error.type(), peer, users); - }).afterDelay(TimeMs(5)).send(); + }).afterDelay(crl::time(5)).send(); }; for (const auto user : users) { list.push_back(user->inputUser); @@ -5612,13 +5612,13 @@ void ApiWrap::readFeed( if (_feedReadsDelayed.empty()) { _feedReadTimer.callOnce(kFeedReadTimeout); } - _feedReadsDelayed.emplace(feed, getms(true) + kFeedReadTimeout); + _feedReadsDelayed.emplace(feed, crl::now() + kFeedReadTimeout); } } void ApiWrap::readFeeds() { auto delay = kFeedReadTimeout; - const auto now = getms(true); + const auto now = crl::now(); //for (auto i = begin(_feedReadsDelayed); i != end(_feedReadsDelayed);) { // #feed // const auto feed = i->first; // const auto time = i->second; diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 8b206d245..fd63d6fc6 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -422,7 +422,7 @@ private: struct StickersByEmoji { std::vector> list; int32 hash = 0; - TimeMs received = 0; + crl::time received = 0; }; void updatesReceived(const MTPUpdates &updates); @@ -728,7 +728,7 @@ private: rpl::event_stream _stickerSetInstalled; - base::flat_map, TimeMs> _feedReadsDelayed; + base::flat_map, crl::time> _feedReadsDelayed; base::flat_map, mtpRequestId> _feedReadRequests; base::Timer _feedReadTimer; @@ -746,7 +746,7 @@ private: mtpRequestId _deepLinkInfoRequestId = 0; - TimeMs _termsUpdateSendAt = 0; + crl::time _termsUpdateSendAt = 0; mtpRequestId _termsUpdateRequestId = 0; mtpRequestId _checkInviteRequestId = 0; diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index 89723fa62..d82d4a228 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -32,7 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kAutoLockTimeoutLateMs = TimeMs(3000); +constexpr auto kAutoLockTimeoutLateMs = crl::time(3000); constexpr auto kLegacyCallsPeerToPeerNobody = 4; } // namespace @@ -470,7 +470,7 @@ void AuthSession::moveSettingsFrom(AuthSessionSettings &&other) { } } -void AuthSession::saveSettingsDelayed(TimeMs delay) { +void AuthSession::saveSettingsDelayed(crl::time delay) { Expects(this == &Auth()); _saveDataTimer.callOnce(delay); @@ -483,7 +483,7 @@ void AuthSession::checkAutoLock() { } Core::App().checkLocalTime(); - auto now = getms(true); + auto now = crl::now(); auto shouldLockInMs = Global::AutoLock() * 1000LL; auto idleForMs = psIdleTime(); auto notPlayingVideoForMs = now - settings().lastTimeVideoPlayedAt(); @@ -496,7 +496,7 @@ void AuthSession::checkAutoLock() { } } -void AuthSession::checkAutoLockIn(TimeMs time) { +void AuthSession::checkAutoLockIn(crl::time time) { if (_autoLockTimer.isActive()) { auto remain = _autoLockTimer.remainingTime(); if (remain > 0 && remain <= time) return; diff --git a/Telegram/SourceFiles/auth_session.h b/Telegram/SourceFiles/auth_session.h index 19d7db7b3..778fc8840 100644 --- a/Telegram/SourceFiles/auth_session.h +++ b/Telegram/SourceFiles/auth_session.h @@ -139,10 +139,10 @@ public: bool smallDialogsList() const { return _variables.smallDialogsList; } - void setLastTimeVideoPlayedAt(TimeMs time) { + void setLastTimeVideoPlayedAt(crl::time time) { _lastTimeVideoPlayedAt = time; } - TimeMs lastTimeVideoPlayedAt() const { + crl::time lastTimeVideoPlayedAt() const { return _lastTimeVideoPlayedAt; } void setSoundOverride(const QString &key, const QString &path) { @@ -263,7 +263,7 @@ private: rpl::event_stream _tabbedReplacedWithInfoValue; Variables _variables; - TimeMs _lastTimeVideoPlayedAt = 0; + crl::time _lastTimeVideoPlayedAt = 0; }; @@ -311,7 +311,7 @@ public: return _settings; } void moveSettingsFrom(AuthSessionSettings &&other); - void saveSettingsDelayed(TimeMs delay = kDefaultSaveDelay); + void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay); ApiWrap &api() { return *_api; @@ -322,7 +322,7 @@ public: } void checkAutoLock(); - void checkAutoLockIn(TimeMs time); + void checkAutoLockIn(crl::time time); rpl::lifetime &lifetime() { return _lifetime; @@ -338,12 +338,12 @@ public: ~AuthSession(); private: - static constexpr auto kDefaultSaveDelay = TimeMs(1000); + static constexpr auto kDefaultSaveDelay = crl::time(1000); AuthSessionSettings _settings; base::Timer _saveDataTimer; - TimeMs _shouldLockAt = 0; + crl::time _shouldLockAt = 0; base::Timer _autoLockTimer; const std::unique_ptr _api; diff --git a/Telegram/SourceFiles/base/basic_types.h b/Telegram/SourceFiles/base/basic_types.h index c32a4b448..bd5ec4059 100644 --- a/Telegram/SourceFiles/base/basic_types.h +++ b/Telegram/SourceFiles/base/basic_types.h @@ -46,7 +46,6 @@ using uint64 = quint64; using float32 = float; using float64 = double; -using TimeMs = int64; using TimeId = int32; // Define specializations for QByteArray for Qt 5.3.2, because diff --git a/Telegram/SourceFiles/base/concurrent_timer.cpp b/Telegram/SourceFiles/base/concurrent_timer.cpp index 03ce351a0..b5417e17a 100644 --- a/Telegram/SourceFiles/base/concurrent_timer.cpp +++ b/Telegram/SourceFiles/base/concurrent_timer.cpp @@ -26,16 +26,16 @@ QMutex EnvironmentMutex; class CallDelayedEvent : public QEvent { public: CallDelayedEvent( - crl::time_type timeout, + crl::time timeout, Qt::TimerType type, FnMut method); - crl::time_type timeout() const; + crl::time timeout() const; Qt::TimerType type() const; FnMut takeMethod(); private: - crl::time_type _timeout = 0; + crl::time _timeout = 0; Qt::TimerType _type = Qt::PreciseTimer; FnMut _method; @@ -48,7 +48,7 @@ public: }; CallDelayedEvent::CallDelayedEvent( - crl::time_type timeout, + crl::time timeout, Qt::TimerType type, FnMut method) : QEvent(kCallDelayedEvent) @@ -58,7 +58,7 @@ CallDelayedEvent::CallDelayedEvent( Expects(_timeout >= 0 && _timeout < std::numeric_limits::max()); } -crl::time_type CallDelayedEvent::timeout() const { +crl::time CallDelayedEvent::timeout() const { return _timeout; } @@ -178,7 +178,7 @@ TimerObjectWrap::~TimerObjectWrap() { } void TimerObjectWrap::call( - crl::time_type timeout, + crl::time timeout, Qt::TimerType type, FnMut method) { sendEvent(std::make_unique( @@ -281,7 +281,7 @@ Fn ConcurrentTimer::createAdjuster() { } void ConcurrentTimer::start( - TimeMs timeout, + crl::time timeout, Qt::TimerType type, Repeat repeat) { _type = type; @@ -290,7 +290,7 @@ void ConcurrentTimer::start( setTimeout(timeout); cancelAndSchedule(_timeout); - _next = crl::time() + _timeout; + _next = crl::now() + _timeout; } void ConcurrentTimer::cancelAndSchedule(int timeout) { @@ -319,7 +319,7 @@ void ConcurrentTimer::timerEvent() { if (_adjusted) { start(_timeout, _type, repeat()); } else { - _next = crl::time() + _timeout; + _next = crl::now() + _timeout; } } else { cancel(); @@ -338,12 +338,12 @@ void ConcurrentTimer::cancel() { } } -TimeMs ConcurrentTimer::remainingTime() const { +crl::time ConcurrentTimer::remainingTime() const { if (!isActive()) { return -1; } - const auto now = crl::time(); - return (_next > now) ? (_next - now) : TimeMs(0); + const auto now = crl::now(); + return (_next > now) ? (_next - now) : crl::time(0); } void ConcurrentTimer::adjust() { @@ -354,7 +354,7 @@ void ConcurrentTimer::adjust() { } } -void ConcurrentTimer::setTimeout(TimeMs timeout) { +void ConcurrentTimer::setTimeout(crl::time timeout) { Expects(timeout >= 0 && timeout <= std::numeric_limits::max()); _timeout = static_cast(timeout); diff --git a/Telegram/SourceFiles/base/concurrent_timer.h b/Telegram/SourceFiles/base/concurrent_timer.h index b279b1d1e..4020ee6ae 100644 --- a/Telegram/SourceFiles/base/concurrent_timer.h +++ b/Telegram/SourceFiles/base/concurrent_timer.h @@ -23,7 +23,7 @@ public: ~TimerObjectWrap(); void call( - crl::time_type timeout, + crl::time timeout, Qt::TimerType type, FnMut method); void cancel(); @@ -67,8 +67,8 @@ public: crl::weak_on_queue weak, Fn callback = nullptr); - static Qt::TimerType DefaultType(TimeMs timeout) { - constexpr auto kThreshold = TimeMs(1000); + static Qt::TimerType DefaultType(crl::time timeout) { + constexpr auto kThreshold = crl::time(1000); return (timeout > kThreshold) ? Qt::CoarseTimer : Qt::PreciseTimer; } @@ -76,19 +76,19 @@ public: _callback = std::move(callback); } - void callOnce(TimeMs timeout) { + void callOnce(crl::time timeout) { callOnce(timeout, DefaultType(timeout)); } - void callEach(TimeMs timeout) { + void callEach(crl::time timeout) { callEach(timeout, DefaultType(timeout)); } - void callOnce(TimeMs timeout, Qt::TimerType type) { + void callOnce(crl::time timeout, Qt::TimerType type) { start(timeout, type, Repeat::SingleShot); } - void callEach(TimeMs timeout, Qt::TimerType type) { + void callEach(crl::time timeout, Qt::TimerType type) { start(timeout, type, Repeat::Interval); } @@ -97,7 +97,7 @@ public: } void cancel(); - TimeMs remainingTime() const; + crl::time remainingTime() const; private: enum class Repeat : unsigned { @@ -105,12 +105,12 @@ private: SingleShot = 1, }; Fn createAdjuster(); - void start(TimeMs timeout, Qt::TimerType type, Repeat repeat); + void start(crl::time timeout, Qt::TimerType type, Repeat repeat); void adjust(); void cancelAndSchedule(int timeout); - void setTimeout(TimeMs timeout); + void setTimeout(crl::time timeout); int timeout() const; void timerEvent(); @@ -127,7 +127,7 @@ private: details::TimerObjectWrap _object; Fn _callback; base::binary_guard _running; - TimeMs _next = 0; + crl::time _next = 0; int _timeout = 0; Qt::TimerType _type : 2; diff --git a/Telegram/SourceFiles/base/timer.cpp b/Telegram/SourceFiles/base/timer.cpp index 32388c1e9..07d8c2424 100644 --- a/Telegram/SourceFiles/base/timer.cpp +++ b/Telegram/SourceFiles/base/timer.cpp @@ -40,7 +40,7 @@ Timer::Timer(Fn callback) Qt::QueuedConnection); } -void Timer::start(TimeMs timeout, Qt::TimerType type, Repeat repeat) { +void Timer::start(crl::time timeout, Qt::TimerType type, Repeat repeat) { cancel(); _type = type; @@ -49,7 +49,7 @@ void Timer::start(TimeMs timeout, Qt::TimerType type, Repeat repeat) { setTimeout(timeout); _timerId = startTimer(_timeout, _type); if (_timerId) { - _next = crl::time() + _timeout; + _next = crl::now() + _timeout; } else { _next = 0; } @@ -61,12 +61,12 @@ void Timer::cancel() { } } -TimeMs Timer::remainingTime() const { +crl::time Timer::remainingTime() const { if (!isActive()) { return -1; } - auto now = crl::time(); - return (_next > now) ? (_next - now) : TimeMs(0); + const auto now = crl::now(); + return (_next > now) ? (_next - now) : crl::time(0); } void Timer::Adjust() { @@ -87,7 +87,7 @@ void Timer::adjust() { } } -void Timer::setTimeout(TimeMs timeout) { +void Timer::setTimeout(crl::time timeout) { Expects(timeout >= 0 && timeout <= std::numeric_limits::max()); _timeout = static_cast(timeout); @@ -102,7 +102,7 @@ void Timer::timerEvent(QTimerEvent *e) { if (_adjusted) { start(_timeout, _type, repeat()); } else { - _next = crl::time() + _timeout; + _next = crl::now() + _timeout; } } else { cancel(); @@ -114,7 +114,7 @@ void Timer::timerEvent(QTimerEvent *e) { } int DelayedCallTimer::call( - TimeMs timeout, + crl::time timeout, FnMut callback, Qt::TimerType type) { Expects(timeout >= 0); diff --git a/Telegram/SourceFiles/base/timer.h b/Telegram/SourceFiles/base/timer.h index 033a068cf..fa11716e6 100644 --- a/Telegram/SourceFiles/base/timer.h +++ b/Telegram/SourceFiles/base/timer.h @@ -21,8 +21,8 @@ public: Fn callback = nullptr); explicit Timer(Fn callback = nullptr); - static Qt::TimerType DefaultType(TimeMs timeout) { - constexpr auto kThreshold = TimeMs(1000); + static Qt::TimerType DefaultType(crl::time timeout) { + constexpr auto kThreshold = crl::time(1000); return (timeout > kThreshold) ? Qt::CoarseTimer : Qt::PreciseTimer; } @@ -30,19 +30,19 @@ public: _callback = std::move(callback); } - void callOnce(TimeMs timeout) { + void callOnce(crl::time timeout) { callOnce(timeout, DefaultType(timeout)); } - void callEach(TimeMs timeout) { + void callEach(crl::time timeout) { callEach(timeout, DefaultType(timeout)); } - void callOnce(TimeMs timeout, Qt::TimerType type) { + void callOnce(crl::time timeout, Qt::TimerType type) { start(timeout, type, Repeat::SingleShot); } - void callEach(TimeMs timeout, Qt::TimerType type) { + void callEach(crl::time timeout, Qt::TimerType type) { start(timeout, type, Repeat::Interval); } @@ -51,7 +51,7 @@ public: } void cancel(); - TimeMs remainingTime() const; + crl::time remainingTime() const; static void Adjust(); @@ -63,10 +63,10 @@ private: Interval = 0, SingleShot = 1, }; - void start(TimeMs timeout, Qt::TimerType type, Repeat repeat); + void start(crl::time timeout, Qt::TimerType type, Repeat repeat); void adjust(); - void setTimeout(TimeMs timeout); + void setTimeout(crl::time timeout); int timeout() const; void setRepeat(Repeat repeat) { @@ -77,7 +77,7 @@ private: } Fn _callback; - TimeMs _next = 0; + crl::time _next = 0; int _timeout = 0; int _timerId = 0; @@ -89,7 +89,7 @@ private: class DelayedCallTimer final : private QObject { public: - int call(TimeMs timeout, FnMut callback) { + int call(crl::time timeout, FnMut callback) { return call( timeout, std::move(callback), @@ -97,7 +97,7 @@ public: } int call( - TimeMs timeout, + crl::time timeout, FnMut callback, Qt::TimerType type); void cancel(int callId); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 09079eb4a..6aeff5f35 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -315,7 +315,7 @@ void BackgroundBox::Inner::paintPaper( if (paper.data.id() == Window::Theme::Background()->id()) { const auto checkLeft = x + st::backgroundSize.width() - st::overviewCheckSkip - st::overviewCheck.size; const auto checkTop = y + st::backgroundSize.height() - st::overviewCheckSkip - st::overviewCheck.size; - _check->paint(p, getms(), checkLeft, checkTop, width()); + _check->paint(p, crl::now(), checkLeft, checkTop, width()); } else if (Data::IsCloudWallPaper(paper.data) && !Data::IsDefaultWallPaper(paper.data) && over.has_value() diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 5268c18e4..23efa859d 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -40,7 +40,7 @@ public: int left, int top, int outerWidth, - TimeMs ms) override; + crl::time ms) override; QImage prepareRippleMask() const override; bool checkRippleStartPosition(QPoint position) const override; @@ -242,7 +242,7 @@ void ServiceCheck::paint( int left, int top, int outerWidth, - TimeMs ms) { + crl::time ms) { Frames().paintFrame( p, left + _st.margin.left(), @@ -496,7 +496,7 @@ void BackgroundPreviewBox::share() { void BackgroundPreviewBox::paintEvent(QPaintEvent *e) { Painter p(this); - const auto ms = getms(); + const auto ms = crl::now(); const auto color = _paper.backgroundColor(); if (color) { p.fillRect(e->rect(), *color); @@ -516,7 +516,7 @@ void BackgroundPreviewBox::paintEvent(QPaintEvent *e) { paintTexts(p, ms); } -void BackgroundPreviewBox::paintImage(Painter &p, TimeMs ms) { +void BackgroundPreviewBox::paintImage(Painter &p, crl::time ms) { Expects(!_scaled.isNull()); const auto master = _paper.isPattern() @@ -544,7 +544,7 @@ void BackgroundPreviewBox::paintImage(Painter &p, TimeMs ms) { checkBlurAnimationStart(); } -void BackgroundPreviewBox::paintRadial(Painter &p, TimeMs ms) { +void BackgroundPreviewBox::paintRadial(Painter &p, crl::time ms) { bool radial = false; float64 radialOpacity = 0; if (_radial.animating()) { @@ -588,7 +588,7 @@ QRect BackgroundPreviewBox::radialRect() const { st::radialSize); } -void BackgroundPreviewBox::paintTexts(Painter &p, TimeMs ms) { +void BackgroundPreviewBox::paintTexts(Painter &p, crl::time ms) { const auto height1 = _text1->height(); const auto height2 = _text2->height(); p.translate(0, textsTop()); @@ -619,7 +619,7 @@ void BackgroundPreviewBox::paintDate(Painter &p) { p.drawText(bubbleLeft + st::msgServicePadding.left(), bubbleTop + st::msgServicePadding.top() + st::msgServiceFont->ascent, text); } -void BackgroundPreviewBox::step_radial(TimeMs ms, bool timer) { +void BackgroundPreviewBox::step_radial(crl::time ms, bool timer) { Expects(_paper.document() != nullptr); const auto document = _paper.document(); @@ -716,7 +716,7 @@ void BackgroundPreviewBox::checkLoadedDocument() { guard = std::move(right) ]() mutable { auto scaled = PrepareScaledFromFull(image, patternBackground); - const auto ms = getms(); + const auto ms = crl::now(); auto blurred = patternBackground ? QImage() : PrepareScaledNonPattern( @@ -782,9 +782,9 @@ void BackgroundPreviewBox::elementAnimationAutoplayAsync( not_null element) { } -TimeMs BackgroundPreviewBox::elementHighlightTime( +crl::time BackgroundPreviewBox::elementHighlightTime( not_null element) { - return TimeMs(); + return crl::time(); } bool BackgroundPreviewBox::elementInSelectionMode() { diff --git a/Telegram/SourceFiles/boxes/background_preview_box.h b/Telegram/SourceFiles/boxes/background_preview_box.h index 37d573c66..7ad07f37c 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.h +++ b/Telegram/SourceFiles/boxes/background_preview_box.h @@ -37,7 +37,7 @@ public: bool elementUnderCursor(not_null view) override; void elementAnimationAutoplayAsync( not_null element) override; - TimeMs elementHighlightTime( + crl::time elementHighlightTime( not_null element) override; bool elementInSelectionMode() override; @@ -49,7 +49,7 @@ protected: private: void apply(); void share(); - void step_radial(TimeMs ms, bool timer); + void step_radial(crl::time ms, bool timer); QRect radialRect() const; void checkLoadedDocument(); @@ -57,9 +57,9 @@ private: void setScaledFromImage(QImage &&image, QImage &&blurred); void updateServiceBg(std::optional background); std::optional patternBackgroundColor() const; - void paintImage(Painter &p, TimeMs ms); - void paintRadial(Painter &p, TimeMs ms); - void paintTexts(Painter &p, TimeMs ms); + void paintImage(Painter &p, crl::time ms); + void paintRadial(Painter &p, crl::time ms); + void paintTexts(Painter &p, crl::time ms); void paintDate(Painter &p); void createBlurCheckbox(); int textsTop() const; diff --git a/Telegram/SourceFiles/boxes/calendar_box.cpp b/Telegram/SourceFiles/boxes/calendar_box.cpp index e5831be39..2e2b81fb3 100644 --- a/Telegram/SourceFiles/boxes/calendar_box.cpp +++ b/Telegram/SourceFiles/boxes/calendar_box.cpp @@ -286,7 +286,7 @@ int CalendarBox::Inner::rowsTop() const { void CalendarBox::Inner::paintRows(Painter &p, QRect clip) { p.setFont(st::calendarDaysFont); - auto ms = getms(); + auto ms = crl::now(); auto y = rowsTop(); auto index = -_context->daysShift(); auto highlightedIndex = _context->highlightedIndex(); diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 2052108e6..beaedd535 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kSaveSettingsDelayedTimeout = TimeMs(1000); +constexpr auto kSaveSettingsDelayedTimeout = crl::time(1000); class ProxyRow : public Ui::RippleButton { public: @@ -52,8 +52,8 @@ protected: private: void setupControls(View &&view); int countAvailableWidth() const; - void step_radial(TimeMs ms, bool timer); - void paintCheck(Painter &p, TimeMs ms); + void step_radial(crl::time ms, bool timer); + void paintCheck(Painter &p, crl::time ms); void showMenu(); View _view; @@ -241,7 +241,7 @@ void ProxyRow::updateFields(View &&view) { update(); } -void ProxyRow::step_radial(TimeMs ms, bool timer) { +void ProxyRow::step_radial(crl::time ms, bool timer) { if (timer && !anim::Disabled()) { update(); } @@ -268,7 +268,7 @@ int ProxyRow::resizeGetHeight(int newWidth) { void ProxyRow::paintEvent(QPaintEvent *e) { Painter p(this); - const auto ms = getms(); + const auto ms = crl::now(); if (!_view.deleted) { paintRipple(p, 0, 0, ms); } @@ -341,7 +341,7 @@ void ProxyRow::paintEvent(QPaintEvent *e) { top += st::normalFont->height + st::proxyRowPadding.bottom(); } -void ProxyRow::paintCheck(Painter &p, TimeMs ms) { +void ProxyRow::paintCheck(Painter &p, crl::time ms) { if (_progress) { _progress->step(ms); } diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 4d42c2898..dada79598 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -373,7 +373,7 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { if (_gifPreview && _gifPreview->started()) { auto s = QSize(_thumbw, _thumbh); auto paused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer); - auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : getms()); + auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : crl::now()); p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), frame); } else { p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), _thumb); diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index 7e1482578..fc84dff09 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -442,7 +442,7 @@ public: protected: void correctValue(const QString &was, int wasCursor, QString &now, int &nowCursor) override; - void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override; + void paintAdditionalPlaceholder(Painter &p, crl::time ms) override; void wheelEvent(QWheelEvent *e) override; void keyPressEvent(QKeyEvent *e) override; @@ -501,7 +501,7 @@ void EditColorBox::Field::correctValue(const QString &was, int wasCursor, QStrin } } -void EditColorBox::Field::paintAdditionalPlaceholder(Painter &p, TimeMs ms) { +void EditColorBox::Field::paintAdditionalPlaceholder(Painter &p, crl::time ms) { p.setFont(_st.font); p.setPen(_st.placeholderFg); auto inner = QRect(_st.textMargins.right(), _st.textMargins.top(), width() - 2 * _st.textMargins.right(), height() - _st.textMargins.top() - _st.textMargins.bottom()); @@ -565,7 +565,7 @@ public: protected: void correctValue(const QString &was, int wasCursor, QString &now, int &nowCursor) override; - void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override; + void paintAdditionalPlaceholder(Painter &p, crl::time ms) override; }; @@ -606,7 +606,7 @@ void EditColorBox::ResultField::correctValue(const QString &was, int wasCursor, } } -void EditColorBox::ResultField::paintAdditionalPlaceholder(Painter &p, TimeMs ms) { +void EditColorBox::ResultField::paintAdditionalPlaceholder(Painter &p, crl::time ms) { p.setFont(_st.font); p.setPen(_st.placeholderFg); p.drawText(QRect(_st.textMargins.right(), _st.textMargins.top(), width(), height() - _st.textMargins.top() - _st.textMargins.bottom()), "#", style::al_topleft); diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 72cfcbc6a..8d9bcfaad 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -772,7 +772,7 @@ int Rows::countAvailableWidth() const { void Rows::paintEvent(QPaintEvent *e) { Painter p(this); - const auto ms = getms(); + const auto ms = crl::now(); const auto clip = e->rect(); const auto checkLeft = st::passportRowPadding.left(); diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index 64e37729f..eaa99b2a1 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -124,7 +124,7 @@ protected: private: QString titleText(const Database::TaggedSummary &data) const; QString sizeText(const Database::TaggedSummary &data) const; - void step_radial(TimeMs ms, bool timer); + void step_radial(crl::time ms, bool timer); Fn _titleFactory; object_ptr _title; @@ -186,7 +186,7 @@ void LocalStorageBox::Row::toggleProgress(bool shown) { } } -void LocalStorageBox::Row::step_radial(TimeMs ms, bool timer) { +void LocalStorageBox::Row::step_radial(crl::time ms, bool timer) { if (timer && !anim::Disabled()) { RpWidget::update(); } @@ -229,11 +229,10 @@ void LocalStorageBox::Row::paintEvent(QPaintEvent *e) { return; } Painter p(this); - const auto padding = st::localStorageRowPadding; const auto height = st::localStorageRowHeight; const auto bottom = height - padding.bottom() - _description->height(); - _progress->step(crl::time()); + _progress->step(crl::now()); _progress->draw( p, { diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index d0d70a910..c5e4f0a82 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -372,7 +372,7 @@ void PasscodeBox::validateEmail( } void PasscodeBox::handleSrpIdInvalid() { - const auto now = getms(true); + const auto now = crl::now(); if (_lastSrpIdInvalidTime > 0 && now - _lastSrpIdInvalidTime < Core::kHandleSrpIdInvalidTimeout) { _curRequest.id = 0; @@ -403,7 +403,7 @@ void PasscodeBox::save(bool force) { if (_turningOff) pwd = conf = QString(); } else { cSetPasscodeBadTries(cPasscodeBadTries() + 1); - cSetPasscodeLastTry(getms(true)); + cSetPasscodeLastTry(crl::now()); badOldPasscode(); return; } diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index ef4381247..a36a84c2b 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -113,7 +113,7 @@ private: mtpRequestId _setRequest = 0; Core::CloudPasswordCheckRequest _curRequest; - TimeMs _lastSrpIdInvalidTime = 0; + crl::time _lastSrpIdInvalidTime = 0; Core::CloudPasswordAlgo _newAlgo; Core::SecureSecretAlgo _newSecureSecretAlgo; bool _hasRecovery = false; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 413ff4e8d..61ee41bf1 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -375,7 +375,7 @@ void PeerListRow::refreshStatus() { if (Data::OnlineTextActive(user, time)) { _statusType = StatusType::Online; } - _statusValidTill = getms() + _statusValidTill = crl::now() + Data::OnlineChangeTimeout(user, time); } } else if (auto chat = peer()->asChat()) { @@ -393,7 +393,7 @@ void PeerListRow::refreshStatus() { } } -TimeMs PeerListRow::refreshStatusTime() const { +crl::time PeerListRow::refreshStatusTime() const { return _statusValidTill; } @@ -457,7 +457,7 @@ void PeerListRow::stopLastRipple() { } } -void PeerListRow::paintRipple(Painter &p, TimeMs ms, int x, int y, int outerWidth) { +void PeerListRow::paintRipple(Painter &p, crl::time ms, int x, int y, int outerWidth) { if (_ripple) { _ripple->paint(p, x, y, outerWidth, ms); if (_ripple->empty()) { @@ -469,7 +469,7 @@ void PeerListRow::paintRipple(Painter &p, TimeMs ms, int x, int y, int outerWidt void PeerListRow::paintUserpic( Painter &p, const style::PeerListItem &st, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth) { @@ -901,7 +901,7 @@ void PeerListContent::paintEvent(QPaintEvent *e) { auto repaintAfterMin = repaintByStatusAfter; auto rowsTopCached = rowsTop(); - auto ms = getms(); + auto ms = crl::now(); auto yFrom = clip.y() - rowsTopCached; auto yTo = clip.y() + clip.height() - rowsTopCached; p.translate(0, rowsTopCached); @@ -1073,7 +1073,7 @@ void PeerListContent::setPressed(Selected pressed) { _pressed = pressed; } -TimeMs PeerListContent::paintRow(Painter &p, TimeMs ms, RowIndex index) { +crl::time PeerListContent::paintRow(Painter &p, crl::time ms, RowIndex index) { auto row = getRow(index); Assert(row != nullptr); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 3cd9867ec..becf3f520 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -92,7 +92,7 @@ public: } virtual void paintAction( Painter &p, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth, @@ -111,7 +111,7 @@ public: Custom, }; void refreshStatus(); - TimeMs refreshStatusTime() const; + crl::time refreshStatusTime() const; void setAbsoluteIndex(int index) { _absoluteIndex = index; @@ -158,11 +158,11 @@ public: QPoint point, UpdateCallback updateCallback); void stopLastRipple(); - void paintRipple(Painter &p, TimeMs ms, int x, int y, int outerWidth); + void paintRipple(Painter &p, crl::time ms, int x, int y, int outerWidth); void paintUserpic( Painter &p, const style::PeerListItem &st, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth); @@ -208,7 +208,7 @@ private: Text _name; Text _status; StatusType _statusType = StatusType::Online; - TimeMs _statusValidTill = 0; + crl::time _statusValidTill = 0; base::flat_set _nameFirstLetters; int _absoluteIndex = -1; State _disabledState = State::Active; @@ -561,7 +561,7 @@ private: RowIndex findRowIndex(not_null row, RowIndex hint = RowIndex()); QRect getActionRect(not_null row, RowIndex index) const; - TimeMs paintRow(Painter &p, TimeMs ms, RowIndex index); + crl::time paintRow(Painter &p, crl::time ms, RowIndex index); void addRowEntry(not_null row); void addToSearchIndex(not_null row); diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 4e02c875b..63b981f63 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -76,7 +76,7 @@ void AddBotToGroup(not_null bot, not_null chat) { //void MembersAddButton::paintEvent(QPaintEvent *e) { // Painter p(this); // -// auto ms = getms(); +// auto ms = crl::now(); // auto over = isOver(); // auto down = isDown(); // @@ -122,7 +122,7 @@ QMargins PeerListRowWithLink::actionMargins() const { void PeerListRowWithLink::paintAction( Painter &p, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth, diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index 8a932bb46..929ebbb99 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -42,7 +42,7 @@ private: QMargins actionMargins() const override; void paintAction( Painter &p, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth, diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index d34e439c0..b0667308f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -35,7 +35,7 @@ constexpr auto kForwardMessagesOnAdd = 100; constexpr auto kParticipantsFirstPageCount = 16; constexpr auto kParticipantsPerPage = 200; -constexpr auto kSortByOnlineDelay = TimeMs(1000); +constexpr auto kSortByOnlineDelay = crl::time(1000); void RemoveAdmin( not_null channel, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 28b8802a9..8c266990c 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -40,7 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kUsernameCheckTimeout = TimeMs(200); +constexpr auto kUsernameCheckTimeout = crl::time(200); constexpr auto kMinUsernameLength = 5; constexpr auto kMaxGroupChannelTitle = 255; // See also add_contact_box. constexpr auto kMaxChannelDescription = 255; // See also add_contact_box. diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index c0bc1b232..e3a46b119 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -37,8 +37,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { constexpr auto kMinPreviewWidth = 20; -constexpr auto kShrinkDuration = TimeMs(150); -constexpr auto kDragDuration = TimeMs(200); +constexpr auto kShrinkDuration = crl::time(150); +constexpr auto kDragDuration = crl::time(200); class SingleMediaPreview : public Ui::RpWidget { public: @@ -123,7 +123,7 @@ public: int top, float64 shrinkProgress, float64 moveProgress, - TimeMs ms); + crl::time ms); void paintPhoto(Painter &p, int left, int top, int outerWidth); void paintFile(Painter &p, int left, int top, int outerWidth); @@ -291,7 +291,7 @@ void AlbumThumb::paintInAlbum( int top, float64 shrinkProgress, float64 moveProgress, - TimeMs ms) { + crl::time ms) { const auto shrink = anim::interpolate(0, _shrinkSize, shrinkProgress); _suggestedMoveAnimation.step(ms); _lastShrinkValue = shrink; @@ -723,7 +723,7 @@ void SingleMediaPreview::paintEvent(QPaintEvent *e) { if (_gifPreview && _gifPreview->started()) { auto s = QSize(_previewWidth, _previewHeight); auto paused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer); - auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : getms()); + auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : crl::now()); p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), frame); } else { p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), _preview); @@ -1187,7 +1187,7 @@ void SendFilesBox::AlbumPreview::paintEvent(QPaintEvent *e) { } void SendFilesBox::AlbumPreview::paintAlbum(Painter &p) const { - const auto ms = getms(); + const auto ms = crl::now(); const auto shrink = _shrinkAnimation.current( ms, _draggedThumb ? 1. : 0.); diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 35dcef99a..fa403b951 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kSessionsShortPollTimeout = 60 * TimeMs(1000); +constexpr auto kSessionsShortPollTimeout = 60 * crl::time(1000); } // namespace diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index c0a640e96..43c43d080 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -93,7 +93,7 @@ private: int displayedChatsCount() const; - void paintChat(Painter &p, TimeMs ms, not_null chat, int index); + void paintChat(Painter &p, crl::time ms, not_null chat, int index); void updateChat(not_null peer); void updateChatName(not_null chat, not_null peer); void repaintChat(not_null peer); @@ -732,7 +732,7 @@ void ShareBox::Inner::setActive(int active) { void ShareBox::Inner::paintChat( Painter &p, - TimeMs ms, + crl::time ms, not_null chat, int index) { auto x = _rowsLeft + qFloor((index % _columnCount) * _rowWidthReal); @@ -761,7 +761,7 @@ ShareBox::Inner::Chat::Chat(PeerData *peer, Fn updateCallback) void ShareBox::Inner::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto r = e->rect(); p.setClipRect(r); p.fillRect(r, st::boxBg); diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 701bd8918..278076f3e 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -451,7 +451,7 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) { if (_pack.isEmpty()) return; - auto ms = getms(); + auto ms = crl::now(); int32 rows = _pack.size() / kStickersPanelPerRow + ((_pack.size() % kStickersPanelPerRow) ? 1 : 0); int32 from = qFloor(e->rect().top() / st::stickersSize.height()), to = qFloor(e->rect().bottom() / st::stickersSize.height()) + 1; diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index b7c0a6b58..78632eae8 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -36,7 +36,7 @@ namespace { constexpr auto kArchivedLimitFirstRequest = 10; constexpr auto kArchivedLimitPerPage = 30; -constexpr auto kHandleMegagroupSetAddressChangeTimeout = TimeMs(1000); +constexpr auto kHandleMegagroupSetAddressChangeTimeout = crl::time(1000); } // namespace @@ -341,7 +341,7 @@ void StickersBox::paintEvent(QPaintEvent *e) { Painter p(this); if (_slideAnimation) { - _slideAnimation->paintFrame(p, 0, getTopSkip(), width(), getms()); + _slideAnimation->paintFrame(p, 0, getTopSkip(), width(), crl::now()); if (!_slideAnimation->animating()) { _slideAnimation.reset(); setInnerVisible(true); @@ -666,7 +666,7 @@ void StickersBox::Inner::paintEvent(QPaintEvent *e) { } auto clip = e->rect(); - auto ms = getms(); + auto ms = crl::now(); p.fillRect(clip, st::boxBg); p.setClipRect(clip); @@ -741,7 +741,7 @@ QRect StickersBox::Inner::relativeButtonRect(bool removeButton) const { return QRect(buttonx, buttony, buttonw, buttonh); } -void StickersBox::Inner::paintRow(Painter &p, Row *set, int index, TimeMs ms) { +void StickersBox::Inner::paintRow(Painter &p, Row *set, int index, crl::time ms) { auto xadd = 0, yadd = qRound(set->yadd.current()); if (xadd || yadd) p.translate(xadd, yadd); @@ -841,7 +841,7 @@ void StickersBox::Inner::paintRow(Painter &p, Row *set, int index, TimeMs ms) { if (xadd || yadd) p.translate(-xadd, -yadd); } -void StickersBox::Inner::paintFakeButton(Painter &p, Row *set, int index, TimeMs ms) { +void StickersBox::Inner::paintFakeButton(Painter &p, Row *set, int index, crl::time ms) { auto removeButton = (_section == Section::Installed && !set->removed); auto rect = relativeButtonRect(removeButton); if (_section != Section::Installed && set->installed && !set->archived && !set->removed) { @@ -1019,7 +1019,7 @@ void StickersBox::Inner::onUpdateSelected() { auto local = mapFromGlobal(_mouse); if (_dragging >= 0) { auto shift = 0; - auto ms = getms(); + auto ms = crl::now(); int firstSetIndex = 0; if (_rows.at(firstSetIndex)->isRecentSet()) { ++firstSetIndex; @@ -1129,7 +1129,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { } else if (_dragging >= 0) { QPoint local(mapFromGlobal(_mouse)); _rows[_dragging]->yadd.start(0.); - _aboveShadowFadeStart = _animStartTimes[_dragging] = getms(); + _aboveShadowFadeStart = _animStartTimes[_dragging] = crl::now(); _aboveShadowFadeOpacity = anim::value(aboveShadowOpacity(), 0); if (!_a_shifting.animating()) { _a_shifting.start(); @@ -1209,7 +1209,7 @@ void StickersBox::Inner::leaveToChildEvent(QEvent *e, QWidget *child) { onUpdateSelected(); } -void StickersBox::Inner::step_shifting(TimeMs ms, bool timer) { +void StickersBox::Inner::step_shifting(crl::time ms, bool timer) { if (anim::Disabled()) { ms += st::stickersRowDuration; } diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index b2780214e..a406bc6fc 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -262,9 +262,9 @@ private: QRect relativeButtonRect(bool removeButton) const; void ensureRipple(const style::RippleAnimation &st, QImage mask, bool removeButton); - void step_shifting(TimeMs ms, bool timer); - void paintRow(Painter &p, Row *set, int index, TimeMs ms); - void paintFakeButton(Painter &p, Row *set, int index, TimeMs ms); + void step_shifting(crl::time ms, bool timer); + void paintRow(Painter &p, Row *set, int index, crl::time ms); + void paintFakeButton(Painter &p, Row *set, int index, crl::time ms); void clear(); void setActionSel(int32 actionSel); float64 aboveShadowOpacity() const; @@ -289,8 +289,8 @@ private: int32 _rowHeight; std::vector> _rows; - QList _animStartTimes; - TimeMs _aboveShadowFadeStart = 0; + QList _animStartTimes; + crl::time _aboveShadowFadeStart = 0; anim::value _aboveShadowFadeOpacity; BasicAnimation _a_shifting; diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 4712651dc..6af707e78 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -97,7 +97,7 @@ public: } void paintAction( Painter &p, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth, @@ -143,7 +143,7 @@ void BoxController::Row::paintStatusText(Painter &p, const style::PeerListItem & void BoxController::Row::paintAction( Painter &p, - TimeMs ms, + crl::time ms, int x, int y, int outerWidth, diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 99ec5b809..bd63bbf2c 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -295,8 +295,8 @@ void Call::setMute(bool mute) { _muteChanged.notify(_mute); } -TimeMs Call::getDurationMs() const { - return _startTime ? (getms(true) - _startTime) : 0; +crl::time Call::getDurationMs() const { + return _startTime ? (crl::now() - _startTime) : 0; } void Call::hangup() { @@ -341,7 +341,7 @@ void Call::startWaitingTrack() { float64 Call::getWaitingSoundPeakValue() const { if (_waitingTrack) { - auto when = getms() + kSoundSampleMs / 4; + auto when = crl::now() + kSoundSampleMs / 4; return _waitingTrack->getPeakValue(when); } return 0.; @@ -740,7 +740,7 @@ void Call::setState(State state) { } switch (_state) { case State::Established: - _startTime = getms(true); + _startTime = crl::now(); break; case State::ExchangingKeys: _delegate->playSound(Delegate::Sound::Connecting); diff --git a/Telegram/SourceFiles/calls/calls_call.h b/Telegram/SourceFiles/calls/calls_call.h index 90f23e782..4f23987f0 100644 --- a/Telegram/SourceFiles/calls/calls_call.h +++ b/Telegram/SourceFiles/calls/calls_call.h @@ -110,7 +110,7 @@ public: return _muteChanged; } - TimeMs getDurationMs() const; + crl::time getDurationMs() const; float64 getWaitingSoundPeakValue() const; void answer(); @@ -190,7 +190,7 @@ private: base::Observable _stateChanged; int _signalBarCount = kSignalBarStarting; base::Observable _signalBarCountChanged; - TimeMs _startTime = 0; + crl::time _startTime = 0; base::DelayedCallTimer _finishByTimeoutTimer; base::Timer _discardByTimeoutTimer; diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 966637848..ed2a5183d 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Calls { namespace { -constexpr auto kServerConfigUpdateTimeoutMs = 24 * 3600 * TimeMs(1000); +constexpr auto kServerConfigUpdateTimeoutMs = 24 * 3600 * crl::time(1000); } // namespace @@ -184,12 +184,12 @@ void Instance::refreshServerConfig() { if (_serverConfigRequestId) { return; } - if (_lastServerConfigUpdateTime && (getms(true) - _lastServerConfigUpdateTime) < kServerConfigUpdateTimeoutMs) { + if (_lastServerConfigUpdateTime && (crl::now() - _lastServerConfigUpdateTime) < kServerConfigUpdateTimeoutMs) { return; } _serverConfigRequestId = request(MTPphone_GetCallConfig()).done([this](const MTPDataJSON &result) { _serverConfigRequestId = 0; - _lastServerConfigUpdateTime = getms(true); + _lastServerConfigUpdateTime = crl::now(); const auto &json = result.c_dataJSON().vdata.v; UpdateConfig(std::string(json.data(), json.size())); diff --git a/Telegram/SourceFiles/calls/calls_instance.h b/Telegram/SourceFiles/calls/calls_instance.h index c59f496d2..ae45949f9 100644 --- a/Telegram/SourceFiles/calls/calls_instance.h +++ b/Telegram/SourceFiles/calls/calls_instance.h @@ -66,7 +66,7 @@ private: DhConfig _dhConfig; - TimeMs _lastServerConfigUpdateTime = 0; + crl::time _lastServerConfigUpdateTime = 0; mtpRequestId _serverConfigRequestId = 0; std::unique_ptr _currentCall; diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 315483c8a..95a372785 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -186,7 +186,7 @@ void Panel::Button::setProgress(float64 progress) { void Panel::Button::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto bgPosition = myrtlpoint(_stFrom->button.rippleAreaPosition); auto paintFrom = (_progress == 0.) || !_stTo; auto paintTo = !paintFrom && (_progress == 1.); @@ -695,7 +695,7 @@ void Panel::updateStatusGeometry() { void Panel::paintEvent(QPaintEvent *e) { Painter p(this); if (!_animationCache.isNull()) { - auto opacity = _opacityAnimation.current(getms(), _call ? 1. : 0.); + auto opacity = _opacityAnimation.current(crl::now(), _call ? 1. : 0.); if (!_opacityAnimation.animating()) { finishAnimating(); if (!_call || isHidden()) return; @@ -921,7 +921,7 @@ void Panel::updateStatusText(State state) { updateStatusGeometry(); } -void Panel::startDurationUpdateTimer(TimeMs currentDuration) { +void Panel::startDurationUpdateTimer(crl::time currentDuration) { auto msTillNextSecond = 1000 - (currentDuration % 1000); _updateDurationTimer.callOnce(msTillNextSecond + 5); } diff --git a/Telegram/SourceFiles/calls/calls_panel.h b/Telegram/SourceFiles/calls/calls_panel.h index d7eef4d22..2d1d979b6 100644 --- a/Telegram/SourceFiles/calls/calls_panel.h +++ b/Telegram/SourceFiles/calls/calls_panel.h @@ -102,7 +102,7 @@ private: void stateChanged(State state); void showControls(); void updateStatusText(State state); - void startDurationUpdateTimer(TimeMs currentDuration); + void startDurationUpdateTimer(crl::time currentDuration); void fillFingerprint(); void toggleOpacityAnimation(bool visible); void finishAnimating(); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index bca48a200..460abe380 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Calls { namespace { -constexpr auto kUpdateDebugTimeoutMs = TimeMs(500); +constexpr auto kUpdateDebugTimeoutMs = crl::time(500); class DebugInfoBox : public BoxContent { public: @@ -162,7 +162,7 @@ void TopBar::updateDurationText() { } } -void TopBar::startDurationUpdateTimer(TimeMs currentDuration) { +void TopBar::startDurationUpdateTimer(crl::time currentDuration) { auto msTillNextSecond = 1000 - (currentDuration % 1000); _updateDurationTimer.callOnce(msTillNextSecond + 5); } diff --git a/Telegram/SourceFiles/calls/calls_top_bar.h b/Telegram/SourceFiles/calls/calls_top_bar.h index d080a2c24..b2d9ce262 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.h +++ b/Telegram/SourceFiles/calls/calls_top_bar.h @@ -39,7 +39,7 @@ private: void setInfoLabels(); void updateDurationText(); void updateControlsGeometry(); - void startDurationUpdateTimer(TimeMs currentDuration); + void startDurationUpdateTimer(crl::time currentDuration); void setMuted(bool mute); base::weak_ptr _call; diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index abab8920b..79280a855 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -110,7 +110,7 @@ void BotKeyboard::paintEvent(QPaintEvent *e) { if (_impl) { int x = rtl() ? st::botKbScroll.width : _st->margin; p.translate(x, st::botKbScroll.deltat); - _impl->paint(p, width(), clip.translated(-x, -st::botKbScroll.deltat), getms()); + _impl->paint(p, width(), clip.translated(-x, -st::botKbScroll.deltat), crl::now()); } } diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.h b/Telegram/SourceFiles/chat_helpers/bot_keyboard.h index 58ef69d3c..e8c0fa589 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.h +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.h @@ -30,7 +30,7 @@ public: bool hasMarkup() const; bool forceReply() const; - void step_selected(TimeMs ms, bool timer); + void step_selected(crl::time ms, bool timer); void resizeToWidth(int newWidth, int maxOuterHeight) { _maxOuterHeight = maxOuterHeight; return TWidget::resizeToWidth(newWidth); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 974c76b20..9fd745de4 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -186,7 +186,7 @@ void EmojiColorPicker::updateSize() { void EmojiColorPicker::paintEvent(QPaintEvent *e) { Painter p(this); - auto opacity = _a_opacity.current(getms(), _hiding ? 0. : 1.); + auto opacity = _a_opacity.current(crl::now(), _hiding ? 0. : 1.); if (opacity < 1.) { if (opacity > 0.) { p.setOpacity(opacity); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 36969e55c..76430b866 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -119,12 +119,12 @@ private: void setupPreview(const Set &set); void setupAnimation(); void paintPreview(Painter &p) const; - void paintRadio(Painter &p, TimeMs ms); - void updateAnimation(TimeMs ms); + void paintRadio(Painter &p, crl::time ms); + void updateAnimation(crl::time ms); void setupHandler(); void load(); - void step_radial(TimeMs ms, bool timer); + void step_radial(crl::time ms, bool timer); int _id = 0; bool _switching = false; @@ -355,7 +355,7 @@ void Row::paintEvent(QPaintEvent *e) { const auto bg = over ? st::windowBgOver : st::windowBg; p.fillRect(rect(), bg); - const auto ms = getms(); + const auto ms = crl::now(); paintRipple(p, 0, 0, ms); paintPreview(p); @@ -377,7 +377,7 @@ void Row::paintPreview(Painter &p) const { } } -void Row::paintRadio(Painter &p, TimeMs ms) { +void Row::paintRadio(Painter &p, crl::time ms) { updateAnimation(ms); const auto loading = _loading @@ -582,7 +582,7 @@ void Row::setupPreview(const Set &set) { } } -void Row::step_radial(TimeMs ms, bool timer) { +void Row::step_radial(crl::time ms, bool timer) { if (timer && !anim::Disabled()) { update(); } @@ -625,7 +625,7 @@ void Row::setupAnimation() { updateStatusColorOverride(); } -void Row::updateAnimation(TimeMs ms) { +void Row::updateAnimation(crl::time ms) { const auto state = _state.current(); if (const auto loading = base::get_if(&state)) { const auto progress = (loading->size > 0) @@ -636,10 +636,10 @@ void Row::updateAnimation(TimeMs ms) { animation(this, &Row::step_radial)); _loading->start(progress); } else { - _loading->update(progress, false, getms()); + _loading->update(progress, false, crl::now()); } } else if (_loading) { - _loading->update(state.is() ? 0. : 1., true, getms()); + _loading->update(state.is() ? 0. : 1., true, crl::now()); } else { _loading = nullptr; } diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp index 02f2d5cba..84a052730 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp @@ -179,7 +179,7 @@ int SuggestionsWidget::countWidth(const Row &row) { void SuggestionsWidget::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto clip = e->rect(); auto topskip = QRect(0, 0, width(), _st->skip); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index af5b8e1fe..4f44b1919 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -47,7 +47,7 @@ FieldAutocomplete::FieldAutocomplete(QWidget *parent) : TWidget(parent) void FieldAutocomplete::paintEvent(QPaintEvent *e) { Painter p(this); - auto opacity = _a_opacity.current(getms(), _hiding ? 0. : 1.); + auto opacity = _a_opacity.current(crl::now(), _hiding ? 0. : 1.); if (opacity < 1.) { if (opacity > 0.) { p.setOpacity(opacity); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index c93d552c0..480b73c9e 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -176,7 +176,7 @@ void GifsListWidget::visibleTopBottomUpdated( auto top = getVisibleTop(); Inner::visibleTopBottomUpdated(visibleTop, visibleBottom); if (top != getVisibleTop()) { - _lastScrolled = getms(); + _lastScrolled = crl::now(); } checkLoadMore(); } @@ -274,7 +274,7 @@ void GifsListWidget::paintInlineItems(Painter &p, QRect clip) { return; } auto gifPaused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs); - InlineBots::Layout::PaintContext context(getms(), false, gifPaused, false); + InlineBots::Layout::PaintContext context(crl::now(), false, gifPaused, false); auto top = st::stickerPanPadding; auto fromx = rtl() ? (width() - clip.x() - clip.width()) : clip.x(); @@ -751,7 +751,7 @@ void GifsListWidget::inlineItemLayoutChanged(const InlineBots::Layout::ItemBase } void GifsListWidget::inlineItemRepaint(const InlineBots::Layout::ItemBase *layout) { - auto ms = getms(); + auto ms = crl::now(); if (_lastScrolled + 100 <= ms) { update(); } else { @@ -1018,7 +1018,7 @@ void GifsListWidget::showPreview() { } void GifsListWidget::updateInlineItems() { - auto ms = getms(); + auto ms = crl::now(); if (_lastScrolled + 100 <= ms) { update(); } else { diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h index c4c42603d..6cb0f239e 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.h @@ -117,7 +117,7 @@ private: void showPreview(); Section _section = Section::Gifs; - TimeMs _lastScrolled = 0; + crl::time _lastScrolled = 0; base::Timer _updateInlineItems; bool _inlineWithThumb = false; diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index d719e57e7..d07540ab8 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -27,7 +27,7 @@ namespace { using EditLinkAction = Ui::InputField::EditLinkAction; using EditLinkSelection = Ui::InputField::EditLinkSelection; -constexpr auto kParseLinksTimeout = TimeMs(1000); +constexpr auto kParseLinksTimeout = crl::time(1000); const auto kMentionTagStart = qstr("mention://user."); bool IsMentionLink(const QString &link) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 76c9f29da..b2aa5d72a 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -98,7 +98,7 @@ private: template void enumerateVisibleIcons(Callback callback); - void step_icons(TimeMs ms, bool timer); + void step_icons(crl::time ms, bool timer); void setSelectedIcon( int newSelected, ValidateIconAnimations animations); @@ -136,7 +136,7 @@ private: int _iconsMax = 0; anim::value _iconsX; anim::value _iconSelX; - TimeMs _iconsStartAnim = 0; + crl::time _iconsStartAnim = 0; bool _horizontal = false; @@ -312,7 +312,7 @@ void StickersListWidget::Footer::setSelectedIcon( _a_icons.stop(); } else { _iconsX.start(iconsXFinal); - _iconsStartAnim = getms(); + _iconsStartAnim = crl::now(); _a_icons.start(); } updateSelected(); @@ -656,7 +656,7 @@ void StickersListWidget::Footer::paintSetIcon( } } -void StickersListWidget::Footer::step_icons(TimeMs ms, bool timer) { +void StickersListWidget::Footer::step_icons(crl::time ms, bool timer) { if (anim::Disabled()) { ms += st::stickerIconMove; } @@ -1151,7 +1151,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) { toColumn = _columnCount - toColumn; } - auto ms = getms(); + auto ms = crl::now(); auto &sets = shownSets(); auto selectedSticker = base::get_if(&_selected); auto selectedButton = base::get_if(_pressed ? &_pressed : &_selected); @@ -1309,7 +1309,7 @@ int StickersListWidget::megagroupSetInfoLeft() const { return st::emojiPanHeaderLeft - st::buttonRadius; } -void StickersListWidget::paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, TimeMs ms) { +void StickersListWidget::paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, crl::time ms) { auto infoLeft = megagroupSetInfoLeft(); _megagroupSetAbout.drawLeft(p, infoLeft, y, width() - infoLeft, width()); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index 36400030e..ef0bdacd8 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -199,7 +199,7 @@ private: void paintFeaturedStickers(Painter &p, QRect clip); void paintStickers(Painter &p, QRect clip); - void paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, TimeMs ms); + void paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, crl::time ms); void paintSticker(Painter &p, Set &set, int y, int index, bool selected, bool deleteSelected); void paintEmptySearchResults(Painter &p); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index 681a00423..d1856829a 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -155,7 +155,7 @@ void TabbedPanel::windowActiveChanged() { void TabbedPanel::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); // This call can finish _a_show animation and destroy _showAnimation. auto opacityAnimating = _a_opacity.animating(ms); @@ -208,7 +208,7 @@ void TabbedPanel::leaveEventHook(QEvent *e) { if (preventAutoHide()) { return; } - auto ms = getms(); + auto ms = crl::now(); if (_a_show.animating(ms) || _a_opacity.animating(ms)) { hideAnimated(); } else { @@ -226,7 +226,7 @@ void TabbedPanel::otherLeave() { return; } - auto ms = getms(); + auto ms = crl::now(); if (_a_opacity.animating(ms)) { hideByTimerOrLeave(); } else { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 782f085a4..695ee187e 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -494,7 +494,7 @@ void TabbedSelector::updateRestrictedLabelGeometry() { void TabbedSelector::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto switching = (_slideAnimation != nullptr); if (switching) { @@ -509,7 +509,7 @@ void TabbedSelector::paintEvent(QPaintEvent *e) { } } -void TabbedSelector::paintSlideFrame(Painter &p, TimeMs ms) { +void TabbedSelector::paintSlideFrame(Painter &p, crl::time ms) { if (_roundRadius > 0) { if (full()) { auto topPart = QRect(0, 0, width(), _tabsSlider->height() + _roundRadius); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index b5d80831a..0cd5073a4 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -149,7 +149,7 @@ private: SelectorTab type, not_null controller); - void paintSlideFrame(Painter &p, TimeMs ms); + void paintSlideFrame(Painter &p, crl::time ms); void paintContent(Painter &p); void checkRestrictedPeer(); diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 4adc8158a..7798a9f2e 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_user.h" #include "base/timer.h" +#include "base/concurrent_timer.h" #include "core/update_checker.h" #include "core/shortcuts.h" #include "core/sandbox.h" @@ -630,8 +631,13 @@ void Application::forceLogOut(const TextWithEntities &explanation) { } void Application::checkLocalTime() { - const auto updated = checkms(); - if (App::main()) App::main()->checkLastUpdate(updated); + if (crl::adjust_time()) { + base::Timer::Adjust(); + base::ConcurrentTimerEnvironment::Adjust(); + if (App::main()) App::main()->checkLastUpdate(true); + } else { + if (App::main()) App::main()->checkLastUpdate(false); + } } void Application::stateChanged(Qt::ApplicationState state) { diff --git a/Telegram/SourceFiles/core/core_cloud_password.h b/Telegram/SourceFiles/core/core_cloud_password.h index bffafe5b7..de5b359c8 100644 --- a/Telegram/SourceFiles/core/core_cloud_password.h +++ b/Telegram/SourceFiles/core/core_cloud_password.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Core { -constexpr auto kHandleSrpIdInvalidTimeout = 60 * TimeMs(1000); +constexpr auto kHandleSrpIdInvalidTimeout = 60 * crl::time(1000); struct CloudPasswordAlgoModPow { static constexpr auto kIterations = 100000; diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index dabeddc36..cbcd312ef 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -36,7 +36,7 @@ extern "C" { namespace Core { namespace { -constexpr auto kUpdaterTimeout = 10 * TimeMs(1000); +constexpr auto kUpdaterTimeout = 10 * crl::time(1000); constexpr auto kMaxResponseSize = 1024 * 1024; #ifdef TDESKTOP_DISABLE_AUTOUPDATE @@ -1227,7 +1227,7 @@ void Updater::start(bool forceWait) { _checking.fire({}); } else { - _timer.callOnce((updateInSecs + 5) * TimeMs(1000)); + _timer.callOnce((updateInSecs + 5) * crl::time(1000)); } } diff --git a/Telegram/SourceFiles/core/utils.cpp b/Telegram/SourceFiles/core/utils.cpp index bd836855e..0c24006ab 100644 --- a/Telegram/SourceFiles/core/utils.cpp +++ b/Telegram/SourceFiles/core/utils.cpp @@ -8,8 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/utils.h" #include "base/qthelp_url.h" -#include "base/timer.h" -#include "base/concurrent_timer.h" #include "platform/platform_specific.h" extern "C" { @@ -226,7 +224,7 @@ namespace { timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - const auto seed = 1000LL * static_cast(ts.tv_sec) + (static_cast(ts.tv_nsec) / 1000000LL); + const auto seed = 1000LL * static_cast(ts.tv_sec) + (static_cast(ts.tv_nsec) / 1000000LL); #endif srand((uint32)(seed & 0xFFFFFFFFL)); } @@ -431,19 +429,6 @@ namespace ThirdParty { } } -bool checkms() { - if (crl::adjust_time()) { - base::Timer::Adjust(); - base::ConcurrentTimerEnvironment::Adjust(); - return true; - } - return false; -} - -TimeMs getms(bool checked) { - return crl::time(); -} - uint64 msgid() { #ifdef Q_OS_WIN LARGE_INTEGER li; diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index e8b0d33b9..ee1dbc596 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -161,10 +161,7 @@ namespace ThirdParty { void start(); void finish(); -} - -bool checkms(); // returns true if time has changed -TimeMs getms(bool checked = false); +} // namespace ThirdParty const static uint32 _md5_block_size = 64; class HashMd5 { @@ -324,7 +321,7 @@ struct ProxyData { QString user, password; std::vector resolvedIPs; - TimeMs resolvedExpireAt = 0; + crl::time resolvedExpireAt = 0; bool valid() const; bool supportsCalls() const; diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 151746057..a12c82e11 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kUpdateFullPeerTimeout = TimeMs(5000); // Not more than once in 5 seconds. +constexpr auto kUpdateFullPeerTimeout = crl::time(5000); // Not more than once in 5 seconds. constexpr auto kUserpicSize = 160; using UpdateFlag = Notify::PeerUpdate::Flag; @@ -431,7 +431,7 @@ PeerData::~PeerData() = default; void PeerData::updateFull() { if (!_lastFullUpdate - || getms(true) > _lastFullUpdate + kUpdateFullPeerTimeout) { + || crl::now() > _lastFullUpdate + kUpdateFullPeerTimeout) { updateFullForced(); } } @@ -446,7 +446,7 @@ void PeerData::updateFullForced() { } void PeerData::fullUpdated() { - _lastFullUpdate = getms(true); + _lastFullUpdate = crl::now(); } UserData *PeerData::asUser() { diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index dae4b7e54..e38a7b448 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -317,7 +317,7 @@ private: base::flat_set _nameWords; // for filtering base::flat_set _nameFirstLetters; - TimeMs _lastFullUpdate = 0; + crl::time _lastFullUpdate = 0; MsgId _pinnedMessageId = 0; QString _about; diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index 41becf1de..36172c27f 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { namespace { -constexpr auto kMinOnlineChangeTimeout = TimeMs(1000); -constexpr auto kMaxOnlineChangeTimeout = 86400 * TimeMs(1000); +constexpr auto kMinOnlineChangeTimeout = crl::time(1000); +constexpr auto kMaxOnlineChangeTimeout = 86400 * crl::time(1000); constexpr auto kSecondsInDay = 86400; int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) { @@ -273,16 +273,16 @@ TimeId SortByOnlineValue(not_null user, TimeId now) { return online; } -TimeMs OnlineChangeTimeout(TimeId online, TimeId now) { +crl::time OnlineChangeTimeout(TimeId online, TimeId now) { const auto result = OnlinePhraseChangeInSeconds(online, now); Assert(result >= 0); return snap( - result * TimeMs(1000), + result * crl::time(1000), kMinOnlineChangeTimeout, kMaxOnlineChangeTimeout); } -TimeMs OnlineChangeTimeout(not_null user, TimeId now) { +crl::time OnlineChangeTimeout(not_null user, TimeId now) { if (isServiceUser(user->id) || user->botInfo) { return kMaxOnlineChangeTimeout; } diff --git a/Telegram/SourceFiles/data/data_peer_values.h b/Telegram/SourceFiles/data/data_peer_values.h index 5196a1d54..8744a46ad 100644 --- a/Telegram/SourceFiles/data/data_peer_values.h +++ b/Telegram/SourceFiles/data/data_peer_values.h @@ -111,8 +111,8 @@ rpl::producer CanWriteValue(ChannelData *channel); rpl::producer CanWriteValue(not_null peer); TimeId SortByOnlineValue(not_null user, TimeId now); -TimeMs OnlineChangeTimeout(TimeId online, TimeId now); -TimeMs OnlineChangeTimeout(not_null user, TimeId now); +crl::time OnlineChangeTimeout(TimeId online, TimeId now); +crl::time OnlineChangeTimeout(not_null user, TimeId now); QString OnlineText(TimeId online, TimeId now); QString OnlineText(not_null user, TimeId now); QString OnlineTextFull(not_null user, TimeId now); diff --git a/Telegram/SourceFiles/data/data_poll.cpp b/Telegram/SourceFiles/data/data_poll.cpp index f4fac096c..1507a7b9c 100644 --- a/Telegram/SourceFiles/data/data_poll.cpp +++ b/Telegram/SourceFiles/data/data_poll.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -constexpr auto kShortPollTimeout = 30 * TimeMs(1000); +constexpr auto kShortPollTimeout = 30 * crl::time(1000); const PollAnswer *AnswerByOption( const std::vector &list, @@ -80,7 +80,7 @@ bool PollData::applyChanges(const MTPDpoll &poll) { bool PollData::applyResults(const MTPPollResults &results) { return results.match([&](const MTPDpollResults &results) { - lastResultsUpdate = getms(); + lastResultsUpdate = crl::now(); const auto newTotalVoters = results.has_total_voters() ? results.vtotal_voters.v @@ -102,7 +102,7 @@ bool PollData::applyResults(const MTPPollResults &results) { }); } -void PollData::checkResultsReload(not_null item, TimeMs now) { +void PollData::checkResultsReload(not_null item, crl::time now) { if (lastResultsUpdate && lastResultsUpdate + kShortPollTimeout > now) { return; } else if (closed) { diff --git a/Telegram/SourceFiles/data/data_poll.h b/Telegram/SourceFiles/data/data_poll.h index 13dfd2477..f89b92bc1 100644 --- a/Telegram/SourceFiles/data/data_poll.h +++ b/Telegram/SourceFiles/data/data_poll.h @@ -28,7 +28,7 @@ struct PollData { bool applyChanges(const MTPDpoll &poll); bool applyResults(const MTPPollResults &results); - void checkResultsReload(not_null item, TimeMs now); + void checkResultsReload(not_null item, crl::time now); PollAnswer *answerByOption(const QByteArray &option); const PollAnswer *answerByOption(const QByteArray &option) const; @@ -41,7 +41,7 @@ struct PollData { int totalVoters = 0; bool closed = false; QByteArray sendingVote; - TimeMs lastResultsUpdate = 0; + crl::time lastResultsUpdate = 0; int version = 0; diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index 198e739d0..89934361d 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -18,7 +18,7 @@ namespace Api { namespace { constexpr auto kSharedMediaLimit = 100; -constexpr auto kDefaultSearchTimeoutMs = TimeMs(200); +constexpr auto kDefaultSearchTimeoutMs = crl::time(200); } // namespace @@ -379,7 +379,7 @@ void DelayedSearchController::setQuery(const Query &query) { void DelayedSearchController::setQuery( const Query &query, - TimeMs delay) { + crl::time delay) { if (currentQuery() == query) { _timer.cancel(); return; diff --git a/Telegram/SourceFiles/data/data_search_controller.h b/Telegram/SourceFiles/data/data_search_controller.h index 172d41206..625c42778 100644 --- a/Telegram/SourceFiles/data/data_search_controller.h +++ b/Telegram/SourceFiles/data/data_search_controller.h @@ -137,7 +137,7 @@ public: using SavedState = SearchController::SavedState; void setQuery(const Query &query); - void setQuery(const Query &query, TimeMs delay); + void setQuery(const Query &query, crl::time delay); void setQueryFast(const Query &query); Query currentQuery() const { diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 0862f4320..a0691aadf 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -44,7 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { namespace { -constexpr auto kMaxNotifyCheckDelay = 24 * 3600 * TimeMs(1000); +constexpr auto kMaxNotifyCheckDelay = 24 * 3600 * crl::time(1000); constexpr auto kMaxWallpaperSize = 10 * 1024 * 1024; using ViewElement = HistoryView::Element; @@ -722,13 +722,13 @@ void Session::registerSendAction( const auto i = _sendActions.find(history); if (!_sendActions.contains(history)) { - _sendActions.emplace(history, getms()); + _sendActions.emplace(history, crl::now()); _a_sendActions.start(); } } } -void Session::step_typings(TimeMs ms, bool timer) { +void Session::step_typings(crl::time ms, bool timer) { for (auto i = begin(_sendActions); i != end(_sendActions);) { if (i->first->updateSendActionNeedsAnimating(ms)) { ++i; @@ -790,7 +790,7 @@ void Session::suggestStartExport() { : (_exportAvailableAt - now); if (left) { App::CallDelayed( - std::min(left + 5, 3600) * TimeMs(1000), + std::min(left + 5, 3600) * crl::time(1000), _session, [=] { suggestStartExport(); }); } else if (_export) { @@ -840,7 +840,7 @@ const Passport::SavedCredentials *Session::passportCredentials() const { void Session::rememberPassportCredentials( Passport::SavedCredentials data, - TimeMs rememberFor) { + crl::time rememberFor) { Expects(rememberFor > 0); static auto generation = 0; @@ -1359,7 +1359,7 @@ const NotifySettings &Session::defaultNotifySettings( void Session::updateNotifySettingsLocal(not_null peer) { const auto history = historyLoaded(peer->id); - auto changesIn = TimeMs(0); + auto changesIn = crl::time(0); const auto muted = notifyIsMuted(peer, &changesIn); if (history && history->changeMute(muted)) { // Notification already sent. @@ -1380,7 +1380,7 @@ void Session::updateNotifySettingsLocal(not_null peer) { } } -void Session::unmuteByFinishedDelayed(TimeMs delay) { +void Session::unmuteByFinishedDelayed(crl::time delay) { accumulate_min(delay, kMaxNotifyCheckDelay); if (!_unmuteByFinishedTimer.isActive() || _unmuteByFinishedTimer.remainingTime() > delay) { @@ -1389,10 +1389,10 @@ void Session::unmuteByFinishedDelayed(TimeMs delay) { } void Session::unmuteByFinished() { - auto changesInMin = TimeMs(0); + auto changesInMin = crl::time(0); for (auto i = begin(_mutedPeers); i != end(_mutedPeers);) { const auto history = historyLoaded((*i)->id); - auto changesIn = TimeMs(0); + auto changesIn = crl::time(0); const auto muted = notifyIsMuted(*i, &changesIn); if (muted) { if (history) { @@ -1571,7 +1571,7 @@ void Session::unreadEntriesChanged( } } -void Session::selfDestructIn(not_null item, TimeMs delay) { +void Session::selfDestructIn(not_null item, crl::time delay) { _selfDestructItems.push_back(item->fullId()); if (!_selfDestructTimer.isActive() || _selfDestructTimer.remainingTime() > delay) { @@ -1580,8 +1580,8 @@ void Session::selfDestructIn(not_null item, TimeMs delay) { } void Session::checkSelfDestructItems() { - auto now = getms(true); - auto nextDestructIn = TimeMs(0); + auto now = crl::now(); + auto nextDestructIn = crl::time(0); for (auto i = _selfDestructItems.begin(); i != _selfDestructItems.cend();) { if (auto item = App::histItemById(*i)) { if (auto destructIn = item->getSelfDestructIn(now)) { @@ -2863,13 +2863,13 @@ void Session::updateNotifySettings( bool Session::notifyIsMuted( not_null peer, - TimeMs *changesIn) const { + crl::time *changesIn) const { const auto resultFromUntil = [&](TimeId until) { const auto now = unixtime(); const auto result = (until > now) ? (until - now) : 0; if (changesIn) { *changesIn = (result > 0) - ? std::min(result * TimeMs(1000), kMaxNotifyCheckDelay) + ? std::min(result * crl::time(1000), kMaxNotifyCheckDelay) : kMaxNotifyCheckDelay; } return (result > 0); diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index e2e877029..0a99abc5d 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -78,7 +78,7 @@ public: const Passport::SavedCredentials *passportCredentials() const; void rememberPassportCredentials( Passport::SavedCredentials data, - TimeMs rememberFor); + crl::time rememberFor); void forgetPassportCredentials(); Storage::Cache::Database &cache(); @@ -205,34 +205,34 @@ public: void notifySavedGifsUpdated(); [[nodiscard]] rpl::producer<> savedGifsUpdated() const; - bool stickersUpdateNeeded(TimeMs now) const { + bool stickersUpdateNeeded(crl::time now) const { return stickersUpdateNeeded(_lastStickersUpdate, now); } - void setLastStickersUpdate(TimeMs update) { + void setLastStickersUpdate(crl::time update) { _lastStickersUpdate = update; } - bool recentStickersUpdateNeeded(TimeMs now) const { + bool recentStickersUpdateNeeded(crl::time now) const { return stickersUpdateNeeded(_lastRecentStickersUpdate, now); } - void setLastRecentStickersUpdate(TimeMs update) { + void setLastRecentStickersUpdate(crl::time update) { _lastRecentStickersUpdate = update; } - bool favedStickersUpdateNeeded(TimeMs now) const { + bool favedStickersUpdateNeeded(crl::time now) const { return stickersUpdateNeeded(_lastFavedStickersUpdate, now); } - void setLastFavedStickersUpdate(TimeMs update) { + void setLastFavedStickersUpdate(crl::time update) { _lastFavedStickersUpdate = update; } - bool featuredStickersUpdateNeeded(TimeMs now) const { + bool featuredStickersUpdateNeeded(crl::time now) const { return stickersUpdateNeeded(_lastFeaturedStickersUpdate, now); } - void setLastFeaturedStickersUpdate(TimeMs update) { + void setLastFeaturedStickersUpdate(crl::time update) { _lastFeaturedStickersUpdate = update; } - bool savedGifsUpdateNeeded(TimeMs now) const { + bool savedGifsUpdateNeeded(crl::time now) const { return stickersUpdateNeeded(_lastSavedGifsUpdate, now); } - void setLastSavedGifsUpdate(TimeMs update) { + void setLastSavedGifsUpdate(crl::time update) { _lastSavedGifsUpdate = update; } int featuredStickerSetsUnreadCount() const { @@ -329,7 +329,7 @@ public: int withUnreadDelta, int mutedWithUnreadDelta); - void selfDestructIn(not_null item, TimeMs delay); + void selfDestructIn(not_null item, crl::time delay); [[nodiscard]] not_null photo(PhotoId id); not_null processPhoto(const MTPPhoto &data); @@ -508,7 +508,7 @@ public: std::optional silentPosts = std::nullopt); bool notifyIsMuted( not_null peer, - TimeMs *changesIn = nullptr) const; + crl::time *changesIn = nullptr) const; bool notifySilentPosts(not_null peer) const; bool notifyMuteUnknown(not_null peer) const; bool notifySilentPostsUnknown(not_null peer) const; @@ -634,8 +634,8 @@ private: PhotoData *photo, DocumentData *document); - bool stickersUpdateNeeded(TimeMs lastUpdate, TimeMs now) const { - constexpr auto kStickersUpdateTimeout = TimeMs(3600'000); + bool stickersUpdateNeeded(crl::time lastUpdate, crl::time now) const { + constexpr auto kStickersUpdateTimeout = crl::time(3600'000); return (lastUpdate == 0) || (now >= lastUpdate + kStickersUpdateTimeout); } @@ -648,7 +648,7 @@ private: const NotifySettings &defaultNotifySettings( not_null peer) const; void unmuteByFinished(); - void unmuteByFinishedDelayed(TimeMs delay); + void unmuteByFinishedDelayed(crl::time delay); void updateNotifySettingsLocal(not_null peer); template @@ -661,7 +661,7 @@ private: const MTPMessageMedia &media, TimeId date); - void step_typings(TimeMs ms, bool timer); + void step_typings(crl::time ms, bool timer); void setWallpapers(const QVector &data, int32 hash); @@ -701,11 +701,11 @@ private: rpl::event_stream<> _stickersUpdated; rpl::event_stream<> _savedGifsUpdated; - TimeMs _lastStickersUpdate = 0; - TimeMs _lastRecentStickersUpdate = 0; - TimeMs _lastFavedStickersUpdate = 0; - TimeMs _lastFeaturedStickersUpdate = 0; - TimeMs _lastSavedGifsUpdate = 0; + crl::time _lastStickersUpdate = 0; + crl::time _lastRecentStickersUpdate = 0; + crl::time _lastFavedStickersUpdate = 0; + crl::time _lastFeaturedStickersUpdate = 0; + crl::time _lastSavedGifsUpdate = 0; rpl::variable _featuredStickerSetsUnreadCount = 0; Stickers::Sets _stickerSets; Stickers::Order _stickerSetsOrder; @@ -722,7 +722,7 @@ private: std::vector _selfDestructItems; // When typing in this history started. - base::flat_map, TimeMs> _sendActions; + base::flat_map, crl::time> _sendActions; BasicAnimation _a_sendActions; std::unordered_map< diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index 3866263e0..d1c2c312a 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -471,14 +471,14 @@ struct SendAction { }; SendAction( Type type, - TimeMs until, + crl::time until, int progress = 0) : type(type) , until(until) , progress(progress) { } Type type = Type::Typing; - TimeMs until = 0; + crl::time until = 0; int progress = 0; }; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 05da6a157..2be31852f 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -253,7 +253,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } const auto activeEntry = _controller->activeChatEntryCurrent(); auto fullWidth = getFullWidth(); - auto ms = getms(); + auto ms = crl::now(); if (_state == State::Default) { if (_a_pinnedShifting.animating()) { _a_pinnedShifting.step(ms, false); @@ -552,7 +552,7 @@ void DialogsInner::paintPeerSearchResult( bool active, bool selected, bool onlyBackground, - TimeMs ms) const { + crl::time ms) const { QRect fullRect(0, 0, fullWidth, st::dialogsRowHeight); p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg)); if (!active) { @@ -608,7 +608,7 @@ void DialogsInner::paintSearchInChat( Painter &p, int fullWidth, bool onlyBackground, - TimeMs ms) const { + crl::time ms) const { auto height = searchInChatSkip(); auto top = st::searchedBarHeight; @@ -900,7 +900,7 @@ void DialogsInner::checkReorderPinnedStart(QPoint localPosition) { } else { _pinnedOrder = Auth().data().pinnedDialogsOrder(); _pinnedRows[_draggingIndex].yadd = anim::value(0, localPosition.y() - _dragStart.y()); - _pinnedRows[_draggingIndex].animStartTime = getms(); + _pinnedRows[_draggingIndex].animStartTime = crl::now(); _a_pinnedShifting.start(); } } @@ -1007,7 +1007,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) { auto yaddWas = _pinnedRows[_draggingIndex].yadd.current(); auto shift = 0; - auto ms = getms(); + auto ms = crl::now(); auto rowHeight = st::dialogsRowHeight; if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) { shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex); @@ -1054,7 +1054,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) { return true; } -void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) { +void DialogsInner::step_pinnedShifting(crl::time ms, bool timer) { if (anim::Disabled()) { ms += st::stickersRowDuration; } @@ -1119,7 +1119,7 @@ void DialogsInner::mousePressReleased( updateReorderIndexGetCount(); if (_draggingIndex >= 0) { _pinnedRows[_draggingIndex].yadd.start(0.); - _pinnedRows[_draggingIndex].animStartTime = getms(); + _pinnedRows[_draggingIndex].animStartTime = crl::now(); if (!_a_pinnedShifting.animating()) { _a_pinnedShifting.start(); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 1977b3257..149b2dbe1 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -236,12 +236,12 @@ private: bool active, bool selected, bool onlyBackground, - TimeMs ms) const; + crl::time ms) const; void paintSearchInChat( Painter &p, int fullWidth, bool onlyBackground, - TimeMs ms) const; + crl::time ms) const; void paintSearchInPeer( Painter &p, not_null peer, @@ -283,7 +283,7 @@ private: void stopReorderPinned(); int countPinnedIndex(Dialogs::Row *ofRow); void savePinnedOrder(); - void step_pinnedShifting(TimeMs ms, bool timer); + void step_pinnedShifting(crl::time ms, bool timer); void handleChatMigration(not_null chat); not_null _controller; @@ -310,7 +310,7 @@ private: QPoint _dragStart; struct PinnedRow { anim::value yadd; - TimeMs animStartTime = 0; + crl::time animStartTime = 0; }; std::vector _pinnedRows; BasicAnimation _a_pinnedShifting; diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index e51fb8612..bea418ad8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -174,7 +174,7 @@ void paintRow( QDateTime date, int fullWidth, base::flags flags, - TimeMs ms, + crl::time ms, PaintItemCallback &&paintItemCallback, PaintCounterCallback &&paintCounterCallback) { const auto supportMode = Auth().supportMode(); @@ -530,7 +530,7 @@ void RowPainter::paint( bool active, bool selected, bool onlyBackground, - TimeMs ms) { + crl::time ms) { const auto entry = row->entry(); const auto history = row->history(); const auto peer = history ? history->peer.get() : nullptr; @@ -669,7 +669,7 @@ void RowPainter::paint( bool active, bool selected, bool onlyBackground, - TimeMs ms, + crl::time ms, bool displayUnreadInfo) { auto item = row->item(); auto history = item->history(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.h b/Telegram/SourceFiles/dialogs/dialogs_layout.h index b75b22d55..9f536b275 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.h +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.h @@ -36,7 +36,7 @@ public: bool active, bool selected, bool onlyBackground, - TimeMs ms); + crl::time ms); static void paint( Painter &p, not_null row, @@ -44,7 +44,7 @@ public: bool active, bool selected, bool onlyBackground, - TimeMs ms, + crl::time ms, bool displayUnreadInfo); static QRect sendActionAnimationRect( int animationWidth, diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index 8aa4cb0a3..1edc781b6 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -31,7 +31,7 @@ void RippleRow::stopLastRipple() { } } -void RippleRow::paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride) const { +void RippleRow::paintRipple(Painter &p, int x, int y, int outerWidth, crl::time ms, const QColor *colorOverride) const { if (_ripple) { _ripple->paint(p, x, y, outerWidth, ms, colorOverride); if (_ripple->empty()) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.h b/Telegram/SourceFiles/dialogs/dialogs_row.h index 756cc88d3..0e7ae08e8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.h +++ b/Telegram/SourceFiles/dialogs/dialogs_row.h @@ -30,7 +30,7 @@ public: void addRipple(QPoint origin, QSize size, Fn updateCallback); void stopLastRipple(); - void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const; + void paintRipple(Painter &p, int x, int y, int outerWidth, crl::time ms, const QColor *colorOverride = nullptr) const; private: mutable std::unique_ptr _ripple; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index aa8ae5737..884b8a055 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -66,7 +66,7 @@ protected: void onStateChanged(State was, StateChangeSource source) override; private: - void step_radial(TimeMs ms, bool timer); + void step_radial(crl::time ms, bool timer); QString _text; const style::FlatButton &_st; @@ -95,7 +95,7 @@ void DialogsWidget::BottomButton::setText(const QString &text) { update(); } -void DialogsWidget::BottomButton::step_radial(TimeMs ms, bool timer) { +void DialogsWidget::BottomButton::step_radial(crl::time ms, bool timer) { if (timer && !anim::Disabled() && width() < st::columnMinimalWidthLeft) { update(); } @@ -125,7 +125,7 @@ void DialogsWidget::BottomButton::paintEvent(QPaintEvent *e) { p.fillRect(r, over ? _st.overBgColor : _st.bgColor); if (!isDisabled()) { - paintRipple(p, 0, 0, getms()); + paintRipple(p, 0, 0, crl::now()); } p.setFont(over ? _st.overFont : _st.font); @@ -1430,7 +1430,7 @@ void DialogsWidget::paintEvent(QPaintEvent *e) { if (r != rect()) { p.setClipRect(r); } - auto progress = _a_show.current(getms(), 1.); + auto progress = _a_show.current(crl::now(), 1.); if (_a_show.animating()) { auto retina = cIntRetinaFactor(); auto fromLeft = (_showDirection == Window::SlideDirection::FromLeft); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index f183f3b86..8583e34a9 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -23,7 +23,7 @@ namespace { constexpr auto kUserpicsSliceLimit = 100; constexpr auto kFileChunkSize = 128 * 1024; constexpr auto kFileRequestsCount = 2; -constexpr auto kFileNextRequestDelay = TimeMs(20); +constexpr auto kFileNextRequestDelay = crl::time(20); constexpr auto kChatsSliceLimit = 100; constexpr auto kMessagesSliceLimit = 100; constexpr auto kTopPeerSliceLimit = 100; diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index fc3ba8ccf..eb488fa3d 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -26,7 +26,7 @@ namespace Export { namespace View { namespace { -constexpr auto kSaveSettingsTimeout = TimeMs(1000); +constexpr auto kSaveSettingsTimeout = crl::time(1000); class SuggestBox : public BoxContent { public: diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index ea46b6461..d7079cfe7 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -246,7 +246,7 @@ void showPeerProfile(not_null history) { void showPeerHistory( const PeerId &peer, MsgId msgId) { - auto ms = getms(); + auto ms = crl::now(); if (auto m = App::main()) { m->ui_showPeerHistory( peer, @@ -410,13 +410,13 @@ struct Data { Stickers::Sets StickerSets; Stickers::Order StickerSetsOrder; - TimeMs LastStickersUpdate = 0; - TimeMs LastRecentStickersUpdate = 0; - TimeMs LastFavedStickersUpdate = 0; + crl::time LastStickersUpdate = 0; + crl::time LastRecentStickersUpdate = 0; + crl::time LastFavedStickersUpdate = 0; Stickers::Order FeaturedStickerSetsOrder; int FeaturedStickerSetsUnreadCount = 0; base::Observable FeaturedStickerSetsUnreadCountChanged; - TimeMs LastFeaturedStickersUpdate = 0; + crl::time LastFeaturedStickersUpdate = 0; Stickers::Order ArchivedStickerSetsOrder; CircleMasksMap CircleMasks; @@ -544,13 +544,13 @@ DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages); DefineVar(Global, Stickers::Sets, StickerSets); DefineVar(Global, Stickers::Order, StickerSetsOrder); -DefineVar(Global, TimeMs, LastStickersUpdate); -DefineVar(Global, TimeMs, LastRecentStickersUpdate); -DefineVar(Global, TimeMs, LastFavedStickersUpdate); +DefineVar(Global, crl::time, LastStickersUpdate); +DefineVar(Global, crl::time, LastRecentStickersUpdate); +DefineVar(Global, crl::time, LastFavedStickersUpdate); DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder); DefineVar(Global, int, FeaturedStickerSetsUnreadCount); DefineRefVar(Global, base::Observable, FeaturedStickerSetsUnreadCountChanged); -DefineVar(Global, TimeMs, LastFeaturedStickersUpdate); +DefineVar(Global, crl::time, LastFeaturedStickersUpdate); DefineVar(Global, Stickers::Order, ArchivedStickerSetsOrder); DefineRefVar(Global, CircleMasksMap, CircleMasks); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index 6ef5742a2..e195f5db7 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -99,7 +99,7 @@ void UserCheckbox::setChecked(bool checked, NotifyAboutChange notify) { void UserCheckbox::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto active = _check->currentAnimationValue(ms); auto color = anim::color(_st.rippleBg, _st.rippleBgActive, active); paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y() + (_checkRect.y() - st::defaultBoxCheckbox.margin.top()), ms, &color); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 30bb4b182..8e62fde75 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -516,9 +516,9 @@ void InnerWidget::elementAnimationAutoplayAsync( }); } -TimeMs InnerWidget::elementHighlightTime( +crl::time InnerWidget::elementHighlightTime( not_null element) { - return TimeMs(0); + return crl::time(0); } bool InnerWidget::elementInSelectionMode() { @@ -755,7 +755,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto clip = e->rect(); if (_items.empty() && _upLoaded && _downLoaded) { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h index 84fb1ecf9..7532806c3 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h @@ -85,7 +85,7 @@ public: not_null view) override; void elementAnimationAutoplayAsync( not_null view) override; - TimeMs elementHighlightTime( + crl::time elementHighlightTime( not_null element) override; bool elementInSelectionMode() override; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index 008e83523..4ea68167d 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -396,7 +396,7 @@ void Widget::paintEvent(QPaintEvent *e) { // updateListSize(); //} - //auto ms = getms(); + //auto ms = crl::now(); //_historyDownShown.step(ms); SectionWidget::PaintBackground(this, e); diff --git a/Telegram/SourceFiles/history/feed/history_feed_section.cpp b/Telegram/SourceFiles/history/feed/history_feed_section.cpp index eaa63c260..8be72a76a 100644 --- a/Telegram/SourceFiles/history/feed/history_feed_section.cpp +++ b/Telegram/SourceFiles/history/feed/history_feed_section.cpp @@ -536,7 +536,7 @@ void Widget::paintEvent(QPaintEvent *e) { // updateListSize(); //} - const auto ms = getms(); + const auto ms = crl::now(); _scrollDownShown.step(ms); SectionWidget::PaintBackground(this, e); @@ -554,7 +554,7 @@ void Widget::paintEvent(QPaintEvent *e) { p, clip.translated(-left, -top), TextSelection(), - getms()); + crl::now()); } } diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 8fb63becc..2b6065a9f 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -337,7 +337,7 @@ bool History::updateSendActionNeedsAnimating( return false; } - auto ms = getms(); + auto ms = crl::now(); switch (action.type()) { case mtpc_sendMessageTypingAction: _typing.insert(user, ms + kStatusShowClientsideTyping); break; case mtpc_sendMessageRecordVideoAction: _sendActions.insert(user, { Type::RecordVideo, ms + kStatusShowClientsideRecordVideo }); break; @@ -362,7 +362,7 @@ bool History::updateSendActionNeedsAnimating( } bool History::mySendActionUpdated(SendAction::Type type, bool doing) { - auto ms = getms(true); + auto ms = crl::now(); auto i = _mySendActions.find(type); if (doing) { if (i == _mySendActions.cend()) { @@ -391,7 +391,7 @@ bool History::paintSendAction( int availableWidth, int outerWidth, style::color color, - TimeMs ms) { + crl::time ms) { if (_sendActionAnimation) { _sendActionAnimation.paint( p, @@ -410,7 +410,7 @@ bool History::paintSendAction( return false; } -bool History::updateSendActionNeedsAnimating(TimeMs ms, bool force) { +bool History::updateSendActionNeedsAnimating(crl::time ms, bool force) { auto changed = force; for (auto i = _typing.begin(), e = _typing.end(); i != e;) { if (ms >= i.value()) { @@ -1111,15 +1111,15 @@ void History::applyServiceChanges( } void History::clearSendAction(not_null from) { - auto updateAtMs = TimeMs(0); + auto updateAtMs = crl::time(0); auto i = _typing.find(from); if (i != _typing.cend()) { - updateAtMs = getms(); + updateAtMs = crl::now(); i.value() = updateAtMs; } auto j = _sendActions.find(from); if (j != _sendActions.cend()) { - if (!updateAtMs) updateAtMs = getms(); + if (!updateAtMs) updateAtMs = crl::now(); j.value().until = updateAtMs; } if (updateAtMs) { diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index e84cfe592..e12879e1a 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -216,10 +216,10 @@ public: void setHasPendingResizedItems(); bool mySendActionUpdated(SendAction::Type type, bool doing); - bool paintSendAction(Painter &p, int x, int y, int availableWidth, int outerWidth, style::color color, TimeMs ms); + bool paintSendAction(Painter &p, int x, int y, int availableWidth, int outerWidth, style::color color, crl::time ms); // Interface for Histories - bool updateSendActionNeedsAnimating(TimeMs ms, bool force = false); + bool updateSendActionNeedsAnimating(crl::time ms, bool force = false); bool updateSendActionNeedsAnimating( not_null user, const MTPSendMessageAction &action); @@ -488,14 +488,14 @@ private: TimeId _lastSentDraftTime = 0; MessageIdsList _forwardDraft; - using TypingUsers = QMap; + using TypingUsers = QMap; TypingUsers _typing; using SendActionUsers = QMap; SendActionUsers _sendActions; QString _sendActionString; Text _sendActionText; Ui::SendActionAnimation _sendActionAnimation; - QMap _mySendActions; + QMap _mySendActions; std::weak_ptr _adminLogIdManager; diff --git a/Telegram/SourceFiles/history/history_drag_area.cpp b/Telegram/SourceFiles/history/history_drag_area.cpp index feb6254cf..eae73270b 100644 --- a/Telegram/SourceFiles/history/history_drag_area.cpp +++ b/Telegram/SourceFiles/history/history_drag_area.cpp @@ -69,7 +69,7 @@ void DragArea::setText(const QString &text, const QString &subtext) { void DragArea::paintEvent(QPaintEvent *e) { Painter p(this); - auto ms = getms(); + auto ms = crl::now(); auto opacity = _a_opacity.current(ms, _hiding ? 0. : 1.); if (!_a_opacity.animating() && _hiding) { return; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 068678418..819478d0d 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -541,7 +541,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) { Painter p(this); auto clip = e->rect(); - auto ms = getms(); + auto ms = crl::now(); const auto historyDisplayedEmpty = _history->isDisplayedEmpty() && (!_migrated || _migrated->isDisplayedEmpty()); @@ -766,7 +766,7 @@ bool HistoryInner::eventHook(QEvent *e) { } void HistoryInner::onTouchScrollTimer() { - auto nowTime = getms(); + auto nowTime = crl::now(); if (_touchScrollState == Ui::TouchScrollState::Acceleration && _touchWaitingAcceleration && (nowTime - _touchAccelerationTime) > 40) { _touchScrollState = Ui::TouchScrollState::Manual; touchResetSpeed(); @@ -787,7 +787,7 @@ void HistoryInner::onTouchScrollTimer() { } void HistoryInner::touchUpdateSpeed() { - const auto nowTime = getms(); + const auto nowTime = crl::now(); if (_touchPrevPosValid) { const int elapsed = nowTime - _touchSpeedTime; if (elapsed) { @@ -867,7 +867,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) { if (_touchScrollState == Ui::TouchScrollState::Auto) { _touchScrollState = Ui::TouchScrollState::Acceleration; _touchWaitingAcceleration = true; - _touchAccelerationTime = getms(); + _touchAccelerationTime = crl::now(); touchUpdateSpeed(); _touchStart = _touchPos; } else { @@ -892,7 +892,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) { touchScrollUpdated(_touchPos); } else if (_touchScrollState == Ui::TouchScrollState::Acceleration) { touchUpdateSpeed(); - _touchAccelerationTime = getms(); + _touchAccelerationTime = crl::now(); if (_touchSpeed.isNull()) { _touchScrollState = Ui::TouchScrollState::Manual; } @@ -914,7 +914,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) { _touchScrollState = Ui::TouchScrollState::Auto; _touchPrevPosValid = false; _touchScrollTimer.start(15); - _touchTime = getms(); + _touchTime = crl::now(); } else if (_touchScrollState == Ui::TouchScrollState::Auto) { _touchScrollState = Ui::TouchScrollState::Manual; _touchScroll = false; @@ -3122,17 +3122,17 @@ not_null HistoryInner::ElementDelegate() { } }); } - TimeMs elementHighlightTime( + crl::time elementHighlightTime( not_null view) override { const auto fullAnimMs = App::main()->highlightStartTime( view->data()); if (fullAnimMs > 0) { - const auto now = getms(); + const auto now = crl::now(); if (fullAnimMs < now) { return now - fullAnimMs; } } - return TimeMs(0); + return crl::time(0); } bool elementInSelectionMode() override { return App::main()->historyInSelectionMode(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index 154f0f385..382ebb350 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -348,9 +348,9 @@ private: bool _touchPrevPosValid = false; bool _touchWaitingAcceleration = false; QPoint _touchSpeed; - TimeMs _touchSpeedTime = 0; - TimeMs _touchAccelerationTime = 0; - TimeMs _touchTime = 0; + crl::time _touchSpeedTime = 0; + crl::time _touchAccelerationTime = 0; + crl::time _touchTime = 0; QTimer _touchScrollTimer; base::unique_qptr _menu; diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 5710d1409..0fee5661e 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -121,7 +121,7 @@ public: void markMediaRead(); // Zero result means this message is not self-destructing right now. - virtual TimeMs getSelfDestructIn(TimeMs now) { + virtual crl::time getSelfDestructIn(crl::time now) { return 0; } diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 7a4702729..3bc105ec2 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -511,7 +511,7 @@ int ReplyKeyboard::naturalHeight() const { return (_rows.size() - 1) * _st->buttonSkip() + _rows.size() * _st->buttonHeight(); } -void ReplyKeyboard::paint(Painter &p, int outerWidth, const QRect &clip, TimeMs ms) const { +void ReplyKeyboard::paint(Painter &p, int outerWidth, const QRect &clip, crl::time ms) const { Assert(_st != nullptr); Assert(_width > 0); @@ -609,7 +609,7 @@ void ReplyKeyboard::startAnimation(int i, int j, int direction) { _animations.remove(-indexForAnimation); if (!_animations.contains(indexForAnimation)) { - _animations.emplace(indexForAnimation, getms()); + _animations.emplace(indexForAnimation, crl::now()); } if (notStarted && !_a_selected.animating()) { @@ -617,7 +617,7 @@ void ReplyKeyboard::startAnimation(int i, int j, int direction) { } } -void ReplyKeyboard::step_selected(TimeMs ms, bool timer) { +void ReplyKeyboard::step_selected(crl::time ms, bool timer) { if (anim::Disabled()) { ms += st::botKbDuration; } @@ -667,7 +667,7 @@ void ReplyKeyboard::Style::paintButton( Painter &p, int outerWidth, const ReplyKeyboard::Button &button, - TimeMs ms) const { + crl::time ms) const { const QRect &rect = button.rect; paintButtonBg(p, rect, button.howMuchOver); if (button.ripple) { diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 42ae62e7c..4d093e75c 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -256,7 +256,7 @@ public: private: const style::BotKeyboardButton *_st; - void paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, TimeMs ms) const; + void paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, crl::time ms) const; friend class ReplyKeyboard; }; @@ -275,7 +275,7 @@ public: int naturalWidth() const; int naturalHeight() const; - void paint(Painter &p, int outerWidth, const QRect &clip, TimeMs ms) const; + void paint(Painter &p, int outerWidth, const QRect &clip, crl::time ms) const; ClickHandlerPtr getLink(QPoint point) const; void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active); @@ -308,14 +308,14 @@ private: ButtonCoords findButtonCoordsByClickHandler(const ClickHandlerPtr &p); - void step_selected(TimeMs ms, bool timer); + void step_selected(crl::time ms, bool timer); const not_null _item; int _width = 0; std::vector> _rows; - base::flat_map _animations; + base::flat_map _animations; BasicAnimation _a_selected; std::unique_ptr