diff --git a/Telegram/Resources/icons/emoji_settings.png b/Telegram/Resources/icons/emoji_settings.png index 041a68cb1..b454439fb 100644 Binary files a/Telegram/Resources/icons/emoji_settings.png and b/Telegram/Resources/icons/emoji_settings.png differ diff --git a/Telegram/Resources/icons/emoji_settings@2x.png b/Telegram/Resources/icons/emoji_settings@2x.png index 7d978f0de..534b24ac8 100644 Binary files a/Telegram/Resources/icons/emoji_settings@2x.png and b/Telegram/Resources/icons/emoji_settings@2x.png differ diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 136c19546..8da1571a0 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -952,8 +952,8 @@ void AppClass::call_handleObservables() { } void AppClass::killDownloadSessions() { - uint64 ms = getms(), left = MTPAckSendWaiting + MTPKillFileSessionTimeout; - for (QMap::iterator i = killDownloadSessionTimes.begin(); i != killDownloadSessionTimes.end(); ) { + auto ms = getms(), left = static_cast(MTPAckSendWaiting) + MTPKillFileSessionTimeout; + for (auto i = killDownloadSessionTimes.begin(); i != killDownloadSessionTimes.end(); ) { if (i.value() <= ms) { for (int j = 0; j < MTPDownloadSessionsCount; ++j) { MTP::stopSession(MTP::dldDcId(i.key(), j)); diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h index a8e9627db..f838eae9b 100644 --- a/Telegram/SourceFiles/application.h +++ b/Telegram/SourceFiles/application.h @@ -169,7 +169,7 @@ public: bool peerPhotoFail(PeerId peerId, const RPCError &e); void peerClearPhoto(PeerId peer); - void writeUserConfigIn(uint64 ms); + void writeUserConfigIn(TimeMs ms); void killDownloadSessionsStart(int32 dc); void killDownloadSessionsStop(int32 dc); @@ -208,10 +208,10 @@ private: QMap photoUpdates; - QMap killDownloadSessionTimes; + QMap killDownloadSessionTimes; SingleTimer killDownloadSessionsTimer; - uint64 _lastActionTime = 0; + TimeMs _lastActionTime = 0; MainWindow *_window = nullptr; FileUploader *_uploader = nullptr; diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 7f8d8b165..dca4f0202 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -923,7 +923,7 @@ ContactsBox::Inner::ContactData *ContactsBox::Inner::contactData(Dialogs::Row *r return data; } -void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, ContactData *data, bool sel) { +void ContactsBox::Inner::paintDialog(Painter &p, TimeMs ms, PeerData *peer, ContactData *data, bool sel) { UserData *user = peer->asUser(); if (_chat && _membersFilter == MembersFilter::Admins) { @@ -1034,7 +1034,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { _time = unixtime(); p.fillRect(r, st::contactsBg); - uint64 ms = getms(); + auto ms = getms(); int32 yFrom = r.y(), yTo = r.y() + r.height(); if (_filter.isEmpty()) { if (!_contacts->isEmpty() || !_byUsername.isEmpty()) { diff --git a/Telegram/SourceFiles/boxes/contactsbox.h b/Telegram/SourceFiles/boxes/contactsbox.h index 66509996b..eaf98c941 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.h +++ b/Telegram/SourceFiles/boxes/contactsbox.h @@ -233,7 +233,7 @@ private: void addAdminDone(const MTPUpdates &result, mtpRequestId req); bool addAdminFail(const RPCError &error, mtpRequestId req); - void paintDialog(Painter &p, uint64 ms, PeerData *peer, ContactData *data, bool sel); + void paintDialog(Painter &p, TimeMs ms, PeerData *peer, ContactData *data, bool sel); void paintDisabledCheckUserpic(Painter &p, PeerData *peer, int x, int y, int outerWidth) const; void changeCheckState(Dialogs::Row *row); diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index 8dbc7d46a..d563122ff 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -496,7 +496,7 @@ void ShareBox::Inner::setActive(int active) { emit mustScrollTo(y, y + _rowHeight); } -void ShareBox::Inner::paintChat(Painter &p, uint64 ms, Chat *chat, int index) { +void ShareBox::Inner::paintChat(Painter &p, TimeMs ms, Chat *chat, int index) { auto x = _rowsLeft + qFloor((index % _columnCount) * _rowWidthReal); auto y = _rowsTop + (index / _columnCount) * _rowHeight; diff --git a/Telegram/SourceFiles/boxes/sharebox.h b/Telegram/SourceFiles/boxes/sharebox.h index 18c6f989f..35fa69d5d 100644 --- a/Telegram/SourceFiles/boxes/sharebox.h +++ b/Telegram/SourceFiles/boxes/sharebox.h @@ -163,7 +163,7 @@ private: Text name; FloatAnimation nameActive; }; - void paintChat(Painter &p, uint64 ms, Chat *chat, int index); + void paintChat(Painter &p, TimeMs ms, Chat *chat, int index); void updateChat(PeerData *peer); void updateChatName(Chat *chat, PeerData *peer); void repaintChat(PeerData *peer); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 8d653fe2f..4be741d7d 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -661,7 +661,7 @@ QRect StickersBox::Inner::relativeButtonRect(bool removeButton) const { return QRect(buttonx, buttony, buttonw, buttonh); } -void StickersBox::Inner::paintRow(Painter &p, int index, uint64 ms) { +void StickersBox::Inner::paintRow(Painter &p, int index, TimeMs ms) { auto s = _rows.at(index); auto xadd = 0, yadd = s->yadd.current(); @@ -734,7 +734,7 @@ void StickersBox::Inner::paintRow(Painter &p, int index, uint64 ms) { if (xadd || yadd) p.translate(-xadd, -yadd); } -void StickersBox::Inner::paintFakeButton(Painter &p, int index, uint64 ms) { +void StickersBox::Inner::paintFakeButton(Painter &p, int index, TimeMs ms) { auto set = _rows[index]; auto removeButton = (_section == Section::Installed && !set->removed); auto rect = relativeButtonRect(removeButton); @@ -846,10 +846,10 @@ void StickersBox::Inner::mouseMoveEvent(QMouseEvent *e) { } void StickersBox::Inner::onUpdateSelected() { - QPoint local(mapFromGlobal(_mouse)); + auto local = mapFromGlobal(_mouse); if (_dragging >= 0) { - int32 shift = 0; - uint64 ms = getms(); + auto shift = 0; + auto ms = getms(); int firstSetIndex = 0; if (_rows.at(firstSetIndex)->isRecentSet()) { ++firstSetIndex; @@ -984,11 +984,12 @@ void StickersBox::Inner::leaveEvent(QEvent *e) { onUpdateSelected(); } -void StickersBox::Inner::step_shifting(uint64 ms, bool timer) { - bool animating = false; - int32 updateMin = -1, updateMax = 0; - for (int32 i = 0, l = _animStartTimes.size(); i < l; ++i) { - uint64 start = _animStartTimes.at(i); +void StickersBox::Inner::step_shifting(TimeMs ms, bool timer) { + auto animating = false; + auto updateMin = -1; + auto updateMax = 0; + for (auto i = 0, l = _animStartTimes.size(); i < l; ++i) { + auto start = _animStartTimes.at(i); if (start) { if (updateMin < 0) updateMin = i; updateMax = i; diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index 2100eea54..3f21d2fec 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -191,9 +191,9 @@ private: QRect relativeButtonRect(bool removeButton) const; void ensureRipple(const style::RippleAnimation &st, QImage mask, bool removeButton); - void step_shifting(uint64 ms, bool timer); - void paintRow(Painter &p, int index, uint64 ms); - void paintFakeButton(Painter &p, int index, uint64 ms); + void step_shifting(TimeMs ms, bool timer); + void paintRow(Painter &p, int index, TimeMs ms); + void paintFakeButton(Painter &p, int index, TimeMs ms); void clear(); void setActionSel(int32 actionSel); float64 aboveShadowOpacity() const; @@ -243,8 +243,8 @@ private: int countMaxNameWidth() const; Rows _rows; - QList _animStartTimes; - uint64 _aboveShadowFadeStart = 0; + QList _animStartTimes; + TimeMs _aboveShadowFadeStart = 0; anim::fvalue _aboveShadowFadeOpacity = { 0., 0. }; Animation _a_shifting; diff --git a/Telegram/SourceFiles/core/single_timer.cpp b/Telegram/SourceFiles/core/single_timer.cpp index eda7d54ed..e054ef517 100644 --- a/Telegram/SourceFiles/core/single_timer.cpp +++ b/Telegram/SourceFiles/core/single_timer.cpp @@ -41,7 +41,7 @@ void SingleTimer::setTimeoutHandler(base::lambda &&handler) { } void SingleTimer::adjust() { - uint64 n = getms(true); + auto n = getms(true); if (isActive()) { if (n >= _finishing) { start(0); @@ -58,7 +58,7 @@ void SingleTimer::onTimeout() { } void SingleTimer::start(int msec) { - _finishing = getms(true) + (msec < 0 ? 0 : uint64(msec)); + _finishing = getms(true) + (msec < 0 ? 0 : msec); if (!_inited && App::app()) { connect(App::app(), SIGNAL(adjustSingleTimers()), this, SLOT(adjust())); _inited = true; diff --git a/Telegram/SourceFiles/core/single_timer.h b/Telegram/SourceFiles/core/single_timer.h index 33e708264..7ef638184 100644 --- a/Telegram/SourceFiles/core/single_timer.h +++ b/Telegram/SourceFiles/core/single_timer.h @@ -42,7 +42,7 @@ private slots: void onTimeout(); private: - uint64 _finishing = 0; + TimeMs _finishing = 0; bool _inited = false; base::lambda _handler; diff --git a/Telegram/SourceFiles/core/utils.cpp b/Telegram/SourceFiles/core/utils.cpp index 63959c272..057d37604 100644 --- a/Telegram/SourceFiles/core/utils.cpp +++ b/Telegram/SourceFiles/core/utils.cpp @@ -206,7 +206,7 @@ namespace { float64 _msFreq; float64 _msgIdCoef; - int64 _msStart = 0, _msAddToMsStart = 0, _msAddToUnixtime = 0; + TimeMs _msStart = 0, _msAddToMsStart = 0, _msAddToUnixtime = 0; int32 _timeStart = 0; class _MsInitializer { @@ -235,7 +235,7 @@ namespace { clock_gettime(CLOCK_MONOTONIC, &ts); //_msFreq = 1 / 1000000.; _msgIdCoef = float64(0xFFFF0000L) / 1000000000.; - _msStart = 1000 * uint64(ts.tv_sec) + (uint64(ts.tv_nsec) / 1000000); + _msStart = 1000LL * static_cast(ts.tv_sec) + (static_cast(ts.tv_nsec) / 1000000LL); #endif _timeStart = myunixtime(); srand((uint32)(_msStart & 0xFFFFFFFFL)); @@ -312,8 +312,8 @@ namespace ThirdParty { } bool checkms() { - int64 unixms = (myunixtime() - _timeStart) * 1000LL + _msAddToUnixtime; - int64 ms = int64(getms(true)); + auto unixms = (myunixtime() - _timeStart) * 1000LL + _msAddToUnixtime; + auto ms = getms(true); if (ms > unixms + 1000LL) { _msAddToUnixtime = ((ms - unixms) / 1000LL) * 1000LL; } else if (unixms > ms + 1000LL) { @@ -324,24 +324,23 @@ bool checkms() { return false; } -uint64 getms(bool checked) { +TimeMs getms(bool checked) { _msInitialize(); #ifdef Q_OS_WIN LARGE_INTEGER li; QueryPerformanceCounter(&li); - return (uint64)((li.QuadPart - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0); + return ((li.QuadPart - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0LL); #elif defined Q_OS_MAC - uint64 msCount = mach_absolute_time(); - return (uint64)((msCount - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0); + auto msCount = static_cast(mach_absolute_time()); + return ((msCount - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0LL); #else timespec ts; - int res = clock_gettime(CLOCK_MONOTONIC, &ts); - if (res != 0) { + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { LOG(("Bad clock_gettime result: %1").arg(res)); return 0; } - uint64 msCount = 1000 * uint64(ts.tv_sec) + (uint64(ts.tv_nsec) / 1000000); - return (uint64)(msCount - _msStart) + (checked ? _msAddToMsStart : 0); + auto msCount = 1000LL * static_cast(ts.tv_sec) + (static_cast(ts.tv_nsec) / 1000000LL); + return (msCount - _msStart) + (checked ? _msAddToMsStart : 0LL); #endif } diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index 8c6684f3b..1f6433dd2 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -220,8 +220,9 @@ void finish(); } +using TimeMs = int64; bool checkms(); // returns true if time has changed -uint64 getms(bool checked = false); +TimeMs getms(bool checked = false); const static uint32 _md5_block_size = 64; class HashMd5 { diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index bf1a8dbec..c7af005ff 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -59,7 +59,7 @@ void paintRowDate(Painter &p, const QDateTime &date, QRect &rectForName, bool ac } template -void paintRow(Painter &p, History *history, HistoryItem *item, Data::Draft *draft, QDateTime date, int w, bool active, bool selected, bool onlyBackground, PaintItemCallback paintItemCallback) { +void paintRow(Painter &p, History *history, HistoryItem *item, Data::Draft *draft, QDateTime date, int w, bool active, bool selected, bool onlyBackground, TimeMs ms, PaintItemCallback paintItemCallback) { QRect fullRect(0, 0, w, st::dialogsRowHeight); p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg)); if (onlyBackground) return; @@ -81,7 +81,8 @@ void paintRow(Painter &p, History *history, HistoryItem *item, Data::Draft *draf paintRowDate(p, date, rectForName, active, selected); p.setFont(st::dialogsTextFont); - if (history->typing.isEmpty() && history->sendActions.isEmpty()) { + auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); + if (!history->paintSendAction(p, nameleft, texttop, namewidth, w, color, ms)) { if (history->cloudDraftTextCache.isEmpty()) { auto draftWrapped = textcmdLink(1, lng_dialogs_text_from_wrapped(lt_from, lang(lng_from_draft))); auto draftText = lng_dialogs_text_with_from(lt_from_part, draftWrapped, lt_message, textClean(draft->textWithTags.text)); @@ -91,17 +92,13 @@ void paintRow(Painter &p, History *history, HistoryItem *item, Data::Draft *draf textstyleSet(&(active ? st::dialogsTextStyleDraftActive : (selected ? st::dialogsTextStyleDraftOver : st::dialogsTextStyleDraft))); history->cloudDraftTextCache.drawElided(p, nameleft, texttop, namewidth, 1); textstyleRestore(); - } else { - p.setPen(active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService)); - history->typingText.drawElided(p, nameleft, texttop, namewidth); } } else if (!item) { + auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); p.setFont(st::dialogsTextFont); - p.setPen(active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService)); - if (history->typing.isEmpty() && history->sendActions.isEmpty()) { + if (!history->paintSendAction(p, nameleft, texttop, namewidth, w, color, ms)) { + p.setPen(color); p.drawText(nameleft, texttop + st::msgNameFont->ascent, lang(lng_empty_history)); - } else { - history->typingText.drawElided(p, nameleft, texttop, namewidth); } } else if (!item->isEmpty()) { paintRowDate(p, date, rectForName, active, selected); @@ -244,7 +241,7 @@ void paintUnreadCount(Painter &p, const QString &text, int x, int y, const Unrea p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + textTop + st.font->ascent, text); } -void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool selected, bool onlyBackground) { +void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool selected, bool onlyBackground, TimeMs ms) { auto history = row->history(); auto item = history->lastMsg; auto cloudDraft = history->cloudDraft(); @@ -270,7 +267,7 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele if (item && cloudDraft && unreadCount > 0) { cloudDraft = nullptr; // Draw item, if draft is older. } - paintRow(p, history, item, cloudDraft, displayDate(), w, active, selected, onlyBackground, [&p, w, active, selected, history, unreadCount](int nameleft, int namewidth, HistoryItem *item) { + paintRow(p, history, item, cloudDraft, displayDate(), w, active, selected, onlyBackground, ms, [&p, w, active, selected, ms, history, unreadCount](int nameleft, int namewidth, HistoryItem *item) { int availableWidth = namewidth; int texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip; if (unreadCount) { @@ -286,19 +283,17 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); availableWidth -= unreadWidth + st.padding; } - if (history->typing.isEmpty() && history->sendActions.isEmpty()) { + auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); + if (!history->paintSendAction(p, nameleft, texttop, availableWidth, w, color, ms)) { item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active, selected, history->textCachedFor, history->lastItemTextCache); - } else { - p.setPen(active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService)); - history->typingText.drawElided(p, nameleft, texttop, availableWidth); } }); } -void RowPainter::paint(Painter &p, const FakeRow *row, int w, bool active, bool selected, bool onlyBackground) { +void RowPainter::paint(Painter &p, const FakeRow *row, int w, bool active, bool selected, bool onlyBackground, TimeMs ms) { auto item = row->item(); auto history = item->history(); - paintRow(p, history, item, nullptr, item->date, w, active, selected, onlyBackground, [&p, row, active, selected](int nameleft, int namewidth, HistoryItem *item) { + paintRow(p, history, item, nullptr, item->date, w, active, selected, onlyBackground, ms, [&p, row, active, selected](int nameleft, int namewidth, HistoryItem *item) { int lastWidth = namewidth, texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip; item->drawInDialog(p, QRect(nameleft, texttop, lastWidth, st::dialogsTextFont->height), active, selected, row->_cacheFor, row->_cache); }); diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.h b/Telegram/SourceFiles/dialogs/dialogs_layout.h index 37ce9c6dc..59c593421 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.h +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.h @@ -31,8 +31,8 @@ const style::icon *ChatTypeIcon(PeerData *peer, bool active, bool selected); class RowPainter { public: - static void paint(Painter &p, const Row *row, int w, bool active, bool selected, bool onlyBackground); - static void paint(Painter &p, const FakeRow *row, int w, bool active, bool selected, bool onlyBackground); + static void paint(Painter &p, const Row *row, int w, bool active, bool selected, bool onlyBackground, TimeMs ms); + static void paint(Painter &p, const FakeRow *row, int w, bool active, bool selected, bool onlyBackground, TimeMs ms); }; void paintImportantSwitch(Painter &p, Mode current, int w, bool selected, bool onlyBackground); diff --git a/Telegram/SourceFiles/dialogs/dialogs_list.cpp b/Telegram/SourceFiles/dialogs/dialogs_list.cpp index 63eff845b..b0ed915a4 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_list.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_list.cpp @@ -47,7 +47,7 @@ void List::adjustCurrent(int32 y, int32 h) const { } } -void List::paint(Painter &p, int32 w, int32 hFrom, int32 hTo, PeerData *act, PeerData *sel, bool onlyBackground) const { +void List::paint(Painter &p, int32 w, int32 hFrom, int32 hTo, PeerData *act, PeerData *sel, bool onlyBackground, TimeMs ms) const { adjustCurrent(hFrom, st::dialogsRowHeight); Row *row = _current; @@ -55,7 +55,7 @@ void List::paint(Painter &p, int32 w, int32 hFrom, int32 hTo, PeerData *act, Pee while (row != _end && row->_pos * st::dialogsRowHeight < hTo) { bool active = (row->history()->peer == act) || (row->history()->peer->migrateTo() && row->history()->peer->migrateTo() == act); bool selected = (row->history()->peer == sel); - Layout::RowPainter::paint(p, row, w, active, selected, onlyBackground); + Layout::RowPainter::paint(p, row, w, active, selected, onlyBackground, ms); row = row->_next; p.translate(0, st::dialogsRowHeight); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_list.h b/Telegram/SourceFiles/dialogs/dialogs_list.h index c6c40950a..3bf402b81 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_list.h +++ b/Telegram/SourceFiles/dialogs/dialogs_list.h @@ -51,7 +51,7 @@ public: return *i; } - void paint(Painter &p, int32 w, int32 hFrom, int32 hTo, PeerData *act, PeerData *sel, bool onlyBackground) const; + void paint(Painter &p, int32 w, int32 hFrom, int32 hTo, PeerData *act, PeerData *sel, bool onlyBackground, TimeMs ms) const; Row *addToEnd(History *history); Row *adjustByName(const PeerData *peer); Row *addByName(History *history); diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 1f77a4773..91b3adfbc 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -96,7 +96,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO if (!paintingOther) { p.setClipRect(r); } - + auto ms = paintingOther ? TimeMs(0) : getms(); if (_state == DefaultState) { QRect dialogsClip = r; if (importantDialogs) { @@ -105,9 +105,9 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO p.translate(0, st::dialogsImportantBarHeight); } int32 otherStart = shownDialogs()->size() * st::dialogsRowHeight; - PeerData *active = App::main()->activePeer(), *selected = _menuPeer ? _menuPeer : (_sel ? _sel->history()->peer : 0); + auto active = App::main()->activePeer(), selected = _menuPeer ? _menuPeer : (_sel ? _sel->history()->peer : nullptr); if (otherStart) { - shownDialogs()->all().paint(p, fullWidth(), dialogsClip.top(), dialogsClip.top() + dialogsClip.height(), active, selected, paintingOther); + shownDialogs()->all().paint(p, fullWidth(), dialogsClip.top(), dialogsClip.top() + dialogsClip.height(), active, selected, paintingOther, ms); } if (!otherStart) { p.fillRect(dialogsClip, st::dialogsBg); @@ -171,7 +171,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO for (; from < to; ++from) { bool active = ((_filterResults[from]->history()->peer == act) || (_filterResults[from]->history()->peer->migrateTo() && _filterResults[from]->history()->peer->migrateTo() == act)) && !actId; bool selected = (from == _filteredSel) || (_filterResults[from]->history()->peer == _menuPeer); - Dialogs::Layout::RowPainter::paint(p, _filterResults[from], w, active, selected, paintingOther); + Dialogs::Layout::RowPainter::paint(p, _filterResults[from], w, active, selected, paintingOther, ms); p.translate(0, st::dialogsRowHeight); } } @@ -241,7 +241,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO auto history = item->history(); bool active = (history->peer == act && item->id == actId) || (history->peer->migrateTo() && history->peer->migrateTo() == act && item->id == -actId); bool selected = (from == _searchedSel); - Dialogs::Layout::RowPainter::paint(p, result, w, active, selected, paintingOther); + Dialogs::Layout::RowPainter::paint(p, result, w, active, selected, paintingOther, ms); p.translate(0, st::dialogsRowHeight); } } diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index 85fe5ad73..14dec9b2b 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -151,7 +151,7 @@ signals: void refreshHashtags(); protected: - void paintRegion(Painter &p, const QRegion ®ion, bool paintingOther); + void paintRegion(Painter &p, const QRegion ®ion, bool paintingOther) override; private: void itemRemoved(HistoryItem *item); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index d2a1440cc..60e6981ab 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -633,12 +633,12 @@ struct Data { Stickers::Sets StickerSets; Stickers::Order StickerSetsOrder; - uint64 LastStickersUpdate = 0; - uint64 LastRecentStickersUpdate = 0; + TimeMs LastStickersUpdate = 0; + TimeMs LastRecentStickersUpdate = 0; Stickers::Order FeaturedStickerSetsOrder; int FeaturedStickerSetsUnreadCount = 0; base::Observable FeaturedStickerSetsUnreadCountChanged; - uint64 LastFeaturedStickersUpdate = 0; + TimeMs LastFeaturedStickersUpdate = 0; Stickers::Order ArchivedStickerSetsOrder; MTP::DcOptions DcOptions; @@ -751,12 +751,12 @@ DefineRefVar(Global, PendingItemsMap, PendingRepaintItems); DefineVar(Global, Stickers::Sets, StickerSets); DefineVar(Global, Stickers::Order, StickerSetsOrder); -DefineVar(Global, uint64, LastStickersUpdate); -DefineVar(Global, uint64, LastRecentStickersUpdate); +DefineVar(Global, TimeMs, LastStickersUpdate); +DefineVar(Global, TimeMs, LastRecentStickersUpdate); DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder); DefineVar(Global, int, FeaturedStickerSetsUnreadCount); DefineRefVar(Global, base::Observable, FeaturedStickerSetsUnreadCountChanged); -DefineVar(Global, uint64, LastFeaturedStickersUpdate); +DefineVar(Global, TimeMs, LastFeaturedStickersUpdate); DefineVar(Global, Stickers::Order, ArchivedStickerSetsOrder); DefineVar(Global, MTP::DcOptions, DcOptions); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 17a2af68f..6b6e05952 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -313,12 +313,12 @@ DeclareRefVar(PendingItemsMap, PendingRepaintItems); DeclareVar(Stickers::Sets, StickerSets); DeclareVar(Stickers::Order, StickerSetsOrder); -DeclareVar(uint64, LastStickersUpdate); -DeclareVar(uint64, LastRecentStickersUpdate); +DeclareVar(TimeMs, LastStickersUpdate); +DeclareVar(TimeMs, LastRecentStickersUpdate); DeclareVar(Stickers::Order, FeaturedStickerSetsOrder); DeclareVar(int, FeaturedStickerSetsUnreadCount); DeclareRefVar(base::Observable, FeaturedStickerSetsUnreadCountChanged); -DeclareVar(uint64, LastFeaturedStickersUpdate); +DeclareVar(TimeMs, LastFeaturedStickersUpdate); DeclareVar(Stickers::Order, ArchivedStickerSetsOrder); DeclareVar(MTP::DcOptions, DcOptions); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 82e3a326b..6f4dc2928 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -34,6 +34,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org namespace { +constexpr int kStatusShowClientsideTyping = 6000; constexpr int kStatusShowClientsideRecordVideo = 6000; constexpr int kStatusShowClientsideUploadVideo = 6000; constexpr int kStatusShowClientsideRecordVoice = 6000; @@ -43,6 +44,7 @@ constexpr int kStatusShowClientsideUploadFile = 6000; constexpr int kStatusShowClientsideChooseLocation = 6000; constexpr int kStatusShowClientsideChooseContact = 6000; constexpr int kStatusShowClientsidePlayGame = 10000; +constexpr int kSetMyActionForMs = 10000; } // namespace @@ -54,7 +56,7 @@ void historyInit() { History::History(const PeerId &peerId) : peer(App::peer(peerId)) , lastItemTextCache(st::dialogsTextWidthMin) -, typingText(st::dialogsTextWidthMin) +, _sendActionText(st::dialogsTextWidthMin) , cloudDraftTextCache(st::dialogsTextWidthMin) , _mute(isNotifyMuted(peer->notify)) { if (peer->isUser() && peer->asUser()->botInfo) { @@ -183,87 +185,165 @@ void History::draftSavedToCloud() { if (App::main()) App::main()->writeDrafts(this); } -bool History::updateTyping(uint64 ms, bool force) { - bool changed = force; - for (auto i = typing.begin(), e = typing.end(); i != e;) { +bool History::updateSendActionNeedsAnimating(UserData *user, const MTPSendMessageAction &action) { + using Type = SendAction::Type; + if (action.type() == mtpc_sendMessageCancelAction) { + unregSendAction(user); + return false; + } else if (action.type() == mtpc_sendMessageGameStopAction) { + auto it = _sendActions.find(user); + if (it != _sendActions.end() && it->type == Type::PlayGame) { + unregSendAction(user); + } + return false; + } + + auto ms = getms(); + switch (action.type()) { + case mtpc_sendMessageTypingAction: _typing.insert(user, ms + kStatusShowClientsideTyping); break; + case mtpc_sendMessageRecordVideoAction: _sendActions.insert(user, { Type::RecordVideo, ms + kStatusShowClientsideRecordVideo }); break; + case mtpc_sendMessageUploadVideoAction: _sendActions.insert(user, { Type::UploadVideo, ms + kStatusShowClientsideUploadVideo, action.c_sendMessageUploadVideoAction().vprogress.v }); break; + case mtpc_sendMessageRecordAudioAction: _sendActions.insert(user, { Type::RecordVoice, ms + kStatusShowClientsideRecordVoice }); break; + case mtpc_sendMessageUploadAudioAction: _sendActions.insert(user, { Type::UploadVoice, ms + kStatusShowClientsideUploadVoice, action.c_sendMessageUploadAudioAction().vprogress.v }); break; + case mtpc_sendMessageUploadPhotoAction: _sendActions.insert(user, { Type::UploadPhoto, ms + kStatusShowClientsideUploadPhoto, action.c_sendMessageUploadPhotoAction().vprogress.v }); break; + case mtpc_sendMessageUploadDocumentAction: _sendActions.insert(user, { Type::UploadFile, ms + kStatusShowClientsideUploadFile, action.c_sendMessageUploadDocumentAction().vprogress.v }); break; + case mtpc_sendMessageGeoLocationAction: _sendActions.insert(user, { Type::ChooseLocation, ms + kStatusShowClientsideChooseLocation }); break; + case mtpc_sendMessageChooseContactAction: _sendActions.insert(user, { Type::ChooseContact, ms + kStatusShowClientsideChooseContact }); break; + case mtpc_sendMessageGamePlayAction: { + auto it = _sendActions.find(user); + if (it == _sendActions.end() || it->type == Type::PlayGame || it->until <= ms) { + _sendActions.insert(user, { Type::PlayGame, ms + kStatusShowClientsidePlayGame }); + } + } break; + default: return false; + } + return updateSendActionNeedsAnimating(ms, true); +} + +bool History::mySendActionUpdated(SendAction::Type type, bool doing) { + auto ms = getms(true); + auto i = _mySendActions.find(type); + if (doing) { + if (i == _mySendActions.cend()) { + _mySendActions.insert(type, ms + kSetMyActionForMs); + } else if (i.value() > ms + (kSetMyActionForMs / 2)) { + return false; + } else { + i.value() = ms + kSetMyActionForMs; + } + } else { + if (i == _mySendActions.cend()) { + return false; + } else if (i.value() <= ms) { + return false; + } else { + _mySendActions.erase(i); + } + } + return true; +} + +bool History::paintSendAction(Painter &p, int x, int y, int availableWidth, int outerWidth, const style::color &color, TimeMs ms) { + if (_sendActionAnimation) { + _sendActionAnimation.paint(p, color, x, y + st::normalFont->ascent, outerWidth, ms); + auto animationWidth = _sendActionAnimation.width(); + x += animationWidth; + availableWidth -= animationWidth; + p.setPen(color); + _sendActionText.drawElided(p, x, y, availableWidth); + updateSendActionAnimationAreas(); + return true; + } + return false; +} + +bool History::updateSendActionNeedsAnimating(TimeMs ms, bool force) { + auto changed = force; + for (auto i = _typing.begin(), e = _typing.end(); i != e;) { if (ms >= i.value()) { - i = typing.erase(i); + i = _typing.erase(i); changed = true; } else { ++i; } } - for (auto i = sendActions.begin(); i != sendActions.cend();) { + for (auto i = _sendActions.begin(); i != _sendActions.cend();) { if (ms >= i.value().until) { - i = sendActions.erase(i); + i = _sendActions.erase(i); changed = true; } else { ++i; } } if (changed) { - QString newTypingStr; - int typingCount = typing.size(); + QString newTypingString; + auto typingCount = _typing.size(); if (typingCount > 2) { - newTypingStr = lng_many_typing(lt_count, typingCount); + newTypingString = lng_many_typing(lt_count, typingCount); } else if (typingCount > 1) { - newTypingStr = lng_users_typing(lt_user, typing.begin().key()->firstName, lt_second_user, (typing.end() - 1).key()->firstName); + newTypingString = lng_users_typing(lt_user, _typing.begin().key()->firstName, lt_second_user, (_typing.end() - 1).key()->firstName); } else if (typingCount) { - newTypingStr = peer->isUser() ? lang(lng_typing) : lng_user_typing(lt_user, typing.begin().key()->firstName); - } else if (!sendActions.isEmpty()) { + newTypingString = peer->isUser() ? lang(lng_typing) : lng_user_typing(lt_user, _typing.begin().key()->firstName); + } else if (!_sendActions.isEmpty()) { // Handles all actions except game playing. - auto sendActionString = [](SendActionType type, const QString &name) -> QString { + using Type = SendAction::Type; + auto sendActionString = [](Type type, const QString &name) -> QString { switch (type) { - case SendActionRecordVideo: return name.isEmpty() ? lang(lng_send_action_record_video) : lng_user_action_record_video(lt_user, name); - case SendActionUploadVideo: return name.isEmpty() ? lang(lng_send_action_upload_video) : lng_user_action_upload_video(lt_user, name); - case SendActionRecordVoice: return name.isEmpty() ? lang(lng_send_action_record_audio) : lng_user_action_record_audio(lt_user, name); - case SendActionUploadVoice: return name.isEmpty() ? lang(lng_send_action_upload_audio) : lng_user_action_upload_audio(lt_user, name); - case SendActionUploadPhoto: return name.isEmpty() ? lang(lng_send_action_upload_photo) : lng_user_action_upload_photo(lt_user, name); - case SendActionUploadFile: return name.isEmpty() ? lang(lng_send_action_upload_file) : lng_user_action_upload_file(lt_user, name); - case SendActionChooseLocation: return name.isEmpty() ? lang(lng_send_action_geo_location) : lng_user_action_geo_location(lt_user, name); - case SendActionChooseContact: return name.isEmpty() ? lang(lng_send_action_choose_contact) : lng_user_action_choose_contact(lt_user, name); + case Type::RecordVideo: return name.isEmpty() ? lang(lng_send_action_record_video) : lng_user_action_record_video(lt_user, name); + case Type::UploadVideo: return name.isEmpty() ? lang(lng_send_action_upload_video) : lng_user_action_upload_video(lt_user, name); + case Type::RecordVoice: return name.isEmpty() ? lang(lng_send_action_record_audio) : lng_user_action_record_audio(lt_user, name); + case Type::UploadVoice: return name.isEmpty() ? lang(lng_send_action_upload_audio) : lng_user_action_upload_audio(lt_user, name); + case Type::UploadPhoto: return name.isEmpty() ? lang(lng_send_action_upload_photo) : lng_user_action_upload_photo(lt_user, name); + case Type::UploadFile: return name.isEmpty() ? lang(lng_send_action_upload_file) : lng_user_action_upload_file(lt_user, name); + case Type::ChooseLocation: return name.isEmpty() ? lang(lng_send_action_geo_location) : lng_user_action_geo_location(lt_user, name); + case Type::ChooseContact: return name.isEmpty() ? lang(lng_send_action_choose_contact) : lng_user_action_choose_contact(lt_user, name); default: break; }; return QString(); }; - for (auto i = sendActions.cbegin(), e = sendActions.cend(); i != e; ++i) { - newTypingStr = sendActionString(i->type, peer->isUser() ? QString() : i.key()->firstName); - if (!newTypingStr.isEmpty()) { + for (auto i = _sendActions.cbegin(), e = _sendActions.cend(); i != e; ++i) { + newTypingString = sendActionString(i->type, peer->isUser() ? QString() : i.key()->firstName); + if (!newTypingString.isEmpty()) { + _sendActionAnimation.start(i->type); break; } } // Everyone in sendActions are playing a game. - if (newTypingStr.isEmpty()) { - int playingCount = sendActions.size(); + if (newTypingString.isEmpty()) { + int playingCount = _sendActions.size(); if (playingCount > 2) { - newTypingStr = lng_many_playing_game(lt_count, playingCount); + newTypingString = lng_many_playing_game(lt_count, playingCount); } else if (playingCount > 1) { - newTypingStr = lng_users_playing_game(lt_user, sendActions.begin().key()->firstName, lt_second_user, (sendActions.end() - 1).key()->firstName); + newTypingString = lng_users_playing_game(lt_user, _sendActions.begin().key()->firstName, lt_second_user, (_sendActions.end() - 1).key()->firstName); } else { - newTypingStr = peer->isUser() ? lang(lng_playing_game) : lng_user_playing_game(lt_user, sendActions.begin().key()->firstName); + newTypingString = peer->isUser() ? lang(lng_playing_game) : lng_user_playing_game(lt_user, _sendActions.begin().key()->firstName); } + _sendActionAnimation.start(Type::PlayGame); } } - if (!newTypingStr.isEmpty()) { - newTypingStr += qsl("..."); + if (typingCount > 0) { + _sendActionAnimation.start(SendAction::Type::Typing); + } else if (newTypingString.isEmpty()) { + _sendActionAnimation.stop(); } - if (typingStr != newTypingStr) { - typingText.setText(st::dialogsTextFont, (typingStr = newTypingStr), _textNameOptions); + if (_sendActionString != newTypingString) { + _sendActionString = newTypingString; + _sendActionText.setText(st::dialogsTextFont, _sendActionString, _textNameOptions); } } - if (!typingStr.isEmpty()) { - if (typingText.lastDots(typingDots % 4)) { - changed = true; - } + auto result = (!_typing.isEmpty() || !_sendActions.isEmpty()); + if (changed || result) { + updateSendActionAnimationAreas(); } - if (changed && App::main()) { - updateChatListEntry(); - if (App::main()->historyPeer() == peer) { - App::main()->topBar()->update(); - } + return result; +} + +void History::updateSendActionAnimationAreas() { + updateChatListEntry(); + if (App::main()->historyPeer() == peer) { + App::main()->topBar()->update(); } - return changed; } ChannelHistory::ChannelHistory(const PeerId &peer) : History(peer) @@ -561,56 +641,23 @@ void Histories::clear() { } void Histories::regSendAction(History *history, UserData *user, const MTPSendMessageAction &action, TimeId when) { - if (action.type() == mtpc_sendMessageCancelAction) { - history->unregTyping(user); - return; - } else if (action.type() == mtpc_sendMessageGameStopAction) { - auto it = history->sendActions.find(user); - if (it != history->sendActions.end() && it->type == SendActionPlayGame) { - history->unregTyping(user); + if (history->updateSendActionNeedsAnimating(user, action)) { + user->madeAction(when); + + auto i = typing.find(history); + if (i == typing.cend()) { + typing.insert(history, getms()); + _a_typings.start(); } - return; } - - uint64 ms = getms(); - switch (action.type()) { - case mtpc_sendMessageTypingAction: history->typing[user] = ms + 6000; break; - case mtpc_sendMessageRecordVideoAction: history->sendActions.insert(user, SendAction(SendActionRecordVideo, ms + kStatusShowClientsideRecordVideo)); break; - case mtpc_sendMessageUploadVideoAction: history->sendActions.insert(user, SendAction(SendActionUploadVideo, ms + kStatusShowClientsideUploadVideo, action.c_sendMessageUploadVideoAction().vprogress.v)); break; - case mtpc_sendMessageRecordAudioAction: history->sendActions.insert(user, SendAction(SendActionRecordVoice, ms + kStatusShowClientsideRecordVoice)); break; - case mtpc_sendMessageUploadAudioAction: history->sendActions.insert(user, SendAction(SendActionUploadVoice, ms + kStatusShowClientsideUploadVoice, action.c_sendMessageUploadAudioAction().vprogress.v)); break; - case mtpc_sendMessageUploadPhotoAction: history->sendActions.insert(user, SendAction(SendActionUploadPhoto, ms + kStatusShowClientsideUploadPhoto, action.c_sendMessageUploadPhotoAction().vprogress.v)); break; - case mtpc_sendMessageUploadDocumentAction: history->sendActions.insert(user, SendAction(SendActionUploadFile, ms + kStatusShowClientsideUploadFile, action.c_sendMessageUploadDocumentAction().vprogress.v)); break; - case mtpc_sendMessageGeoLocationAction: history->sendActions.insert(user, SendAction(SendActionChooseLocation, ms + kStatusShowClientsideChooseLocation)); break; - case mtpc_sendMessageChooseContactAction: history->sendActions.insert(user, SendAction(SendActionChooseContact, ms + kStatusShowClientsideChooseContact)); break; - case mtpc_sendMessageGamePlayAction: { - auto it = history->sendActions.find(user); - if (it == history->sendActions.end() || it->type == SendActionPlayGame || it->until <= ms) { - history->sendActions.insert(user, SendAction(SendActionPlayGame, ms + kStatusShowClientsidePlayGame)); - } - } break; - default: return; - } - - user->madeAction(when); - - auto i = typing.find(history); - if (i == typing.cend()) { - typing.insert(history, ms); - history->typingDots = 0; - _a_typings.start(); - } - history->updateTyping(ms, true); } -void Histories::step_typings(uint64 ms, bool timer) { - for (TypingHistories::iterator i = typing.begin(), e = typing.end(); i != e;) { - i.key()->typingDots = (ms - i.value()) / 150; - i.key()->updateTyping(ms); - if (i.key()->typing.isEmpty() && i.key()->sendActions.isEmpty()) { - i = typing.erase(i); - } else { +void Histories::step_typings(TimeMs ms, bool timer) { + for (auto i = typing.begin(), e = typing.end(); i != e;) { + if (i.key()->updateSendActionNeedsAnimating(ms)) { ++i; + } else { + i = typing.erase(i); } } if (typing.isEmpty()) { @@ -1107,20 +1154,20 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) { return adding; } -void History::unregTyping(UserData *from) { - uint64 updateAtMs = 0; - auto i = typing.find(from); - if (i != typing.cend()) { +void History::unregSendAction(UserData *from) { + auto updateAtMs = TimeMs(0); + auto i = _typing.find(from); + if (i != _typing.cend()) { updateAtMs = getms(); i.value() = updateAtMs; } - auto j = sendActions.find(from); - if (j != sendActions.cend()) { + auto j = _sendActions.find(from); + if (j != _sendActions.cend()) { if (!updateAtMs) updateAtMs = getms(); j.value().until = updateAtMs; } if (updateAtMs) { - updateTyping(updateAtMs, true); + updateSendActionNeedsAnimating(updateAtMs, true); } } @@ -1128,7 +1175,7 @@ void History::newItemAdded(HistoryItem *item) { App::checkImageCacheSize(); if (item->from() && item->from()->isUser()) { if (item->from() == item->author()) { - unregTyping(item->from()->asUser()); + unregSendAction(item->from()->asUser()); } MTPint itemServerTime; toServerTime(item->date.toTime_t(), itemServerTime); diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 5cc99a617..d929cb748 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -20,14 +20,14 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once +#include "structs.h" +#include "dialogs/dialogs_common.h" +#include "ui/effects/send_action_animations.h" + void historyInit(); class HistoryItem; - -typedef QMap SelectedItemSet; - -#include "structs.h" -#include "dialogs/dialogs_common.h" +using SelectedItemSet = QMap; enum NewMessageType { NewMessageUnread, @@ -45,7 +45,7 @@ public: } void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action, TimeId when); - void step_typings(uint64 ms, bool timer); + void step_typings(TimeMs ms, bool timer); History *find(const PeerId &peerId); History *findOrInsert(const PeerId &peerId); @@ -59,7 +59,7 @@ public: HistoryItem *addNewMessage(const MTPMessage &msg, NewMessageType type); - typedef QMap TypingHistories; // when typing in this history started + typedef QMap TypingHistories; // when typing in this history started TypingHistories typing; Animation _a_typings; @@ -132,26 +132,6 @@ inline MTPMessagesFilter typeToMediaFilter(MediaOverviewType &type) { return MTPMessagesFilter(); } -enum SendActionType { - SendActionTyping, - SendActionRecordVideo, - SendActionUploadVideo, - SendActionRecordVoice, - SendActionUploadVoice, - SendActionUploadPhoto, - SendActionUploadFile, - SendActionChooseLocation, - SendActionChooseContact, - SendActionPlayGame, -}; -struct SendAction { - SendAction(SendActionType type, uint64 until, int32 progress = 0) : type(type), until(until), progress(progress) { - } - SendActionType type; - uint64 until; - int32 progress; -}; - struct TextWithTags { struct Tag { int offset, length; @@ -237,7 +217,6 @@ public: void eraseFromOverview(MediaOverviewType type, MsgId msgId); void newItemAdded(HistoryItem *item); - void unregTyping(UserData *from); int countUnread(MsgId upTo); void updateShowFrom(); @@ -332,7 +311,13 @@ public: } void paintDialog(Painter &p, int32 w, bool sel) const; - bool updateTyping(uint64 ms, bool force = false); + bool updateSendActionNeedsAnimating(TimeMs ms, bool force = false); + void unregSendAction(UserData *from); + bool updateSendActionNeedsAnimating(UserData *user, const MTPSendMessageAction &action); + void updateSendActionAnimationAreas(); + bool mySendActionUpdated(SendAction::Type type, bool doing); + bool paintSendAction(Painter &p, int x, int y, int availableWidth, int outerWidth, const style::color &color, TimeMs ms); + void clearLastKeyboard(); // optimization for userpics displayed on the left @@ -425,15 +410,6 @@ public: mutable const HistoryItem *textCachedFor = nullptr; // cache mutable Text lastItemTextCache; - using TypingUsers = QMap; - TypingUsers typing; - using SendActionUsers = QMap; - SendActionUsers sendActions; - QString typingStr; - Text typingText; - uint32 typingDots; - QMap mySendActions; - typedef QList MediaOverview; MediaOverview overview[OverviewCount]; @@ -569,6 +545,16 @@ private: std_::unique_ptr _localDraft, _cloudDraft; std_::unique_ptr _editDraft; + using TypingUsers = QMap; + TypingUsers _typing; + using SendActionUsers = QMap; + SendActionUsers _sendActions; + QString _sendActionString; + Text _sendActionText; + Ui::SendActionAnimation _sendActionAnimation; + QMap _mySendActions; + + }; class HistoryJoined; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index ca051753f..cbb9a6827 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -222,7 +222,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, uint64 ms) const { +void ReplyKeyboard::paint(Painter &p, int outerWidth, const QRect &clip, TimeMs ms) const { t_assert(_st != nullptr); t_assert(_width > 0); @@ -322,7 +322,7 @@ void ReplyKeyboard::startAnimation(int i, int j, int direction) { } } -void ReplyKeyboard::step_selected(uint64 ms, bool timer) { +void ReplyKeyboard::step_selected(TimeMs ms, bool timer) { for (Animations::iterator i = _animations.begin(); i != _animations.end();) { int index = qAbs(i.key()) - 1, row = (index / MatrixRowShift), col = index % MatrixRowShift; float64 dt = float64(ms - i.value()) / st::botKbDuration; @@ -361,7 +361,7 @@ int ReplyKeyboard::Style::buttonHeight() const { return _st->height; } -void ReplyKeyboard::Style::paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, uint64 ms) const { +void ReplyKeyboard::Style::paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, TimeMs ms) const { const QRect &rect = button.rect; paintButtonBg(p, rect, button.howMuchOver); if (button.ripple) { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index a09115f2f..23835375f 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -314,7 +314,7 @@ public: private: const style::BotKeyboardButton *_st; - void paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, uint64 ms) const; + void paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button, TimeMs ms) const; friend class ReplyKeyboard; }; @@ -332,7 +332,7 @@ public: int naturalWidth() const; int naturalHeight() const; - void paint(Painter &p, int outerWidth, const QRect &clip, uint64 ms) const; + void paint(Painter &p, int outerWidth, const QRect &clip, TimeMs ms) const; ClickHandlerPtr getState(int x, int y) const; void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active); @@ -363,8 +363,8 @@ private: }; ButtonCoords findButtonCoordsByClickHandler(const ClickHandlerPtr &p); - using Animations = QMap; - void step_selected(uint64 ms, bool timer); + using Animations = QMap; + void step_selected(TimeMs ms, bool timer); const HistoryItem *_item; int _width = 0; @@ -473,7 +473,7 @@ public: } return resizeGetHeight_(width); } - virtual void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const = 0; + virtual void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const = 0; virtual void dependencyItemRemoved(HistoryItem *dependency) { } diff --git a/Telegram/SourceFiles/history/history_media.h b/Telegram/SourceFiles/history/history_media.h index eea88a510..0f0658555 100644 --- a/Telegram/SourceFiles/history/history_media.h +++ b/Telegram/SourceFiles/history/history_media.h @@ -64,7 +64,7 @@ public: _width = qMin(width, _maxw); return _height; } - virtual void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const = 0; + virtual void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const = 0; virtual HistoryTextState getState(int x, int y, HistoryStateRequest request) const = 0; // if we are in selecting items mode perhaps we want to diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 26c319882..ac3f7669a 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -203,7 +203,7 @@ void HistoryFileMedia::step_thumbOver(float64 ms, bool timer) { } } -void HistoryFileMedia::step_radial(uint64 ms, bool timer) { +void HistoryFileMedia::step_radial(TimeMs ms, bool timer) { if (timer) { Ui::repaintHistoryItem(_parent); } else { @@ -356,7 +356,7 @@ int HistoryPhoto::resizeGetHeight(int width) { return _height; } -void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->automaticLoad(_parent); @@ -703,7 +703,7 @@ int HistoryVideo::resizeGetHeight(int width) { return _height; } -void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->automaticLoad(_parent); @@ -1064,7 +1064,7 @@ int HistoryDocument::resizeGetHeight(int width) { return _height; } -void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->automaticLoad(_parent); @@ -1671,7 +1671,7 @@ int HistoryGif::resizeGetHeight(int width) { return _height; } -void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->automaticLoad(_parent); @@ -2001,7 +2001,7 @@ int HistorySticker::resizeGetHeight(int width) { // return new height return _height; } -void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { auto sticker = _data->sticker(); if (!sticker) return; @@ -2270,7 +2270,7 @@ void HistoryContact::initDimensions() { _height = _minh; } -void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; int32 skipx = 0, skipy = 0, width = _width, height = _height; @@ -2643,7 +2643,7 @@ int HistoryWebPage::resizeGetHeight(int width) { return _height; } -void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; int32 skipx = 0, skipy = 0, width = _width, height = _height; @@ -3042,7 +3042,7 @@ int HistoryGame::resizeGetHeight(int width) { return _height; } -void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; int32 width = _width, height = _height; @@ -3367,7 +3367,7 @@ int HistoryLocation::resizeGetHeight(int width) { return _height; } -void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; int32 skipx = 0, skipy = 0, width = _width, height = _height; bool bubble = _parent->hasBubble(); diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index 15879e710..51e8524cb 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -72,18 +72,18 @@ protected: void setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const; void step_thumbOver(float64 ms, bool timer); - void step_radial(uint64 ms, bool timer); + void step_radial(TimeMs ms, bool timer); void ensureAnimation() const; void checkAnimationFinished(); - bool isRadialAnimation(uint64 ms) const { + bool isRadialAnimation(TimeMs ms) const { if (!_animation || !_animation->radial.animating()) return false; _animation->radial.step(ms); return _animation && _animation->radial.animating(); } - bool isThumbAnimation(uint64 ms) const { + bool isThumbAnimation(TimeMs ms) const { if (!_animation || !_animation->_a_thumbOver.animating()) return false; _animation->_a_thumbOver.step(ms); @@ -125,7 +125,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { @@ -212,7 +212,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { @@ -336,7 +336,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { @@ -433,7 +433,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { @@ -530,7 +530,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { @@ -593,7 +593,7 @@ public: void initDimensions() override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { @@ -656,7 +656,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override; @@ -756,7 +756,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override; @@ -859,7 +859,7 @@ public: void initDimensions() override; int resizeGetHeight(int32 width) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index ad684859e..f0ac64921 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -1236,7 +1236,7 @@ void HistoryMessage::setId(MsgId newId) { } } -void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { bool outbg = out() && !isPost(), bubble = drawBubble(), selected = (selection == FullSelection); int left = 0, width = 0, height = _height; @@ -1256,7 +1256,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, u } } - uint64 fullAnimMs = App::main() ? App::main()->animActiveTimeStart(this) : 0; + auto fullAnimMs = App::main() ? App::main()->animActiveTimeStart(this) : 0LL; if (fullAnimMs > 0 && fullAnimMs <= ms) { int animms = ms - fullAnimMs; if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) { @@ -2111,7 +2111,7 @@ void HistoryService::setServiceText(const QString &text, const Links &links) { _textHeight = 0; } -void HistoryService::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { +void HistoryService::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const { int height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); QRect clip(r); diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index ef38463db..dfaf81cfc 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -71,7 +71,7 @@ public: void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const override; void setViewsCount(int32 count) override; void setId(MsgId newId) override; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; void dependencyItemRemoved(HistoryItem *dependency) override; @@ -279,7 +279,7 @@ public: void countPositionAndSize(int32 &left, int32 &width) const; - void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override; + void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; bool hasPoint(int x, int y) const override; HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp index beb585ba0..71eac5a8a 100644 --- a/Telegram/SourceFiles/history/history_service_layout.cpp +++ b/Telegram/SourceFiles/history/history_service_layout.cpp @@ -188,7 +188,7 @@ void ServiceMessagePainter::paint(Painter &p, const HistoryService *message, con message->countPositionAndSize(left, width); if (width < 1) return; - uint64 fullAnimMs = App::main() ? App::main()->animActiveTimeStart(message) : 0; + auto fullAnimMs = App::main() ? App::main()->animActiveTimeStart(message) : 0LL; if (fullAnimMs > 0 && fullAnimMs <= context.ms) { int animms = context.ms - fullAnimMs; if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) { diff --git a/Telegram/SourceFiles/history/history_service_layout.h b/Telegram/SourceFiles/history/history_service_layout.h index d38482829..f1688428f 100644 --- a/Telegram/SourceFiles/history/history_service_layout.h +++ b/Telegram/SourceFiles/history/history_service_layout.h @@ -23,12 +23,12 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org namespace HistoryLayout { struct PaintContext { - PaintContext(uint64 ms, const QRect &clip, TextSelection selection) + PaintContext(TimeMs ms, const QRect &clip, TextSelection selection) : ms(ms) , clip(clip) , selection(selection) { } - uint64 ms; + TimeMs ms; const QRect &clip; TextSelection selection; }; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index c25333d81..d0d0989a0 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -409,7 +409,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) { if (!trivial) { p.setClipRect(r); } - uint64 ms = getms(); + auto ms = getms(); bool historyDisplayedEmpty = (_history->isDisplayedEmpty() && (!_migrated || _migrated->isDisplayedEmpty())); bool noHistoryDisplayed = _firstLoading || historyDisplayedEmpty; @@ -612,7 +612,7 @@ bool HistoryInner::event(QEvent *e) { } void HistoryInner::onTouchScrollTimer() { - uint64 nowTime = getms(); + auto nowTime = getms(); if (_touchScrollState == Ui::TouchScrollState::Acceleration && _touchWaitingAcceleration && (nowTime - _touchAccelerationTime) > 40) { _touchScrollState = Ui::TouchScrollState::Manual; touchResetSpeed(); @@ -633,7 +633,7 @@ void HistoryInner::onTouchScrollTimer() { } void HistoryInner::touchUpdateSpeed() { - const uint64 nowTime = getms(); + const auto nowTime = getms(); if (_touchPrevPosValid) { const int elapsed = nowTime - _touchSpeedTime; if (elapsed) { @@ -3296,7 +3296,7 @@ void HistoryWidget::onTextChange() { if (_peer && (!_peer->isChannel() || _peer->isMegagroup())) { if (!_inlineBot && !_editMsgId && (_textUpdateEvents.testFlag(TextUpdateEvent::SendTyping))) { - updateSendAction(_history, SendActionTyping); + updateSendAction(_history, SendAction::Type::Typing); } } @@ -3345,7 +3345,7 @@ void HistoryWidget::onDraftSaveDelayed() { void HistoryWidget::onDraftSave(bool delayed) { if (!_peer) return; if (delayed) { - uint64 ms = getms(); + auto ms = getms(); if (!_saveDraftStart) { _saveDraftStart = ms; return _saveDraftTimer.start(SaveDraftTimeout); @@ -3435,8 +3435,8 @@ void HistoryWidget::writeDrafts(Data::Draft **localDraft, Data::Draft **editDraf } } -void HistoryWidget::cancelSendAction(History *history, SendActionType type) { - QMap, mtpRequestId>::iterator i = _sendActionRequests.find(qMakePair(history, type)); +void HistoryWidget::cancelSendAction(History *history, SendAction::Type type) { + auto i = _sendActionRequests.find(qMakePair(history, type)); if (i != _sendActionRequests.cend()) { MTP::cancel(i.value()); _sendActionRequests.erase(i); @@ -3444,46 +3444,33 @@ void HistoryWidget::cancelSendAction(History *history, SendActionType type) { } void HistoryWidget::onCancelSendAction() { - cancelSendAction(_history, SendActionTyping); + cancelSendAction(_history, SendAction::Type::Typing); } -void HistoryWidget::updateSendAction(History *history, SendActionType type, int32 progress) { +void HistoryWidget::updateSendAction(History *history, SendAction::Type type, int32 progress) { if (!history) return; - bool doing = (progress >= 0); - - uint64 ms = getms(true) + 10000; - QMap::iterator i = history->mySendActions.find(type); - if (doing && i != history->mySendActions.cend() && i.value() + 5000 > ms) return; - if (!doing && (i == history->mySendActions.cend() || i.value() + 5000 <= ms)) return; - - if (doing) { - if (i == history->mySendActions.cend()) { - history->mySendActions.insert(type, ms); - } else { - i.value() = ms; + auto doing = (progress >= 0); + if (history->mySendActionUpdated(type, doing)) { + cancelSendAction(history, type); + if (doing) { + using Type = SendAction::Type; + MTPsendMessageAction action; + switch (type) { + case Type::Typing: action = MTP_sendMessageTypingAction(); break; + case Type::RecordVideo: action = MTP_sendMessageRecordVideoAction(); break; + case Type::UploadVideo: action = MTP_sendMessageUploadVideoAction(MTP_int(progress)); break; + case Type::RecordVoice: action = MTP_sendMessageRecordAudioAction(); break; + case Type::UploadVoice: action = MTP_sendMessageUploadAudioAction(MTP_int(progress)); break; + case Type::UploadPhoto: action = MTP_sendMessageUploadPhotoAction(MTP_int(progress)); break; + case Type::UploadFile: action = MTP_sendMessageUploadDocumentAction(MTP_int(progress)); break; + case Type::ChooseLocation: action = MTP_sendMessageGeoLocationAction(); break; + case Type::ChooseContact: action = MTP_sendMessageChooseContactAction(); break; + case Type::PlayGame: action = MTP_sendMessageGamePlayAction(); break; + } + _sendActionRequests.insert(qMakePair(history, type), MTP::send(MTPmessages_SetTyping(history->peer->input, action), rpcDone(&HistoryWidget::sendActionDone))); + if (type == Type::Typing) _sendActionStopTimer.start(5000); } - } else if (i != history->mySendActions.cend()) { - history->mySendActions.erase(i); - } - - cancelSendAction(history, type); - if (doing) { - MTPsendMessageAction action; - switch (type) { - case SendActionTyping: action = MTP_sendMessageTypingAction(); break; - case SendActionRecordVideo: action = MTP_sendMessageRecordVideoAction(); break; - case SendActionUploadVideo: action = MTP_sendMessageUploadVideoAction(MTP_int(progress)); break; - case SendActionRecordVoice: action = MTP_sendMessageRecordAudioAction(); break; - case SendActionUploadVoice: action = MTP_sendMessageUploadAudioAction(MTP_int(progress)); break; - case SendActionUploadPhoto: action = MTP_sendMessageUploadPhotoAction(MTP_int(progress)); break; - case SendActionUploadFile: action = MTP_sendMessageUploadDocumentAction(MTP_int(progress)); break; - case SendActionChooseLocation: action = MTP_sendMessageGeoLocationAction(); break; - case SendActionChooseContact: action = MTP_sendMessageChooseContactAction(); break; - case SendActionPlayGame: action = MTP_sendMessageGamePlayAction(); break; - } - _sendActionRequests.insert(qMakePair(history, type), MTP::send(MTPmessages_SetTyping(history->peer->input, action), rpcDone(&HistoryWidget::sendActionDone))); - if (type == SendActionTyping) _sendActionStopTimer.start(5000); } } @@ -3496,7 +3483,7 @@ void HistoryWidget::stickersInstalled(uint64 setId) { } void HistoryWidget::sendActionDone(const MTPBool &result, mtpRequestId req) { - for (QMap, mtpRequestId>::iterator i = _sendActionRequests.begin(), e = _sendActionRequests.end(); i != e; ++i) { + for (auto i = _sendActionRequests.begin(), e = _sendActionRequests.end(); i != e; ++i) { if (i.value() == req) { _sendActionRequests.erase(i); break; @@ -3555,7 +3542,7 @@ void HistoryWidget::onRecordUpdate(quint16 level, qint32 samples) { } updateField(); if (_peer && (!_peer->isChannel() || _peer->isMegagroup())) { - updateSendAction(_history, SendActionRecordVoice); + updateSendAction(_history, SendAction::Type::RecordVoice); } } @@ -4220,9 +4207,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re } return; } - if (_history->mySendActions.contains(SendActionTyping)) { - updateSendAction(_history, SendActionTyping, -1); - } + updateSendAction(_history, SendAction::Type::Typing, -1); } if (!cAutoPlayGif()) { @@ -5715,7 +5700,7 @@ void HistoryWidget::stopRecording(bool send) { _recording = false; _recordingSamples = 0; if (_peer && (!_peer->isChannel() || _peer->isMegagroup())) { - updateSendAction(_history, SendActionRecordVoice, -1); + updateSendAction(_history, SendAction::Type::RecordVoice, -1); } updateControlsVisibility(); @@ -5838,7 +5823,7 @@ void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotC url = appendShareGameScoreUrl(url, info.msgId); BotGameUrlClickHandler(info.bot, url).onClick(Qt::LeftButton); if (item && (!item->history()->peer->isChannel() || item->history()->peer->isMegagroup())) { - updateSendAction(item->history(), SendActionPlayGame); + updateSendAction(item->history(), SendAction::Type::PlayGame); } } else { UrlClickHandler(url).onClick(Qt::LeftButton); @@ -6211,7 +6196,7 @@ void HistoryWidget::onForwardHere() { App::forward(_peer->id, ForwardContextMessage); } -bool HistoryWidget::paintTopBar(Painter &p, int decreaseWidth) { +bool HistoryWidget::paintTopBar(Painter &p, int decreaseWidth, TimeMs ms) { if (_a_show.animating()) { int retina = cIntRetinaFactor(); if (a_coordOver.current() > 0) { @@ -6232,12 +6217,9 @@ bool HistoryWidget::paintTopBar(Painter &p, int decreaseWidth) { decreaseWidth += increaseLeft; QRect rectForName(st::topBarArrowPadding.right() + increaseLeft, st::topBarArrowPadding.top(), width() - decreaseWidth - st::topBarArrowPadding.left() - st::topBarArrowPadding.right(), st::msgNameFont->height); p.setFont(st::dialogsTextFont); - if (_history->typing.isEmpty() && _history->sendActions.isEmpty()) { + if (!_history->paintSendAction(p, rectForName.x(), st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height, rectForName.width(), width(), st::statusFgActive, ms)) { p.setPen(_titlePeerTextOnline ? st::statusFgActive : st::statusFg); p.drawText(rectForName.x(), st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height + st::dialogsTextFont->ascent, _titlePeerText); - } else { - p.setPen(st::statusFgTyping); - _history->typingText.drawElided(p, rectForName.x(), st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height, rectForName.width()); } p.setPen(st::dialogsNameFg); @@ -6900,7 +6882,7 @@ void HistoryWidget::onPhotoProgress(const FullMsgId &newId) { if (HistoryItem *item = App::histItemById(newId)) { PhotoData *photo = (item->getMedia() && item->getMedia()->type() == MediaTypePhoto) ? static_cast(item->getMedia())->photo() : 0; if (!item->isPost()) { - updateSendAction(item->history(), SendActionUploadPhoto, 0); + updateSendAction(item->history(), SendAction::Type::UploadPhoto, 0); } Ui::repaintHistoryItem(item); } @@ -6912,7 +6894,7 @@ void HistoryWidget::onDocumentProgress(const FullMsgId &newId) { HistoryMedia *media = item->getMedia(); DocumentData *doc = media ? media->getDocument() : 0; if (!item->isPost()) { - updateSendAction(item->history(), (doc && doc->voice()) ? SendActionUploadVoice : SendActionUploadFile, doc ? doc->uploadOffset : 0); + updateSendAction(item->history(), (doc && doc->voice()) ? SendAction::Type::UploadVoice : SendAction::Type::UploadFile, doc ? doc->uploadOffset : 0); } Ui::repaintHistoryItem(item); } @@ -6923,7 +6905,7 @@ void HistoryWidget::onPhotoFailed(const FullMsgId &newId) { HistoryItem *item = App::histItemById(newId); if (item) { if (!item->isPost()) { - updateSendAction(item->history(), SendActionUploadPhoto, -1); + updateSendAction(item->history(), SendAction::Type::UploadPhoto, -1); } // Ui::repaintHistoryItem(item); } @@ -6936,7 +6918,7 @@ void HistoryWidget::onDocumentFailed(const FullMsgId &newId) { HistoryMedia *media = item->getMedia(); DocumentData *doc = media ? media->getDocument() : 0; if (!item->isPost()) { - updateSendAction(item->history(), (doc && doc->voice()) ? SendActionUploadVoice : SendActionUploadFile, -1); + updateSendAction(item->history(), (doc && doc->voice()) ? SendAction::Type::UploadVoice : SendAction::Type::UploadFile, -1); } Ui::repaintHistoryItem(item); } @@ -7051,7 +7033,7 @@ bool HistoryWidget::isItemVisible(HistoryItem *item) { void HistoryWidget::ui_repaintHistoryItem(const HistoryItem *item) { if (_peer && _list && (item->history() == _history || (_migrated && item->history() == _migrated))) { - uint64 ms = getms(); + auto ms = getms(); if (_lastScrolled + 100 <= ms) { _list->repaintItem(item); } else { @@ -7063,7 +7045,7 @@ void HistoryWidget::ui_repaintHistoryItem(const HistoryItem *item) { void HistoryWidget::onUpdateHistoryItems() { if (!_list) return; - uint64 ms = getms(); + auto ms = getms(); if (_lastScrolled + 100 <= ms) { _list->update(); } else { diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index a25281118..26b486eaa 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -261,9 +261,9 @@ private: bool _touchPrevPosValid = false; bool _touchWaitingAcceleration = false; QPoint _touchSpeed; - uint64 _touchSpeedTime = 0; - uint64 _touchAccelerationTime = 0; - uint64 _touchTime = 0; + TimeMs _touchSpeedTime = 0; + TimeMs _touchAccelerationTime = 0; + TimeMs _touchTime = 0; QTimer _touchScrollTimer; // context menu @@ -385,7 +385,7 @@ public: bool hasMarkup() const; bool forceReply() const; - void step_selected(uint64 ms, bool timer); + void step_selected(TimeMs ms, bool timer); void resizeToWidth(int newWidth, int maxOuterHeight) { _maxOuterHeight = maxOuterHeight; return TWidget::resizeToWidth(newWidth); @@ -552,7 +552,7 @@ public: void updateTopBarSelection(); - bool paintTopBar(Painter &p, int decreaseWidth); + bool paintTopBar(Painter &p, int decreaseWidth, TimeMs ms); QRect getMembersShowAreaGeometry() const; void setMembersShowAreaActive(bool active); void topBarClick(); @@ -572,8 +572,8 @@ public: QRect historyRect() const; - void updateSendAction(History *history, SendActionType type, int32 progress = 0); - void cancelSendAction(History *history, SendActionType type); + void updateSendAction(History *history, SendAction::Type type, int32 progress = 0); + void cancelSendAction(History *history, SendAction::Type type); void updateRecentStickers(); void stickersInstalled(uint64 setId); @@ -1085,7 +1085,7 @@ private: int _addToScroll = 0; int _lastScroll = 0;// gifs optimization - uint64 _lastScrolled = 0; + TimeMs _lastScrolled = 0; QTimer _updateHistoryItems; ChildWidget _historyToEnd; @@ -1174,10 +1174,10 @@ private: QTimer _animActiveTimer; float64 _animActiveStart = 0; - QMap, mtpRequestId> _sendActionRequests; + QMap, mtpRequestId> _sendActionRequests; QTimer _sendActionStopTimer; - uint64 _saveDraftStart = 0; + TimeMs _saveDraftStart = 0; bool _saveDraftText = false; QTimer _saveDraftTimer, _saveCloudDraftTimer; diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 44ff47b6b..27c3ffe8d 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -308,14 +308,14 @@ void Gif::ensureAnimation() const { } } -bool Gif::isRadialAnimation(uint64 ms) const { +bool Gif::isRadialAnimation(TimeMs ms) const { if (!_animation || !_animation->radial.animating()) return false; _animation->radial.step(ms); return _animation && _animation->radial.animating(); } -void Gif::step_radial(uint64 ms, bool timer) { +void Gif::step_radial(TimeMs ms, bool timer) { if (timer) { update(); } else { @@ -811,7 +811,7 @@ void File::step_thumbOver(float64 ms, bool timer) { } } -void File::step_radial(uint64 ms, bool timer) { +void File::step_radial(TimeMs ms, bool timer) { if (timer) { Ui::repaintInlineItem(this); } else { @@ -1319,14 +1319,14 @@ void Game::prepareThumb(int width, int height) const { } } -bool Game::isRadialAnimation(uint64 ms) const { +bool Game::isRadialAnimation(TimeMs ms) const { if (!_radial || !_radial->animating()) return false; _radial->step(ms); return _radial && _radial->animating(); } -void Game::step_radial(uint64 ms, bool timer) { +void Game::step_radial(TimeMs ms, bool timer) { if (timer) { update(); } else { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h index 4ea9093b0..f9170280a 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h @@ -96,8 +96,8 @@ private: void prepareThumb(int32 width, int32 height, const QSize &frame) const; void ensureAnimation() const; - bool isRadialAnimation(uint64 ms) const; - void step_radial(uint64 ms, bool timer); + bool isRadialAnimation(TimeMs ms) const; + void step_radial(TimeMs ms, bool timer); void clipCallback(Media::Clip::Notification notification); @@ -243,19 +243,19 @@ public: private: void step_thumbOver(float64 ms, bool timer); - void step_radial(uint64 ms, bool timer); + void step_radial(TimeMs ms, bool timer); void ensureAnimation() const; void checkAnimationFinished(); bool updateStatusText() const; - bool isRadialAnimation(uint64 ms) const { + bool isRadialAnimation(TimeMs ms) const { if (!_animation || !_animation->radial.animating()) return false; _animation->radial.step(ms); return _animation && _animation->radial.animating(); } - bool isThumbAnimation(uint64 ms) const { + bool isThumbAnimation(TimeMs ms) const { if (!_animation || !_animation->_a_thumbOver.animating()) return false; _animation->_a_thumbOver.step(ms); @@ -348,8 +348,8 @@ private: void prepareThumb(int32 width, int32 height) const; - bool isRadialAnimation(uint64 ms) const; - void step_radial(uint64 ms, bool timer); + bool isRadialAnimation(TimeMs ms) const; + void step_radial(TimeMs ms, bool timer); void clipCallback(Media::Clip::Notification notification); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h index ddd606f62..db0178919 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h @@ -31,7 +31,7 @@ namespace Layout { class PaintContext : public PaintContextBase { public: - PaintContext(uint64 ms, bool selecting, bool paused, bool lastRow) + PaintContext(TimeMs ms, bool selecting, bool paused, bool lastRow) : PaintContextBase(ms, selecting) , paused(paused) , lastRow(lastRow) { diff --git a/Telegram/SourceFiles/layout.h b/Telegram/SourceFiles/layout.h index eb8d59911..72a1b2a3d 100644 --- a/Telegram/SourceFiles/layout.h +++ b/Telegram/SourceFiles/layout.h @@ -92,9 +92,9 @@ bool documentIsValidMediaFile(const QString &filepath); class PaintContextBase { public: - PaintContextBase(uint64 ms, bool selecting) : ms(ms), selecting(selecting) { + PaintContextBase(TimeMs ms, bool selecting) : ms(ms), selecting(selecting) { } - uint64 ms; + TimeMs ms; bool selecting; }; diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index b00f0304b..d75fbc348 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -1748,7 +1748,7 @@ void _readMtpData() { } ReadMapState _readMap(const QByteArray &pass) { - uint64 ms = getms(); + auto ms = getms(); QByteArray dataNameUtf8 = (cDataFile() + (cTestMode() ? qsl(":/test/") : QString())).toUtf8(); FileKey dataNameHash[2]; hashMd5(dataNameUtf8.constData(), dataNameUtf8.size(), dataNameHash); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index dc7a499f0..7c9a29639 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1292,7 +1292,7 @@ void MainWidget::unreadCountChanged(History *history) { _history->unreadCountChanged(history); } -uint64 MainWidget::animActiveTimeStart(const HistoryItem *msg) const { +TimeMs MainWidget::animActiveTimeStart(const HistoryItem *msg) const { return _history->animActiveTimeStart(msg); } @@ -1449,7 +1449,7 @@ void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many } void MainWidget::checkLastUpdate(bool afterSleep) { - uint64 n = getms(true); + auto n = getms(true); if (_lastUpdateTime && n > _lastUpdateTime + (afterSleep ? NoUpdatesAfterSleepTimeout : NoUpdatesTimeout)) { _lastUpdateTime = n; MTP::ping(); @@ -2969,11 +2969,11 @@ bool MainWidget::needBackButton() { return _overview || _wideSection || _history->peer(); } -bool MainWidget::paintTopBar(Painter &p, int decreaseWidth) { +bool MainWidget::paintTopBar(Painter &p, int decreaseWidth, TimeMs ms) { if (_overview) { return _overview->paintTopBar(p, decreaseWidth); } else if (!_wideSection) { - return _history->paintTopBar(p, decreaseWidth); + return _history->paintTopBar(p, decreaseWidth, ms); } return false; } @@ -3325,7 +3325,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &diff) { }; } -bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, uint64 &curTime) { +bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, TimeMs &curTime) { if (channel) { if (ms <= 0) { ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel); @@ -3335,7 +3335,7 @@ bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, Channe return false; } } else { - uint64 when = getms(true) + ms; + auto when = getms(true) + ms; ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel); if (i != channelCurTime.cend()) { if (i.value() > when) { @@ -3355,7 +3355,7 @@ bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, Channe return false; } } else { - uint64 when = getms(true) + ms; + auto when = getms(true) + ms; if (!curTime || curTime > when) { curTime = when; } else { @@ -3431,7 +3431,7 @@ bool MainWidget::failDifference(const RPCError &error) { void MainWidget::onGetDifferenceTimeByPts() { if (!MTP::authedId()) return; - uint64 now = getms(true), wait = 0; + auto now = getms(true), wait = 0LL; if (_getDifferenceTimeByPts) { if (_getDifferenceTimeByPts > now) { wait = _getDifferenceTimeByPts - now; @@ -3458,7 +3458,7 @@ void MainWidget::onGetDifferenceTimeByPts() { void MainWidget::onGetDifferenceTimeAfterFail() { if (!MTP::authedId()) return; - uint64 now = getms(true), wait = 0; + auto now = getms(true), wait = 0LL; if (_getDifferenceTimeAfterFail) { if (_getDifferenceTimeAfterFail > now) { wait = _getDifferenceTimeAfterFail - now; @@ -3468,7 +3468,7 @@ void MainWidget::onGetDifferenceTimeAfterFail() { getDifference(); } } - for (ChannelGetDifferenceTime::iterator i = _channelGetDifferenceTimeAfterFail.begin(); i != _channelGetDifferenceTimeAfterFail.cend();) { + for (auto i = _channelGetDifferenceTimeAfterFail.begin(); i != _channelGetDifferenceTimeAfterFail.cend();) { if (i.value() > now) { wait = wait ? qMin(wait, i.value() - now) : (i.value() - now); ++i; @@ -4054,7 +4054,7 @@ bool MainWidget::lastWasOnline() const { return _lastWasOnline; } -uint64 MainWidget::lastSetOnline() const { +TimeMs MainWidget::lastSetOnline() const { return _lastSetOnline; } @@ -4081,8 +4081,8 @@ void MainWidget::updateOnline(bool gotOtherOffline) { bool isOnline = App::wnd()->isActive(); int updateIn = Global::OnlineUpdatePeriod(); if (isOnline) { - uint64 idle = psIdleTime(); - if (idle >= uint64(Global::OfflineIdleTimeout())) { + auto idle = psIdleTime(); + if (idle >= Global::OfflineIdleTimeout()) { isOnline = false; if (!_isIdle) { _isIdle = true; @@ -4092,7 +4092,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) { updateIn = qMin(updateIn, int(Global::OfflineIdleTimeout() - idle)); } } - uint64 ms = getms(true); + auto ms = getms(true); if (isOnline != _lastWasOnline || (isOnline && _lastSetOnline + Global::OnlineUpdatePeriod() <= ms) || (isOnline && gotOtherOffline)) { if (_onlineRequest) { MTP::cancel(_onlineRequest); @@ -4158,7 +4158,7 @@ void MainWidget::writeDrafts(History *history) { void MainWidget::checkIdleFinish() { if (this != App::main()) return; - if (psIdleTime() < uint64(Global::OfflineIdleTimeout())) { + if (psIdleTime() < Global::OfflineIdleTimeout()) { _idleFinishTimer.stop(); _isIdle = false; updateOnline(); @@ -4481,7 +4481,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (App::wnd()) App::wnd()->changingMsgId(msgRow, d.vid.v); msgRow->setId(d.vid.v); if (msgRow->history()->peer->isSelf()) { - msgRow->history()->unregTyping(App::self()); + msgRow->history()->unregSendAction(App::self()); } App::historyRegItem(msgRow); Ui::repaintHistoryItem(msgRow); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 0f8f0a29f..3e76fe95b 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -144,7 +144,7 @@ public: bool needBackButton(); // Temporary methods, while top bar was not done inside HistoryWidget / OverviewWidget. - bool paintTopBar(Painter &, int decreaseWidth); + bool paintTopBar(Painter &, int decreaseWidth, TimeMs ms); QRect getMembersShowAreaGeometry() const; void setMembersShowAreaActive(bool active); Window::TopBarWidget *topBar(); @@ -221,7 +221,7 @@ public: bool isActive() const; bool doWeReadServerHistory() const; bool lastWasOnline() const; - uint64 lastSetOnline() const; + TimeMs lastSetOnline() const; void saveDraftToCloud(); void applyCloudDraft(History *history); @@ -293,7 +293,7 @@ public: void readServerHistory(History *history, ReadServerHistoryChecks checks = ReadServerHistoryChecks::OnlyIfUnread); void unreadCountChanged(History *history); - uint64 animActiveTimeStart(const HistoryItem *msg) const; + TimeMs animActiveTimeStart(const HistoryItem *msg) const; void stopAnimActive(); void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo); @@ -633,12 +633,12 @@ private: return _ptsWaiter.requesting(); } - typedef QMap ChannelGetDifferenceTime; + typedef QMap ChannelGetDifferenceTime; ChannelGetDifferenceTime _channelGetDifferenceTimeByPts, _channelGetDifferenceTimeAfterFail; - uint64 _getDifferenceTimeByPts = 0; - uint64 _getDifferenceTimeAfterFail = 0; + TimeMs _getDifferenceTimeByPts = 0; + TimeMs _getDifferenceTimeAfterFail = 0; - bool getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, uint64 &curTime); + bool getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, TimeMs &curTime); SingleTimer _byPtsTimer; @@ -650,7 +650,7 @@ private: mtpRequestId _onlineRequest = 0; SingleTimer _onlineTimer, _onlineUpdater, _idleFinishTimer; bool _lastWasOnline = false; - uint64 _lastSetOnline = 0; + TimeMs _lastSetOnline = 0; bool _isIdle = false; QSet updateNotifySettingPeers; @@ -669,7 +669,7 @@ private: ChannelFailDifferenceTimeout _channelFailDifferenceTimeout; // growing timeout for getChannelDifference calls, if it fails SingleTimer _failDifferenceTimer; - uint64 _lastUpdateTime = 0; + TimeMs _lastUpdateTime = 0; bool _handlingChannelDifference = false; QPixmap _cachedBackground; diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 1df7014be..614656aed 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -285,7 +285,7 @@ void MainWindow::checkAutoLock() { if (!Global::LocalPasscode() || App::passcoded()) return; App::app()->checkLocalTime(); - uint64 ms = getms(true), idle = psIdleTime(), should = Global::AutoLock() * 1000ULL; + auto ms = getms(true), idle = psIdleTime(), should = Global::AutoLock() * 1000LL; if (idle >= should || (_shouldLockAt > 0 && ms > _shouldLockAt + 3000ULL)) { setupPasscode(); } else { @@ -1043,16 +1043,16 @@ void MainWindow::notifySchedule(History *history, HistoryItem *item) { } int delay = item->Has() ? 500 : 100, t = unixtime(); - uint64 ms = getms(true); - bool isOnline = _main->lastWasOnline(), otherNotOld = ((cOtherOnline() * uint64(1000)) + Global::OnlineCloudTimeout() > t * uint64(1000)); - bool otherLaterThanMe = (cOtherOnline() * uint64(1000) + (ms - _main->lastSetOnline()) > t * uint64(1000)); + auto ms = getms(true); + bool isOnline = _main->lastWasOnline(), otherNotOld = ((cOtherOnline() * 1000LL) + Global::OnlineCloudTimeout() > t * 1000LL); + bool otherLaterThanMe = (cOtherOnline() * 1000LL + (ms - _main->lastSetOnline()) > t * 1000LL); if (!isOnline && otherNotOld && otherLaterThanMe) { delay = Global::NotifyCloudDelay(); } else if (cOtherOnline() >= t) { delay = Global::NotifyDefaultDelay(); } - uint64 when = ms + delay; + auto when = ms + delay; _notifyWhenAlerts[history].insert(when, notifyByFrom); if (Global::DesktopNotify() && !Platform::Notifications::skipToast()) { NotifyWhenMaps::iterator i = _notifyWhenMaps.find(history); @@ -1155,7 +1155,7 @@ void MainWindow::notifySettingGot() { void MainWindow::notifyShowNext() { if (App::quitting()) return; - uint64 ms = getms(true), nextAlert = 0; + auto ms = getms(true), nextAlert = 0LL; bool alert = false; int32 now = unixtime(); for (NotifyWhenAlerts::iterator i = _notifyWhenAlerts.begin(); i != _notifyWhenAlerts.end();) { @@ -1192,7 +1192,7 @@ void MainWindow::notifyShowNext() { } while (true) { - uint64 next = 0; + auto next = 0LL; HistoryItem *notifyItem = 0; History *notifyHistory = 0; for (NotifyWaiters::iterator i = _notifyWaiters.begin(); i != _notifyWaiters.end();) { @@ -1219,7 +1219,7 @@ void MainWindow::notifyShowNext() { i = _notifyWaiters.erase(i); continue; } - uint64 when = i.value().when; + auto when = i.value().when; if (!notifyItem || next > when) { next = when; notifyItem = history->currentNotification(); @@ -1239,7 +1239,7 @@ void MainWindow::notifyShowNext() { HistoryItem *fwd = notifyItem->Has() ? notifyItem : nullptr; // forwarded notify grouping int32 fwdCount = 1; - uint64 ms = getms(true); + auto ms = getms(true); History *history = notifyItem->history(); NotifyWhenMaps::iterator j = _notifyWhenMaps.find(history); if (j == _notifyWhenMaps.cend()) { diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index aadff4956..c88924056 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -261,19 +261,19 @@ private: QTimer _inactiveTimer; SingleTimer _autoLockTimer; - uint64 _shouldLockAt = 0; + TimeMs _shouldLockAt = 0; - using NotifyWhenMap = QMap; + using NotifyWhenMap = QMap; using NotifyWhenMaps = QMap; NotifyWhenMaps _notifyWhenMaps; struct NotifyWaiter { - NotifyWaiter(MsgId msg, uint64 when, PeerData *notifyByFrom) + NotifyWaiter(MsgId msg, TimeMs when, PeerData *notifyByFrom) : msg(msg) , when(when) , notifyByFrom(notifyByFrom) { } MsgId msg; - uint64 when; + TimeMs when; PeerData *notifyByFrom; }; using NotifyWaiters = QMap; @@ -281,7 +281,7 @@ private: NotifyWaiters _notifySettingWaiters; SingleTimer _notifyWaitTimer; - using NotifyWhenAlert = QMap; + using NotifyWhenAlert = QMap; using NotifyWhenAlerts = QMap; NotifyWhenAlerts _notifyWhenAlerts; diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp index 8a6f08d03..eb8a71309 100644 --- a/Telegram/SourceFiles/media/media_audio.cpp +++ b/Telegram/SourceFiles/media/media_audio.cpp @@ -60,7 +60,7 @@ namespace { ALuint notifySource = 0; ALuint notifyBuffer = 0; - uint64 notifyLengthMs = 0; + TimeMs notifyLengthMs = 0; QMutex playerMutex; AudioPlayer *player = 0; @@ -669,12 +669,12 @@ void AudioPlayer::feedFromVideo(VideoSoundPart &&part) { _loader->feedFromVideo(std_::move(part)); } -int64 AudioPlayer::getVideoCorrectedTime(uint64 playId, int64 frameMs, uint64 systemMs) { - int64 result = frameMs; +TimeMs AudioPlayer::getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs) { + auto result = frameMs; QMutexLocker videoLock(&_lastVideoMutex); if (_lastVideoPlayId == playId && _lastVideoPlaybackWhen > 0) { - result = static_cast(_lastVideoPlaybackCorrectedMs); + result = static_cast(_lastVideoPlaybackCorrectedMs); if (systemMs > _lastVideoPlaybackWhen) { result += (systemMs - _lastVideoPlaybackWhen); } @@ -985,7 +985,7 @@ void AudioPlayerFader::onTimer() { bool suppressAudioChanged = false, suppressSongChanged = false; if (_suppressAll || _suppressSongAnim) { - uint64 ms = getms(); + auto ms = getms(); float64 wasSong = suppressSongGain; if (_suppressAll) { float64 wasAudio = suppressAllGain; diff --git a/Telegram/SourceFiles/media/media_audio.h b/Telegram/SourceFiles/media/media_audio.h index f372feb1f..46046c51f 100644 --- a/Telegram/SourceFiles/media/media_audio.h +++ b/Telegram/SourceFiles/media/media_audio.h @@ -51,7 +51,7 @@ struct VideoSoundPart; struct AudioPlaybackState { AudioPlayerState state = AudioPlayerStopped; int64 position = 0; - int64 duration = 0; + TimeMs duration = 0; int32 frequency = 0; }; @@ -69,7 +69,7 @@ public: // Video player audio stream interface. void initFromVideo(uint64 videoPlayId, std_::unique_ptr &&data, int64 position); void feedFromVideo(VideoSoundPart &&part); - int64 getVideoCorrectedTime(uint64 playId, int64 frameMs, uint64 systemMs); + int64 getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs); AudioPlaybackState currentVideoState(uint64 videoPlayId); void stopFromVideo(uint64 videoPlayId); void pauseFromVideo(uint64 videoPlayId); @@ -155,8 +155,8 @@ private: AudioMsg _videoData; uint64 _lastVideoPlayId = 0; - uint64 _lastVideoPlaybackWhen = 0; - uint64 _lastVideoPlaybackCorrectedMs = 0; + TimeMs _lastVideoPlaybackWhen = 0; + TimeMs _lastVideoPlaybackCorrectedMs = 0; QMutex _lastVideoMutex; QMutex _mutex; @@ -258,8 +258,8 @@ private: bool _suppressSongAnim = false; bool _songVolumeChanged, _videoVolumeChanged; anim::fvalue _suppressAllGain, _suppressSongGain; - uint64 _suppressAllStart = 0; - uint64 _suppressSongStart = 0; + TimeMs _suppressAllStart = 0; + TimeMs _suppressSongStart = 0; }; diff --git a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h index 4b9ec0349..bcac859dd 100644 --- a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h +++ b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h @@ -38,7 +38,7 @@ public: bool open(qint64 &position) override; - int64 duration() override { + TimeMs duration() override { return len; } @@ -50,7 +50,7 @@ public: protected: int32 freq = AudioVoiceMsgFrequency; - int64 len = 0; + TimeMs len = 0; uchar *ioBuffer = nullptr; AVIOContext *ioContext = nullptr; diff --git a/Telegram/SourceFiles/media/media_audio_loader.h b/Telegram/SourceFiles/media/media_audio_loader.h index 5e8a55012..d8eaecf06 100644 --- a/Telegram/SourceFiles/media/media_audio_loader.h +++ b/Telegram/SourceFiles/media/media_audio_loader.h @@ -28,7 +28,7 @@ public: virtual bool check(const FileLocation &file, const QByteArray &data); virtual bool open(qint64 &position) = 0; - virtual int64 duration() = 0; + virtual TimeMs duration() = 0; virtual int32 frequency() = 0; virtual int32 format() = 0; diff --git a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h index d7542cd12..5fac0a312 100644 --- a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h +++ b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h @@ -34,7 +34,7 @@ extern "C" { struct VideoSoundData { AVCodecContext *context = nullptr; int32 frequency = AudioVoiceMsgFrequency; - int64 length = 0; + TimeMs length = 0; ~VideoSoundData(); }; @@ -93,7 +93,7 @@ public: return _format; } - int64 duration() override { + TimeMs duration() override { return _parentData->length; } diff --git a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp index cec2dff1e..c34c8837b 100644 --- a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp @@ -127,7 +127,7 @@ ReaderImplementation::ReadResult FFMpegReaderImplementation::readNextFrame() { void FFMpegReaderImplementation::processReadFrame() { int64 duration = av_frame_get_pkt_duration(_frame); int64 framePts = (_frame->pkt_pts == AV_NOPTS_VALUE) ? _frame->pkt_dts : _frame->pkt_pts; - int64 frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den; + TimeMs frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den; _currentFrameDelay = _nextFrameDelay; if (_frameMs + _currentFrameDelay < frameMs) { _currentFrameDelay = int32(frameMs - _frameMs); @@ -146,7 +146,7 @@ void FFMpegReaderImplementation::processReadFrame() { _frameTime += _currentFrameDelay; } -ReaderImplementation::ReadResult FFMpegReaderImplementation::readFramesTill(int64 frameMs, uint64 systemMs) { +ReaderImplementation::ReadResult FFMpegReaderImplementation::readFramesTill(TimeMs frameMs, TimeMs systemMs) { if (_audioStreamId < 0) { // just keep up if (_frameRead && _frameTime > frameMs) { return ReadResult::Success; @@ -182,15 +182,15 @@ ReaderImplementation::ReadResult FFMpegReaderImplementation::readFramesTill(int6 return ReadResult::Success; } -int64 FFMpegReaderImplementation::frameRealTime() const { +TimeMs FFMpegReaderImplementation::frameRealTime() const { return _frameMs; } -uint64 FFMpegReaderImplementation::framePresentationTime() const { - return static_cast(qMax(_frameTime + _frameTimeCorrection, 0LL)); +TimeMs FFMpegReaderImplementation::framePresentationTime() const { + return qMax(_frameTime + _frameTimeCorrection, 0LL); } -int64 FFMpegReaderImplementation::durationMs() const { +TimeMs FFMpegReaderImplementation::durationMs() const { if (_fmtContext->streams[_streamId]->duration == AV_NOPTS_VALUE) return 0; return (_fmtContext->streams[_streamId]->duration * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den; } @@ -280,7 +280,7 @@ FFMpegReaderImplementation::Rotation FFMpegReaderImplementation::rotationFromDeg return Rotation::None; } -bool FFMpegReaderImplementation::start(Mode mode, int64 &positionMs) { +bool FFMpegReaderImplementation::start(Mode mode, TimeMs &positionMs) { _mode = mode; initDevice(); @@ -498,9 +498,9 @@ void FFMpegReaderImplementation::processPacket(AVPacket *packet) { } } -int64 FFMpegReaderImplementation::countPacketMs(AVPacket *packet) const { +TimeMs FFMpegReaderImplementation::countPacketMs(AVPacket *packet) const { int64 packetPts = (packet->pts == AV_NOPTS_VALUE) ? packet->dts : packet->pts; - int64 packetMs = (packetPts * 1000LL * _fmtContext->streams[packet->stream_index]->time_base.num) / _fmtContext->streams[packet->stream_index]->time_base.den; + TimeMs packetMs = (packetPts * 1000LL * _fmtContext->streams[packet->stream_index]->time_base.num) / _fmtContext->streams[packet->stream_index]->time_base.den; return packetMs; } diff --git a/Telegram/SourceFiles/media/media_clip_ffmpeg.h b/Telegram/SourceFiles/media/media_clip_ffmpeg.h index 3860c766d..50be7313a 100644 --- a/Telegram/SourceFiles/media/media_clip_ffmpeg.h +++ b/Telegram/SourceFiles/media/media_clip_ffmpeg.h @@ -37,14 +37,14 @@ class FFMpegReaderImplementation : public ReaderImplementation { public: FFMpegReaderImplementation(FileLocation *location, QByteArray *data, uint64 playId); - ReadResult readFramesTill(int64 frameMs, uint64 systemMs) override; + ReadResult readFramesTill(TimeMs frameMs, TimeMs systemMs) override; - int64 frameRealTime() const override; - uint64 framePresentationTime() const override; + TimeMs frameRealTime() const override; + TimeMs framePresentationTime() const override; bool renderFrame(QImage &to, bool &hasAlpha, const QSize &size) override; - int64 durationMs() const override; + TimeMs durationMs() const override; bool hasAudio() const override { return (_audioStreamId >= 0); } @@ -68,7 +68,7 @@ private: }; PacketResult readPacket(AVPacket *packet); void processPacket(AVPacket *packet); - int64 countPacketMs(AVPacket *packet) const; + TimeMs countPacketMs(AVPacket *packet) const; PacketResult readAndProcessPacket(); enum class Rotation { @@ -107,8 +107,8 @@ private: int _audioStreamId = -1; uint64 _playId = 0; - int64 _lastReadVideoMs = 0; - int64 _lastReadAudioMs = 0; + TimeMs _lastReadVideoMs = 0; + TimeMs _lastReadAudioMs = 0; QQueue _packetQueue; AVPacket _packetNull; // for final decoding @@ -121,12 +121,12 @@ private: SwsContext *_swsContext = nullptr; QSize _swsSize; - int64 _frameMs = 0; + TimeMs _frameMs = 0; int _nextFrameDelay = 0; int _currentFrameDelay = 0; - int64 _frameTime = 0; - int64 _frameTimeCorrection = 0; + TimeMs _frameTime = 0; + TimeMs _frameTimeCorrection = 0; }; diff --git a/Telegram/SourceFiles/media/media_clip_implementation.h b/Telegram/SourceFiles/media/media_clip_implementation.h index 303c8ee2a..ec1392889 100644 --- a/Telegram/SourceFiles/media/media_clip_implementation.h +++ b/Telegram/SourceFiles/media/media_clip_implementation.h @@ -44,21 +44,21 @@ public: EndOfFile, }; // Read frames till current frame will have presentation time > frameMs, systemMs = getms(). - virtual ReadResult readFramesTill(int64 frameMs, uint64 systemMs) = 0; + virtual ReadResult readFramesTill(TimeMs frameMs, TimeMs systemMs) = 0; // Get current frame real and presentation time. - virtual int64 frameRealTime() const = 0; - virtual uint64 framePresentationTime() const = 0; + virtual TimeMs frameRealTime() const = 0; + virtual TimeMs framePresentationTime() const = 0; // Render current frame to an image with specific size. virtual bool renderFrame(QImage &to, bool &hasAlpha, const QSize &size) = 0; - virtual int64 durationMs() const = 0; + virtual TimeMs durationMs() const = 0; virtual bool hasAudio() const = 0; virtual void pauseAudio() = 0; virtual void resumeAudio() = 0; - virtual bool start(Mode mode, int64 &positionMs) = 0; + virtual bool start(Mode mode, TimeMs &positionMs) = 0; virtual ~ReaderImplementation() { } int64 dataSize() const { diff --git a/Telegram/SourceFiles/media/media_clip_qtgif.cpp b/Telegram/SourceFiles/media/media_clip_qtgif.cpp index e82624691..f34890c04 100644 --- a/Telegram/SourceFiles/media/media_clip_qtgif.cpp +++ b/Telegram/SourceFiles/media/media_clip_qtgif.cpp @@ -28,7 +28,7 @@ namespace internal { QtGifReaderImplementation::QtGifReaderImplementation(FileLocation *location, QByteArray *data) : ReaderImplementation(location, data) { } -ReaderImplementation::ReadResult QtGifReaderImplementation::readFramesTill(int64 frameMs, uint64 systemMs) { +ReaderImplementation::ReadResult QtGifReaderImplementation::readFramesTill(TimeMs frameMs, TimeMs systemMs) { if (!_frame.isNull() && _frameTime > frameMs) { return ReadResult::Success; } @@ -43,12 +43,12 @@ ReaderImplementation::ReadResult QtGifReaderImplementation::readFramesTill(int64 return readResult; } -int64 QtGifReaderImplementation::frameRealTime() const { +TimeMs QtGifReaderImplementation::frameRealTime() const { return _frameRealTime; } -uint64 QtGifReaderImplementation::framePresentationTime() const { - return static_cast(qMax(_frameTime, 0LL)); +TimeMs QtGifReaderImplementation::framePresentationTime() const { + return qMax(_frameTime, 0LL); } ReaderImplementation::ReadResult QtGifReaderImplementation::readNextFrame() { @@ -95,7 +95,7 @@ bool QtGifReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const QS return true; } -int64 QtGifReaderImplementation::durationMs() const { +TimeMs QtGifReaderImplementation::durationMs() const { return 0; // not supported } diff --git a/Telegram/SourceFiles/media/media_clip_qtgif.h b/Telegram/SourceFiles/media/media_clip_qtgif.h index 441cdb7d4..1046d0acb 100644 --- a/Telegram/SourceFiles/media/media_clip_qtgif.h +++ b/Telegram/SourceFiles/media/media_clip_qtgif.h @@ -31,14 +31,14 @@ public: QtGifReaderImplementation(FileLocation *location, QByteArray *data); - ReadResult readFramesTill(int64 frameMs, uint64 systemMs) override; + ReadResult readFramesTill(TimeMs frameMs, TimeMs systemMs) override; - int64 frameRealTime() const override; - uint64 framePresentationTime() const override; + TimeMs frameRealTime() const override; + TimeMs framePresentationTime() const override; bool renderFrame(QImage &to, bool &hasAlpha, const QSize &size) override; - int64 durationMs() const override; + TimeMs durationMs() const override; bool hasAudio() const override { return false; } @@ -47,7 +47,7 @@ public: void resumeAudio() override { } - bool start(Mode mode, int64 &positionMs) override; + bool start(Mode mode, TimeMs &positionMs) override; ~QtGifReaderImplementation(); @@ -59,8 +59,8 @@ private: QImageReader *_reader = nullptr; int _framesLeft = 0; - int64 _frameRealTime = 0; - int64 _frameTime = 0; + TimeMs _frameRealTime = 0; + TimeMs _frameTime = 0; int _frameDelay = 0; QImage _frame; diff --git a/Telegram/SourceFiles/media/media_clip_reader.cpp b/Telegram/SourceFiles/media/media_clip_reader.cpp index b0c2ff511..302e85cd1 100644 --- a/Telegram/SourceFiles/media/media_clip_reader.cpp +++ b/Telegram/SourceFiles/media/media_clip_reader.cpp @@ -205,7 +205,7 @@ void Reader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, Image } } -QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, uint64 ms) { +QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms) { auto frame = frameToShow(); t_assert(frame != nullptr); @@ -271,14 +271,14 @@ bool Reader::hasAudio() const { return ready() ? _hasAudio : false; } -int64 Reader::getPositionMs() const { +TimeMs Reader::getPositionMs() const { if (auto frame = frameToShow()) { return frame->positionMs; } return _seekPositionMs; } -int64 Reader::getDurationMs() const { +TimeMs Reader::getDurationMs() const { return ready() ? _durationMs : 0; } @@ -345,7 +345,7 @@ public: _accessed = true; } - ProcessResult start(uint64 ms) { + ProcessResult start(TimeMs ms) { if (!_implementation && !init()) { return error(); } @@ -393,7 +393,7 @@ public: return ProcessResult::Wait; } - ProcessResult process(uint64 ms) { // -1 - do nothing, 0 - update, 1 - reinit + ProcessResult process(TimeMs ms) { // -1 - do nothing, 0 - update, 1 - reinit if (_state == State::Error) { return ProcessResult::Error; } else if (_state == State::Finished) { @@ -416,7 +416,7 @@ public: return ProcessResult::Wait; } - ProcessResult finishProcess(uint64 ms) { + ProcessResult finishProcess(TimeMs ms) { auto frameMs = _seekPositionMs + ms - _animationStarted; auto readResult = _implementation->readFramesTill(frameMs, ms); if (readResult == internal::ReaderImplementation::ReadResult::EndOfFile) { @@ -428,7 +428,7 @@ public: } _nextFramePositionMs = _implementation->frameRealTime(); _nextFrameWhen = _animationStarted + _implementation->framePresentationTime(); - if (static_cast(_nextFrameWhen) > _seekPositionMs) { + if (_nextFrameWhen > _seekPositionMs) { _nextFrameWhen -= _seekPositionMs; } else { _nextFrameWhen = 1; @@ -477,21 +477,21 @@ public: return _implementation->start(implementationMode(), _seekPositionMs); } - void startedAt(uint64 ms) { + void startedAt(TimeMs ms) { _animationStarted = _nextFrameWhen = ms; } - void pauseVideo(uint64 ms) { + void pauseVideo(TimeMs ms) { if (_videoPausedAtMs) return; // Paused already. _videoPausedAtMs = ms; _implementation->pauseAudio(); } - void resumeVideo(uint64 ms) { + void resumeVideo(TimeMs ms) { if (!_videoPausedAtMs) return; // Not paused. - int64 delta = static_cast(ms) - static_cast(_videoPausedAtMs); + auto delta = ms - _videoPausedAtMs; _animationStarted += delta; _nextFrameWhen += delta; @@ -527,7 +527,7 @@ private: State _state = State::Reading; Reader::Mode _mode; uint64 _playId; - int64 _seekPositionMs = 0; + TimeMs _seekPositionMs = 0; QByteArray _data; std_::unique_ptr _location; @@ -541,10 +541,10 @@ private: QPixmap pix; QImage original, cache; bool alpha = true; - uint64 when = 0; + TimeMs when = 0; // Counted from the end, so that positionMs <= durationMs despite keep up delays. - int64 positionMs = 0; + TimeMs positionMs = 0; }; Frame _frames[3]; int _frame = 0; @@ -556,14 +556,14 @@ private: int _height = 0; bool _hasAudio = false; - int64 _durationMs = 0; - uint64 _animationStarted = 0; - uint64 _nextFrameWhen = 0; - int64 _nextFramePositionMs = 0; + TimeMs _durationMs = 0; + TimeMs _animationStarted = 0; + TimeMs _nextFrameWhen = 0; + TimeMs _nextFramePositionMs = 0; bool _autoPausedGif = false; bool _started = false; - uint64 _videoPausedAtMs = 0; + TimeMs _videoPausedAtMs = 0; friend class Manager; @@ -630,7 +630,7 @@ Manager::ReaderPointers::const_iterator Manager::constUnsafeFindReaderPointer(Re return (it == _readerPointers.cend() || it.key()->_private == reader) ? it : _readerPointers.cend(); } -bool Manager::handleProcessResult(ReaderPrivate *reader, ProcessResult result, uint64 ms) { +bool Manager::handleProcessResult(ReaderPrivate *reader, ProcessResult result, TimeMs ms) { QMutexLocker lock(&_readerPointersMutex); auto it = unsafeFindReaderPointer(reader); if (result == ProcessResult::Error) { @@ -692,7 +692,7 @@ bool Manager::handleProcessResult(ReaderPrivate *reader, ProcessResult result, u return true; } -Manager::ResultHandleState Manager::handleResult(ReaderPrivate *reader, ProcessResult result, uint64 ms) { +Manager::ResultHandleState Manager::handleResult(ReaderPrivate *reader, ProcessResult result, TimeMs ms) { if (!handleProcessResult(reader, result, ms)) { _loadLevel.fetchAndAddRelaxed(-1 * (reader->_width > 0 ? reader->_width * reader->_height : AverageGifSize)); delete reader; @@ -736,7 +736,7 @@ void Manager::process() { _processingInThread = thread(); bool checkAllReaders = false; - uint64 ms = getms(), minms = ms + 86400 * 1000ULL; + auto ms = getms(), minms = ms + 86400 * 1000LL; { QMutexLocker lock(&_readerPointersMutex); for (auto it = _readerPointers.begin(), e = _readerPointers.end(); it != e; ++it) { diff --git a/Telegram/SourceFiles/media/media_clip_reader.h b/Telegram/SourceFiles/media/media_clip_reader.h index f3f9cce31..e3dcfc417 100644 --- a/Telegram/SourceFiles/media/media_clip_reader.h +++ b/Telegram/SourceFiles/media/media_clip_reader.h @@ -59,7 +59,7 @@ public: Video, }; - Reader(const FileLocation &location, const QByteArray &data, Callback &&callback, Mode mode = Mode::Gif, int64 seekMs = 0); + Reader(const FileLocation &location, const QByteArray &data, Callback &&callback, Mode mode = Mode::Gif, TimeMs seekMs = 0); static void callback(Reader *reader, int threadIndex, Notification notification); // reader can be deleted void setAutoplay() { @@ -72,12 +72,12 @@ public: uint64 playId() const { return _playId; } - int64 seekPositionMs() const { + TimeMs seekPositionMs() const { return _seekPositionMs; } void start(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, ImageRoundCorners corners); - QPixmap current(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, ImageRoundCorners corners, uint64 ms); + QPixmap current(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms); QPixmap frameOriginal() const { if (auto frame = frameToShow()) { auto result = QPixmap::fromImage(frame->original); @@ -109,8 +109,8 @@ public: bool ready() const; bool hasAudio() const; - int64 getPositionMs() const; - int64 getDurationMs() const; + TimeMs getPositionMs() const; + TimeMs getDurationMs() const; void pauseResumeVideo(); void stop(); @@ -132,8 +132,8 @@ private: uint64 _playId; bool _hasAudio = false; - int64 _durationMs = 0; - int64 _seekPositionMs = 0; + TimeMs _durationMs = 0; + TimeMs _seekPositionMs = 0; mutable int _width = 0; mutable int _height = 0; @@ -152,7 +152,7 @@ private: // Should be counted from the end, // so that positionMs <= _durationMs. - int64 positionMs = 0; + TimeMs positionMs = 0; }; mutable Frame _frames[3]; Frame *frameToShow(int *index = 0) const; // 0 means not ready @@ -225,16 +225,16 @@ private: ReaderPointers::const_iterator constUnsafeFindReaderPointer(ReaderPrivate *reader) const; ReaderPointers::iterator unsafeFindReaderPointer(ReaderPrivate *reader); - bool handleProcessResult(ReaderPrivate *reader, ProcessResult result, uint64 ms); + bool handleProcessResult(ReaderPrivate *reader, ProcessResult result, TimeMs ms); enum ResultHandleState { ResultHandleRemove, ResultHandleStop, ResultHandleContinue, }; - ResultHandleState handleResult(ReaderPrivate *reader, ProcessResult result, uint64 ms); + ResultHandleState handleResult(ReaderPrivate *reader, ProcessResult result, TimeMs ms); - typedef QMap Readers; + typedef QMap Readers; Readers _readers; QTimer _timer; diff --git a/Telegram/SourceFiles/media/player/media_player_cover.cpp b/Telegram/SourceFiles/media/player/media_player_cover.cpp index 89a694f4a..8a45f3df6 100644 --- a/Telegram/SourceFiles/media/player/media_player_cover.cpp +++ b/Telegram/SourceFiles/media/player/media_player_cover.cpp @@ -144,7 +144,7 @@ void CoverWidget::setCloseCallback(ButtonCallback &&callback) { void CoverWidget::handleSeekProgress(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); if (_seekPositionMs != positionMs) { _seekPositionMs = positionMs; updateTimeLabel(); @@ -157,7 +157,7 @@ void CoverWidget::handleSeekProgress(float64 progress) { void CoverWidget::handleSeekFinished(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); _seekPositionMs = -1; AudioMsgId playing; diff --git a/Telegram/SourceFiles/media/player/media_player_cover.h b/Telegram/SourceFiles/media/player/media_player_cover.h index d0edaae4d..18674fbbc 100644 --- a/Telegram/SourceFiles/media/player/media_player_cover.h +++ b/Telegram/SourceFiles/media/player/media_player_cover.h @@ -73,8 +73,8 @@ private: void updateTimeText(const AudioMsgId &audioId, const AudioPlaybackState &playbackState); void updateTimeLabel(); - int64 _seekPositionMs = -1; - int64 _lastDurationMs = 0; + TimeMs _seekPositionMs = -1; + TimeMs _lastDurationMs = 0; QString _time; class PlayButton; diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 7695ecdde..23bc0c0c7 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -181,7 +181,7 @@ void Widget::volumeWidgetCreated(VolumeWidget *widget) { void Widget::handleSeekProgress(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); if (_seekPositionMs != positionMs) { _seekPositionMs = positionMs; updateTimeLabel(); @@ -194,7 +194,7 @@ void Widget::handleSeekProgress(float64 progress) { void Widget::handleSeekFinished(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); _seekPositionMs = -1; AudioMsgId playing; diff --git a/Telegram/SourceFiles/media/player/media_player_widget.h b/Telegram/SourceFiles/media/player/media_player_widget.h index a128964e5..cbcf9223f 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.h +++ b/Telegram/SourceFiles/media/player/media_player_widget.h @@ -86,8 +86,8 @@ private: void updateTimeText(const AudioMsgId &audioId, const AudioPlaybackState &playbackState); void updateTimeLabel(); - int64 _seekPositionMs = -1; - int64 _lastDurationMs = 0; + TimeMs _seekPositionMs = -1; + TimeMs _lastDurationMs = 0; QString _time; class PlayButton; diff --git a/Telegram/SourceFiles/media/view/media_clip_controller.cpp b/Telegram/SourceFiles/media/view/media_clip_controller.cpp index fe73580ea..4bb35f49a 100644 --- a/Telegram/SourceFiles/media/view/media_clip_controller.cpp +++ b/Telegram/SourceFiles/media/view/media_clip_controller.cpp @@ -62,7 +62,7 @@ Controller::Controller(QWidget *parent) : TWidget(parent) void Controller::handleSeekProgress(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); if (_seekPositionMs != positionMs) { _seekPositionMs = positionMs; refreshTimeTexts(); @@ -73,7 +73,7 @@ void Controller::handleSeekProgress(float64 progress) { void Controller::handleSeekFinished(float64 progress) { if (!_lastDurationMs) return; - auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); + auto positionMs = snap(static_cast(progress * _lastDurationMs), 0LL, _lastDurationMs); _seekPositionMs = -1; emit seekFinished(positionMs); refreshTimeTexts(); diff --git a/Telegram/SourceFiles/media/view/media_clip_controller.h b/Telegram/SourceFiles/media/view/media_clip_controller.h index 1fb589800..203d2a6a2 100644 --- a/Telegram/SourceFiles/media/view/media_clip_controller.h +++ b/Telegram/SourceFiles/media/view/media_clip_controller.h @@ -54,8 +54,8 @@ public: signals: void playPressed(); void pausePressed(); - void seekProgress(int64 positionMs); - void seekFinished(int64 positionMs); + void seekProgress(TimeMs positionMs); + void seekFinished(TimeMs positionMs); void volumeChanged(float64 volume); void toFullScreenPressed(); void fromFullScreenPressed(); @@ -80,8 +80,8 @@ private: bool _showPause = false; QString _timeAlready, _timeLeft; - int64 _seekPositionMs = -1; - int64 _lastDurationMs = 0; + TimeMs _seekPositionMs = -1; + TimeMs _lastDurationMs = 0; ChildWidget _playPauseResume; ChildWidget _playback; diff --git a/Telegram/SourceFiles/media/view/media_clip_playback.h b/Telegram/SourceFiles/media/view/media_clip_playback.h index b1f3804e2..e0a0055fd 100644 --- a/Telegram/SourceFiles/media/view/media_clip_playback.h +++ b/Telegram/SourceFiles/media/view/media_clip_playback.h @@ -66,7 +66,7 @@ private: Ui::ContinuousSlider *_slider; int64 _position = 0; - int64 _duration = 0; + TimeMs _duration = 0; bool _playing = false; diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index c5d979c94..e999aaf32 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -394,10 +394,10 @@ void MediaView::updateActions() { } } -void MediaView::step_state(uint64 ms, bool timer) { +void MediaView::step_state(TimeMs ms, bool timer) { bool result = false; for (Showing::iterator i = _animations.begin(); i != _animations.end();) { - int64 start = i.value(); + TimeMs start = i.value(); switch (i.key()) { case OverLeftNav: update(_leftNav); break; case OverRightNav: update(_rightNav); break; @@ -477,11 +477,11 @@ void MediaView::radialStart() { } } -uint64 MediaView::radialTimeShift() const { +TimeMs MediaView::radialTimeShift() const { return _photo ? st::radialDuration : 0; } -void MediaView::step_radial(uint64 ms, bool timer) { +void MediaView::step_radial(TimeMs ms, bool timer) { if (!_doc && !_photo) { _radial.stop(); return; @@ -1373,8 +1373,8 @@ void MediaView::createClipController() { connect(_clipController, SIGNAL(playPressed()), this, SLOT(onVideoPauseResume())); connect(_clipController, SIGNAL(pausePressed()), this, SLOT(onVideoPauseResume())); - connect(_clipController, SIGNAL(seekProgress(int64)), this, SLOT(onVideoSeekProgress(int64))); - connect(_clipController, SIGNAL(seekFinished(int64)), this, SLOT(onVideoSeekFinished(int64))); + connect(_clipController, SIGNAL(seekProgress(TimeMs)), this, SLOT(onVideoSeekProgress(TimeMs))); + connect(_clipController, SIGNAL(seekFinished(TimeMs)), this, SLOT(onVideoSeekFinished(TimeMs))); connect(_clipController, SIGNAL(volumeChanged(float64)), this, SLOT(onVideoVolumeChanged(float64))); connect(_clipController, SIGNAL(toFullScreenPressed()), this, SLOT(onVideoToggleFullScreen())); connect(_clipController, SIGNAL(fromFullScreenPressed()), this, SLOT(onVideoToggleFullScreen())); @@ -1418,7 +1418,7 @@ void MediaView::onVideoPauseResume() { } } -void MediaView::restartVideoAtSeekPosition(int64 positionMs) { +void MediaView::restartVideoAtSeekPosition(TimeMs positionMs) { _autoplayVideoDocument = _doc; if (_current.isNull()) { @@ -1440,13 +1440,13 @@ void MediaView::restartVideoAtSeekPosition(int64 positionMs) { updateVideoPlaybackState(state); } -void MediaView::onVideoSeekProgress(int64 positionMs) { +void MediaView::onVideoSeekProgress(TimeMs positionMs) { if (!_videoPaused && !_videoStopped) { onVideoPauseResume(); } } -void MediaView::onVideoSeekFinished(int64 positionMs) { +void MediaView::onVideoSeekFinished(TimeMs positionMs) { restartVideoAtSeekPosition(positionMs); } @@ -1516,7 +1516,7 @@ void MediaView::paintEvent(QPaintEvent *e) { QRegion region(e->region()); QVector rs(region.rects()); - uint64 ms = getms(); + auto ms = getms(); Painter p(this); @@ -1624,7 +1624,7 @@ void MediaView::paintEvent(QPaintEvent *e) { p.setOpacity(1); } if (_full >= 1) { - uint64 nextFrame = (dt < st::medviewSaveMsgShowing || hidingDt >= 0) ? int(AnimationTimerDelta) : (st::medviewSaveMsgShowing + st::medviewSaveMsgShown + 1 - dt); + auto nextFrame = (dt < st::medviewSaveMsgShowing || hidingDt >= 0) ? int(AnimationTimerDelta) : (st::medviewSaveMsgShowing + st::medviewSaveMsgShown + 1 - dt); _saveMsgUpdater.start(nextFrame); } } else { diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index 85a360be0..8cc2368fe 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -120,8 +120,8 @@ private slots: void updateImage(); void onVideoPauseResume(); - void onVideoSeekProgress(int64 positionMs); - void onVideoSeekFinished(int64 positionMs); + void onVideoSeekProgress(TimeMs positionMs); + void onVideoSeekFinished(TimeMs positionMs); void onVideoVolumeChanged(float64 volume); void onVideoToggleFullScreen(); void onVideoPlayProgress(const AudioMsgId &audioId); @@ -147,7 +147,7 @@ private: void updateVideoPlaybackState(const AudioPlaybackState &state); void updateSilentVideoPlaybackState(); - void restartVideoAtSeekPosition(int64 positionMs); + void restartVideoAtSeekPosition(TimeMs positionMs); void createClipController(); void setClipControllerGeometry(); @@ -160,7 +160,7 @@ private: bool radialLoading() const; QRect radialRect() const; void radialStart(); - uint64 radialTimeShift() const; + TimeMs radialTimeShift() const; // Computes the last OverviewChatPhotos PhotoData* from _history or _migrated. struct LastChatPhoto { @@ -178,8 +178,8 @@ private: void updateHeader(); void snapXY(); - void step_state(uint64 ms, bool timer); - void step_radial(uint64 ms, bool timer); + void step_state(TimeMs ms, bool timer); + void step_radial(TimeMs ms, bool timer); void zoomIn(); void zoomOut(); @@ -212,7 +212,7 @@ private: Text _caption; QRect _captionRect; - uint64 _animStarted; + TimeMs _animStarted; int _width = 0; int _x = 0, _y = 0, _w = 0, _h = 0; @@ -230,8 +230,8 @@ private: bool _videoIsSilent = false; bool _videoPaused = false; bool _videoStopped = false; - int64 _videoPositionMs = 0; - int64 _videoDurationMs = 0; + TimeMs _videoPositionMs = 0; + TimeMs _videoDurationMs = 0; int32 _videoFrequencyMs = 1000; // 1000 ms per second. bool fileShown() const; @@ -305,7 +305,7 @@ private: ControlsHidden, }; ControlsState _controlsState = ControlsShown; - uint64 _controlsAnimStarted = 0; + TimeMs _controlsAnimStarted = 0; QTimer _controlsHideTimer; anim::fvalue a_cOpacity; bool _mousePressed = false; @@ -327,13 +327,13 @@ private: QPoint _accumScroll; QString _saveMsgFilename; - uint64 _saveMsgStarted = 0; + TimeMs _saveMsgStarted = 0; anim::fvalue _saveMsgOpacity = { 0 }; QRect _saveMsg; QTimer _saveMsgUpdater; Text _saveMsgText; - typedef QMap Showing; + typedef QMap Showing; Showing _animations; typedef QMap ShowingOpacities; ShowingOpacities _animOpacities; diff --git a/Telegram/SourceFiles/mtproto/connection.cpp b/Telegram/SourceFiles/mtproto/connection.cpp index 296aa47ac..149e4a7e1 100644 --- a/Telegram/SourceFiles/mtproto/connection.cpp +++ b/Telegram/SourceFiles/mtproto/connection.cpp @@ -478,12 +478,12 @@ ConnectionPrivate::ConnectionPrivate(QThread *thread, Connection *owner, Session } connect(this, SIGNAL(needToSendAsync()), sessionData->owner(), SLOT(needToResumeAndSend()), Qt::QueuedConnection); - connect(this, SIGNAL(sendAnythingAsync(quint64)), sessionData->owner(), SLOT(sendAnything(quint64)), Qt::QueuedConnection); + connect(this, SIGNAL(sendAnythingAsync(qint64)), sessionData->owner(), SLOT(sendAnything(qint64)), Qt::QueuedConnection); connect(this, SIGNAL(sendHttpWaitAsync()), sessionData->owner(), SLOT(sendAnything()), Qt::QueuedConnection); connect(this, SIGNAL(sendPongAsync(quint64,quint64)), sessionData->owner(), SLOT(sendPong(quint64,quint64)), Qt::QueuedConnection); connect(this, SIGNAL(sendMsgsStateInfoAsync(quint64, QByteArray)), sessionData->owner(), SLOT(sendMsgsStateInfo(quint64,QByteArray)), Qt::QueuedConnection); - connect(this, SIGNAL(resendAsync(quint64,quint64,bool,bool)), sessionData->owner(), SLOT(resend(quint64,quint64,bool,bool)), Qt::QueuedConnection); - connect(this, SIGNAL(resendManyAsync(QVector,quint64,bool,bool)), sessionData->owner(), SLOT(resendMany(QVector,quint64,bool,bool)), Qt::QueuedConnection); + connect(this, SIGNAL(resendAsync(quint64,qint64,bool,bool)), sessionData->owner(), SLOT(resend(quint64,qint64,bool,bool)), Qt::QueuedConnection); + connect(this, SIGNAL(resendManyAsync(QVector,qint64,bool,bool)), sessionData->owner(), SLOT(resendMany(QVector,qint64,bool,bool)), Qt::QueuedConnection); connect(this, SIGNAL(resendAllAsync()), sessionData->owner(), SLOT(resendAll())); } @@ -780,7 +780,7 @@ void ConnectionPrivate::tryToSend() { } pingRequest->msDate = getms(true); // > 0 - can send without container - _pingSendAt = pingRequest->msDate + (MTPPingSendAfterAuto * 1000ULL); + _pingSendAt = pingRequest->msDate + (MTPPingSendAfterAuto * 1000LL); pingRequest->requestId = 0; // dont add to haveSent / wereAcked maps if (dc == bareDcId(dc) && !prependOnly) { // main session @@ -1255,11 +1255,11 @@ void ConnectionPrivate::onOldConnection() { void ConnectionPrivate::onPingSender() { if (_pingId) { - if (_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto - 1) * 1000ULL < getms(true)) { + if (_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto - 1) * 1000LL < getms(true)) { LOG(("Could not send ping for MTPPingSendAfter seconds, restarting...")); return restart(); } else { - _pingSender.start(_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto) * 1000ULL - getms(true)); + _pingSender.start(_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto) * 1000LL - getms(true)); } } else { emit needToSendAsync(); @@ -2257,12 +2257,12 @@ void ConnectionPrivate::handleMsgsStates(const QVector &ids, const stri } } -void ConnectionPrivate::resend(quint64 msgId, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { +void ConnectionPrivate::resend(quint64 msgId, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { if (msgId == _pingMsgId) return; emit resendAsync(msgId, msCanWait, forceContainer, sendMsgStateInfo); } -void ConnectionPrivate::resendMany(QVector msgIds, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { +void ConnectionPrivate::resendMany(QVector msgIds, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { for (int32 i = 0, l = msgIds.size(); i < l; ++i) { if (msgIds.at(i) == _pingMsgId) { msgIds.remove(i); diff --git a/Telegram/SourceFiles/mtproto/connection.h b/Telegram/SourceFiles/mtproto/connection.h index c6fc41ef7..2eeacc482 100644 --- a/Telegram/SourceFiles/mtproto/connection.h +++ b/Telegram/SourceFiles/mtproto/connection.h @@ -96,12 +96,12 @@ signals: void sessionResetDone(); void needToSendAsync(); - void sendAnythingAsync(quint64 msWait); + void sendAnythingAsync(qint64 msWait); void sendHttpWaitAsync(); void sendPongAsync(quint64 msgId, quint64 pingId); void sendMsgsStateInfoAsync(quint64 msgId, QByteArray data); - void resendAsync(quint64 msgId, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); - void resendManyAsync(QVector msgIds, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); + void resendAsync(quint64 msgId, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); + void resendManyAsync(QVector msgIds, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); void resendAllAsync(); void finished(Connection *connection); @@ -183,14 +183,14 @@ private: SingleTimer retryTimer; // exp retry timer int retryTimeout; - quint64 retryWillFinish; + qint64 retryWillFinish; SingleTimer oldConnectionTimer; bool oldConnection; SingleTimer _waitForConnectedTimer, _waitForReceivedTimer, _waitForIPv4Timer; uint32 _waitForReceived, _waitForConnected; - int64 firstSentAt; + TimeMs firstSentAt; QVector ackRequestData, resendRequestData; @@ -201,12 +201,12 @@ private: void requestsAcked(const QVector &ids, bool byResponse = false); mtpPingId _pingId, _pingIdToSend; - uint64 _pingSendAt; + TimeMs _pingSendAt; mtpMsgId _pingMsgId; SingleTimer _pingSender; - void resend(quint64 msgId, quint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); - void resendMany(QVector msgIds, quint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); + void resend(quint64 msgId, qint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); + void resendMany(QVector msgIds, qint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); template void sendRequestNotSecure(const TRequest &request); diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h index edf3dd9c3..bab6da418 100644 --- a/Telegram/SourceFiles/mtproto/core_types.h +++ b/Telegram/SourceFiles/mtproto/core_types.h @@ -59,7 +59,7 @@ class mtpRequestData : public mtpBuffer { public: // in toSend: = 0 - must send in container, > 0 - can send without container // in haveSent: = 0 - container with msgIds, > 0 - when was sent - uint64 msDate; + TimeMs msDate; mtpRequestId requestId; mtpRequest after; diff --git a/Telegram/SourceFiles/mtproto/facade.cpp b/Telegram/SourceFiles/mtproto/facade.cpp index c1f10068b..a025225a3 100644 --- a/Telegram/SourceFiles/mtproto/facade.cpp +++ b/Telegram/SourceFiles/mtproto/facade.cpp @@ -51,7 +51,7 @@ namespace { RequestMap requestMap; QReadWriteLock requestMapLock; - typedef QPair DelayedRequest; + typedef QPair DelayedRequest; typedef QList DelayedRequestsList; DelayedRequestsList delayedRequests; @@ -226,7 +226,7 @@ namespace { secs = m.captured(1).toInt(); // if (secs >= 60) return false; } - uint64 sendAt = getms(true) + secs * 1000 + 10; + auto sendAt = getms(true) + secs * 1000 + 10; DelayedRequestsList::iterator i = delayedRequests.begin(), e = delayedRequests.end(); for (; i != e; ++i) { if (i->first == requestId) return true; @@ -340,7 +340,6 @@ namespace { } } } else { - uint64 at = 0; DelayedRequestsList::iterator i = delayedRequests.begin(), e = delayedRequests.end(); for (; i != e; ++i) { if (i->first == requestId) return true; @@ -587,7 +586,7 @@ GlobalSlotCarrier::GlobalSlotCarrier() { } void GlobalSlotCarrier::checkDelayed() { - uint64 now = getms(true); + auto now = getms(true); while (!delayedRequests.isEmpty() && now >= delayedRequests.front().second) { mtpRequestId requestId = delayedRequests.front().first; delayedRequests.pop_front(); diff --git a/Telegram/SourceFiles/mtproto/facade.h b/Telegram/SourceFiles/mtproto/facade.h index dacb58e17..fced81484 100644 --- a/Telegram/SourceFiles/mtproto/facade.h +++ b/Telegram/SourceFiles/mtproto/facade.h @@ -150,18 +150,18 @@ int32 dcstate(int32 dc = 0); QString dctransport(int32 dc = 0); template -inline mtpRequestId send(const TRequest &request, RPCResponseHandler callbacks = RPCResponseHandler(), int32 dc = 0, uint64 msCanWait = 0, mtpRequestId after = 0) { +inline mtpRequestId send(const TRequest &request, RPCResponseHandler callbacks = RPCResponseHandler(), int32 dc = 0, TimeMs msCanWait = 0, mtpRequestId after = 0) { if (internal::Session *session = internal::getSession(dc)) { return session->send(request, callbacks, msCanWait, true, !dc, after); } return 0; } template -inline mtpRequestId send(const TRequest &request, RPCDoneHandlerPtr onDone, RPCFailHandlerPtr onFail = RPCFailHandlerPtr(), int32 dc = 0, uint64 msCanWait = 0, mtpRequestId after = 0) { +inline mtpRequestId send(const TRequest &request, RPCDoneHandlerPtr onDone, RPCFailHandlerPtr onFail = RPCFailHandlerPtr(), int32 dc = 0, TimeMs msCanWait = 0, mtpRequestId after = 0) { return send(request, RPCResponseHandler(onDone, onFail), dc, msCanWait, after); } -inline void sendAnything(int32 dc = 0, uint64 msCanWait = 0) { - if (internal::Session *session = internal::getSession(dc)) { +inline void sendAnything(int32 dc = 0, TimeMs msCanWait = 0) { + if (auto session = internal::getSession(dc)) { return session->sendAnything(msCanWait); } } @@ -210,7 +210,7 @@ typedef QMap DcOptions; namespace internal { template - mtpRequestId Session::send(const TRequest &request, RPCResponseHandler callbacks, uint64 msCanWait, bool needsLayer, bool toMainDC, mtpRequestId after) { + mtpRequestId Session::send(const TRequest &request, RPCResponseHandler callbacks, TimeMs msCanWait, bool needsLayer, bool toMainDC, mtpRequestId after) { mtpRequestId requestId = 0; try { uint32 requestSize = request.innerLength() >> 2; diff --git a/Telegram/SourceFiles/mtproto/session.cpp b/Telegram/SourceFiles/mtproto/session.cpp index b9e7453e2..de41f51ac 100644 --- a/Telegram/SourceFiles/mtproto/session.cpp +++ b/Telegram/SourceFiles/mtproto/session.cpp @@ -165,12 +165,12 @@ void Session::unpaused() { } } -void Session::sendAnything(quint64 msCanWait) { +void Session::sendAnything(qint64 msCanWait) { if (_killed) { DEBUG_LOG(("Session Error: can't send anything in a killed session")); return; } - uint64 ms = getms(true); + auto ms = getms(true); if (msSendCall) { if (ms > msSendCall + msWait) { msWait = 0; @@ -246,7 +246,7 @@ void Session::checkRequestsByTimer() { QReadLocker locker(data.haveSentMutex()); mtpRequestMap &haveSent(data.haveSentMap()); uint32 haveSentCount(haveSent.size()); - uint64 ms = getms(true); + auto ms = getms(true); for (mtpRequestMap::iterator i = haveSent.begin(), e = haveSent.end(); i != e; ++i) { mtpRequest &req(i.value()); if (req->msDate > 0) { @@ -386,7 +386,7 @@ QString Session::transport() const { return _connection ? _connection->transport() : QString(); } -mtpRequestId Session::resend(quint64 msgId, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { +mtpRequestId Session::resend(quint64 msgId, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { mtpRequest request; { QWriteLocker locker(data.haveSentMutex()); @@ -426,7 +426,7 @@ mtpRequestId Session::resend(quint64 msgId, quint64 msCanWait, bool forceContain } } -void Session::resendMany(QVector msgIds, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { +void Session::resendMany(QVector msgIds, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo) { for (int32 i = 0, l = msgIds.size(); i < l; ++i) { resend(msgIds.at(i), msCanWait, forceContainer, sendMsgStateInfo); } @@ -447,7 +447,7 @@ void Session::resendAll() { } } -void Session::sendPrepared(const mtpRequest &request, uint64 msCanWait, bool newRequest) { // returns true, if emit of needToSend() is needed +void Session::sendPrepared(const mtpRequest &request, TimeMs msCanWait, bool newRequest) { // returns true, if emit of needToSend() is needed { QWriteLocker locker(data.toSendMutex()); data.toSendMap().insert(request->requestId, request); diff --git a/Telegram/SourceFiles/mtproto/session.h b/Telegram/SourceFiles/mtproto/session.h index 3ac603fb5..204876b64 100644 --- a/Telegram/SourceFiles/mtproto/session.h +++ b/Telegram/SourceFiles/mtproto/session.h @@ -243,7 +243,7 @@ public: void notifyLayerInited(bool wasInited); template - mtpRequestId send(const TRequest &request, RPCResponseHandler callbacks = RPCResponseHandler(), uint64 msCanWait = 0, bool needsLayer = false, bool toMainDC = false, mtpRequestId after = 0); // send mtp request + mtpRequestId send(const TRequest &request, RPCResponseHandler callbacks = RPCResponseHandler(), TimeMs msCanWait = 0, bool needsLayer = false, bool toMainDC = false, mtpRequestId after = 0); // send mtp request void ping(); void cancel(mtpRequestId requestId, mtpMsgId msgId); @@ -251,7 +251,7 @@ public: int32 getState() const; QString transport() const; - void sendPrepared(const mtpRequest &request, uint64 msCanWait = 0, bool newRequest = true); // nulls msgId and seqNo in request, if newRequest = true + void sendPrepared(const mtpRequest &request, TimeMs msCanWait = 0, bool newRequest = true); // nulls msgId and seqNo in request, if newRequest = true ~Session(); @@ -264,8 +264,8 @@ signals: public slots: void needToResumeAndSend(); - mtpRequestId resend(quint64 msgId, quint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); - void resendMany(QVector msgIds, quint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); + mtpRequestId resend(quint64 msgId, qint64 msCanWait = 0, bool forceContainer = false, bool sendMsgStateInfo = false); + void resendMany(QVector msgIds, qint64 msCanWait, bool forceContainer, bool sendMsgStateInfo); void resendAll(); // after connection restart void authKeyCreatedForDC(); @@ -276,7 +276,7 @@ public slots: void onConnectionStateChange(qint32 newState); void onResetDone(); - void sendAnything(quint64 msCanWait = 0); + void sendAnything(qint64 msCanWait = 0); void sendPong(quint64 msgId, quint64 pingId); void sendMsgsStateInfo(quint64 msgId, QByteArray data); @@ -293,7 +293,7 @@ private: int32 dcWithShift; DcenterPtr dc; - uint64 msSendCall, msWait; + TimeMs msSendCall, msWait; bool _ping; diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 23302cb0a..3c03eafd6 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -91,7 +91,7 @@ void RadialProgressItem::step_iconOver(float64 ms, bool timer) { } } -void RadialProgressItem::step_radial(uint64 ms, bool timer) { +void RadialProgressItem::step_radial(TimeMs ms, bool timer) { if (timer) { Ui::repaintHistoryItem(_parent); } else { @@ -119,7 +119,7 @@ RadialProgressItem::~RadialProgressItem() { delete base::take(_radial); } -void StatusText::update(int newSize, int fullSize, int duration, int64 realDuration) { +void StatusText::update(int newSize, int fullSize, int duration, TimeMs realDuration) { setSize(newSize); if (_size == FileStatusSizeReady) { _text = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize)); @@ -163,7 +163,7 @@ public: PhotoVideoCheckbox(UpdateCallback callback) : _updateCallback(callback), _check(st::overviewCheck, _updateCallback) { } - void paint(Painter &p, uint64 ms, int width, int height, bool selected, bool selecting); + void paint(Painter &p, TimeMs ms, int width, int height, bool selected, bool selecting); void setActive(bool active); void setPressed(bool pressed); @@ -180,7 +180,7 @@ private: }; -void PhotoVideoCheckbox::paint(Painter &p, uint64 ms, int width, int height, bool selected, bool selecting) { +void PhotoVideoCheckbox::paint(Painter &p, TimeMs ms, int width, int height, bool selected, bool selecting) { if (selected) { p.fillRect(0, 0, width, height, st::overviewPhotoSelectOverlay); } diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h index 608fdfdd4..4356c94b4 100644 --- a/Telegram/SourceFiles/overview/overview_layout.h +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -30,7 +30,7 @@ namespace Layout { class PaintContext : public PaintContextBase { public: - PaintContext(uint64 ms, bool selecting) : PaintContextBase(ms, selecting), isAfterDate(false) { + PaintContext(TimeMs ms, bool selecting) : PaintContextBase(ms, selecting), isAfterDate(false) { } bool isAfterDate; @@ -112,12 +112,12 @@ protected: } void step_iconOver(float64 ms, bool timer); - void step_radial(uint64 ms, bool timer); + void step_radial(TimeMs ms, bool timer); void ensureRadial(); void checkRadialFinished(); - bool isRadialAnimation(uint64 ms) const { + bool isRadialAnimation(TimeMs ms) const { if (!_radial || !_radial->animating()) return false; _radial->step(ms); @@ -140,7 +140,7 @@ protected: class StatusText { public: // duration = -1 - no duration, duration = -2 - "GIF" duration - void update(int newSize, int fullSize, int duration, int64 realDuration); + void update(int newSize, int fullSize, int duration, TimeMs realDuration); void setSize(int newSize); int size() const { diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index c64fdd56a..e01fc4711 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -105,7 +105,7 @@ bool OverviewInner::event(QEvent *e) { } void OverviewInner::touchUpdateSpeed() { - const uint64 nowTime = getms(); + const auto nowTime = getms(); if (_touchPrevPosValid) { const int elapsed = nowTime - _touchSpeedTime; if (elapsed) { @@ -781,7 +781,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) { if (!trivial) { p.setClipRect(r); } - uint64 ms = getms(); + auto ms = getms(); Overview::Layout::PaintContext context(ms, _selMode); if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) { @@ -1560,7 +1560,7 @@ void OverviewInner::onTouchSelect() { } void OverviewInner::onTouchScrollTimer() { - uint64 nowTime = getms(); + auto nowTime = getms(); if (_touchScrollState == Ui::TouchScrollState::Acceleration && _touchWaitingAcceleration && (nowTime - _touchAccelerationTime) > 40) { _touchScrollState = Ui::TouchScrollState::Manual; touchResetSpeed(); diff --git a/Telegram/SourceFiles/overviewwidget.h b/Telegram/SourceFiles/overviewwidget.h index 37782812a..0e7acdd8d 100644 --- a/Telegram/SourceFiles/overviewwidget.h +++ b/Telegram/SourceFiles/overviewwidget.h @@ -263,9 +263,9 @@ private: bool _touchPrevPosValid = false; bool _touchWaitingAcceleration = false; QPoint _touchSpeed; - uint64 _touchSpeedTime = 0; - uint64 _touchAccelerationTime = 0; - uint64 _touchTime = 0; + TimeMs _touchSpeedTime = 0; + TimeMs _touchAccelerationTime = 0; + TimeMs _touchTime = 0; QTimer _touchScrollTimer; Ui::PopupMenu *_menu = nullptr; diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 95fc18b69..17a0a0199 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -81,7 +81,7 @@ private: int _psCheckStatusIconLeft = 100; QTimer _psUpdateIndicatorTimer; - uint64 _psLastIndicatorUpdate = 0; + TimeMs _psLastIndicatorUpdate = 0; }; diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index b9c8e24ea..b96932097 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -576,7 +576,7 @@ void queryUserNotificationState() { } static constexpr int QuerySettingsEachMs = 1000; -uint64 LastSettingsQueryMs = 0; +TimeMs LastSettingsQueryMs = 0; void querySystemNotificationSettings() { auto ms = getms(true); diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index 84ed14603..8158d56b6 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -75,13 +75,13 @@ public: _PsEventFilter *_psEventFilter = nullptr; QRect _monitorRect; -uint64 _monitorLastGot = 0; +auto _monitorLastGot = 0LL; } // namespace QRect psDesktopRect() { - uint64 tnow = getms(); - if (tnow > _monitorLastGot + 1000 || tnow < _monitorLastGot) { + auto tnow = getms(); + if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) { _monitorLastGot = tnow; _monitorRect = QApplication::desktop()->availableGeometry(App::wnd()); } @@ -279,7 +279,7 @@ void psDeleteDir(const QString &dir) { namespace { -uint64 _lastUserAction = 0; +auto _lastUserAction = 0LL; } // namespace @@ -291,7 +291,7 @@ bool psIdleSupported() { return false; } -uint64 psIdleTime() { +TimeMs psIdleTime() { return getms(true) - _lastUserAction; } diff --git a/Telegram/SourceFiles/pspecific_linux.h b/Telegram/SourceFiles/pspecific_linux.h index 82578282a..2c8081e30 100644 --- a/Telegram/SourceFiles/pspecific_linux.h +++ b/Telegram/SourceFiles/pspecific_linux.h @@ -37,7 +37,7 @@ void psDeleteDir(const QString &dir); void psUserActionDone(); bool psIdleSupported(); -uint64 psIdleTime(); +TimeMs psIdleTime(); QStringList psInitLogs(); void psClearInitLogs(); diff --git a/Telegram/SourceFiles/pspecific_mac.cpp b/Telegram/SourceFiles/pspecific_mac.cpp index 062097a5e..959b81264 100644 --- a/Telegram/SourceFiles/pspecific_mac.cpp +++ b/Telegram/SourceFiles/pspecific_mac.cpp @@ -49,12 +49,14 @@ namespace { }; namespace { - QRect _monitorRect; - uint64 _monitorLastGot = 0; -} + +QRect _monitorRect; +TimeMs _monitorLastGot = 0; + +} // namespace QRect psDesktopRect() { - uint64 tnow = getms(true); + auto tnow = getms(true); if (tnow > _monitorLastGot + 1000 || tnow < _monitorLastGot) { _monitorLastGot = tnow; _monitorRect = QApplication::desktop()->availableGeometry(App::wnd()); @@ -286,8 +288,10 @@ void psDeleteDir(const QString &dir) { } namespace { - uint64 _lastUserAction = 0; -} + +auto _lastUserAction = 0LL; + +} // namespace void psUserActionDone() { _lastUserAction = getms(true); @@ -297,8 +301,8 @@ bool psIdleSupported() { return objc_idleSupported(); } -uint64 psIdleTime() { - int64 idleTime = 0; +TimeMs psIdleTime() { + auto idleTime = 0LL; return objc_idleTime(idleTime) ? idleTime : (getms(true) - _lastUserAction); } diff --git a/Telegram/SourceFiles/pspecific_mac.h b/Telegram/SourceFiles/pspecific_mac.h index de3508e13..68f273240 100644 --- a/Telegram/SourceFiles/pspecific_mac.h +++ b/Telegram/SourceFiles/pspecific_mac.h @@ -40,7 +40,7 @@ void psDeleteDir(const QString &dir); void psUserActionDone(); bool psIdleSupported(); -uint64 psIdleTime(); +TimeMs psIdleTime(); QStringList psInitLogs(); void psClearInitLogs(); diff --git a/Telegram/SourceFiles/pspecific_mac_p.h b/Telegram/SourceFiles/pspecific_mac_p.h index 2bfd8232d..e6a156e60 100644 --- a/Telegram/SourceFiles/pspecific_mac_p.h +++ b/Telegram/SourceFiles/pspecific_mac_p.h @@ -29,7 +29,7 @@ void objc_activateWnd(WId winId); void objc_debugShowAlert(const QString &str); void objc_outputDebugString(const QString &str); bool objc_idleSupported(); -bool objc_idleTime(int64 &idleTime); +bool objc_idleTime(TimeMs &idleTime); bool objc_showOpenWithMenu(int x, int y, const QString &file); diff --git a/Telegram/SourceFiles/pspecific_mac_p.mm b/Telegram/SourceFiles/pspecific_mac_p.mm index 2f57d50ab..abb3c48b4 100644 --- a/Telegram/SourceFiles/pspecific_mac_p.mm +++ b/Telegram/SourceFiles/pspecific_mac_p.mm @@ -261,11 +261,11 @@ void objc_outputDebugString(const QString &str) { } bool objc_idleSupported() { - int64 idleTime = 0; + auto idleTime = 0LL; return objc_idleTime(idleTime); } -bool objc_idleTime(int64 &idleTime) { // taken from https://github.com/trueinteractions/tint/issues/53 +bool objc_idleTime(TimeMs &idleTime) { // taken from https://github.com/trueinteractions/tint/issues/53 CFMutableDictionaryRef properties = 0; CFTypeRef obj; mach_port_t masterPort; @@ -314,7 +314,7 @@ bool objc_idleTime(int64 &idleTime) { // taken from https://github.com/trueinter IOObjectRelease(iter); if (result == err) return false; - idleTime = int64(result); + idleTime = static_cast(result); return true; } diff --git a/Telegram/SourceFiles/pspecific_win.cpp b/Telegram/SourceFiles/pspecific_win.cpp index 0c13c4787..51f612772 100644 --- a/Telegram/SourceFiles/pspecific_win.cpp +++ b/Telegram/SourceFiles/pspecific_win.cpp @@ -156,8 +156,10 @@ namespace { } namespace { - uint64 _lastUserAction = 0; -} + +TimeMs _lastUserAction = 0; + +} // namespace void psUserActionDone() { _lastUserAction = getms(true); @@ -170,7 +172,7 @@ bool psIdleSupported() { return GetLastInputInfo(&lii); } -uint64 psIdleTime() { +TimeMs psIdleTime() { LASTINPUTINFO lii; lii.cbSize = sizeof(LASTINPUTINFO); return GetLastInputInfo(&lii) ? (GetTickCount() - lii.dwTime) : (getms(true) - _lastUserAction); @@ -417,13 +419,15 @@ void psDoCleanup() { } namespace { + QRect _monitorRect; -uint64 _monitorLastGot = 0; -} +TimeMs _monitorLastGot = 0; + +} // namespace QRect psDesktopRect() { - uint64 tnow = getms(); - if (tnow > _monitorLastGot + 1000 || tnow < _monitorLastGot) { + auto tnow = getms(); + if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) { _monitorLastGot = tnow; HMONITOR hMonitor = MonitorFromWindow(App::wnd()->psHwnd(), MONITOR_DEFAULTTONEAREST); if (hMonitor) { diff --git a/Telegram/SourceFiles/pspecific_win.h b/Telegram/SourceFiles/pspecific_win.h index 127df5e68..20226d32a 100644 --- a/Telegram/SourceFiles/pspecific_win.h +++ b/Telegram/SourceFiles/pspecific_win.h @@ -36,7 +36,7 @@ void psDeleteDir(const QString &dir); void psUserActionDone(); bool psIdleSupported(); -uint64 psIdleTime(); +TimeMs psIdleTime(); QStringList psInitLogs(); void psClearInitLogs(); diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 3f9c1e56c..0dd7185e4 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -85,7 +85,7 @@ RecentStickerPreload gRecentStickersPreload; RecentStickerPack gRecentStickers; SavedGifs gSavedGifs; -uint64 gLastSavedGifsUpdate = 0; +TimeMs gLastSavedGifsUpdate = 0; bool gShowingSavedGifs = false; RecentHashtagPack gRecentWriteHashtags, gRecentSearchHashtags; @@ -94,7 +94,7 @@ RecentInlineBots gRecentInlineBots; bool gPasswordRecovered = false; int32 gPasscodeBadTries = 0; -uint64 gPasscodeLastTry = 0; +TimeMs gPasscodeLastTry = 0; int32 gLang = -2; // auto QString gLangFile; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index 82de08c4d..22779bd44 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -183,7 +183,7 @@ typedef QMap StickersByEmojiMap; typedef QVector SavedGifs; DeclareRefSetting(SavedGifs, SavedGifs); -DeclareSetting(uint64, LastSavedGifsUpdate); +DeclareSetting(TimeMs, LastSavedGifsUpdate); DeclareSetting(bool, ShowingSavedGifs); typedef QList > RecentHashtagPack; @@ -197,11 +197,11 @@ DeclareRefSetting(RecentInlineBots, RecentInlineBots); DeclareSetting(bool, PasswordRecovered); DeclareSetting(int32, PasscodeBadTries); -DeclareSetting(uint64, PasscodeLastTry); +DeclareSetting(TimeMs, PasscodeLastTry); inline bool passcodeCanTry() { if (cPasscodeBadTries() < 3) return true; - uint64 dt = getms(true) - cPasscodeLastTry(); + auto dt = getms(true) - cPasscodeLastTry(); switch (cPasscodeBadTries()) { case 3: return dt >= 5000; case 4: return dt >= 10000; diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index 8fe8e9937..52b104744 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -127,11 +127,11 @@ void BackgroundRow::radialStart() { } } -uint64 BackgroundRow::radialTimeShift() const { +TimeMs BackgroundRow::radialTimeShift() const { return st::radialDuration; } -void BackgroundRow::step_radial(uint64 ms, bool timer) { +void BackgroundRow::step_radial(TimeMs ms, bool timer) { _radial.update(radialProgress(), !radialLoading(), ms + radialTimeShift()); if (timer && _radial.animating()) { rtlupdate(radialRect()); diff --git a/Telegram/SourceFiles/settings/settings_background_widget.h b/Telegram/SourceFiles/settings/settings_background_widget.h index 5793dfa9c..5f749dc1a 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.h +++ b/Telegram/SourceFiles/settings/settings_background_widget.h @@ -48,8 +48,8 @@ private: bool radialLoading() const; QRect radialRect() const; void radialStart(); - uint64 radialTimeShift() const; - void step_radial(uint64 ms, bool timer); + TimeMs radialTimeShift() const; + void step_radial(TimeMs ms, bool timer); QPixmap _background; ChildWidget _chooseFromGallery; diff --git a/Telegram/SourceFiles/stickers/emoji_pan.cpp b/Telegram/SourceFiles/stickers/emoji_pan.cpp index a93bc885b..d4d649c3d 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.cpp +++ b/Telegram/SourceFiles/stickers/emoji_pan.cpp @@ -1779,7 +1779,7 @@ void StickerPanInner::notify_inlineItemLayoutChanged(const InlineItem *layout) { } void StickerPanInner::ui_repaintInlineItem(const InlineItem *layout) { - uint64 ms = getms(); + auto ms = getms(); if (_lastScrolled + 100 <= ms) { update(); } else { @@ -2186,7 +2186,7 @@ void StickerPanInner::onPreview() { void StickerPanInner::onUpdateInlineItems() { if (!showingInlineItems()) return; - uint64 ms = getms(); + auto ms = getms(); if (_lastScrolled + 100 <= ms) { update(); } else { @@ -3198,7 +3198,7 @@ void EmojiPan::updateIcons() { update(r.left(), _iconsTop, r.width(), st::emojiCategory.height); } -void EmojiPan::step_icons(uint64 ms, bool timer) { +void EmojiPan::step_icons(TimeMs ms, bool timer) { if (_emojiShown) { _a_icons.stop(); return; diff --git a/Telegram/SourceFiles/stickers/emoji_pan.h b/Telegram/SourceFiles/stickers/emoji_pan.h index 355f91221..5e63c00fa 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.h +++ b/Telegram/SourceFiles/stickers/emoji_pan.h @@ -364,7 +364,7 @@ private: bool _setGifCommand = false; UserData *_inlineBot; QString _inlineBotTitle; - uint64 _lastScrolled = 0; + TimeMs _lastScrolled = 0; QTimer _updateInlineItems; bool _inlineWithThumb = false; @@ -488,7 +488,7 @@ public: return _hiding || _hideTimer.isActive(); } - void step_icons(uint64 ms, bool timer); + void step_icons(TimeMs ms, bool timer); void leaveToChildEvent(QEvent *e, QWidget *child) override; @@ -663,7 +663,7 @@ private: int _iconsMax = 0; anim::ivalue _iconsX = { 0, 0 }; anim::ivalue _iconSelX = { 0, 0 }; - uint64 _iconsStartAnim = 0; + TimeMs _iconsStartAnim = 0; bool _emojiShown = true; bool _shownFromInlineQuery = false; diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index 64519e620..425a198d2 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -810,7 +810,7 @@ public: private: PtsWaiter _ptsWaiter; - uint64 _lastFullUpdate = 0; + TimeMs _lastFullUpdate = 0; int _membersCount = 1; int _adminsCount = 1; @@ -1410,3 +1410,23 @@ struct MessageCursor { inline bool operator==(const MessageCursor &a, const MessageCursor &b) { return (a.position == b.position) && (a.anchor == b.anchor) && (a.scroll == b.scroll); } + +struct SendAction { + enum class Type { + Typing, + RecordVideo, + UploadVideo, + RecordVoice, + UploadVoice, + UploadPhoto, + UploadFile, + ChooseLocation, + ChooseContact, + PlayGame, + }; + SendAction(Type type, TimeMs until, int progress = 0) : type(type), until(until), progress(progress) { + } + Type type; + TimeMs until; + int progress; +}; diff --git a/Telegram/SourceFiles/ui/animation.cpp b/Telegram/SourceFiles/ui/animation.cpp index 8a18e0595..b6ad77207 100644 --- a/Telegram/SourceFiles/ui/animation.cpp +++ b/Telegram/SourceFiles/ui/animation.cpp @@ -165,7 +165,7 @@ void AnimationManager::stop(Animation *obj) { void AnimationManager::timeout() { _iterating = true; - uint64 ms = getms(); + auto ms = getms(); for_const (auto object, _objects) { if (!_stopping.contains(object)) { object->step(ms, true); diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index f27f1006f..7b1f005ce 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -438,7 +438,7 @@ class Animation; class AnimationImplementation { public: virtual void start() {} - virtual void step(Animation *a, uint64 ms, bool timer) = 0; + virtual void step(Animation *a, TimeMs ms, bool timer) = 0; virtual ~AnimationImplementation() {} }; @@ -457,7 +457,7 @@ public: } void start() { _implementation->start(); } - void step(Animation *a, uint64 ms, bool timer) { _implementation->step(a, ms, timer); } + void step(Animation *a, TimeMs ms, bool timer) { _implementation->step(a, ms, timer); } ~AnimationCallbacks() { delete base::take(_implementation); } private: @@ -475,7 +475,7 @@ public: void start(); void stop(); - void step(uint64 ms, bool timer = false) { + void step(TimeMs ms, bool timer = false) { _callbacks.step(this, ms, timer); } @@ -509,7 +509,7 @@ public: _started = float64(getms()); } - void step(Animation *a, uint64 ms, bool timer) { + void step(Animation *a, TimeMs ms, bool timer) { (_obj->*_method)(ms - _started, timer); } @@ -527,12 +527,12 @@ AnimationCallbacks animation(Type *obj, typename AnimationCallbacksRelative class AnimationCallbacksAbsolute : public AnimationImplementation { public: - typedef void (Type::*Method)(uint64, bool); + typedef void (Type::*Method)(TimeMs, bool); AnimationCallbacksAbsolute(Type *obj, Method method) : _obj(obj), _method(method) { } - void step(Animation *a, uint64 ms, bool timer) { + void step(Animation *a, TimeMs ms, bool timer) { (_obj->*_method)(ms, timer); } @@ -558,7 +558,7 @@ public: _started = float64(getms()); } - void step(Animation *a, uint64 ms, bool timer) { + void step(Animation *a, TimeMs ms, bool timer) { (_obj->*_method)(_param, ms - _started, timer); } @@ -577,12 +577,12 @@ AnimationCallbacks animation(Param param, Type *obj, typename AnimationCallbacks template class AnimationCallbacksAbsoluteWithParam : public AnimationImplementation { public: - typedef void (Type::*Method)(Param, uint64, bool); + typedef void (Type::*Method)(Param, TimeMs, bool); AnimationCallbacksAbsoluteWithParam(Param param, Type *obj, Method method) : _param(param), _obj(obj), _method(method) { } - void step(Animation *a, uint64 ms, bool timer) { + void step(Animation *a, TimeMs ms, bool timer) { (_obj->*_method)(_param, ms, timer); } @@ -603,7 +603,7 @@ public: using ValueType = typename AnimType::ValueType; using Callback = base::lambda; - void step(uint64 ms) { + void step(TimeMs ms) { if (_data) { _data->a_animation.step(ms); if (_data && !_data->a_animation.animating()) { @@ -621,7 +621,7 @@ public: } return false; } - bool animating(uint64 ms) { + bool animating(TimeMs ms) { step(ms); return animating(); } @@ -633,7 +633,7 @@ public: ValueType current(const ValueType &def) const { return _data ? current() : def; } - ValueType current(uint64 ms, const ValueType &def) { + ValueType current(TimeMs ms, const ValueType &def) { return animating(ms) ? current() : def; } diff --git a/Telegram/SourceFiles/ui/buttons/history_down_button.cpp b/Telegram/SourceFiles/ui/buttons/history_down_button.cpp index 1ba5d6f46..f222c6a69 100644 --- a/Telegram/SourceFiles/ui/buttons/history_down_button.cpp +++ b/Telegram/SourceFiles/ui/buttons/history_down_button.cpp @@ -149,8 +149,8 @@ void EmojiButton::paintEvent(QPaintEvent *e) { p.setRenderHint(QPainter::HighQualityAntialiasing); QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle); if (loading > 0) { - int32 full = 5760; - int32 start = qRound(full * float64(ms % uint64(st::historyEmojiCirclePeriod)) / st::historyEmojiCirclePeriod), part = qRound(loading * full / st::historyEmojiCirclePart); + int32 full = FullArcLength; + int32 start = qRound(full * float64(ms % st::historyEmojiCirclePeriod) / st::historyEmojiCirclePeriod), part = qRound(loading * full / st::historyEmojiCirclePart); p.drawArc(inner, start, full - part); } else { p.drawEllipse(inner); diff --git a/Telegram/SourceFiles/ui/buttons/history_down_button.h b/Telegram/SourceFiles/ui/buttons/history_down_button.h index d3e521347..8c427b067 100644 --- a/Telegram/SourceFiles/ui/buttons/history_down_button.h +++ b/Telegram/SourceFiles/ui/buttons/history_down_button.h @@ -81,7 +81,7 @@ private: FloatAnimation a_loading; Animation _a_loading; - void step_loading(uint64 ms, bool timer) { + void step_loading(TimeMs ms, bool timer) { if (timer) { update(); } diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.cpp b/Telegram/SourceFiles/ui/effects/radial_animation.cpp index 4b851dcf0..7437fbb6e 100644 --- a/Telegram/SourceFiles/ui/effects/radial_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/radial_animation.cpp @@ -36,7 +36,7 @@ void RadialAnimation::start(float64 prg) { _animation.start(); } -void RadialAnimation::update(float64 prg, bool finished, uint64 ms) { +void RadialAnimation::update(float64 prg, bool finished, TimeMs ms) { int32 iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength); if (iprg != a_arcEnd.to()) { a_arcEnd.start(iprg); @@ -66,7 +66,7 @@ void RadialAnimation::stop() { _animation.stop(); } -void RadialAnimation::step(uint64 ms) { +void RadialAnimation::step(TimeMs ms) { _animation.step(ms); } diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.h b/Telegram/SourceFiles/ui/effects/radial_animation.h index d4bcfcf40..dcc1130b9 100644 --- a/Telegram/SourceFiles/ui/effects/radial_animation.h +++ b/Telegram/SourceFiles/ui/effects/radial_animation.h @@ -34,10 +34,10 @@ public: } void start(float64 prg); - void update(float64 prg, bool finished, uint64 ms); + void update(float64 prg, bool finished, TimeMs ms); void stop(); - void step(uint64 ms); + void step(TimeMs ms); void step() { step(getms()); } @@ -45,9 +45,9 @@ public: void draw(Painter &p, const QRect &inner, int32 thickness, const style::color &color); private: - uint64 _firstStart = 0; - uint64 _lastStart = 0; - uint64 _lastTime = 0; + TimeMs _firstStart = 0; + TimeMs _lastStart = 0; + TimeMs _lastTime = 0; float64 _opacity = 0.; anim::ivalue a_arcEnd, a_arcStart; Animation _animation; diff --git a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp index 3398b996a..d03918f59 100644 --- a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp @@ -28,7 +28,7 @@ public: Ripple(const style::RippleAnimation &st, QPoint origin, int startRadius, const QPixmap &mask, const UpdateCallback &update); Ripple(const style::RippleAnimation &st, const QPixmap &mask, const UpdateCallback &update); - void paint(QPainter &p, const QPixmap &mask, uint64 ms); + void paint(QPainter &p, const QPixmap &mask, TimeMs ms); void stop(); void unstop(); @@ -86,7 +86,7 @@ RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, const QPixmap _hide.start(UpdateCallback(_update), 0., 1., _st.hideDuration); } -void RippleAnimation::Ripple::paint(QPainter &p, const QPixmap &mask, uint64 ms) { +void RippleAnimation::Ripple::paint(QPainter &p, const QPixmap &mask, TimeMs ms) { auto opacity = _hide.current(ms, _hiding ? 0. : 1.); if (opacity == 0.) { return; @@ -176,7 +176,7 @@ void RippleAnimation::lastFinish() { } } -void RippleAnimation::paint(QPainter &p, int x, int y, int outerWidth, uint64 ms) { +void RippleAnimation::paint(QPainter &p, int x, int y, int outerWidth, TimeMs ms) { if (_ripples.isEmpty()) { return; } diff --git a/Telegram/SourceFiles/ui/effects/ripple_animation.h b/Telegram/SourceFiles/ui/effects/ripple_animation.h index 55a558d5b..7333b8a28 100644 --- a/Telegram/SourceFiles/ui/effects/ripple_animation.h +++ b/Telegram/SourceFiles/ui/effects/ripple_animation.h @@ -37,7 +37,7 @@ public: void lastUnstop(); void lastFinish(); - void paint(QPainter &p, int x, int y, int outerWidth, uint64 ms); + void paint(QPainter &p, int x, int y, int outerWidth, TimeMs ms); bool empty() const { return _ripples.isEmpty(); diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp index a059db321..19e1465cd 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp @@ -75,7 +75,7 @@ QRect RoundCheckbox::cacheDestRect(int x, int y, float64 scale) const { return QRect(iconLeft, iconTop, iconSize, iconSize); } -void RoundCheckbox::paint(Painter &p, uint64 ms, int x, int y, int outerWidth, float64 masterScale) { +void RoundCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWidth, float64 masterScale) { for (auto &icon : _icons) { icon.fadeIn.step(ms); icon.fadeOut.step(ms); @@ -227,7 +227,7 @@ RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, cons , _check(_st.check, _updateCallback) { } -void RoundImageCheckbox::paint(Painter &p, uint64 ms, int x, int y, int outerWidth) { +void RoundImageCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWidth) { _selection.step(ms); auto selectionLevel = _selection.current(checked() ? 1. : 0.); diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.h b/Telegram/SourceFiles/ui/effects/round_checkbox.h index b528bced8..f0769186f 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.h +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.h @@ -28,7 +28,7 @@ class RoundCheckbox { public: RoundCheckbox(const style::RoundCheckbox &st, const base::lambda_copy &updateCallback); - void paint(Painter &p, uint64 ms, int x, int y, int outerWidth, float64 masterScale = 1.); + void paint(Painter &p, TimeMs ms, int x, int y, int outerWidth, float64 masterScale = 1.); void setDisplayInactive(bool displayInactive); bool checked() const { @@ -70,7 +70,7 @@ public: using PaintRoundImage = base::lambda; RoundImageCheckbox(const style::RoundImageCheckbox &st, const base::lambda_copy &updateCallback, PaintRoundImage &&paintRoundImage); - void paint(Painter &p, uint64 ms, int x, int y, int outerWidth); + void paint(Painter &p, TimeMs ms, int x, int y, int outerWidth); float64 checkedAnimationRatio() const; bool checked() const { diff --git a/Telegram/SourceFiles/ui/effects/send_action_animations.cpp b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp new file mode 100644 index 000000000..8f31333fb --- /dev/null +++ b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp @@ -0,0 +1,223 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#include "stdafx.h" +#include "ui/effects/send_action_animations.h" + +#include "styles/style_widgets.h" + +namespace Ui { +namespace { + +constexpr int kTypingDotsCount = 3; +constexpr int kRecordArcsCount = 4; +constexpr int kUploadArrowsCount = 3; + +using ImplementationsMap = QMap; +NeverFreedPointer Implementations; + +class TypingAnimation : public SendActionAnimation::Impl { +public: + TypingAnimation() : Impl(st::historySendActionTypingDuration) { + } + + static const MetaData kMeta; + static std_::unique_ptr create() { + return std_::make_unique(); + } + const MetaData *metaData() const override { + return &kMeta; + } + + int width() const override { + return st::historySendActionTypingPosition.x() + kTypingDotsCount * st::historySendActionTypingDelta; + } + +private: + void paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) override; + +}; + +const TypingAnimation::MetaData TypingAnimation::kMeta = { 0, &TypingAnimation::create }; + +void TypingAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.setPen(Qt::NoPen); + p.setBrush(color); + auto position = QPointF(x + 0.5, y - 0.5) + st::historySendActionTypingPosition; + for (auto i = 0; i != kTypingDotsCount; ++i) { + auto r = st::historySendActionTypingSmallNumerator / st::historySendActionTypingDenominator; + if (frameMs < 2 * st::historySendActionTypingHalfPeriod) { + auto delta = (st::historySendActionTypingLargeNumerator - st::historySendActionTypingSmallNumerator) / st::historySendActionTypingDenominator; + if (frameMs < st::historySendActionTypingHalfPeriod) { + r += delta * anim::easeOutCirc(1., float64(frameMs) / st::historySendActionTypingHalfPeriod); + } else { + r += delta * (1. - anim::easeOutCirc(1., float64(frameMs - st::historySendActionTypingHalfPeriod) / st::historySendActionTypingHalfPeriod)); + } + } + p.drawEllipse(position, r, r); + position.setX(position.x() + st::historySendActionTypingDelta); + frameMs = (frameMs + st::historySendActionTypingDuration - st::historySendActionTypingDeltaTime) % st::historySendActionTypingDuration; + } + p.setRenderHint(QPainter::HighQualityAntialiasing, false); +} + +class RecordAnimation : public SendActionAnimation::Impl { +public: + RecordAnimation() : Impl(st::historySendActionRecordDuration) { + } + + static const MetaData kMeta; + static std_::unique_ptr create() { + return std_::make_unique(); + } + const MetaData *metaData() const override { + return &kMeta; + } + + int width() const override { + return st::historySendActionRecordPosition.x() + (kRecordArcsCount + 1) * st::historySendActionRecordDelta; + } + +private: + void paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) override; + +}; + +const RecordAnimation::MetaData RecordAnimation::kMeta = { 0, &RecordAnimation::create }; + +void RecordAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { + p.setRenderHint(QPainter::HighQualityAntialiasing); + auto pen = color->p; + pen.setWidth(st::historySendActionRecordStrokeNumerator / st::historySendActionRecordDenominator); + pen.setJoinStyle(Qt::RoundJoin); + pen.setCapStyle(Qt::RoundCap); + p.setPen(pen); + p.setBrush(Qt::NoBrush); + auto progress = frameMs / float64(st::historySendActionRecordDuration); + auto size = st::historySendActionRecordPosition.x() + st::historySendActionRecordDelta * progress; + y += st::historySendActionRecordPosition.y(); + for (auto i = 0; i != kRecordArcsCount; ++i) { + p.setOpacity((i == 0) ? progress : (i == kRecordArcsCount - 1) ? (1. - progress) : 1.); + auto rect = QRectF(x - size, y - size, 2 * size, 2 * size); + p.drawArc(rect, -FullArcLength / 24, FullArcLength / 12); + size += st::historySendActionRecordDelta; + } + p.setOpacity(1.); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); +} + +class UploadAnimation : public SendActionAnimation::Impl { +public: + UploadAnimation() : Impl(st::historySendActionUploadDuration) { + } + + static const MetaData kMeta; + static std_::unique_ptr create() { + return std_::make_unique(); + } + const MetaData *metaData() const override { + return &kMeta; + } + + int width() const override { + return st::historySendActionUploadPosition.x() + (kUploadArrowsCount + 1) * st::historySendActionUploadDelta; + } + +private: + void paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) override; + +}; + +const UploadAnimation::MetaData UploadAnimation::kMeta = { 0, &UploadAnimation::create }; + +void UploadAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { + p.setRenderHint(QPainter::HighQualityAntialiasing); + auto pen = color->p; + pen.setWidth(st::historySendActionUploadStrokeNumerator / st::historySendActionUploadDenominator); + pen.setJoinStyle(Qt::RoundJoin); + pen.setCapStyle(Qt::RoundCap); + p.setPen(pen); + p.setBrush(Qt::NoBrush); + auto progress = frameMs / float64(st::historySendActionUploadDuration); + auto position = QPointF(x + st::historySendActionUploadDelta * progress, y) + st::historySendActionUploadPosition; + auto path = QPainterPath(); + path.moveTo(0., -st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator); + path.lineTo(st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator, 0.); + path.lineTo(0., st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator); + p.translate(position); + for (auto i = 0; i != kUploadArrowsCount; ++i) { + p.setOpacity((i == 0) ? progress : (i == kUploadArrowsCount - 1) ? (1. - progress) : 1.); + p.drawPath(path); + position.setX(position.x() + st::historySendActionUploadDelta); + p.translate(st::historySendActionUploadDelta, 0); + } + p.setOpacity(1.); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + p.translate(-position); +} + +void CreateImplementationsMap() { + if (Implementations) { + return; + } + using Type = SendAction::Type; + Implementations.createIfNull(); + Type recordTypes[] = { + Type::RecordVideo, + Type::RecordVoice + }; + for_const (auto type, recordTypes) { + Implementations->insert(type, &RecordAnimation::kMeta); + } + Type uploadTypes[] = { + Type::UploadFile, + Type::UploadPhoto, + Type::UploadVideo, + Type::UploadVoice + }; + for_const (auto type, uploadTypes) { + Implementations->insert(type, &UploadAnimation::kMeta); + } +} + +} // namespace + +bool SendActionAnimation::Impl::supports(Type type) const { + CreateImplementationsMap(); + return Implementations->value(type, &TypingAnimation::kMeta) == metaData(); +} + +void SendActionAnimation::start(Type type) { + if (!_impl || !_impl->supports(type)) { + _impl = createByType(type); + } +} + +void SendActionAnimation::stop() { + _impl.reset(); +} + +std_::unique_ptr SendActionAnimation::createByType(Type type) { + CreateImplementationsMap(); + return Implementations->value(type, &TypingAnimation::kMeta)->creator(); +} + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/send_action_animations.h b/Telegram/SourceFiles/ui/effects/send_action_animations.h new file mode 100644 index 000000000..2e9a3c611 --- /dev/null +++ b/Telegram/SourceFiles/ui/effects/send_action_animations.h @@ -0,0 +1,79 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +namespace Ui { + +class SendActionAnimation { +public: + using Type = SendAction::Type; + + void start(Type type); + void stop(); + + int width() const { + return _impl ? _impl->width() : 0; + } + void paint(Painter &p, const style::color &color, int x, int y, int outerWidth, TimeMs ms) { + if (_impl) { + _impl->paint(p, color, x, y, outerWidth, ms); + } + } + + explicit operator bool() const { + return _impl != nullptr; + } + + class Impl { + public: + using Type = SendAction::Type; + + Impl(int period) : _period(period), _started(getms()) { + } + + struct MetaData { + int index; + std_::unique_ptr (*creator)(); + }; + virtual const MetaData *metaData() const = 0; + bool supports(Type type) const; + + virtual int width() const = 0; + void paint(Painter &p, const style::color &color, int x, int y, int outerWidth, TimeMs ms) { + paintFrame(p, color, x, y, outerWidth, qMax(ms - _started, 0LL) % _period); + } + + private: + virtual void paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) = 0; + + int _period = 1; + TimeMs _started = 0; + + }; + +private: + std_::unique_ptr createByType(Type type); + + std_::unique_ptr _impl; + +}; + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/slide_animation.cpp b/Telegram/SourceFiles/ui/effects/slide_animation.cpp index 9ebdfc002..749f0d231 100644 --- a/Telegram/SourceFiles/ui/effects/slide_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/slide_animation.cpp @@ -32,7 +32,7 @@ void SlideAnimation::setSnapshots(QPixmap leftSnapshot, QPixmap rightSnapshot) { _rightSnapshot.setDevicePixelRatio(cRetinaFactor()); } -void SlideAnimation::paintFrame(Painter &p, int x, int y, int outerWidth, uint64 ms) { +void SlideAnimation::paintFrame(Painter &p, int x, int y, int outerWidth, TimeMs ms) { auto dt = _animation.current(ms, 1.); if (!animating()) return; diff --git a/Telegram/SourceFiles/ui/effects/slide_animation.h b/Telegram/SourceFiles/ui/effects/slide_animation.h index ddbb5c4b8..241e6569b 100644 --- a/Telegram/SourceFiles/ui/effects/slide_animation.h +++ b/Telegram/SourceFiles/ui/effects/slide_animation.h @@ -33,7 +33,7 @@ public: template void start(bool slideLeft, Lambda &&updateCallback, float64 duration); - void paintFrame(Painter &p, int x, int y, int outerWidth, uint64 ms); + void paintFrame(Painter &p, int x, int y, int outerWidth, TimeMs ms); bool animating() const { return _animation.animating(); diff --git a/Telegram/SourceFiles/ui/toast/toast.h b/Telegram/SourceFiles/ui/toast/toast.h index d4a15b3a0..16a4aa33c 100644 --- a/Telegram/SourceFiles/ui/toast/toast.h +++ b/Telegram/SourceFiles/ui/toast/toast.h @@ -53,7 +53,7 @@ private: bool _fadingOut = false; Animation _a_fade; - const uint64 _hideAtMs; + const TimeMs _hideAtMs; // ToastManager should reset _widget pointer if _widget is destroyed. friend class internal::Manager; diff --git a/Telegram/SourceFiles/ui/toast/toast_manager.cpp b/Telegram/SourceFiles/ui/toast/toast_manager.cpp index a65dcc7e5..4026a29a6 100644 --- a/Telegram/SourceFiles/ui/toast/toast_manager.cpp +++ b/Telegram/SourceFiles/ui/toast/toast_manager.cpp @@ -57,7 +57,7 @@ void Manager::addToast(std_::unique_ptr &&toast) { connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(onToastWidgetDestroyed(QObject*))); connect(widget->parentWidget(), SIGNAL(resized(QSize)), this, SLOT(onToastWidgetParentResized()), Qt::UniqueConnection); - uint64 oldHideNearestMs = _toastByHideTime.isEmpty() ? 0 : _toastByHideTime.firstKey(); + auto oldHideNearestMs = _toastByHideTime.isEmpty() ? 0LL : _toastByHideTime.firstKey(); _toastByHideTime.insert(t->_hideAtMs, t); if (!oldHideNearestMs || _toastByHideTime.firstKey() < oldHideNearestMs) { startNextHideTimer(); @@ -65,7 +65,7 @@ void Manager::addToast(std_::unique_ptr &&toast) { } void Manager::onHideTimeout() { - uint64 now = getms(true); + auto now = getms(true); for (auto i = _toastByHideTime.begin(); i != _toastByHideTime.cend();) { if (i.key() <= now) { Instance *toast = i.value(); @@ -107,7 +107,7 @@ void Manager::onToastWidgetParentResized() { void Manager::startNextHideTimer() { if (_toastByHideTime.isEmpty()) return; - uint64 ms = getms(true); + auto ms = getms(true); if (ms >= _toastByHideTime.firstKey()) { QMetaObject::invokeMethod(this, SLOT("onHideTimeout"), Qt::QueuedConnection); } else { diff --git a/Telegram/SourceFiles/ui/toast/toast_manager.h b/Telegram/SourceFiles/ui/toast/toast_manager.h index e8e42f9f8..3c40081c7 100644 --- a/Telegram/SourceFiles/ui/toast/toast_manager.h +++ b/Telegram/SourceFiles/ui/toast/toast_manager.h @@ -51,9 +51,9 @@ private: void startNextHideTimer(); SingleTimer _hideTimer; - uint64 _nextHide = 0; + TimeMs _nextHide = 0; - QMultiMap _toastByHideTime; + QMultiMap _toastByHideTime; QMap _toastByWidget; QList _toasts; diff --git a/Telegram/SourceFiles/ui/widgets/buttons.cpp b/Telegram/SourceFiles/ui/widgets/buttons.cpp index d4ba1b90a..a7145e7f6 100644 --- a/Telegram/SourceFiles/ui/widgets/buttons.cpp +++ b/Telegram/SourceFiles/ui/widgets/buttons.cpp @@ -86,7 +86,7 @@ void RippleButton::setForceRippled(bool rippled, SetForceRippledWay way) { update(); } -void RippleButton::paintRipple(QPainter &p, int x, int y, uint64 ms) { +void RippleButton::paintRipple(QPainter &p, int x, int y, TimeMs ms) { if (_ripple) { _ripple->paint(p, x, y, width(), ms); if (_ripple->empty()) { diff --git a/Telegram/SourceFiles/ui/widgets/buttons.h b/Telegram/SourceFiles/ui/widgets/buttons.h index 7e3aa4824..413219c12 100644 --- a/Telegram/SourceFiles/ui/widgets/buttons.h +++ b/Telegram/SourceFiles/ui/widgets/buttons.h @@ -64,7 +64,7 @@ public: ~RippleButton(); protected: - void paintRipple(QPainter &p, int x, int y, uint64 ms); + void paintRipple(QPainter &p, int x, int y, TimeMs ms); void onStateChanged(int oldState, StateChangeSource source) override; diff --git a/Telegram/SourceFiles/ui/widgets/continuous_sliders.h b/Telegram/SourceFiles/ui/widgets/continuous_sliders.h index 9e7b1a74f..539a251a6 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_sliders.h +++ b/Telegram/SourceFiles/ui/widgets/continuous_sliders.h @@ -69,11 +69,11 @@ protected: float64 fadeOpacity() const { return _fadeOpacity; } - float64 getCurrentValue(uint64 ms) { + float64 getCurrentValue(TimeMs ms) { _a_value.step(ms); return _mouseDown ? _downValue : a_value.current(); } - float64 getCurrentOverFactor(uint64 ms) { + float64 getCurrentOverFactor(TimeMs ms) { return _disabled ? 0. : _a_over.current(ms, _over ? 1. : 0.); } Direction getDirection() const { diff --git a/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp b/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp index 9d7936050..99045d5f1 100644 --- a/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp +++ b/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp @@ -75,7 +75,7 @@ void DiscreteSlider::setSections(const QStringList &labels) { resizeToWidth(width()); } -int DiscreteSlider::getCurrentActiveLeft(uint64 ms) { +int DiscreteSlider::getCurrentActiveLeft(TimeMs ms) { return _a_left.current(ms, _sections.isEmpty() ? 0 : _sections[_selected].left); } diff --git a/Telegram/SourceFiles/ui/widgets/discrete_sliders.h b/Telegram/SourceFiles/ui/widgets/discrete_sliders.h index 056e3e6e4..d472f0a87 100644 --- a/Telegram/SourceFiles/ui/widgets/discrete_sliders.h +++ b/Telegram/SourceFiles/ui/widgets/discrete_sliders.h @@ -55,7 +55,7 @@ protected: int labelWidth; }; - int getCurrentActiveLeft(uint64 ms); + int getCurrentActiveLeft(TimeMs ms); int getSectionsCount() const { return _sections.size(); diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index 38573c005..74127f8f5 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -61,7 +61,7 @@ public: _updateCallback = updateCallback; } void setText(const QString &text); - void paint(Painter &p, int outerWidth, uint64 ms); + void paint(Painter &p, int outerWidth, TimeMs ms); void mouseMoveEvent(QPoint point); void leaveEvent(); @@ -79,7 +79,7 @@ public: private: void setOver(bool over); - void paintOnce(Painter &p, int x, int y, int outerWidth, uint64 ms); + void paintOnce(Painter &p, int x, int y, int outerWidth, TimeMs ms); void paintDeleteButton(Painter &p, int x, int y, int outerWidth, float64 overOpacity); bool paintCached(Painter &p, int x, int y, int outerWidth); void prepareCache(); @@ -131,7 +131,7 @@ void MultiSelect::Inner::Item::setText(const QString &text) { accumulate_min(_width, _st.maxWidth); } -void MultiSelect::Inner::Item::paint(Painter &p, int outerWidth, uint64 ms) { +void MultiSelect::Inner::Item::paint(Painter &p, int outerWidth, TimeMs ms) { if (!_cache.isNull() && !_visibility.animating(ms)) { if (_hiding) { return; @@ -159,7 +159,7 @@ void MultiSelect::Inner::Item::paint(Painter &p, int outerWidth, uint64 ms) { } } -void MultiSelect::Inner::Item::paintOnce(Painter &p, int x, int y, int outerWidth, uint64 ms) { +void MultiSelect::Inner::Item::paintOnce(Painter &p, int x, int y, int outerWidth, TimeMs ms) { if (!_cache.isNull()) { paintCached(p, x, y, outerWidth); return; diff --git a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp index eb41f76a6..1a7016467 100644 --- a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp +++ b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp @@ -175,7 +175,7 @@ void ScrollBar::step_appearance(float64 ms, bool timer) { if (timer) update(); } -void ScrollBar::hideTimeout(int64 dt) { +void ScrollBar::hideTimeout(TimeMs dt) { if (_hideIn < 0) { a_bgOver.start(_over ? 1. : 0.); a_barOver.start(_over ? 1. : 0.); @@ -330,7 +330,7 @@ void SplittedWidget::update(const QRegion &r) { void SplittedWidgetOther::paintEvent(QPaintEvent *e) { Painter p(this); - SplittedWidget *s = static_cast(static_cast(parentWidget())->widget()); + auto s = static_cast(static_cast(parentWidget())->widget()); if (rtl()) { s->paintRegion(p, e->region(), true); } else { @@ -444,7 +444,7 @@ void ScrollArea::onTouchTimer() { } void ScrollArea::onTouchScrollTimer() { - uint64 nowTime = getms(); + auto nowTime = getms(); if (_touchScrollState == TouchScrollState::Acceleration && _touchWaitingAcceleration && (nowTime - _touchAccelerationTime) > 40) { _touchScrollState = TouchScrollState::Manual; touchResetSpeed(); @@ -465,7 +465,7 @@ void ScrollArea::onTouchScrollTimer() { } void ScrollArea::touchUpdateSpeed() { - const uint64 nowTime = getms(); + const auto nowTime = getms(); if (_touchPrevPosValid) { const int elapsed = nowTime - _touchSpeedTime; if (elapsed) { diff --git a/Telegram/SourceFiles/ui/widgets/scroll_area.h b/Telegram/SourceFiles/ui/widgets/scroll_area.h index aefb37527..16b4cb745 100644 --- a/Telegram/SourceFiles/ui/widgets/scroll_area.h +++ b/Telegram/SourceFiles/ui/widgets/scroll_area.h @@ -70,7 +70,7 @@ public: void step_appearance(float64 ms, bool timer); - void hideTimeout(int64 dt); + void hideTimeout(TimeMs dt); public slots: @@ -97,7 +97,7 @@ private: int32 _startFrom, _scrollMax; - int64 _hideIn; + TimeMs _hideIn; QTimer _hideTimer; anim::fvalue a_bgOver, a_barOver, a_fullOpacity; @@ -249,9 +249,9 @@ private: bool _touchPrevPosValid = false; bool _touchWaitingAcceleration = false; QPoint _touchSpeed; - uint64 _touchSpeedTime = 0; - uint64 _touchAccelerationTime = 0; - uint64 _touchTime = 0; + TimeMs _touchSpeedTime = 0; + TimeMs _touchAccelerationTime = 0; + TimeMs _touchTime = 0; QTimer _touchScrollTimer; bool _widgetAcceptsTouch = false; diff --git a/Telegram/SourceFiles/ui/widgets/widgets.style b/Telegram/SourceFiles/ui/widgets/widgets.style index 748b03d07..2699ba148 100644 --- a/Telegram/SourceFiles/ui/widgets/widgets.style +++ b/Telegram/SourceFiles/ui/widgets/widgets.style @@ -746,12 +746,9 @@ defaultSettingsSlider: SettingsSlider { barFg: #e1eaef; barFgActive: windowBgActive; labelTop: 17px; - labelFont: semiboldFont; -// labelFont: normalFont; - labelFg: #999999; - labelFgActive: lightButtonFg; -// labelFg: #1485c2; -// labelFgActive: #1485c2; + labelFont: normalFont; + labelFg: #1485c2; + labelFgActive: #1485c2; duration: 150; } @@ -898,3 +895,25 @@ TwoIconButton { rippleAreaSize: pixels; ripple: RippleAnimation; } + +historySendActionTypingDuration: 800; +historySendActionTypingHalfPeriod: 320; +historySendActionTypingDeltaTime: 150; +historySendActionTypingPosition: point(4px, -4px); +historySendActionTypingDelta: 7px; +historySendActionTypingLargeNumerator: 28px; +historySendActionTypingSmallNumerator: 16px; +historySendActionTypingDenominator: 12.; + +historySendActionRecordDuration: 300; +historySendActionRecordPosition: point(1px, -4px); +historySendActionRecordDelta: 3px; +historySendActionRecordStrokeNumerator: 12px; +historySendActionRecordDenominator: 8.; + +historySendActionUploadDuration: 500; +historySendActionUploadPosition: point(0px, -4px); +historySendActionUploadDelta: 5px; +historySendActionUploadStrokeNumerator: 12px; +historySendActionUploadSizeNumerator: 28px; +historySendActionUploadDenominator: 8.; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.h b/Telegram/SourceFiles/window/notifications_manager_default.h index 076b0baf0..8002e9eda 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.h +++ b/Telegram/SourceFiles/window/notifications_manager_default.h @@ -238,7 +238,7 @@ private: QPixmap _buttonsCache; #if defined Q_OS_WIN && !defined Q_OS_WINRT - uint64 _started; + TimeMs _started; #endif // Q_OS_WIN && !Q_OS_WINRT History *_history; diff --git a/Telegram/SourceFiles/window/notifications_utilities.cpp b/Telegram/SourceFiles/window/notifications_utilities.cpp index 2d48cdd4c..3f72cbb36 100644 --- a/Telegram/SourceFiles/window/notifications_utilities.cpp +++ b/Telegram/SourceFiles/window/notifications_utilities.cpp @@ -40,7 +40,7 @@ CachedUserpics::CachedUserpics() { } QString CachedUserpics::get(const StorageKey &key, PeerData *peer) { - uint64 ms = getms(true); + auto ms = getms(true); auto i = _images.find(key); if (i != _images.cend()) { if (i->until) { @@ -67,8 +67,8 @@ QString CachedUserpics::get(const StorageKey &key, PeerData *peer) { return i->path; } -uint64 CachedUserpics::clear(uint64 ms) { - uint64 result = 0; +TimeMs CachedUserpics::clear(TimeMs ms) { + TimeMs result = 0; for (auto i = _images.begin(); i != _images.end();) { if (!i->until) { ++i; diff --git a/Telegram/SourceFiles/window/notifications_utilities.h b/Telegram/SourceFiles/window/notifications_utilities.h index f5609210b..d37576f42 100644 --- a/Telegram/SourceFiles/window/notifications_utilities.h +++ b/Telegram/SourceFiles/window/notifications_utilities.h @@ -41,10 +41,10 @@ private slots: private: void clearInMs(int ms); - uint64 clear(uint64 ms); + TimeMs clear(TimeMs ms); struct Image { - uint64 until; + TimeMs until; QString path; }; using Images = QMap; diff --git a/Telegram/SourceFiles/window/top_bar_widget.cpp b/Telegram/SourceFiles/window/top_bar_widget.cpp index 3904ac6d3..6024db5e9 100644 --- a/Telegram/SourceFiles/window/top_bar_widget.cpp +++ b/Telegram/SourceFiles/window/top_bar_widget.cpp @@ -162,7 +162,8 @@ void TopBarWidget::paintEvent(QPaintEvent *e) { if (!_search->isHidden()) { decreaseWidth += _search->width(); } - auto paintCounter = main()->paintTopBar(p, decreaseWidth); + auto ms = getms(); + auto paintCounter = main()->paintTopBar(p, decreaseWidth, ms); p.restore(); if (paintCounter) { diff --git a/Telegram/SourceFiles/window/window_theme_warning.h b/Telegram/SourceFiles/window/window_theme_warning.h index 3f2970a03..91a1ca365 100644 --- a/Telegram/SourceFiles/window/window_theme_warning.h +++ b/Telegram/SourceFiles/window/window_theme_warning.h @@ -57,7 +57,7 @@ private: QRect _inner, _outer; SingleTimer _timer; - uint64 _started = 0; + TimeMs _started = 0; int _secondsLeft = 0; QString _text; diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index cceb4b8d9..4d9f0dde6 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -468,6 +468,8 @@ '<(src_loc)/ui/effects/ripple_animation.h', '<(src_loc)/ui/effects/round_checkbox.cpp', '<(src_loc)/ui/effects/round_checkbox.h', + '<(src_loc)/ui/effects/send_action_animations.cpp', + '<(src_loc)/ui/effects/send_action_animations.h', '<(src_loc)/ui/effects/slide_animation.cpp', '<(src_loc)/ui/effects/slide_animation.h', '<(src_loc)/ui/effects/widget_fade_wrap.cpp',