2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class ProfileWidget;
|
2015-12-08 12:33:37 +00:00
|
|
|
class ProfileInner : public TWidget, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-11-16 16:04:37 +00:00
|
|
|
ProfileInner(ProfileWidget *profile, ScrollArea *scroll, PeerData *peer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-06-17 19:43:03 +00:00
|
|
|
void start();
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void peerUsernameChanged();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
bool event(QEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
|
|
|
void enterEvent(QEvent *e);
|
|
|
|
void leaveEvent(QEvent *e);
|
|
|
|
void leaveToChildEvent(QEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_photo(float64 ms, bool timer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
PeerData *peer() const;
|
2014-08-15 11:19:32 +00:00
|
|
|
bool allMediaShown() const;
|
2016-02-28 12:36:23 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
void reorderParticipants();
|
|
|
|
|
|
|
|
void saveError(const QString &str = QString());
|
|
|
|
|
|
|
|
void loadProfilePhotos(int32 yFrom);
|
|
|
|
|
|
|
|
void updateNotifySettings();
|
2015-09-06 10:17:09 +00:00
|
|
|
int32 mediaOverviewUpdated(PeerData *peer, MediaOverviewType type); // returns scroll shift
|
|
|
|
|
|
|
|
void requestHeight(int32 newHeight);
|
2015-09-21 20:57:42 +00:00
|
|
|
int32 countMinHeight();
|
2015-09-06 10:17:09 +00:00
|
|
|
void allowDecreaseHeight(int32 decreaseBy);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
~ProfileInner();
|
2016-02-28 12:36:23 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void peerUpdated(PeerData *data);
|
|
|
|
void updateSelected();
|
|
|
|
|
|
|
|
void openContextImage();
|
|
|
|
void deleteContextImage();
|
|
|
|
|
|
|
|
void onShareContact();
|
2015-06-15 17:19:24 +00:00
|
|
|
void onInviteToGroup();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onSendMessage();
|
2015-08-04 15:01:47 +00:00
|
|
|
void onSearchInPeer();
|
2016-03-04 22:04:15 +00:00
|
|
|
void onConvertToSupergroup();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onEnableNotifications();
|
|
|
|
|
|
|
|
void onClearHistory();
|
|
|
|
void onClearHistorySure();
|
2015-08-04 15:01:47 +00:00
|
|
|
void onDeleteConversation();
|
|
|
|
void onDeleteConversationSure();
|
2015-09-21 20:57:42 +00:00
|
|
|
void onDeleteChannel();
|
|
|
|
void onDeleteChannelSure();
|
2015-08-12 18:01:32 +00:00
|
|
|
void onBlockUser();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onAddParticipant();
|
2015-11-06 17:48:49 +00:00
|
|
|
void onMigrate();
|
|
|
|
void onMigrateSure();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void onUpdatePhoto();
|
|
|
|
void onUpdatePhotoCancel();
|
|
|
|
|
|
|
|
void onPhotoUpdateDone(PeerId peer);
|
|
|
|
void onPhotoUpdateFail(PeerId peer);
|
|
|
|
void onPhotoUpdateStart();
|
|
|
|
|
|
|
|
void onKickConfirm();
|
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
void onMediaPhotos();
|
|
|
|
void onMediaVideos();
|
2015-10-23 19:24:05 +00:00
|
|
|
void onMediaSongs();
|
2014-08-15 11:19:32 +00:00
|
|
|
void onMediaDocuments();
|
|
|
|
void onMediaAudios();
|
2015-08-28 15:15:56 +00:00
|
|
|
void onMediaLinks();
|
2014-08-15 11:19:32 +00:00
|
|
|
|
2014-08-22 14:55:23 +00:00
|
|
|
void onMenuDestroy(QObject *obj);
|
|
|
|
void onCopyPhone();
|
2015-03-25 15:42:15 +00:00
|
|
|
void onCopyUsername();
|
2014-08-22 14:55:23 +00:00
|
|
|
|
2015-04-30 13:53:36 +00:00
|
|
|
void onInvitationLink();
|
|
|
|
void onCreateInvitationLink();
|
|
|
|
void onCreateInvitationLinkSure();
|
2015-09-21 20:57:42 +00:00
|
|
|
void onPublicLink();
|
2015-04-30 13:53:36 +00:00
|
|
|
|
2015-09-23 17:43:08 +00:00
|
|
|
void onMembers();
|
|
|
|
void onAdmins();
|
|
|
|
|
2015-06-15 17:19:24 +00:00
|
|
|
void onFullPeerUpdated(PeerData *peer);
|
|
|
|
|
|
|
|
void onBotSettings();
|
|
|
|
void onBotHelp();
|
2016-03-10 10:15:21 +00:00
|
|
|
void onPinnedMessage();
|
2015-04-30 13:53:36 +00:00
|
|
|
|
2016-03-04 15:34:46 +00:00
|
|
|
void onUpdateDelayed();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void showAll();
|
2015-04-30 13:53:36 +00:00
|
|
|
void updateInvitationLink();
|
2015-06-15 17:19:24 +00:00
|
|
|
void updateBotLinksVisibility();
|
2016-03-10 10:15:21 +00:00
|
|
|
void updatePinnedMessageVisibility();
|
2015-04-30 13:53:36 +00:00
|
|
|
|
|
|
|
void chatInviteDone(const MTPExportedChatInvite &result);
|
2015-09-06 10:17:09 +00:00
|
|
|
bool updateMediaLinks(int32 *addToScroll = 0); // returns if anything changed
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-11-06 17:48:49 +00:00
|
|
|
void migrateDone(const MTPUpdates &updates);
|
|
|
|
bool migrateFail(const RPCError &error);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
ProfileWidget *_profile;
|
|
|
|
ScrollArea *_scroll;
|
|
|
|
|
|
|
|
PeerData *_peer;
|
|
|
|
UserData *_peerUser;
|
|
|
|
ChatData *_peerChat;
|
2015-09-03 10:48:40 +00:00
|
|
|
ChannelData *_peerChannel;
|
2015-11-16 16:04:37 +00:00
|
|
|
History *_migrated, *_history;
|
2015-09-21 20:57:42 +00:00
|
|
|
bool _amCreator;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-06 10:17:09 +00:00
|
|
|
int32 _width, _left, _addToHeight;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// profile
|
|
|
|
Text _nameText;
|
|
|
|
QString _nameCache;
|
|
|
|
QString _phoneText;
|
|
|
|
TextLinkPtr _photoLink;
|
|
|
|
FlatButton _uploadPhoto, _addParticipant;
|
2015-06-15 17:19:24 +00:00
|
|
|
FlatButton _sendMessage, _shareContact, _inviteToGroup;
|
2015-04-30 13:53:36 +00:00
|
|
|
LinkButton _cancelPhoto, _createInvitationLink, _invitationLink;
|
|
|
|
QString _invitationText;
|
2016-03-10 10:15:21 +00:00
|
|
|
LinkButton _botSettings, _botHelp, _pinnedMessage, _username, _members, _admins;
|
2015-06-15 17:19:24 +00:00
|
|
|
|
|
|
|
Text _about;
|
|
|
|
int32 _aboutTop, _aboutHeight;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
anim::fvalue a_photoOver;
|
|
|
|
Animation _a_photo;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool _photoOver;
|
|
|
|
|
|
|
|
QString _errorText;
|
|
|
|
|
2015-11-06 17:48:49 +00:00
|
|
|
// migrate to megagroup
|
2015-11-24 11:01:53 +00:00
|
|
|
bool _showMigrate, _forceShowMigrate;
|
2015-11-06 17:48:49 +00:00
|
|
|
Text _aboutMigrate;
|
|
|
|
FlatButton _migrate;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// settings
|
|
|
|
FlatCheckbox _enableNotifications;
|
2015-08-04 15:01:47 +00:00
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
// shared media
|
2015-09-06 10:17:09 +00:00
|
|
|
bool _notAllMediaLoaded;
|
2015-08-28 15:15:56 +00:00
|
|
|
LinkButton *_mediaButtons[OverviewCount];
|
2014-08-15 11:19:32 +00:00
|
|
|
QString overviewLinkText(int32 type, int32 count);
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
// actions
|
2016-03-04 22:04:15 +00:00
|
|
|
LinkButton _searchInPeer, _convertToSupergroup, _clearHistory, _deleteConversation;
|
2015-08-12 18:01:32 +00:00
|
|
|
UserBlockedStatus _wasBlocked;
|
|
|
|
mtpRequestId _blockRequest;
|
2015-09-21 20:57:42 +00:00
|
|
|
LinkButton _blockUser, _deleteChannel;
|
2016-03-23 16:50:40 +00:00
|
|
|
bool canDeleteChannel() const;
|
2015-08-12 18:01:32 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// participants
|
|
|
|
int32 _pHeight;
|
|
|
|
int32 _kickWidth, _selectedRow, _lastPreload;
|
|
|
|
uint64 _contactId;
|
|
|
|
UserData *_kickOver, *_kickDown, *_kickConfirm;
|
|
|
|
|
2016-03-04 14:01:39 +00:00
|
|
|
struct ParticipantData {
|
2014-05-30 08:53:19 +00:00
|
|
|
Text name;
|
|
|
|
QString online;
|
2016-03-04 14:01:39 +00:00
|
|
|
bool cankick, admin;
|
|
|
|
};
|
2014-05-30 08:53:19 +00:00
|
|
|
typedef QVector<UserData*> Participants;
|
|
|
|
Participants _participants;
|
|
|
|
typedef QVector<ParticipantData*> ParticipantsData;
|
|
|
|
ParticipantsData _participantsData;
|
|
|
|
|
|
|
|
QPoint _lastPos;
|
|
|
|
|
2014-08-22 14:55:23 +00:00
|
|
|
QString _onlineText;
|
2015-10-23 16:15:24 +00:00
|
|
|
PopupMenu *_menu;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-11-24 11:01:53 +00:00
|
|
|
QString _secretText;
|
|
|
|
|
2016-03-04 15:34:46 +00:00
|
|
|
bool _updateDelayed;
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void blockDone(bool blocked, const MTPBool &result);
|
|
|
|
bool blockFail(const RPCError &error);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
class ProfileWidget : public TWidget, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-11-16 16:04:37 +00:00
|
|
|
ProfileWidget(QWidget *parent, PeerData *peer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-01 02:36:23 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
|
|
|
|
void topBarClick();
|
|
|
|
|
|
|
|
PeerData *peer() const;
|
2014-08-15 11:19:32 +00:00
|
|
|
int32 lastScrollTop() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-06 10:17:09 +00:00
|
|
|
void animShow(const QPixmap &oldAnimCache, const QPixmap &bgAnimTopBarCache, bool back = false, int32 lastScrollTop = -1);
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_show(float64 ms, bool timer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void peerUsernameChanged();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateNotifySettings();
|
2015-07-03 08:47:16 +00:00
|
|
|
void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
|
2016-02-08 14:54:55 +00:00
|
|
|
void updateAdaptiveLayout();
|
2015-10-17 14:52:26 +00:00
|
|
|
|
2016-02-28 12:36:23 +00:00
|
|
|
void grabStart() override {
|
2015-10-17 14:52:26 +00:00
|
|
|
_sideShadow.hide();
|
|
|
|
_inGrab = true;
|
|
|
|
resizeEvent(0);
|
|
|
|
}
|
2016-02-28 12:36:23 +00:00
|
|
|
void grabFinish() override {
|
2016-02-08 14:54:55 +00:00
|
|
|
_sideShadow.setVisible(!Adaptive::OneColumn());
|
2015-10-17 14:52:26 +00:00
|
|
|
_inGrab = false;
|
|
|
|
resizeEvent(0);
|
|
|
|
}
|
2016-02-28 12:36:23 +00:00
|
|
|
void rpcClear() override {
|
|
|
|
_inner.rpcClear();
|
|
|
|
RPCSender::rpcClear();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-06-17 19:43:03 +00:00
|
|
|
void clear();
|
2014-05-30 08:53:19 +00:00
|
|
|
~ProfileWidget();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void activate();
|
|
|
|
void onScroll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
ScrollArea _scroll;
|
|
|
|
ProfileInner _inner;
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
Animation _a_show;
|
|
|
|
QPixmap _cacheUnder, _cacheOver, _cacheTopBarUnder, _cacheTopBarOver;
|
|
|
|
anim::ivalue a_coordUnder, a_coordOver;
|
|
|
|
anim::fvalue a_shadow;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 08:31:48 +00:00
|
|
|
PlainShadow _sideShadow, _topShadow;
|
2015-10-17 14:52:26 +00:00
|
|
|
bool _inGrab;
|
2015-10-17 08:31:48 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|