mirror of https://github.com/procxx/kepka.git
Actions block done for the new profile implementation.
User block status moved to private data. Notify::PeerUpdateFlag[s] moved to Notify::PeerUpdate::Flag[s].
This commit is contained in:
parent
15d6a1aacf
commit
3fc7cc3453
|
@ -342,7 +342,7 @@ void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestI
|
|||
} else {
|
||||
peer->asUser()->setBotInfoVersion(-1);
|
||||
}
|
||||
peer->asUser()->blocked = d.is_blocked() ? UserIsBlocked : UserIsNotBlocked;
|
||||
peer->asUser()->setBlockStatus(d.is_blocked() ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
||||
peer->asUser()->setAbout(d.has_about() ? qs(d.vabout) : QString());
|
||||
|
||||
if (req) {
|
||||
|
@ -702,9 +702,7 @@ void ApiWrap::leaveChannel(ChannelData *channel) {
|
|||
}
|
||||
|
||||
void ApiWrap::channelAmInUpdated(ChannelData *channel) {
|
||||
Notify::PeerUpdate update(channel);
|
||||
update.flags |= Notify::PeerUpdateFlag::ChannelAmIn;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(channel, Notify::PeerUpdate::Flag::ChannelAmIn);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
|
@ -721,6 +719,47 @@ bool ApiWrap::channelAmInFail(ChannelData *channel, const RPCError &error) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void ApiWrap::blockUser(UserData *user) {
|
||||
if (user->isBlocked()) {
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserIsBlocked);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
} else if (!_blockRequests.contains(user)) {
|
||||
auto requestId = MTP::send(MTPcontacts_Block(user->inputUser), rpcDone(&ApiWrap::blockDone, user), rpcFail(&ApiWrap::blockFail, user));
|
||||
_blockRequests.insert(user, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::unblockUser(UserData *user) {
|
||||
if (!user->isBlocked()) {
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserIsBlocked);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
} else if (!_blockRequests.contains(user)) {
|
||||
auto requestId = MTP::send(MTPcontacts_Unblock(user->inputUser), rpcDone(&ApiWrap::unblockDone, user), rpcFail(&ApiWrap::blockFail, user));
|
||||
_blockRequests.insert(user, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::blockDone(UserData *user, const MTPBool &result) {
|
||||
_blockRequests.remove(user);
|
||||
user->setBlockStatus(UserData::BlockStatus::Blocked);
|
||||
emit App::main()->peerUpdated(user);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
void ApiWrap::unblockDone(UserData *user, const MTPBool &result) {
|
||||
_blockRequests.remove(user);
|
||||
user->setBlockStatus(UserData::BlockStatus::NotBlocked);
|
||||
emit App::main()->peerUpdated(user);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
bool ApiWrap::blockFail(UserData *user, const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
_blockRequests.remove(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApiWrap::exportInviteLink(PeerData *peer) {
|
||||
if (_exportInviteRequests.contains(peer)) {
|
||||
return;
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
void joinChannel(ChannelData *channel);
|
||||
void leaveChannel(ChannelData *channel);
|
||||
|
||||
void blockUser(UserData *user);
|
||||
void unblockUser(UserData *user);
|
||||
|
||||
void exportInviteLink(PeerData *peer);
|
||||
void requestNotifySetting(PeerData *peer);
|
||||
|
||||
|
@ -133,6 +136,11 @@ private:
|
|||
void channelAmInDone(ChannelData *channel, const MTPUpdates &updates);
|
||||
bool channelAmInFail(ChannelData *channel, const RPCError &error);
|
||||
|
||||
QMap<UserData*, mtpRequestId> _blockRequests;
|
||||
void blockDone(UserData *user, const MTPBool &result);
|
||||
void unblockDone(UserData *user, const MTPBool &result);
|
||||
bool blockFail(UserData *user, const RPCError &error);
|
||||
|
||||
QMap<PeerData*, mtpRequestId> _exportInviteRequests;
|
||||
void exportInviteDone(PeerData *peer, const MTPExportedChatInvite &result);
|
||||
bool exportInviteFail(PeerData *peer, const RPCError &error);
|
||||
|
|
|
@ -373,7 +373,7 @@ namespace {
|
|||
const MTPUserStatus *status = 0, emptyStatus = MTP_userStatusEmpty();
|
||||
|
||||
Notify::PeerUpdate update;
|
||||
using UpdateFlag = Notify::PeerUpdateFlag;
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
switch (user.type()) {
|
||||
case mtpc_userEmpty: {
|
||||
|
@ -554,7 +554,7 @@ namespace {
|
|||
bool minimal = false;
|
||||
|
||||
Notify::PeerUpdate update;
|
||||
using UpdateFlag = Notify::PeerUpdateFlag;
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
switch (chat.type()) {
|
||||
case mtpc_chat: {
|
||||
|
@ -1270,9 +1270,7 @@ namespace {
|
|||
}
|
||||
|
||||
if (wasContact != user->isContact()) {
|
||||
Notify::PeerUpdate update(user);
|
||||
update.flags |= Notify::PeerUpdateFlag::UserIsContact;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserIsContact);
|
||||
}
|
||||
if ((user->contact > 0 && !wasContact) || (wasContact && user->contact < 1)) {
|
||||
Notify::userIsContactChanged(user);
|
||||
|
@ -2381,9 +2379,7 @@ namespace {
|
|||
auto canShareThisContact = user ? user->canShareThisContact() : false;
|
||||
::sharedContactItems[userId].insert(item, NullType());
|
||||
if (canShareThisContact != (user ? user->canShareThisContact() : false)) {
|
||||
Notify::PeerUpdate update(user);
|
||||
update.flags |= Notify::PeerUpdateFlag::UserCanShareContact;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserCanShareContact);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2392,9 +2388,7 @@ namespace {
|
|||
auto canShareThisContact = user ? user->canShareThisContact() : false;
|
||||
::sharedContactItems[userId].remove(item);
|
||||
if (canShareThisContact != (user ? user->canShareThisContact() : false)) {
|
||||
Notify::PeerUpdate update(user);
|
||||
update.flags |= Notify::PeerUpdateFlag::UserCanShareContact;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserCanShareContact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "boxes/addcontactbox.h"
|
||||
#include "boxes/contactsbox.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "observer_peer.h"
|
||||
#include "localstorage.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
|
@ -640,7 +641,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
|
|||
_menu->addAction(lang(lng_profile_clear_history), this, SLOT(onContextClearHistory()))->setEnabled(true);
|
||||
_menu->addAction(lang(lng_profile_delete_conversation), this, SLOT(onContextDeleteAndLeave()))->setEnabled(true);
|
||||
if (_menuPeer->asUser()->access != UserNoAccess && _menuPeer != App::self()) {
|
||||
_menu->addAction(lang((_menuPeer->asUser()->blocked == UserIsBlocked) ? (_menuPeer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_menuPeer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)), this, SLOT(onContextToggleBlock()))->setEnabled(true);
|
||||
_menu->addAction(lang(_menuPeer->asUser()->isBlocked() ? (_menuPeer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_menuPeer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)), this, SLOT(onContextToggleBlock()))->setEnabled(true);
|
||||
connect(App::main(), SIGNAL(peerUpdated(PeerData*)), this, SLOT(peerUpdated(PeerData*)));
|
||||
}
|
||||
} else if (_menuPeer->isChat()) {
|
||||
|
@ -717,7 +718,7 @@ void DialogsInner::onContextDeleteAndLeaveSure() {
|
|||
|
||||
void DialogsInner::onContextToggleBlock() {
|
||||
if (!_menuPeer || !_menuPeer->isUser()) return;
|
||||
if (_menuPeer->asUser()->blocked == UserIsBlocked) {
|
||||
if (_menuPeer->asUser()->isBlocked()) {
|
||||
MTP::send(MTPcontacts_Unblock(_menuPeer->asUser()->inputUser), rpcDone(&DialogsInner::contextBlockDone, qMakePair(_menuPeer->asUser(), false)));
|
||||
} else {
|
||||
MTP::send(MTPcontacts_Block(_menuPeer->asUser()->inputUser), rpcDone(&DialogsInner::contextBlockDone, qMakePair(_menuPeer->asUser(), true)));
|
||||
|
@ -725,8 +726,9 @@ void DialogsInner::onContextToggleBlock() {
|
|||
}
|
||||
|
||||
void DialogsInner::contextBlockDone(QPair<UserData*, bool> data, const MTPBool &result) {
|
||||
data.first->blocked = data.second ? UserIsBlocked : UserIsNotBlocked;
|
||||
data.first->setBlockStatus(data.second ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
||||
emit App::main()->peerUpdated(data.first);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
void DialogsInner::onMenuDestroyed(QObject *obj) {
|
||||
|
@ -934,7 +936,7 @@ void DialogsInner::updateNotifySettings(PeerData *peer) {
|
|||
|
||||
void DialogsInner::peerUpdated(PeerData *peer) {
|
||||
if (_menu && _menuPeer == peer && _menuPeer->isUser() && _menu->actions().size() > 5) {
|
||||
_menu->actions().at(5)->setText(lang((_menuPeer->asUser()->blocked == UserIsBlocked) ? (_menuPeer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_menuPeer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
||||
_menu->actions().at(5)->setText(lang(_menuPeer->asUser()->isBlocked() ? (_menuPeer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_menuPeer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "profile/profile_section_memento.h"
|
||||
#include "core/vector_of_moveable.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "observer_peer.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "application.h"
|
||||
|
@ -305,7 +306,10 @@ void userIsContactChanged(UserData *user, bool fromThisApp) {
|
|||
}
|
||||
|
||||
void botCommandsChanged(UserData *user) {
|
||||
if (MainWidget *m = App::main()) m->notify_botCommandsChanged(user);
|
||||
if (MainWidget *m = App::main()) {
|
||||
m->notify_botCommandsChanged(user);
|
||||
}
|
||||
peerUpdatedDelayed(user, PeerUpdate::Flag::BotCommandsChanged);
|
||||
}
|
||||
|
||||
void inlineBotRequesting(bool requesting) {
|
||||
|
|
|
@ -37,6 +37,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "localstorage.h"
|
||||
#include "apiwrap.h"
|
||||
#include "window/top_bar_widget.h"
|
||||
#include "observer_peer.h"
|
||||
#include "playerwidget.h"
|
||||
|
||||
namespace {
|
||||
|
@ -4951,7 +4952,7 @@ void HistoryWidget::onSend(bool ctrlShiftEnter, MsgId replyTo) {
|
|||
|
||||
void HistoryWidget::onUnblock() {
|
||||
if (_unblockRequest) return;
|
||||
if (!_peer || !_peer->isUser() || _peer->asUser()->blocked != UserIsBlocked) {
|
||||
if (!_peer || !_peer->isUser() || !_peer->asUser()->isBlocked()) {
|
||||
updateControlsVisibility();
|
||||
return;
|
||||
}
|
||||
|
@ -4962,8 +4963,9 @@ void HistoryWidget::onUnblock() {
|
|||
void HistoryWidget::unblockDone(PeerData *peer, const MTPBool &result, mtpRequestId req) {
|
||||
if (!peer->isUser()) return;
|
||||
if (_unblockRequest == req) _unblockRequest = 0;
|
||||
peer->asUser()->blocked = UserIsNotBlocked;
|
||||
peer->asUser()->setBlockStatus(UserData::BlockStatus::NotBlocked);
|
||||
emit App::main()->peerUpdated(peer);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
bool HistoryWidget::unblockFail(const RPCError &error, mtpRequestId req) {
|
||||
|
@ -4976,8 +4978,9 @@ bool HistoryWidget::unblockFail(const RPCError &error, mtpRequestId req) {
|
|||
void HistoryWidget::blockDone(PeerData *peer, const MTPBool &result) {
|
||||
if (!peer->isUser()) return;
|
||||
|
||||
peer->asUser()->blocked = UserIsBlocked;
|
||||
peer->asUser()->setBlockStatus(UserData::BlockStatus::Blocked);
|
||||
emit App::main()->peerUpdated(peer);
|
||||
Notify::peerUpdatedSendDelayed();
|
||||
}
|
||||
|
||||
void HistoryWidget::onBotStart() {
|
||||
|
@ -5720,7 +5723,7 @@ bool HistoryWidget::isBotStart() const {
|
|||
}
|
||||
|
||||
bool HistoryWidget::isBlocked() const {
|
||||
return _peer && _peer->isUser() && _peer->asUser()->blocked == UserIsBlocked;
|
||||
return _peer && _peer->isUser() && _peer->asUser()->isBlocked();
|
||||
}
|
||||
|
||||
bool HistoryWidget::isJoinChannel() const {
|
||||
|
@ -7896,7 +7899,7 @@ void HistoryWidget::peerUpdated(PeerData *data) {
|
|||
if (App::api()) {
|
||||
if (data->isChat() && data->asChat()->noParticipantInfo()) {
|
||||
App::api()->requestFullPeer(data);
|
||||
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
|
||||
} else if (data->isUser() && data->asUser()->blockStatus() == UserData::BlockStatus::Unknown) {
|
||||
App::api()->requestFullPeer(data);
|
||||
} else if (data->isMegagroup() && !data->asChannel()->mgInfo->botStatus) {
|
||||
App::api()->requestBots(data->asChannel());
|
||||
|
|
|
@ -766,6 +766,11 @@ void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWidget::deleteAndExit(ChatData *chat) {
|
||||
PeerData *peer = chat;
|
||||
MTP::send(MTPmessages_DeleteChatUser(chat->inputChat, App::self()->inputUser), rpcDone(&MainWidget::deleteHistoryAfterLeave, peer), rpcFail(&MainWidget::leaveChatFailed, peer));
|
||||
}
|
||||
|
||||
void MainWidget::deleteAllFromUser(ChannelData *channel, UserData *from) {
|
||||
t_assert(channel != nullptr && from != nullptr);
|
||||
|
||||
|
@ -3593,9 +3598,7 @@ void MainWidget::applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNoti
|
|||
}
|
||||
_dialogs->updateNotifySettings(updatePeer);
|
||||
|
||||
Notify::PeerUpdate update(updatePeer);
|
||||
update.flags |= Notify::PeerUpdateFlag::NotificationsEnabled;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(updatePeer, Notify::PeerUpdate::Flag::NotificationsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4368,9 +4371,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
|||
user->setNameDelayed(user->firstName, user->lastName, (user->contact || isServiceUser(user->id) || user->isSelf() || user->phone().isEmpty()) ? QString() : App::formatPhone(user->phone()), user->username);
|
||||
App::markPeerUpdated(user);
|
||||
|
||||
Notify::PeerUpdate update(user);
|
||||
update.flags |= Notify::PeerUpdateFlag::UserPhoneChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserPhoneChanged);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -4394,7 +4395,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
|||
case mtpc_updateUserBlocked: {
|
||||
const auto &d(update.c_updateUserBlocked());
|
||||
if (UserData *user = App::userLoaded(d.vuser_id.v)) {
|
||||
user->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked;
|
||||
user->setBlockStatus(mtpIsTrue(d.vblocked) ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
||||
App::markPeerUpdated(user);
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -270,6 +270,7 @@ public:
|
|||
void deleteMessages(PeerData *peer, const QVector<MTPint> &ids);
|
||||
void deletedContact(UserData *user, const MTPcontacts_Link &result);
|
||||
void deleteConversation(PeerData *peer, bool deleteHistory = true);
|
||||
void deleteAndExit(ChatData *chat);
|
||||
void clearHistory(PeerData *peer);
|
||||
void deleteAllFromUser(ChannelData *channel, UserData *from);
|
||||
|
||||
|
|
|
@ -46,21 +46,21 @@ void FinishCallback() {
|
|||
SmallUpdates.clear();
|
||||
AllUpdates.clear();
|
||||
}
|
||||
ObservedEventRegistrator<PeerUpdateFlags, PeerUpdateHandler> creator(StartCallback, FinishCallback);
|
||||
ObservedEventRegistrator<PeerUpdate::Flags, PeerUpdateHandler> creator(StartCallback, FinishCallback);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace internal {
|
||||
|
||||
ConnectionId plainRegisterPeerObserver(PeerUpdateFlags events, PeerUpdateHandler &&handler) {
|
||||
ConnectionId plainRegisterPeerObserver(PeerUpdate::Flags events, PeerUpdateHandler &&handler) {
|
||||
return creator.registerObserver(events, std_::forward<PeerUpdateHandler>(handler));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
void mergePeerUpdate(PeerUpdate &mergeTo, const PeerUpdate &mergeFrom) {
|
||||
if (!(mergeTo.flags & PeerUpdateFlag::NameChanged)) {
|
||||
if (mergeFrom.flags & PeerUpdateFlag::NameChanged) {
|
||||
if (!(mergeTo.flags & PeerUpdate::Flag::NameChanged)) {
|
||||
if (mergeFrom.flags & PeerUpdate::Flag::NameChanged) {
|
||||
mergeTo.oldNames = mergeFrom.oldNames;
|
||||
mergeTo.oldNameFirstChars = mergeFrom.oldNameFirstChars;
|
||||
}
|
||||
|
|
|
@ -28,52 +28,58 @@ namespace Notify {
|
|||
// You can subscribe to them by Notify::registerPeerObserver().
|
||||
// 0x0000FFFFU for general peer updates (valid for any peer).
|
||||
// 0xFFFF0000U for specific peer updates (valid for user / chat / channel).
|
||||
|
||||
enum class PeerUpdateFlag {
|
||||
NameChanged = 0x00000001U,
|
||||
UsernameChanged = 0x00000002U,
|
||||
PhotoChanged = 0x00000004U,
|
||||
AboutChanged = 0x00000008U,
|
||||
NotificationsEnabled = 0x00000010U,
|
||||
InviteLinkChanged = 0x00000020U,
|
||||
|
||||
UserCanShareContact = 0x00010000U,
|
||||
UserIsContact = 0x00020000U,
|
||||
UserPhoneChanged = 0x00040000U,
|
||||
|
||||
ChatCanEdit = 0x00010000U,
|
||||
|
||||
ChannelAmIn = 0x00010000U,
|
||||
ChannelAmEditor = 0x00020000U,
|
||||
ChannelCanEditPhoto = 0x00040000U,
|
||||
ChannelCanAddMembers = 0x00080000U,
|
||||
};
|
||||
Q_DECLARE_FLAGS(PeerUpdateFlags, PeerUpdateFlag);
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PeerUpdateFlags);
|
||||
|
||||
struct PeerUpdate {
|
||||
PeerUpdate(PeerData *updated = nullptr) : peer(updated) {
|
||||
}
|
||||
PeerData *peer;
|
||||
PeerUpdateFlags flags = 0;
|
||||
|
||||
enum class Flag {
|
||||
NameChanged = 0x00000001U,
|
||||
UsernameChanged = 0x00000002U,
|
||||
PhotoChanged = 0x00000004U,
|
||||
AboutChanged = 0x00000008U,
|
||||
NotificationsEnabled = 0x00000010U,
|
||||
InviteLinkChanged = 0x00000020U,
|
||||
|
||||
UserCanShareContact = 0x00010000U,
|
||||
UserIsContact = 0x00020000U,
|
||||
UserPhoneChanged = 0x00040000U,
|
||||
UserIsBlocked = 0x00080000U,
|
||||
BotCommandsChanged = 0x00100000U,
|
||||
|
||||
ChatCanEdit = 0x00010000U,
|
||||
|
||||
ChannelAmIn = 0x00010000U,
|
||||
ChannelAmEditor = 0x00020000U,
|
||||
ChannelCanEditPhoto = 0x00040000U,
|
||||
ChannelCanAddMembers = 0x00080000U,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag);
|
||||
Flags flags = 0;
|
||||
|
||||
// NameChanged data
|
||||
PeerData::Names oldNames;
|
||||
PeerData::NameFirstChars oldNameFirstChars;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PeerUpdate::Flags);
|
||||
|
||||
void peerUpdatedDelayed(const PeerUpdate &update);
|
||||
inline void peerUpdatedDelayed(PeerData *peer, PeerUpdate::Flags events) {
|
||||
PeerUpdate update(peer);
|
||||
update.flags = events;
|
||||
peerUpdatedDelayed(update);
|
||||
}
|
||||
void peerUpdatedSendDelayed();
|
||||
|
||||
namespace internal {
|
||||
|
||||
using PeerUpdateHandler = Function<void, const PeerUpdate&>;
|
||||
ConnectionId plainRegisterPeerObserver(PeerUpdateFlags events, PeerUpdateHandler &&handler);
|
||||
ConnectionId plainRegisterPeerObserver(PeerUpdate::Flags events, PeerUpdateHandler &&handler);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename ObserverType>
|
||||
void registerPeerObserver(PeerUpdateFlags events, ObserverType *observer, void (ObserverType::*handler)(const PeerUpdate &)) {
|
||||
void registerPeerObserver(PeerUpdate::Flags events, ObserverType *observer, void (ObserverType::*handler)(const PeerUpdate &)) {
|
||||
auto connection = internal::plainRegisterPeerObserver(events, func(observer, handler));
|
||||
observerRegistered(observer, connection);
|
||||
}
|
||||
|
|
|
@ -22,19 +22,318 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "profile/profile_actions_widget.h"
|
||||
|
||||
#include "styles/style_profile.h"
|
||||
#include "ui/buttons/left_outline_button.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "mainwidget.h"
|
||||
#include "observer_peer.h"
|
||||
#include "apiwrap.h"
|
||||
#include "lang.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
ActionsWidget::ActionsWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_actions_section))
|
||||
{
|
||||
show();
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
ActionsWidget::ActionsWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_actions_section)) {
|
||||
auto observeEvents = UpdateFlag::ChannelAmIn | UpdateFlag::UserIsBlocked | UpdateFlag::BotCommandsChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &ActionsWidget::notifyPeerUpdated);
|
||||
|
||||
validateBlockStatus();
|
||||
refreshButtons();
|
||||
}
|
||||
|
||||
void ActionsWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
||||
if (update.peer != peer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto needFullRefresh = [&update, this]() {
|
||||
if (update.flags & UpdateFlag::BotCommandsChanged) {
|
||||
if (_hasBotHelp != hasBotCommand(qsl("help")) || _hasBotSettings != hasBotCommand(qsl("settings"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if (needFullRefresh()) {
|
||||
refreshButtons();
|
||||
} else {
|
||||
if (update.flags & UpdateFlag::ChannelAmIn) {
|
||||
refreshLeaveChannel();
|
||||
}
|
||||
if (update.flags & UpdateFlag::UserIsBlocked) {
|
||||
refreshBlockUser();
|
||||
}
|
||||
refreshVisibility();
|
||||
}
|
||||
|
||||
contentSizeUpdated();
|
||||
}
|
||||
|
||||
void ActionsWidget::validateBlockStatus() const {
|
||||
auto needFullPeer = [this]() {
|
||||
return true;
|
||||
if (auto user = peer()->asUser()) {
|
||||
if (user->blockStatus() == UserData::BlockStatus::Unknown) {
|
||||
return true;
|
||||
} else if (user->botInfo && !user->botInfo->inited) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if (needFullPeer()) {
|
||||
if (App::api()) App::api()->requestFullPeer(peer());
|
||||
}
|
||||
}
|
||||
|
||||
Ui::LeftOutlineButton *ActionsWidget::addButton(const QString &text, const char *slot, const style::OutlineButton &st, int skipHeight) {
|
||||
auto result = new Ui::LeftOutlineButton(this, text, st);
|
||||
connect(result, SIGNAL(clicked()), this, slot);
|
||||
result->show();
|
||||
|
||||
int top = buttonsBottom() + skipHeight;
|
||||
resizeButton(result, top);
|
||||
|
||||
_buttons.push_back(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
void ActionsWidget::resizeButton(Ui::LeftOutlineButton *button, int top) {
|
||||
int left = st::profileBlockTitlePosition.x();
|
||||
int availableWidth = width() - left + st::defaultLeftOutlineButton.padding.left() - st::profileBlockMarginRight;
|
||||
accumulate_min(availableWidth, st::profileBlockOneLineWidthMax);
|
||||
button->resizeToWidth(availableWidth);
|
||||
button->moveToLeft(left - st::defaultLeftOutlineButton.padding.left(), top);
|
||||
}
|
||||
|
||||
void ActionsWidget::refreshButtons() {
|
||||
auto buttons = createAndSwap(_buttons);
|
||||
for_const (auto &button, buttons) {
|
||||
delete button;
|
||||
}
|
||||
_blockUser = _leaveChannel = nullptr;
|
||||
|
||||
if (auto user = peer()->asUser()) {
|
||||
if ((_hasBotHelp = hasBotCommand(qsl("help")))) {
|
||||
addButton(lang(lng_profile_bot_help), SLOT(onBotHelp()));
|
||||
}
|
||||
if ((_hasBotSettings = hasBotCommand(qsl("settings")))) {
|
||||
addButton(lang(lng_profile_bot_settings), SLOT(onBotSettings()));
|
||||
}
|
||||
addButton(lang(lng_profile_clear_history), SLOT(onClearHistory()));
|
||||
addButton(lang(lng_profile_delete_conversation), SLOT(onDeleteConversation()));
|
||||
refreshBlockUser();
|
||||
} else if (auto chat = peer()->asChat()) {
|
||||
if (chat->amCreator()) {
|
||||
addButton(lang(lng_profile_migrate_button), SLOT(onUpgradeToSupergroup()));
|
||||
}
|
||||
addButton(lang(lng_profile_clear_history), SLOT(onClearHistory()));
|
||||
addButton(lang(lng_profile_clear_and_exit), SLOT(onDeleteConversation()));
|
||||
} else if (auto channel = peer()->asChannel()) {
|
||||
// addButton(lang(lng_profile_report), SLOT(onReport()));
|
||||
if (channel->amCreator()) {
|
||||
addButton(lang(channel->isMegagroup() ? lng_profile_delete_group : lng_profile_delete_channel), SLOT(onDeleteChannel()), st::attentionLeftOutlineButton);
|
||||
}
|
||||
refreshLeaveChannel();
|
||||
}
|
||||
|
||||
refreshVisibility();
|
||||
}
|
||||
|
||||
void ActionsWidget::refreshVisibility() {
|
||||
setVisible(!_buttons.isEmpty());
|
||||
}
|
||||
|
||||
QString ActionsWidget::getBlockButtonText() const {
|
||||
auto user = peer()->asUser();
|
||||
if (!user || (user->id == peerFromUser(MTP::authedId()))) return QString();
|
||||
if (user->blockStatus() == UserData::BlockStatus::Unknown) return QString();
|
||||
|
||||
if (user->isBlocked()) {
|
||||
if (user->botInfo) {
|
||||
return lang(lng_profile_unblock_bot);
|
||||
}
|
||||
return lang(lng_profile_unblock_user);
|
||||
} else if (user->botInfo) {
|
||||
return lang(lng_profile_block_bot);
|
||||
}
|
||||
return lang(lng_profile_block_user);
|
||||
}
|
||||
|
||||
bool ActionsWidget::hasBotCommand(const QString &command) const {
|
||||
auto user = peer()->asUser();
|
||||
if (!user || !user->botInfo || user->botInfo->commands.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for_const (auto &cmd, user->botInfo->commands) {
|
||||
if (!cmd.command.compare(command, Qt::CaseInsensitive)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActionsWidget::sendBotCommand(const QString &command) {
|
||||
auto user = peer()->asUser();
|
||||
if (user && user->botInfo && !user->botInfo->commands.isEmpty()) {
|
||||
for_const (auto &cmd, user->botInfo->commands) {
|
||||
if (!cmd.command.compare(command, Qt::CaseInsensitive)) {
|
||||
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
||||
App::sendBotCommand(user, user, '/' + cmd.command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Command was not found.
|
||||
refreshButtons();
|
||||
contentSizeUpdated();
|
||||
}
|
||||
|
||||
void ActionsWidget::refreshBlockUser() {
|
||||
if (auto user = peer()->asUser()) {
|
||||
auto blockText = getBlockButtonText();
|
||||
if (_blockUser) {
|
||||
if (blockText.isEmpty()) {
|
||||
_buttons.removeOne(_blockUser);
|
||||
delete _blockUser;
|
||||
_blockUser = nullptr;
|
||||
} else {
|
||||
_blockUser->setText(blockText);
|
||||
}
|
||||
} else if (!blockText.isEmpty()) {
|
||||
_blockUser = addButton(blockText, SLOT(onBlockUser()), st::attentionLeftOutlineButton, st::profileBlockOneLineSkip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::refreshLeaveChannel() {
|
||||
if (auto channel = peer()->asChannel()) {
|
||||
if (!channel->amCreator()) {
|
||||
if (channel->amIn() && !_leaveChannel) {
|
||||
_leaveChannel = addButton(lang(channel->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel), SLOT(onLeaveChannel()));
|
||||
} else if (!channel->amIn() && _leaveChannel) {
|
||||
_buttons.removeOne(_leaveChannel);
|
||||
delete _leaveChannel;
|
||||
_leaveChannel = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ActionsWidget::resizeGetHeight(int newWidth) {
|
||||
int newHeight = contentTop();
|
||||
for_const (auto button, _buttons) {
|
||||
resizeButton(button, button->y());
|
||||
}
|
||||
return buttonsBottom();
|
||||
}
|
||||
|
||||
return newHeight;
|
||||
int ActionsWidget::buttonsBottom() const {
|
||||
if (_buttons.isEmpty()) {
|
||||
return contentTop();
|
||||
}
|
||||
auto lastButton = _buttons.back();
|
||||
return lastButton->y() + lastButton->height();
|
||||
}
|
||||
|
||||
void ActionsWidget::onBotHelp() {
|
||||
sendBotCommand(qsl("help"));
|
||||
}
|
||||
|
||||
void ActionsWidget::onBotSettings() {
|
||||
sendBotCommand(qsl("settings"));
|
||||
}
|
||||
|
||||
void ActionsWidget::onClearHistory() {
|
||||
QString confirmation;
|
||||
if (auto user = peer()->asUser()) {
|
||||
confirmation = lng_sure_delete_history(lt_contact, App::peerName(peer()));
|
||||
} else if (auto chat = peer()->asChat()) {
|
||||
confirmation = lng_sure_delete_group_history(lt_group, App::peerName(peer()));
|
||||
}
|
||||
if (!confirmation.isEmpty()) {
|
||||
auto box = new ConfirmBox(confirmation, lang(lng_box_delete), st::attentionBoxButton);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onClearHistorySure()));
|
||||
Ui::showLayer(box);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onClearHistorySure() {
|
||||
Ui::hideLayer();
|
||||
App::main()->clearHistory(peer());
|
||||
}
|
||||
|
||||
void ActionsWidget::onDeleteConversation() {
|
||||
QString confirmation, confirmButton;
|
||||
if (auto user = peer()->asUser()) {
|
||||
confirmation = lng_sure_delete_history(lt_contact, App::peerName(peer()));
|
||||
confirmButton = lang(lng_box_delete);
|
||||
} else if (auto chat = peer()->asChat()) {
|
||||
confirmation = lng_sure_delete_and_exit(lt_group, App::peerName(peer()));
|
||||
confirmButton = lang(lng_box_leave);
|
||||
}
|
||||
if (!confirmation.isEmpty()) {
|
||||
auto box = new ConfirmBox(confirmation, confirmButton, st::attentionBoxButton);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteConversationSure()));
|
||||
Ui::showLayer(box);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onDeleteConversationSure() {
|
||||
Ui::hideLayer();
|
||||
Ui::showChatsList();
|
||||
if (auto user = peer()->asUser()) {
|
||||
App::main()->deleteConversation(peer());
|
||||
} else if (auto chat = peer()->asChat()) {
|
||||
App::main()->deleteAndExit(chat);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onBlockUser() {
|
||||
if (auto user = peer()->asUser()) {
|
||||
if (user->isBlocked()) {
|
||||
App::api()->unblockUser(user);
|
||||
} else {
|
||||
App::api()->blockUser(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onUpgradeToSupergroup() {
|
||||
if (auto chat = peer()->asChat()) {
|
||||
Ui::showLayer(new ConvertToSupergroupBox(chat));
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onDeleteChannel() {
|
||||
auto box = new ConfirmBox(lang(peer()->isMegagroup() ? lng_sure_delete_group : lng_sure_delete_channel), lang(lng_box_delete), st::attentionBoxButton);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteChannelSure()));
|
||||
Ui::showLayer(box);
|
||||
}
|
||||
|
||||
void ActionsWidget::onDeleteChannelSure() {
|
||||
Ui::hideLayer();
|
||||
Ui::showChatsList();
|
||||
if (auto chat = peer()->migrateFrom()) {
|
||||
App::main()->deleteAndExit(chat);
|
||||
}
|
||||
if (auto channel = peer()->asChannel()) {
|
||||
MTP::send(MTPchannels_DeleteChannel(channel->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::deleteChannelFailed));
|
||||
}
|
||||
}
|
||||
|
||||
void ActionsWidget::onLeaveChannel() {
|
||||
auto channel = peer()->asChannel();
|
||||
if (!channel) return;
|
||||
|
||||
auto box = new ConfirmBox(lang(channel->isMegagroup() ? lng_sure_leave_group : lng_sure_leave_channel), lang(lng_box_leave));
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onLeaveChannelSure()));
|
||||
Ui::showLayer(box);
|
||||
}
|
||||
|
||||
void ActionsWidget::onLeaveChannelSure() {
|
||||
App::api()->leaveChannel(peer()->asChannel());
|
||||
}
|
||||
|
||||
} // namespace Profile
|
||||
|
|
|
@ -21,10 +21,21 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#pragma once
|
||||
|
||||
#include "profile/profile_block_widget.h"
|
||||
#include "core/observer.h"
|
||||
|
||||
namespace Ui {
|
||||
class LeftOutlineButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Notify {
|
||||
struct PeerUpdate;
|
||||
} // namespace Notify
|
||||
|
||||
namespace Profile {
|
||||
|
||||
class ActionsWidget : public BlockWidget {
|
||||
class ActionsWidget : public BlockWidget, public Notify::Observer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionsWidget(QWidget *parent, PeerData *peer);
|
||||
|
||||
|
@ -32,6 +43,58 @@ protected:
|
|||
// Resizes content and counts natural widget height for the desired width.
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
private slots:
|
||||
void onBotHelp();
|
||||
void onBotSettings();
|
||||
void onClearHistory();
|
||||
void onClearHistorySure();
|
||||
void onDeleteConversation();
|
||||
void onDeleteConversationSure();
|
||||
void onBlockUser();
|
||||
void onUpgradeToSupergroup();
|
||||
void onDeleteChannel();
|
||||
void onDeleteChannelSure();
|
||||
void onLeaveChannel();
|
||||
void onLeaveChannelSure();
|
||||
|
||||
private:
|
||||
// Observed notifications.
|
||||
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
||||
|
||||
void validateBlockStatus() const;
|
||||
|
||||
int buttonsBottom() const;
|
||||
|
||||
void refreshButtons();
|
||||
void refreshBlockUser();
|
||||
void refreshLeaveChannel();
|
||||
void refreshVisibility();
|
||||
|
||||
Ui::LeftOutlineButton *addButton(const QString &text, const char *slot
|
||||
, const style::OutlineButton &st = st::defaultLeftOutlineButton, int skipHeight = 0);
|
||||
void resizeButton(Ui::LeftOutlineButton *button, int top);
|
||||
|
||||
QString getBlockButtonText() const;
|
||||
bool hasBotCommand(const QString &command) const;
|
||||
void sendBotCommand(const QString &command);
|
||||
|
||||
QList<Ui::LeftOutlineButton*> _buttons;
|
||||
//ChildWidget<Ui::LeftOutlineButton> _botHelp = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _botSettings = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _reportChannel = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _leaveChannel = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _deleteChannel = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _upgradeToSupergroup = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _clearHistory = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _deleteConversation = { nullptr };
|
||||
//ChildWidget<Ui::LeftOutlineButton> _blockUser = { nullptr };
|
||||
|
||||
// Hold some button pointers to update / toggle them.
|
||||
bool _hasBotHelp = false;
|
||||
bool _hasBotSettings = false;
|
||||
Ui::LeftOutlineButton *_blockUser = nullptr;
|
||||
Ui::LeftOutlineButton *_leaveChannel = nullptr;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Profile
|
||||
|
|
|
@ -65,11 +65,12 @@ private:
|
|||
|
||||
};
|
||||
|
||||
const Notify::PeerUpdateFlags ButtonsUpdateFlags = Notify::PeerUpdateFlag::UserCanShareContact
|
||||
| Notify::PeerUpdateFlag::ChatCanEdit
|
||||
| Notify::PeerUpdateFlag::ChannelCanEditPhoto
|
||||
| Notify::PeerUpdateFlag::ChannelCanAddMembers
|
||||
| Notify::PeerUpdateFlag::ChannelAmIn;
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
const auto ButtonsUpdateFlags = UpdateFlag::UserCanShareContact
|
||||
| UpdateFlag::ChatCanEdit
|
||||
| UpdateFlag::ChannelCanEditPhoto
|
||||
| UpdateFlag::ChannelCanAddMembers
|
||||
| UpdateFlag::ChannelAmIn;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -87,11 +88,12 @@ CoverWidget::CoverWidget(QWidget *parent, PeerData *peer) : TWidget(parent)
|
|||
_name.setSelectable(true);
|
||||
_name.setContextCopyText(lang(lng_profile_copy_fullname));
|
||||
|
||||
auto observeEvents = ButtonsUpdateFlags | Notify::PeerUpdateFlag::NameChanged;
|
||||
auto observeEvents = ButtonsUpdateFlags | UpdateFlag::NameChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &CoverWidget::notifyPeerUpdated);
|
||||
FileDialog::registerObserver(this, &CoverWidget::notifyFileQueryUpdated);
|
||||
|
||||
connect(_userpicButton, SIGNAL(clicked()), this, SLOT(onPhotoShow()));
|
||||
validatePhoto();
|
||||
|
||||
refreshNameText();
|
||||
refreshStatusText();
|
||||
|
@ -99,12 +101,17 @@ CoverWidget::CoverWidget(QWidget *parent, PeerData *peer) : TWidget(parent)
|
|||
refreshButtons();
|
||||
}
|
||||
|
||||
void CoverWidget::onPhotoShow() {
|
||||
PhotoData *CoverWidget::validatePhoto() const {
|
||||
PhotoData *photo = (_peer->photoId && _peer->photoId != UnknownPeerPhotoId) ? App::photo(_peer->photoId) : nullptr;
|
||||
if ((_peer->photoId == UnknownPeerPhotoId) || (_peer->photoId && !photo->date)) {
|
||||
if ((_peer->photoId == UnknownPeerPhotoId) || (_peer->photoId && (!photo || !photo->date))) {
|
||||
App::api()->requestFullPeer(_peer);
|
||||
return nullptr;
|
||||
}
|
||||
if (photo && photo->date) {
|
||||
return photo;
|
||||
}
|
||||
|
||||
void CoverWidget::onPhotoShow() {
|
||||
if (auto photo = validatePhoto()) {
|
||||
App::wnd()->showPhoto(photo, _peer);
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +330,7 @@ void CoverWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
if ((update.flags & ButtonsUpdateFlags) != 0) {
|
||||
refreshButtons();
|
||||
}
|
||||
if (update.flags & Notify::PeerUpdateFlag::NameChanged) {
|
||||
if (update.flags & UpdateFlag::NameChanged) {
|
||||
refreshNameText();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ private:
|
|||
|
||||
// Counts userpic button left offset for a new widget width.
|
||||
int countPhotoLeft(int newWidth) const;
|
||||
PhotoData *validatePhoto() const;
|
||||
|
||||
void refreshNameGeometry(int newWidth);
|
||||
void moveAndToggleButtons(int newWiddth);
|
||||
|
|
|
@ -63,10 +63,11 @@ private:
|
|||
|
||||
namespace {
|
||||
|
||||
const Notify::PeerUpdateFlags ButtonsUpdateFlags = Notify::PeerUpdateFlag::UserCanShareContact
|
||||
| Notify::PeerUpdateFlag::UserIsContact
|
||||
| Notify::PeerUpdateFlag::ChatCanEdit
|
||||
| Notify::PeerUpdateFlag::ChannelAmEditor;
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
const auto ButtonsUpdateFlags = UpdateFlag::UserCanShareContact
|
||||
| UpdateFlag::UserIsContact
|
||||
| UpdateFlag::ChatCanEdit
|
||||
| UpdateFlag::ChannelAmEditor;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -210,7 +211,7 @@ void FixedBar::onLeaveGroup() {
|
|||
void FixedBar::onLeaveGroupSure() {
|
||||
Ui::showChatsList();
|
||||
Ui::hideLayer();
|
||||
MTP::send(MTPmessages_DeleteChatUser(_peerChat->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _peer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _peer));
|
||||
App::main()->deleteAndExit(_peerChat);
|
||||
}
|
||||
|
||||
void FixedBar::resizeToWidth(int newWidth) {
|
||||
|
|
|
@ -29,11 +29,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
namespace Profile {
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
InfoWidget::InfoWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_info_section)) {
|
||||
auto observeEvents = Notify::PeerUpdateFlag::AboutChanged
|
||||
| Notify::PeerUpdateFlag::UsernameChanged
|
||||
| Notify::PeerUpdateFlag::UserPhoneChanged
|
||||
| Notify::PeerUpdateFlag::UserCanShareContact;
|
||||
auto observeEvents = UpdateFlag::AboutChanged
|
||||
| UpdateFlag::UsernameChanged
|
||||
| UpdateFlag::UserPhoneChanged
|
||||
| UpdateFlag::UserCanShareContact;
|
||||
Notify::registerPeerObserver(observeEvents, this, &InfoWidget::notifyPeerUpdated);
|
||||
|
||||
refreshLabels();
|
||||
|
@ -44,14 +46,14 @@ void InfoWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (update.flags & Notify::PeerUpdateFlag::AboutChanged) {
|
||||
if (update.flags & UpdateFlag::AboutChanged) {
|
||||
refreshAbout();
|
||||
}
|
||||
if (update.flags & Notify::PeerUpdateFlag::UsernameChanged) {
|
||||
if (update.flags & UpdateFlag::UsernameChanged) {
|
||||
refreshUsername();
|
||||
refreshChannelLink();
|
||||
}
|
||||
if (update.flags & (Notify::PeerUpdateFlag::UserPhoneChanged | Notify::PeerUpdateFlag::UserCanShareContact)) {
|
||||
if (update.flags & (UpdateFlag::UserPhoneChanged | UpdateFlag::UserCanShareContact)) {
|
||||
refreshMobileNumber();
|
||||
}
|
||||
refreshVisibility();
|
||||
|
|
|
@ -30,7 +30,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
namespace Profile {
|
||||
|
||||
InviteLinkWidget::InviteLinkWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_invite_link_section)) {
|
||||
auto observeEvents = Notify::PeerUpdateFlag::InviteLinkChanged;
|
||||
auto observeEvents = Notify::PeerUpdate::Flag::InviteLinkChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &InviteLinkWidget::notifyPeerUpdated);
|
||||
|
||||
refreshLink();
|
||||
|
@ -42,7 +42,7 @@ void InviteLinkWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (update.flags & Notify::PeerUpdateFlag::InviteLinkChanged) {
|
||||
if (update.flags & Notify::PeerUpdate::Flag::InviteLinkChanged) {
|
||||
refreshLink();
|
||||
refreshVisibility();
|
||||
|
||||
|
|
|
@ -35,18 +35,20 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
namespace Profile {
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
SettingsWidget::SettingsWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_settings_section))
|
||||
, _enableNotifications(this, lang(lng_profile_enable_notifications), true, st::defaultCheckbox) {
|
||||
connect(_enableNotifications, SIGNAL(changed()), this, SLOT(onNotificationsChange()));
|
||||
|
||||
Notify::PeerUpdateFlags observeEvents = Notify::PeerUpdateFlag::NotificationsEnabled;
|
||||
Notify::PeerUpdate::Flags observeEvents = UpdateFlag::NotificationsEnabled;
|
||||
if (auto chat = peer->asChat()) {
|
||||
if (chat->amCreator()) {
|
||||
observeEvents |= Notify::PeerUpdateFlag::ChatCanEdit | Notify::PeerUpdateFlag::InviteLinkChanged;
|
||||
observeEvents |= UpdateFlag::ChatCanEdit | UpdateFlag::InviteLinkChanged;
|
||||
}
|
||||
} else if (auto channel = peer->asChannel()) {
|
||||
if (channel->amCreator()) {
|
||||
observeEvents |= Notify::PeerUpdateFlag::UsernameChanged | Notify::PeerUpdateFlag::InviteLinkChanged;
|
||||
observeEvents |= UpdateFlag::UsernameChanged | UpdateFlag::InviteLinkChanged;
|
||||
}
|
||||
}
|
||||
Notify::registerPeerObserver(observeEvents, this, &SettingsWidget::notifyPeerUpdated);
|
||||
|
@ -62,13 +64,13 @@ void SettingsWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (update.flags & Notify::PeerUpdateFlag::NotificationsEnabled) {
|
||||
if (update.flags & UpdateFlag::NotificationsEnabled) {
|
||||
refreshEnableNotifications();
|
||||
}
|
||||
if (update.flags & (Notify::PeerUpdateFlag::ChatCanEdit | Notify::PeerUpdateFlag::UsernameChanged | Notify::PeerUpdateFlag::InviteLinkChanged)) {
|
||||
if (update.flags & (UpdateFlag::ChatCanEdit | UpdateFlag::UsernameChanged | UpdateFlag::InviteLinkChanged)) {
|
||||
refreshInviteLinkButton();
|
||||
}
|
||||
if (update.flags & (Notify::PeerUpdateFlag::ChatCanEdit)) {
|
||||
if (update.flags & (UpdateFlag::ChatCanEdit)) {
|
||||
refreshManageAdminsButton();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ UserpicButton::UserpicButton(QWidget *parent, PeerData *peer) : Button(parent),
|
|||
_userpic = prepareUserpicPixmap();
|
||||
}
|
||||
|
||||
Notify::registerPeerObserver(Notify::PeerUpdateFlag::PhotoChanged, this, &UserpicButton::notifyPeerUpdated);
|
||||
Notify::registerPeerObserver(Notify::PeerUpdate::Flag::PhotoChanged, this, &UserpicButton::notifyPeerUpdated);
|
||||
FileDownload::registerImageLoadedObserver(this, &UserpicButton::notifyImageLoaded);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ ProfileInner::ProfileInner(ProfileWidget *profile, PeerData *peer) : TWidget(0)
|
|||
, _convertToSupergroup(this, lang(lng_profile_convert_button))
|
||||
, _clearHistory(this, lang(lng_profile_clear_history))
|
||||
, _deleteConversation(this, lang(_peer->isUser() ? lng_profile_delete_conversation : (_peer->isChat() ? lng_profile_clear_and_exit : (_peer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel))))
|
||||
, _wasBlocked(_peerUser ? _peerUser->blocked : UserBlockUnknown)
|
||||
//, _wasBlocked(_peerUser ? _peerUser->blocked : UserBlockUnknown)
|
||||
, _blockRequest(0)
|
||||
, _blockUser(this, lang((_peerUser && _peerUser->botInfo) ? lng_profile_block_bot : lng_profile_block_user), st::btnRedLink)
|
||||
, _deleteChannel(this, lang(_peer->isMegagroup() ? lng_profile_delete_group : lng_profile_delete_channel), st::btnRedLink)
|
||||
|
@ -112,17 +112,17 @@ ProfileInner::ProfileInner(ProfileWidget *profile, PeerData *peer) : TWidget(0)
|
|||
connect(App::api(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*)));
|
||||
|
||||
if (_peerUser) {
|
||||
if (_peerUser->blocked == UserIsBlocked) {
|
||||
_blockUser.setText(lang(_peerUser->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user));
|
||||
}
|
||||
//if (_peerUser->blocked == UserIsBlocked) {
|
||||
// _blockUser.setText(lang(_peerUser->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user));
|
||||
//}
|
||||
_phoneText = App::formatPhone(_peerUser->phone().isEmpty() ? App::phoneFromSharedContact(peerToUser(_peerUser->id)) : _peerUser->phone());
|
||||
PhotoData *userPhoto = (_peerUser->photoId && _peerUser->photoId != UnknownPeerPhotoId) ? App::photo(_peerUser->photoId) : 0;
|
||||
if (userPhoto && userPhoto->date) {
|
||||
_photoLink.reset(new PhotoOpenClickHandler(userPhoto, _peer));
|
||||
}
|
||||
if ((_peerUser->botInfo && !_peerUser->botInfo->inited) || (_peerUser->photoId == UnknownPeerPhotoId) || (_peerUser->photoId && !userPhoto->date) || (_peerUser->blocked == UserBlockUnknown)) {
|
||||
if (App::api()) App::api()->requestFullPeer(_peer);
|
||||
}
|
||||
//if ((_peerUser->botInfo && !_peerUser->botInfo->inited) || (_peerUser->photoId == UnknownPeerPhotoId) || (_peerUser->photoId && !userPhoto->date) || (_peerUser->blocked == UserBlockUnknown)) {
|
||||
// if (App::api()) App::api()->requestFullPeer(_peer);
|
||||
//}
|
||||
} else if (_peerChat) {
|
||||
PhotoData *chatPhoto = (_peerChat->photoId && _peerChat->photoId != UnknownPeerPhotoId) ? App::photo(_peerChat->photoId) : 0;
|
||||
if (chatPhoto && chatPhoto->date) {
|
||||
|
@ -370,26 +370,26 @@ void ProfileInner::onDeleteChannelSure() {
|
|||
}
|
||||
void ProfileInner::onBlockUser() {
|
||||
if (!_peerUser || _blockRequest) return;
|
||||
if (_peerUser->blocked == UserIsBlocked) {
|
||||
_blockRequest = MTP::send(MTPcontacts_Unblock(_peerUser->inputUser), rpcDone(&ProfileInner::blockDone, false), rpcFail(&ProfileInner::blockFail));
|
||||
} else {
|
||||
_blockRequest = MTP::send(MTPcontacts_Block(_peerUser->inputUser), rpcDone(&ProfileInner::blockDone, true), rpcFail(&ProfileInner::blockFail));
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileInner::blockDone(bool blocked, const MTPBool &result) {
|
||||
_blockRequest = 0;
|
||||
if (!_peerUser) return;
|
||||
_peerUser->blocked = blocked ? UserIsBlocked : UserIsNotBlocked;
|
||||
emit App::main()->peerUpdated(_peerUser);
|
||||
}
|
||||
|
||||
bool ProfileInner::blockFail(const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
_blockRequest = 0;
|
||||
return false;
|
||||
// if (_peerUser->blocked == UserIsBlocked) {
|
||||
// _blockRequest = MTP::send(MTPcontacts_Unblock(_peerUser->inputUser), rpcDone(&ProfileInner::blockDone, false), rpcFail(&ProfileInner::blockFail));
|
||||
// } else {
|
||||
// _blockRequest = MTP::send(MTPcontacts_Block(_peerUser->inputUser), rpcDone(&ProfileInner::blockDone, true), rpcFail(&ProfileInner::blockFail));
|
||||
// }
|
||||
}
|
||||
//
|
||||
//void ProfileInner::blockDone(bool blocked, const MTPBool &result) {
|
||||
// _blockRequest = 0;
|
||||
// if (!_peerUser) return;
|
||||
// _peerUser->blocked = blocked ? UserIsBlocked : UserIsNotBlocked;
|
||||
// emit App::main()->peerUpdated(_peerUser);
|
||||
//}
|
||||
//
|
||||
//bool ProfileInner::blockFail(const RPCError &error) {
|
||||
// if (MTP::isDefaultHandledError(error)) return false;
|
||||
//
|
||||
// _blockRequest = 0;
|
||||
// return false;
|
||||
//}
|
||||
|
||||
void ProfileInner::onAddParticipant() {
|
||||
if (_peerChat) {
|
||||
|
@ -609,10 +609,10 @@ void ProfileInner::peerUpdated(PeerData *data) {
|
|||
if (_peerUser) {
|
||||
_phoneText = App::formatPhone(_peerUser->phone().isEmpty() ? App::phoneFromSharedContact(peerToUser(_peerUser->id)) : _peerUser->phone());
|
||||
if (_peerUser->photoId && _peerUser->photoId != UnknownPeerPhotoId) photo = App::photo(_peerUser->photoId);
|
||||
if (_wasBlocked != _peerUser->blocked) {
|
||||
_wasBlocked = _peerUser->blocked;
|
||||
_blockUser.setText(lang((_peerUser->blocked == UserIsBlocked) ? (_peerUser->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_peerUser->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
||||
}
|
||||
//if (_wasBlocked != _peerUser->blocked) {
|
||||
// _wasBlocked = _peerUser->blocked;
|
||||
// _blockUser.setText(lang((_peerUser->blocked == UserIsBlocked) ? (_peerUser->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (_peerUser->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
||||
//}
|
||||
} else if (_peerChat) {
|
||||
if (_peerChat->photoId && _peerChat->photoId != UnknownPeerPhotoId) photo = App::photo(_peerChat->photoId);
|
||||
_admins.setText(lng_channel_admins_link(lt_count, _peerChat->adminsEnabled() ? (_peerChat->admins.size() + 1) : 0));
|
||||
|
|
|
@ -192,7 +192,7 @@ private:
|
|||
|
||||
// actions
|
||||
LinkButton _searchInPeer, _convertToSupergroup, _clearHistory, _deleteConversation;
|
||||
UserBlockedStatus _wasBlocked;
|
||||
//UserBlockedStatus _wasBlocked;
|
||||
mtpRequestId _blockRequest;
|
||||
LinkButton _blockUser, _deleteChannel;
|
||||
bool canDeleteChannel() const;
|
||||
|
|
|
@ -206,7 +206,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
, _telegramFAQ(this, lang(lng_settings_faq))
|
||||
, _logOut(this, lang(lng_settings_logout), st::btnRedLink)
|
||||
, _supportGetRequest(0) {
|
||||
Notify::registerPeerObserver(Notify::PeerUpdateFlag::UsernameChanged, this, &SettingsInner::notifyPeerUpdated);
|
||||
Notify::registerPeerObserver(Notify::PeerUpdate::Flag::UsernameChanged, this, &SettingsInner::notifyPeerUpdated);
|
||||
|
||||
if (self()) {
|
||||
self()->loadUserpic();
|
||||
|
@ -354,7 +354,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
|
||||
void SettingsInner::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
||||
if (update.peer == App::self()) {
|
||||
if (update.flags & Notify::PeerUpdateFlag::UsernameChanged) {
|
||||
if (update.flags & Notify::PeerUpdate::Flag::UsernameChanged) {
|
||||
usernameChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ ImagePtr channelDefPhoto(int index) {
|
|||
return channelDefPhotos[index];
|
||||
}
|
||||
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
NotifySettings globalNotifyAll, globalNotifyUsers, globalNotifyChats;
|
||||
NotifySettingsPtr globalNotifyAllPtr = UnknownNotifySettings, globalNotifyUsersPtr = UnknownNotifySettings, globalNotifyChatsPtr = UnknownNotifySettings;
|
||||
|
||||
|
@ -126,14 +128,14 @@ void PeerData::updateNameDelayed(const QString &newName, const QString &newNameO
|
|||
nameText.setText(st::msgNameFont, name, _textNameOptions);
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags |= Notify::PeerUpdateFlag::NameChanged;
|
||||
update.flags |= UpdateFlag::NameChanged;
|
||||
update.oldNames = names;
|
||||
update.oldNameFirstChars = chars;
|
||||
|
||||
if (isUser()) {
|
||||
if (asUser()->username != newUsername) {
|
||||
asUser()->username = newUsername;
|
||||
update.flags |= Notify::PeerUpdateFlag::UsernameChanged;
|
||||
update.flags |= UpdateFlag::UsernameChanged;
|
||||
}
|
||||
asUser()->setNameOrPhone(newNameOrPhone);
|
||||
} else if (isChannel()) {
|
||||
|
@ -144,7 +146,7 @@ void PeerData::updateNameDelayed(const QString &newName, const QString &newNameO
|
|||
} else {
|
||||
asChannel()->flags |= MTPDchannel::Flag::f_username;
|
||||
}
|
||||
update.flags |= Notify::PeerUpdateFlag::UsernameChanged;
|
||||
update.flags |= UpdateFlag::UsernameChanged;
|
||||
}
|
||||
}
|
||||
fillNames();
|
||||
|
@ -233,10 +235,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
|
|||
if (App::main()) {
|
||||
emit App::main()->peerPhotoChanged(this);
|
||||
}
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags = Notify::PeerUpdateFlag::PhotoChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,11 +265,8 @@ bool UserData::setAbout(const QString &newAbout) {
|
|||
if (_about == newAbout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_about = newAbout;
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags |= Notify::PeerUpdateFlag::AboutChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::AboutChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -395,6 +391,13 @@ void UserData::madeAction() {
|
|||
}
|
||||
}
|
||||
|
||||
void UserData::setBlockStatus(BlockStatus blockStatus) {
|
||||
if (blockStatus != _blockStatus) {
|
||||
_blockStatus = blockStatus;
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserIsBlocked);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see Local::readPeer as well
|
||||
PhotoId newPhotoId = photoId;
|
||||
ImagePtr newPhoto = _userpic;
|
||||
|
@ -420,11 +423,10 @@ void ChatData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see Loc
|
|||
photoId = newPhotoId;
|
||||
setUserpic(newPhoto);
|
||||
photoLoc = newPhotoLoc;
|
||||
emit App::main()->peerPhotoChanged(this);
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags = Notify::PeerUpdateFlag::PhotoChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
if (App::main()) {
|
||||
emit App::main()->peerPhotoChanged(this);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,10 +442,7 @@ void ChatData::setNameDelayed(const QString &newName) {
|
|||
void ChatData::setInviteLink(const QString &newInviteLink) {
|
||||
if (newInviteLink != _inviteLink) {
|
||||
_inviteLink = newInviteLink;
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags |= Notify::PeerUpdateFlag::InviteLinkChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,11 +471,10 @@ void ChannelData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see
|
|||
photoId = newPhotoId;
|
||||
setUserpic(newPhoto);
|
||||
photoLoc = newPhotoLoc;
|
||||
if (App::main()) emit App::main()->peerPhotoChanged(this);
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags = Notify::PeerUpdateFlag::PhotoChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
if (App::main()) {
|
||||
emit App::main()->peerPhotoChanged(this);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,21 +504,15 @@ bool ChannelData::setAbout(const QString &newAbout) {
|
|||
if (_about == newAbout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_about = newAbout;
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags |= Notify::PeerUpdateFlag::AboutChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::AboutChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChannelData::setInviteLink(const QString &newInviteLink) {
|
||||
if (newInviteLink != _inviteLink) {
|
||||
_inviteLink = newInviteLink;
|
||||
|
||||
Notify::PeerUpdate update(this);
|
||||
update.flags |= Notify::PeerUpdateFlag::InviteLinkChanged;
|
||||
Notify::peerUpdatedDelayed(update);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -388,12 +388,6 @@ struct BotInfo {
|
|||
PeerId inlineReturnPeerId = 0;
|
||||
};
|
||||
|
||||
enum UserBlockedStatus {
|
||||
UserBlockUnknown = 0,
|
||||
UserIsBlocked,
|
||||
UserIsNotBlocked,
|
||||
};
|
||||
|
||||
class PhotoData;
|
||||
class UserData : public PeerData {
|
||||
public:
|
||||
|
@ -457,7 +451,19 @@ public:
|
|||
Text phoneText;
|
||||
TimeId onlineTill = 0;
|
||||
int32 contact = -1; // -1 - not contact, cant add (self, empty, deleted, foreign), 0 - not contact, can add (request), 1 - contact
|
||||
UserBlockedStatus blocked = UserBlockUnknown;
|
||||
|
||||
enum class BlockStatus {
|
||||
Unknown,
|
||||
Blocked,
|
||||
NotBlocked,
|
||||
};
|
||||
BlockStatus blockStatus() const {
|
||||
return _blockStatus;
|
||||
}
|
||||
bool isBlocked() const {
|
||||
return (blockStatus() == BlockStatus::Blocked);
|
||||
}
|
||||
void setBlockStatus(BlockStatus blockStatus);
|
||||
|
||||
typedef QList<PhotoData*> Photos;
|
||||
Photos photos;
|
||||
|
@ -481,6 +487,7 @@ private:
|
|||
QString _restrictionReason;
|
||||
QString _about;
|
||||
QString _phone;
|
||||
BlockStatus _blockStatus = BlockStatus::Unknown;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ LeftOutlineButton::LeftOutlineButton(QWidget *parent, const QString &text, const
|
|||
, _text(text)
|
||||
, _fullText(text)
|
||||
, _textWidth(st.font->width(_text))
|
||||
, _fullTextWidth(_textWidth)
|
||||
, _st(st) {
|
||||
resizeToWidth(_textWidth + _st.padding.left() + _st.padding.right());
|
||||
|
||||
|
@ -36,13 +37,14 @@ LeftOutlineButton::LeftOutlineButton(QWidget *parent, const QString &text, const
|
|||
void LeftOutlineButton::setText(const QString &text) {
|
||||
_text = text;
|
||||
_fullText = text;
|
||||
_textWidth = _st.font->width(_text);
|
||||
_fullTextWidth = _textWidth = _st.font->width(_text);
|
||||
resizeToWidth(width());
|
||||
update();
|
||||
}
|
||||
|
||||
void LeftOutlineButton::resizeToWidth(int newWidth) {
|
||||
int availableWidth = qMax(newWidth - _st.padding.left() - _st.padding.right(), 1);
|
||||
if (availableWidth < _textWidth) {
|
||||
if ((availableWidth < _fullTextWidth) || (_textWidth < availableWidth)) {
|
||||
_text = _st.font->elided(_fullText, availableWidth);
|
||||
_textWidth = _st.font->width(_text);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
|
||||
private:
|
||||
QString _text, _fullText;
|
||||
int _textWidth;
|
||||
int _textWidth, _fullTextWidth;
|
||||
|
||||
const style::OutlineButton &_st;
|
||||
|
||||
|
|
|
@ -390,6 +390,10 @@
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Debug\moc_profile_actions_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Debug\moc_profile_block_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
@ -709,6 +713,10 @@
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Deploy\moc_profile_actions_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Deploy\moc_profile_block_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
@ -1054,6 +1062,10 @@
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Release\moc_profile_actions_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Release\moc_profile_block_widget.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
|
@ -1581,7 +1593,20 @@
|
|||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/profile/profile_block_widget.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore\5.6.0\QtCore" "-I$(QTDIR)\include\QtGui\5.6.0\QtGui" "-I.\..\..\Libraries\breakpad\src" "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\ThirdParty\minizip" "-I.\..\..\Libraries\openssl\Release\include"</Command>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="SourceFiles\profile\profile_actions_widget.h" />
|
||||
<CustomBuild Include="SourceFiles\profile\profile_actions_widget.h">
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">Moc%27ing profile_actions_widget.h...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/profile/profile_actions_widget.h" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore\5.6.0\QtCore" "-I$(QTDIR)\include\QtGui\5.6.0\QtGui" "-I.\..\..\Libraries\breakpad\src" "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\ThirdParty\minizip" "-I.\..\..\Libraries\openssl\Release\include"</Command>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing profile_actions_widget.h...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/profile/profile_actions_widget.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore\5.6.0\QtCore" "-I$(QTDIR)\include\QtGui\5.6.0\QtGui" "-I.\..\..\Libraries\breakpad\src" "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\ThirdParty\minizip" "-I.\..\..\Libraries\openssl_debug\Debug\include"</Command>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing profile_actions_widget.h...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/profile/profile_actions_widget.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore\5.6.0\QtCore" "-I$(QTDIR)\include\QtGui\5.6.0\QtGui" "-I.\..\..\Libraries\breakpad\src" "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\ThirdParty\minizip" "-I.\..\..\Libraries\openssl\Release\include"</Command>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="SourceFiles\profile\profile_cover_drop_area.h" />
|
||||
<ClInclude Include="SourceFiles\profile\profile_info_widget.h" />
|
||||
<ClInclude Include="SourceFiles\profile\profile_invite_link_widget.h" />
|
||||
|
|
|
@ -1245,6 +1245,15 @@
|
|||
<ClCompile Include="GeneratedFiles\Release\moc_profile_settings_widget.cpp">
|
||||
<Filter>GeneratedFiles\Release</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Deploy\moc_profile_actions_widget.cpp">
|
||||
<Filter>GeneratedFiles\Deploy</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Debug\moc_profile_actions_widget.cpp">
|
||||
<Filter>GeneratedFiles\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeneratedFiles\Release\moc_profile_actions_widget.cpp">
|
||||
<Filter>GeneratedFiles\Release</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="SourceFiles\stdafx.h">
|
||||
|
@ -1451,9 +1460,6 @@
|
|||
<ClInclude Include="SourceFiles\profile\profile_info_widget.h">
|
||||
<Filter>SourceFiles\profile</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SourceFiles\profile\profile_actions_widget.h">
|
||||
<Filter>SourceFiles\profile</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SourceFiles\profile\profile_invite_link_widget.h">
|
||||
<Filter>SourceFiles\profile</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1732,6 +1738,9 @@
|
|||
<CustomBuild Include="SourceFiles\profile\profile_settings_widget.h">
|
||||
<Filter>SourceFiles\profile</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="SourceFiles\profile\profile_actions_widget.h">
|
||||
<Filter>SourceFiles\profile</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\langs\lang_it.strings">
|
||||
|
|
Loading…
Reference in New Issue