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.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class ProfileWidget;
|
|
|
|
class ProfileInner : public TWidget, public RPCSender, public Animated {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const PeerData *peer);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
bool animStep(float64 ms);
|
|
|
|
|
|
|
|
PeerData *peer() const;
|
2014-08-15 11:19:32 +00:00
|
|
|
bool allMediaShown() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void gotFullUser(const MTPUserFull &user);
|
|
|
|
void gotFullChat(const MTPmessages_ChatFull &res);
|
|
|
|
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
void reorderParticipants();
|
|
|
|
|
|
|
|
void saveError(const QString &str = QString());
|
|
|
|
|
|
|
|
void loadProfilePhotos(int32 yFrom);
|
|
|
|
|
|
|
|
void updateNotifySettings();
|
2014-08-15 11:19:32 +00:00
|
|
|
void mediaOverviewUpdated(PeerData *peer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
~ProfileInner();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void peerUpdated(PeerData *data);
|
|
|
|
void updateSelected();
|
|
|
|
|
|
|
|
void openContextImage();
|
|
|
|
void deleteContextImage();
|
|
|
|
|
|
|
|
void onShareContact();
|
|
|
|
void onSendMessage();
|
|
|
|
void onEnableNotifications();
|
|
|
|
|
|
|
|
void onClearHistory();
|
|
|
|
void onClearHistorySure();
|
|
|
|
void onAddParticipant();
|
|
|
|
|
|
|
|
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 onMediaShowAll();
|
|
|
|
void onMediaPhotos();
|
|
|
|
void onMediaVideos();
|
|
|
|
void onMediaDocuments();
|
|
|
|
void onMediaAudios();
|
|
|
|
|
2014-08-22 14:55:23 +00:00
|
|
|
void onMenuDestroy(QObject *obj);
|
|
|
|
void onCopyPhone();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void showAll();
|
|
|
|
|
|
|
|
ProfileWidget *_profile;
|
|
|
|
ScrollArea *_scroll;
|
|
|
|
|
|
|
|
PeerData *_peer;
|
|
|
|
UserData *_peerUser;
|
|
|
|
ChatData *_peerChat;
|
2014-08-15 11:19:32 +00:00
|
|
|
History *_hist;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool _chatAdmin;
|
|
|
|
|
|
|
|
int32 _width, _left;
|
|
|
|
|
|
|
|
// profile
|
|
|
|
Text _nameText;
|
|
|
|
QString _nameCache;
|
|
|
|
QString _phoneText;
|
|
|
|
TextLinkPtr _photoLink;
|
|
|
|
FlatButton _uploadPhoto, _addParticipant;
|
|
|
|
FlatButton _sendMessage, _shareContact;
|
|
|
|
LinkButton _cancelPhoto;
|
|
|
|
|
|
|
|
anim::fvalue a_photo;
|
|
|
|
bool _photoOver;
|
|
|
|
|
|
|
|
QString _errorText;
|
|
|
|
|
|
|
|
// settings
|
|
|
|
FlatCheckbox _enableNotifications;
|
|
|
|
LinkButton _clearHistory;
|
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
// shared media
|
|
|
|
bool _allMediaTypes;
|
|
|
|
LinkButton _mediaShowAll, _mediaPhotos, _mediaVideos, _mediaDocuments, _mediaAudios;
|
|
|
|
LinkButton *_mediaLinks[OverviewCount];
|
|
|
|
QString overviewLinkText(int32 type, int32 count);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// participants
|
|
|
|
int32 _pHeight;
|
|
|
|
int32 _kickWidth, _selectedRow, _lastPreload;
|
|
|
|
uint64 _contactId;
|
|
|
|
UserData *_kickOver, *_kickDown, *_kickConfirm;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Text name;
|
|
|
|
QString online;
|
|
|
|
bool cankick;
|
|
|
|
} ParticipantData;
|
|
|
|
typedef QVector<UserData*> Participants;
|
|
|
|
Participants _participants;
|
|
|
|
typedef QVector<ParticipantData*> ParticipantsData;
|
|
|
|
ParticipantsData _participantsData;
|
|
|
|
|
|
|
|
mtpRequestId _loadingId;
|
|
|
|
|
|
|
|
QPoint _lastPos;
|
|
|
|
|
2014-08-22 14:55:23 +00:00
|
|
|
QString _onlineText;
|
2014-09-29 02:47:30 +00:00
|
|
|
ContextMenu *_menu;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class ProfileWidget : public QWidget, public RPCSender, public Animated {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ProfileWidget(QWidget *parent, const PeerData *peer);
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e);
|
|
|
|
void dropEvent(QDropEvent *e);
|
|
|
|
|
|
|
|
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
|
|
|
|
void topBarClick();
|
|
|
|
|
|
|
|
PeerData *peer() const;
|
2014-08-15 11:19:32 +00:00
|
|
|
int32 lastScrollTop() const;
|
|
|
|
bool allMediaShown() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
void animShow(const QPixmap &oldAnimCache, const QPixmap &bgAnimTopBarCache, bool back = false, int32 lastScrollTop = -1, bool allMediaShown = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
bool animStep(float64 ms);
|
|
|
|
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
|
|
|
|
void updateNotifySettings();
|
2014-08-15 11:19:32 +00:00
|
|
|
void mediaOverviewUpdated(PeerData *peer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
~ProfileWidget();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void activate();
|
|
|
|
void onScroll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
ScrollArea _scroll;
|
|
|
|
ProfileInner _inner;
|
|
|
|
|
|
|
|
bool _showing;
|
|
|
|
QPixmap _animCache, _bgAnimCache, _animTopBarCache, _bgAnimTopBarCache;
|
|
|
|
anim::ivalue a_coord, a_bgCoord;
|
|
|
|
anim::fvalue a_alpha, a_bgAlpha;
|
|
|
|
|
|
|
|
};
|
|
|
|
|