2016-05-14 16:57:06 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-05-27 15:45:35 +00:00
|
|
|
#include "core/observer.h"
|
|
|
|
|
|
|
|
namespace Notify {
|
|
|
|
struct PeerUpdate;
|
|
|
|
} // namespace Notify
|
|
|
|
|
2016-06-07 19:59:39 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RoundButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-05-14 16:57:06 +00:00
|
|
|
namespace Profile {
|
|
|
|
|
|
|
|
class BackButton;
|
|
|
|
|
2016-09-26 18:33:34 +00:00
|
|
|
class FixedBar final : public TWidget, private base::Subscriber {
|
2016-05-14 16:57:06 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FixedBar(QWidget *parent, PeerData *peer);
|
|
|
|
|
|
|
|
// When animating mode is enabled the content is hidden and the
|
|
|
|
// whole fixed bar acts like a back button.
|
|
|
|
void setAnimatingMode(bool enabled);
|
|
|
|
|
2016-05-27 13:56:35 +00:00
|
|
|
// The "Share contact" button should be hidden if it is shown in the profile cover.
|
|
|
|
void setHideShareContactButton(bool hideButton);
|
|
|
|
|
2016-05-14 16:57:06 +00:00
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
2016-08-22 17:16:21 +00:00
|
|
|
int resizeGetHeight(int newWidth) override;
|
2016-05-14 16:57:06 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onBack();
|
|
|
|
|
2016-05-23 12:41:09 +00:00
|
|
|
private slots:
|
|
|
|
void onEditChannel();
|
|
|
|
void onEditGroup();
|
|
|
|
void onAddContact();
|
|
|
|
void onEditContact();
|
2016-05-27 13:56:35 +00:00
|
|
|
void onShareContact();
|
2016-05-23 12:41:09 +00:00
|
|
|
void onDeleteContact();
|
2016-05-27 13:56:35 +00:00
|
|
|
void onDeleteContactSure();
|
|
|
|
void onLeaveGroup();
|
|
|
|
void onLeaveGroupSure();
|
2016-05-23 12:41:09 +00:00
|
|
|
|
2016-05-14 16:57:06 +00:00
|
|
|
private:
|
2016-05-27 15:45:35 +00:00
|
|
|
void notifyPeerUpdate(const Notify::PeerUpdate &update);
|
|
|
|
|
2016-05-23 12:41:09 +00:00
|
|
|
void refreshRightActions();
|
2016-05-27 13:56:35 +00:00
|
|
|
void setUserActions();
|
|
|
|
void setChatActions();
|
|
|
|
void setMegagroupActions();
|
|
|
|
void setChannelActions();
|
|
|
|
|
2016-05-23 12:41:09 +00:00
|
|
|
enum class RightActionType {
|
2016-05-27 15:45:35 +00:00
|
|
|
None,
|
2016-05-23 12:41:09 +00:00
|
|
|
EditChannel,
|
|
|
|
EditGroup,
|
|
|
|
LeaveGroup,
|
|
|
|
AddContact,
|
|
|
|
EditContact,
|
2016-05-27 13:56:35 +00:00
|
|
|
DeleteContact,
|
|
|
|
ShareContact,
|
2016-05-23 12:41:09 +00:00
|
|
|
};
|
|
|
|
|
2016-05-27 13:56:35 +00:00
|
|
|
void addRightAction(RightActionType type, const QString &text, const char *slot);
|
|
|
|
void applyHideShareContactButton();
|
|
|
|
|
2016-05-14 16:57:06 +00:00
|
|
|
PeerData *_peer;
|
|
|
|
UserData *_peerUser;
|
|
|
|
ChatData *_peerChat;
|
|
|
|
ChannelData *_peerChannel;
|
|
|
|
ChannelData *_peerMegagroup;
|
|
|
|
|
|
|
|
ChildWidget<BackButton> _backButton;
|
2016-05-27 13:56:35 +00:00
|
|
|
|
|
|
|
int _currentAction = 0;
|
|
|
|
struct RightAction {
|
2016-05-27 15:45:35 +00:00
|
|
|
RightActionType type = RightActionType::None;
|
2016-06-07 19:59:39 +00:00
|
|
|
Ui::RoundButton *button = nullptr;
|
2016-05-27 13:56:35 +00:00
|
|
|
};
|
|
|
|
QList<RightAction> _rightActions;
|
2016-05-14 16:57:06 +00:00
|
|
|
|
|
|
|
bool _animatingMode = false;
|
2016-05-27 13:56:35 +00:00
|
|
|
bool _hideShareContactButton = false;
|
2016-05-14 16:57:06 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Profile
|