2016-04-13 00:31:28 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-13 00:31:28 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-16 19:53:41 +03:00
|
|
|
#include "ui/rp_widget.h"
|
2017-11-13 12:05:56 +04:00
|
|
|
#include "base/timer.h"
|
2016-04-13 00:31:28 +03:00
|
|
|
|
|
|
|
namespace Ui {
|
2017-11-13 17:19:14 +04:00
|
|
|
class UserpicButton;
|
2016-06-07 22:59:39 +03:00
|
|
|
class RoundButton;
|
2016-11-05 11:36:24 +03:00
|
|
|
class IconButton;
|
|
|
|
class DropdownMenu;
|
2017-12-17 15:04:47 +04:00
|
|
|
class UnreadBadge;
|
2016-04-13 00:31:28 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Window {
|
2017-03-27 15:24:38 +03:00
|
|
|
class Controller;
|
2017-11-13 12:05:56 +04:00
|
|
|
} // namespace Window
|
2017-03-27 15:24:38 +03:00
|
|
|
|
2017-11-13 12:05:56 +04:00
|
|
|
class HistoryTopBarWidget : public Ui::RpWidget, private base::Subscriber {
|
2016-04-13 00:31:28 +03:00
|
|
|
public:
|
2017-11-13 12:05:56 +04:00
|
|
|
HistoryTopBarWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::Controller*> controller);
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2017-04-28 00:17:00 +03:00
|
|
|
struct SelectedState {
|
|
|
|
bool textSelected = false;
|
|
|
|
int count = 0;
|
|
|
|
int canDeleteCount = 0;
|
|
|
|
int canForwardCount = 0;
|
|
|
|
};
|
|
|
|
|
2017-04-28 20:16:14 +03:00
|
|
|
void updateControlsVisibility();
|
2017-12-02 14:22:48 +04:00
|
|
|
void finishAnimating();
|
2017-04-28 00:17:00 +03:00
|
|
|
void showSelected(SelectedState state);
|
2017-11-13 12:05:56 +04:00
|
|
|
rpl::producer<bool> membersShowAreaActive() const {
|
|
|
|
return _membersShowAreaActive.events();
|
|
|
|
}
|
2017-11-16 19:24:01 +04:00
|
|
|
void setAnimationMode(bool enabled);
|
2016-06-17 21:18:01 +03:00
|
|
|
|
2017-12-02 15:11:01 +04:00
|
|
|
void setHistoryPeer(PeerData *historyPeer);
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2017-11-13 12:05:56 +04:00
|
|
|
static void paintUnreadCounter(
|
|
|
|
Painter &p,
|
|
|
|
int outerWidth,
|
|
|
|
PeerData *substractPeer = nullptr);
|
2016-11-06 20:23:13 +03:00
|
|
|
|
2016-06-17 21:18:01 +03:00
|
|
|
protected:
|
2016-11-19 12:22:53 +03:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2016-06-17 21:18:01 +03:00
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
|
|
|
|
2016-11-05 11:36:24 +03:00
|
|
|
private:
|
2017-05-30 18:21:05 +03:00
|
|
|
void refreshLang();
|
2016-12-27 02:46:36 +04:00
|
|
|
void updateControlsGeometry();
|
|
|
|
void selectedShowCallback();
|
2017-09-16 19:53:41 +03:00
|
|
|
void updateInfoToggleActive();
|
2016-12-27 02:46:36 +04:00
|
|
|
|
2016-04-13 00:31:28 +03:00
|
|
|
void onForwardSelection();
|
|
|
|
void onDeleteSelection();
|
|
|
|
void onClearSelection();
|
2017-04-19 21:06:01 +03:00
|
|
|
void onCall();
|
2016-04-13 00:31:28 +03:00
|
|
|
void onSearch();
|
2016-11-05 11:36:24 +03:00
|
|
|
void showMenu();
|
2017-09-16 19:53:41 +03:00
|
|
|
void toggleInfoSection();
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2016-08-26 22:49:18 -06:00
|
|
|
void updateAdaptiveLayout();
|
2016-12-27 02:46:36 +04:00
|
|
|
int countSelectedButtonsTop(float64 selectedShown);
|
2016-08-26 22:49:18 -06:00
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
void paintTopBar(Painter &p, TimeMs ms);
|
2017-11-13 12:05:56 +04:00
|
|
|
QRect getMembersShowAreaGeometry() const;
|
|
|
|
void updateMembersShowArea();
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
void updateOnlineDisplayIn(TimeMs timeout);
|
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
void infoClicked();
|
|
|
|
void backClicked();
|
|
|
|
|
2017-11-17 18:54:01 +04:00
|
|
|
void createUnreadBadge();
|
|
|
|
void updateUnreadBadge();
|
|
|
|
|
2017-08-17 11:31:24 +03:00
|
|
|
not_null<Window::Controller*> _controller;
|
2017-11-08 20:45:30 +04:00
|
|
|
PeerData *_historyPeer = nullptr;
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2016-12-27 02:46:36 +04:00
|
|
|
int _selectedCount = 0;
|
2016-06-22 20:11:35 +03:00
|
|
|
bool _canDelete = false;
|
2017-04-28 00:17:00 +03:00
|
|
|
bool _canForward = false;
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2016-12-27 02:46:36 +04:00
|
|
|
Animation _selectedShown;
|
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::RoundButton> _clearSelection;
|
|
|
|
object_ptr<Ui::RoundButton> _forward, _delete;
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
object_ptr<Ui::IconButton> _back;
|
2017-12-17 15:04:47 +04:00
|
|
|
object_ptr<Ui::UnreadBadge> _unreadBadge = { nullptr };
|
2017-11-13 17:19:14 +04:00
|
|
|
object_ptr<Ui::UserpicButton> _info = { nullptr };
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2017-04-19 21:06:01 +03:00
|
|
|
object_ptr<Ui::IconButton> _call;
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::IconButton> _search;
|
2017-09-16 19:53:41 +03:00
|
|
|
object_ptr<Ui::IconButton> _infoToggle;
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::IconButton> _menuToggle;
|
|
|
|
object_ptr<Ui::DropdownMenu> _menu = { nullptr };
|
2016-11-05 11:36:24 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<TWidget> _membersShowArea = { nullptr };
|
2017-11-13 12:05:56 +04:00
|
|
|
rpl::event_stream<bool> _membersShowAreaActive;
|
|
|
|
|
|
|
|
QString _titlePeerText;
|
|
|
|
bool _titlePeerTextOnline = false;
|
|
|
|
int _titlePeerTextWidth = 0;
|
2017-11-16 19:24:01 +04:00
|
|
|
int _leftTaken = 0;
|
|
|
|
int _rightTaken = 0;
|
|
|
|
bool _animationMode = false;
|
2016-04-13 00:31:28 +03:00
|
|
|
|
2016-11-06 20:23:13 +03:00
|
|
|
int _unreadCounterSubscription = 0;
|
2017-11-13 12:05:56 +04:00
|
|
|
base::Timer _onlineUpdater;
|
2016-11-06 20:23:13 +03:00
|
|
|
|
2016-04-13 00:31:28 +03:00
|
|
|
};
|