From cbde6e1ee9b20b06d3f09a7abd674858890e7cce Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 22 Jun 2016 21:41:13 +0300 Subject: [PATCH] Using square rounded photos in native notifications (Win, OS X). When updating local online status from user action events we use action timestamp, and ignoring events from getDifference, if no timestamp is available for the specific action. Couple of hidden actions added in Settings. Alpha version 0.9.54. --- Telegram/Resources/winrc/Telegram.rc | 8 ++-- Telegram/Resources/winrc/Updater.rc | 8 ++-- Telegram/SourceFiles/app.cpp | 4 +- Telegram/SourceFiles/app.h | 2 +- Telegram/SourceFiles/application.cpp | 4 +- Telegram/SourceFiles/core/basic_types.cpp | 4 +- Telegram/SourceFiles/core/basic_types.h | 1 + Telegram/SourceFiles/core/version.h | 4 +- Telegram/SourceFiles/facades.cpp | 2 + Telegram/SourceFiles/facades.h | 1 + Telegram/SourceFiles/history.cpp | 8 ++-- Telegram/SourceFiles/history.h | 2 +- .../history/field_autocomplete.cpp | 20 ++++++--- .../SourceFiles/history/field_autocomplete.h | 2 + Telegram/SourceFiles/historywidget.cpp | 22 +++++++++- Telegram/SourceFiles/historywidget.h | 4 ++ Telegram/SourceFiles/localstorage.cpp | 12 +++++- Telegram/SourceFiles/mainwidget.cpp | 22 ++++++---- Telegram/SourceFiles/mainwidget.h | 3 ++ .../platform/win/windows_toasts.cpp | 2 +- Telegram/SourceFiles/settingswidget.cpp | 42 ++++++++++++++++++- Telegram/SourceFiles/settingswidget.h | 4 ++ Telegram/SourceFiles/structs.cpp | 19 ++++----- Telegram/SourceFiles/structs.h | 4 +- Telegram/Telegram.xcodeproj/project.pbxproj | 4 +- Telegram/build/version | 6 +-- 26 files changed, 159 insertions(+), 55 deletions(-) diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index f6394b547a..1a71484ad0 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,53,0 - PRODUCTVERSION 0,9,53,0 + FILEVERSION 0,9,54,0 + PRODUCTVERSION 0,9,54,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.9.53.0" + VALUE "FileVersion", "0.9.54.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.9.53.0" + VALUE "ProductVersion", "0.9.54.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 92da90e080..ff3c99beb1 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,53,0 - PRODUCTVERSION 0,9,53,0 + FILEVERSION 0,9,54,0 + PRODUCTVERSION 0,9,54,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.9.53.0" + VALUE "FileVersion", "0.9.54.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.9.53.0" + VALUE "ProductVersion", "0.9.54.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index be6c451c4d..256421f300 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -1223,7 +1223,7 @@ namespace { } } - void feedOutboxRead(const PeerId &peer, MsgId upTo) { + void feedOutboxRead(const PeerId &peer, MsgId upTo, TimeId when) { if (auto history = App::historyLoaded(peer)) { history->outboxRead(upTo); if (history->lastMsg && history->lastMsg->out() && history->lastMsg->id <= upTo) { @@ -1232,7 +1232,7 @@ namespace { history->updateChatListEntry(); if (history->peer->isUser()) { - history->peer->asUser()->madeAction(); + history->peer->asUser()->madeAction(when); } } } diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index 6a27b3af41..d2e06ce10e 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -83,7 +83,7 @@ namespace App { void feedMsgs(const QVector &msgs, NewMessageType type); void feedMsgs(const MTPVector &msgs, NewMessageType type); void feedInboxRead(const PeerId &peer, MsgId upTo); - void feedOutboxRead(const PeerId &peer, MsgId upTo); + void feedOutboxRead(const PeerId &peer, MsgId upTo, TimeId when); void feedWereDeleted(ChannelId channelId, const QVector &msgsIds); void feedUserLink(MTPint userId, const MTPContactLink &myLink, const MTPContactLink &foreignLink); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index e6b5a5a0e2..b9387b86bb 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -1049,8 +1049,8 @@ void AppClass::checkMapVersion() { if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion()) { QString versionFeatures; - if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 9053) { - versionFeatures = QString::fromUtf8("\xe2\x80\x94 Put your cursor over the members count in a group chat to see the members list\n\xe2\x80\x94 Bug fixes and other minor improvements"); + if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 9054) { + versionFeatures = QString::fromUtf8("\xe2\x80\x94 Photo viewer handles screen resolution change\n\xe2\x80\x94 Forward photo by drag-n-drop fixed\n\xe2\x80\x94 Some design improvements and bug fixes"); // versionFeatures = langNewVersionText(); } else if (Local::oldMapVersion() < 9050) { versionFeatures = langNewVersionText(); diff --git a/Telegram/SourceFiles/core/basic_types.cpp b/Telegram/SourceFiles/core/basic_types.cpp index 65d9910d75..89bbd34bf6 100644 --- a/Telegram/SourceFiles/core/basic_types.cpp +++ b/Telegram/SourceFiles/core/basic_types.cpp @@ -130,9 +130,9 @@ TimeId fromServerTime(const MTPint &serverTime) { return serverTime.v - unixtimeDelta; } -MTPint toServerTime(const TimeId &clientTime) { +void toServerTime(const TimeId &clientTime, MTPint &outServerTime) { QReadLocker locker(&unixtimeLock); - return MTP_int(clientTime + unixtimeDelta); + outServerTime = MTP_int(clientTime + unixtimeDelta); } QDateTime dateFromServerTime(TimeId time) { diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index f6a57ba4e3..c4cc892e4c 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -490,6 +490,7 @@ void unixtimeInit(); void unixtimeSet(TimeId servertime, bool force = false); TimeId unixtime(); TimeId fromServerTime(const MTPint &serverTime); +void toServerTime(const TimeId &clientTime, MTPint &outServerTime); uint64 msgid(); int32 reqid(); diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index c0eee7a0fa..deaeed2f4d 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 9053; -constexpr str_const AppVersionStr = "0.9.53"; +constexpr int AppVersion = 9054; +constexpr str_const AppVersionStr = "0.9.54"; constexpr bool AppAlphaVersion = true; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 03ba4065d5..4a3597d481 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -532,6 +532,7 @@ struct Data { bool AdaptiveForWide = true; bool DialogsModeEnabled = false; Dialogs::Mode DialogsMode = Dialogs::Mode::All; + bool ModerateModeEnabled = false; int32 DebugLoggingFlags = 0; @@ -597,6 +598,7 @@ DefineVar(Global, Adaptive::Layout, AdaptiveLayout); DefineVar(Global, bool, AdaptiveForWide); DefineVar(Global, bool, DialogsModeEnabled); DefineVar(Global, Dialogs::Mode, DialogsMode); +DefineVar(Global, bool, ModerateModeEnabled); DefineVar(Global, int32, DebugLoggingFlags); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index a368db47cd..ab621be037 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -211,6 +211,7 @@ DeclareVar(Adaptive::Layout, AdaptiveLayout); DeclareVar(bool, AdaptiveForWide); DeclareVar(bool, DialogsModeEnabled); DeclareVar(Dialogs::Mode, DialogsMode); +DeclareVar(bool, ModerateModeEnabled); DeclareVar(int32, DebugLoggingFlags); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index b95d11850c..ae585def9d 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -604,7 +604,7 @@ void Histories::clear() { typing.clear(); } -void Histories::regSendAction(History *history, UserData *user, const MTPSendMessageAction &action) { +void Histories::regSendAction(History *history, UserData *user, const MTPSendMessageAction &action, TimeId when) { if (action.type() == mtpc_sendMessageCancelAction) { history->unregTyping(user); return; @@ -624,7 +624,7 @@ void Histories::regSendAction(History *history, UserData *user, const MTPSendMes default: return; } - user->madeAction(); + user->madeAction(when); TypingHistories::const_iterator i = typing.find(history); if (i == typing.cend()) { @@ -1140,7 +1140,9 @@ void History::newItemAdded(HistoryItem *item) { if (item->from() == item->author()) { unregTyping(item->from()->asUser()); } - item->from()->asUser()->madeAction(); + MTPint itemServerTime; + toServerTime(item->date.toTime_t(), itemServerTime); + item->from()->asUser()->madeAction(itemServerTime.v); } if (item->out()) { if (unreadBar) unreadBar->destroyUnreadBar(); diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 12efd9ac0f..a38257e024 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -44,7 +44,7 @@ public: Histories() : _a_typings(animation(this, &Histories::step_typings)), _unreadFull(0), _unreadMuted(0) { } - void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action); + void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action, TimeId when); void step_typings(uint64 ms, bool timer); History *find(const PeerId &peerId); diff --git a/Telegram/SourceFiles/history/field_autocomplete.cpp b/Telegram/SourceFiles/history/field_autocomplete.cpp index d1c9d373dd..7bc693a7fe 100644 --- a/Telegram/SourceFiles/history/field_autocomplete.cpp +++ b/Telegram/SourceFiles/history/field_autocomplete.cpp @@ -493,14 +493,24 @@ bool FieldAutocomplete::chooseSelected(ChooseMethod method) const { } bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) { - if (isHidden()) return QWidget::eventFilter(obj, e); + auto hidden = isHidden(); + auto moderate = Global::ModerateModeEnabled(); + if (hidden && !moderate) return QWidget::eventFilter(obj, e); + if (e->type() == QEvent::KeyPress) { QKeyEvent *ev = static_cast(e); if (!(ev->modifiers() & (Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier | Qt::MetaModifier))) { - if (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down || (!_srows.isEmpty() && (ev->key() == Qt::Key_Left || ev->key() == Qt::Key_Right))) { - return _inner->moveSel(ev->key()); - } else if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) { - return _inner->chooseSelected(ChooseMethod::ByEnter); + if (!hidden) { + if (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down || (!_srows.isEmpty() && (ev->key() == Qt::Key_Left || ev->key() == Qt::Key_Right))) { + return _inner->moveSel(ev->key()); + } else if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) { + return _inner->chooseSelected(ChooseMethod::ByEnter); + } + } + if (moderate && ev->key() >= Qt::Key_1 && ev->key() <= Qt::Key_9) { + bool handled = false; + emit moderateKeyActivate(ev->key() - Qt::Key_1, &handled); + return handled; } } } diff --git a/Telegram/SourceFiles/history/field_autocomplete.h b/Telegram/SourceFiles/history/field_autocomplete.h index 200a720fd1..596034aaa4 100644 --- a/Telegram/SourceFiles/history/field_autocomplete.h +++ b/Telegram/SourceFiles/history/field_autocomplete.h @@ -85,6 +85,8 @@ signals: void botCommandChosen(QString command, FieldAutocomplete::ChooseMethod method) const; void stickerChosen(DocumentData *sticker, FieldAutocomplete::ChooseMethod method) const; + void moderateKeyActivate(int index, bool *outHandled) const; + public slots: void hideStart(); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 559aee306d..fecb234871 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2481,6 +2481,18 @@ void BotKeyboard::leaveEvent(QEvent *e) { clearSelection(); } +bool BotKeyboard::moderateKeyActivate(int index) { + if (auto item = App::histItemById(_wasForMsgId)) { + if (auto markup = item->Get()) { + if (!markup->rows.isEmpty() && index >= 0 && index < markup->rows.front().size()) { + App::activateBotCommand(item, 0, index); + return true; + } + } + } + return false; +} + void BotKeyboard::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { if (!_impl) return; _impl->clickHandlerActiveChanged(p, active); @@ -3086,6 +3098,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent) connect(_fieldAutocomplete, SIGNAL(hashtagChosen(QString,FieldAutocomplete::ChooseMethod)), this, SLOT(onHashtagOrBotCommandInsert(QString,FieldAutocomplete::ChooseMethod))); connect(_fieldAutocomplete, SIGNAL(botCommandChosen(QString,FieldAutocomplete::ChooseMethod)), this, SLOT(onHashtagOrBotCommandInsert(QString,FieldAutocomplete::ChooseMethod))); connect(_fieldAutocomplete, SIGNAL(stickerChosen(DocumentData*,FieldAutocomplete::ChooseMethod)), this, SLOT(onStickerSend(DocumentData*))); + connect(_fieldAutocomplete, SIGNAL(moderateKeyActivate(int,bool*)), this, SLOT(onModerateKeyActivate(int,bool*))); _field.installEventFilter(_fieldAutocomplete); _field.setTagMimeProcessor(std_::make_unique()); updateFieldSubmitSettings(); @@ -5646,7 +5659,10 @@ bool HistoryWidget::eventFilter(QObject *obj, QEvent *e) { } DragState HistoryWidget::getDragState(const QMimeData *d) { - if (!d || d->hasFormat(qsl("application/x-td-forward-pressed-link"))) return DragStateNone; + if (!d + || d->hasFormat(qsl("application/x-td-forward-selected")) + || d->hasFormat(qsl("application/x-td-forward-pressed")) + || d->hasFormat(qsl("application/x-td-forward-pressed-link"))) return DragStateNone; if (d->hasImage()) return DragStateImage; @@ -6062,6 +6078,10 @@ void HistoryWidget::onMembersDropdownShow() { _membersDropdown->otherEnter(); } +void HistoryWidget::onModerateKeyActivate(int index, bool *outHandled) { + *outHandled = _keyboard.isHidden() ? false : _keyboard.moderateKeyActivate(index); +} + void HistoryWidget::onMembersDropdownHidden() { _membersDropdown.destroyDelayed(); } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index a79a71e52f..c2474c014d 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -364,6 +364,8 @@ public: void enterEvent(QEvent *e) override; void leaveEvent(QEvent *e) override; + bool moderateKeyActivate(int index); + // With force=true the markup is updated even if it is // already shown for the passed history item. bool updateMarkup(HistoryItem *last, bool force = false); @@ -846,6 +848,8 @@ private slots: void onMembersDropdownHidden(); void onMembersDropdownShow(); + void onModerateKeyActivate(int index, bool *outHandled); + void updateField(); private: diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index 51c1d1487e..6ab0612b8b 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -540,6 +540,7 @@ namespace { dbiAdaptiveForWide = 0x38, dbiHiddenPinnedMessages = 0x39, dbiDialogsMode = 0x40, + dbiModerateMode = 0x41, dbiEncryptedWithSalt = 333, dbiEncrypted = 444, @@ -933,6 +934,14 @@ namespace { Global::SetDialogsMode(mode); } break; + case dbiModerateMode: { + qint32 enabled; + stream >> enabled; + if (!_checkStreamStatus(stream)) return false; + + Global::SetModerateModeEnabled(enabled == 1); + } break; + case dbiIncludeMuted: { qint32 v; stream >> v; @@ -1523,7 +1532,7 @@ namespace { _writeMap(WriteMapFast); } - uint32 size = 16 * (sizeof(quint32) + sizeof(qint32)); + uint32 size = 17 * (sizeof(quint32) + sizeof(qint32)); size += sizeof(quint32) + Serialize::stringSize(cAskDownloadPath() ? QString() : cDownloadPath()) + Serialize::bytearraySize(cAskDownloadPath() ? QByteArray() : cDownloadPathBookmark()); size += sizeof(quint32) + sizeof(qint32) + (cRecentEmojisPreload().isEmpty() ? cGetRecentEmojis().size() : cRecentEmojisPreload().size()) * (sizeof(uint64) + sizeof(ushort)); size += sizeof(quint32) + sizeof(qint32) + cEmojiVariants().size() * (sizeof(uint32) + sizeof(uint64)); @@ -1555,6 +1564,7 @@ namespace { data.stream << quint32(dbiSongVolume) << qint32(qRound(cSongVolume() * 1e6)); data.stream << quint32(dbiAutoDownload) << qint32(cAutoDownloadPhoto()) << qint32(cAutoDownloadAudio()) << qint32(cAutoDownloadGif()); data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast(Global::DialogsMode()); + data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 1 : 0); data.stream << quint32(dbiAutoPlay) << qint32(cAutoPlayGif() ? 1 : 0); { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 2bea9b9ffb..fab6779307 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3215,7 +3215,7 @@ void MainWidget::getDifference() { _getDifferenceTimeByPts = 0; LOG(("Getting difference! no updates timer: %1, remains: %2").arg(noUpdatesTimer.isActive() ? 1 : 0).arg(noUpdatesTimer.remainingTime())); - if (_ptsWaiter.requesting()) return; + if (requestingDifference()) return; _bySeqUpdates.clear(); _bySeqTimer.stop(); @@ -3879,7 +3879,7 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) { _lastUpdateTime = getms(true); noUpdatesTimer.start(NoUpdatesTimeout); - if (!_ptsWaiter.requesting()) { + if (!requestingDifference()) { feedUpdates(updates); } } catch (mtpErrorUnexpected &) { // just some other type @@ -4195,8 +4195,10 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (item->isMediaUnread()) { item->markMediaRead(); Ui::repaintHistoryItem(item); + if (item->out() && item->history()->peer->isUser()) { - item->history()->peer->asUser()->madeAction(); + auto when = requestingDifference() ? 0 : unixtime(); + item->history()->peer->asUser()->madeAction(when); } } } @@ -4227,7 +4229,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped auto peerId = peerFromMTP(d.vpeer); - App::feedOutboxRead(peerId, d.vmax_id.v); + auto when = requestingDifference() ? 0 : unixtime(); + App::feedOutboxRead(peerId, d.vmax_id.v, when); if (_history->peer() && _history->peer()->id == peerId) { _history->update(); } @@ -4269,7 +4272,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { History *history = App::historyLoaded(peerFromUser(d.vuser_id)); UserData *user = App::userLoaded(d.vuser_id.v); if (history && user) { - App::histories().regSendAction(history, user, d.vaction); + auto when = requestingDifference() ? 0 : unixtime(); + App::histories().regSendAction(history, user, d.vaction, when); } } break; @@ -4283,7 +4287,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { } UserData *user = (d.vuser_id.v == MTP::authedId()) ? 0 : App::userLoaded(d.vuser_id.v); if (history && user) { - App::histories().regSendAction(history, user, d.vaction); + auto when = requestingDifference() ? 0 : unixtime(); + App::histories().regSendAction(history, user, d.vaction, when); } } break; @@ -4481,7 +4486,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { const auto &d(update.c_updateNewChannelMessage()); ChannelData *channel = App::channelLoaded(peerToChannel(peerFromMessage(d.vmessage))); DataIsLoadedResult isDataLoaded = allDataLoadedForMessage(d.vmessage); - if (!_ptsWaiter.requesting() && (!channel || isDataLoaded != DataIsLoadedResult::Ok)) { + if (!requestingDifference() && (!channel || isDataLoaded != DataIsLoadedResult::Ok)) { MTP_LOG(0, ("getDifference { good - after not all data loaded in updateNewChannelMessage }%1").arg(cTestMode() ? " TESTMODE" : "")); // Request last active supergroup participants if the 'from' user was not loaded yet. @@ -4586,7 +4591,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { case mtpc_updateReadChannelOutbox: { auto &d(update.c_updateReadChannelOutbox()); auto peerId = peerFromChannel(d.vchannel_id.v); - App::feedOutboxRead(peerId, d.vmax_id.v); + auto when = requestingDifference() ? 0 : unixtime(); + App::feedOutboxRead(peerId, d.vmax_id.v, when); if (_history->peer() && _history->peer()->id == peerId) { _history->update(); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index a3514f8f0c..c6e937e423 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -618,6 +618,9 @@ private: bool ptsUpdated(int32 pts, int32 ptsCount, const MTPUpdate &update); void ptsApplySkippedUpdates(); PtsWaiter _ptsWaiter; + bool requestingDifference() const { + return _ptsWaiter.requesting(); + } typedef QMap ChannelGetDifferenceTime; ChannelGetDifferenceTime _channelGetDifferenceTimeByPts, _channelGetDifferenceTimeAfterFail; diff --git a/Telegram/SourceFiles/platform/win/windows_toasts.cpp b/Telegram/SourceFiles/platform/win/windows_toasts.cpp index 17aa620cf5..63550d549d 100644 --- a/Telegram/SourceFiles/platform/win/windows_toasts.cpp +++ b/Telegram/SourceFiles/platform/win/windows_toasts.cpp @@ -437,7 +437,7 @@ QString getImage(const StorageKey &key, PeerData *peer) { } v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value(), 16) + qsl(".png"); if (key.first || key.second) { - peer->saveUserpic(v.path); + peer->saveUserpic(v.path, st::notifyMacPhotoSize); } else { App::wnd()->iconLarge().save(v.path, "PNG"); } diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index 7381d0f39a..afb3112e21 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -824,6 +824,7 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) { break; } else if (str == qstr("loadlang")) { chooseCustomLang(); + break; } else if (str == qstr("debugfiles") && cDebug()) { if (DebugLogging::FileLoader()) { Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag; @@ -831,19 +832,34 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) { Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag; } Ui::showLayer(new InformBox(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging"))); + break; } else if (str == qstr("crashplease")) { t_assert(!"Crashed in Settings!"); + break; } else if (str == qstr("workmode")) { - QString text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?"); + auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?"); auto box = std_::make_unique(text); connect(box.get(), SIGNAL(confirmed()), App::app(), SLOT(onSwitchWorkMode())); Ui::showLayer(box.release()); from = size; break; + } else if (str == qstr("moderate")) { + auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?"); + auto box = std_::make_unique(text); + connect(box.get(), SIGNAL(confirmed()), this, SLOT(onSwitchModerateMode())); + Ui::showLayer(box.release()); + break; + } else if (str == qstr("clearstickers")) { + auto box = std_::make_unique(qsl("Clear frequently used stickers list?")); + connect(box.get(), SIGNAL(confirmed()), this, SLOT(onClearStickers())); + Ui::showLayer(box.release()); + break; } else if ( qsl("debugmode").startsWith(str) || qsl("testmode").startsWith(str) || qsl("loadlang").startsWith(str) || + qsl("clearstickers").startsWith(str) || + qsl("moderate").startsWith(str) || qsl("debugfiles").startsWith(str) || qsl("workmode").startsWith(str) || qsl("crashplease").startsWith(str)) { @@ -1251,6 +1267,30 @@ void SettingsInner::onShowSessions() { Ui::showLayer(box); } +void SettingsInner::onClearStickers() { + auto &recent(cGetRecentStickers()); + if (!recent.isEmpty()) { + recent.clear(); + Local::writeUserSettings(); + } + auto &sets(Global::RefStickerSets()); + auto it = sets.find(Stickers::CustomSetId); + if (it != sets.cend()) { + sets.erase(it); + Local::writeStickers(); + } + if (auto m = App::main()) { + emit m->stickersUpdated(); + } + Ui::hideLayer(); +} + +void SettingsInner::onSwitchModerateMode() { + Global::SetModerateModeEnabled(!Global::ModerateModeEnabled()); + Local::writeUserSettings(); + Ui::hideLayer(); +} + void SettingsInner::onAskQuestion() { if (!App::self()) return; diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h index 72f9d7b21b..d88df93c80 100644 --- a/Telegram/SourceFiles/settingswidget.h +++ b/Telegram/SourceFiles/settingswidget.h @@ -186,6 +186,10 @@ public slots: void onUpdateLocalStorage(); +private slots: + void onClearStickers(); + void onSwitchModerateMode(); + void onAskQuestion(); void onAskQuestionSure(); void onTelegramFAQ(); diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 7c547f1903..4b3e006d7d 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -185,12 +185,12 @@ StorageKey PeerData::userpicUniqueKey() const { return storageKey(photoLoc); } -void PeerData::saveUserpic(const QString &path) const { - currentUserpic()->pixCircled().save(path, "PNG"); +void PeerData::saveUserpic(const QString &path, int size) const { + currentUserpic()->pixRounded(size, size).save(path, "PNG"); } QPixmap PeerData::genUserpic(int size) const { - return currentUserpic()->pixCircled(size, size); + return currentUserpic()->pixRounded(size, size); } const Text &BotCommand::descriptionText() const { @@ -373,16 +373,15 @@ void UserData::setNameOrPhone(const QString &newNameOrPhone) { } } -void UserData::madeAction() { - if (botInfo || isServiceUser(id)) return; +void UserData::madeAction(TimeId when) { + if (botInfo || isServiceUser(id) || when <= 0) return; - int32 t = unixtime(); - if (onlineTill <= 0 && -onlineTill < t) { - onlineTill = -t - SetOnlineAfterActivity; + if (onlineTill <= 0 && -onlineTill < when) { + onlineTill = -when - SetOnlineAfterActivity; App::markPeerUpdated(this); Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged); - } else if (onlineTill > 0 && onlineTill < t + 1) { - onlineTill = t + SetOnlineAfterActivity; + } else if (onlineTill > 0 && onlineTill < when + 1) { + onlineTill = when + SetOnlineAfterActivity; App::markPeerUpdated(this); Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged); } diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index 87390e7ce8..1a948de465 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -315,7 +315,7 @@ public: return _userpic->loaded(); } StorageKey userpicUniqueKey() const; - void saveUserpic(const QString &path) const; + void saveUserpic(const QString &path, int size) const; QPixmap genUserpic(int size) const; PhotoId photoId = UnknownPeerPhotoId; @@ -406,7 +406,7 @@ public: void setNameOrPhone(const QString &newNameOrPhone); - void madeAction(); // pseudo-online + void madeAction(TimeId when); // pseudo-online uint64 access = 0; diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 3398801c1e..791bb84e4f 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -2375,7 +2375,7 @@ SDKROOT = macosx; SYMROOT = ./../Mac; TDESKTOP_MAJOR_VERSION = 0.9; - TDESKTOP_VERSION = 0.9.53; + TDESKTOP_VERSION = 0.9.54; }; name = Release; }; @@ -2516,7 +2516,7 @@ SDKROOT = macosx; SYMROOT = ./../Mac; TDESKTOP_MAJOR_VERSION = 0.9; - TDESKTOP_VERSION = 0.9.53; + TDESKTOP_VERSION = 0.9.54; }; name = Debug; }; diff --git a/Telegram/build/version b/Telegram/build/version index 14713536e8..28606fe25d 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 9053 +AppVersion 9054 AppVersionStrMajor 0.9 -AppVersionStrSmall 0.9.53 -AppVersionStr 0.9.53 +AppVersionStrSmall 0.9.54 +AppVersionStr 0.9.54 AlphaChannel 1 BetaVersion 0