2016-04-12 21:31:28 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-12 21:31:28 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2017-11-13 08:05:56 +00:00
|
|
|
#include "base/timer.h"
|
2018-01-22 17:39:20 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2019-07-24 11:13:51 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
namespace Ui {
|
2018-01-30 14:31:25 +00:00
|
|
|
class AbstractButton;
|
2016-06-07 19:59:39 +00:00
|
|
|
class RoundButton;
|
2016-11-05 08:36:24 +00:00
|
|
|
class IconButton;
|
|
|
|
class DropdownMenu;
|
2017-12-17 11:04:47 +00:00
|
|
|
class UnreadBadge;
|
2018-05-10 10:16:21 +00:00
|
|
|
class InfiniteRadialAnimation;
|
2016-04-12 21:31:28 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2017-11-13 08:05:56 +00:00
|
|
|
} // namespace Window
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
|
|
|
|
class TopBarWidget : public Ui::RpWidget, private base::Subscriber {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-04-27 21:17:00 +00:00
|
|
|
struct SelectedState {
|
|
|
|
bool textSelected = false;
|
|
|
|
int count = 0;
|
|
|
|
int canDeleteCount = 0;
|
|
|
|
int canForwardCount = 0;
|
2019-08-09 17:58:58 +00:00
|
|
|
int canSendNowCount = 0;
|
2017-04-27 21:17:00 +00:00
|
|
|
};
|
2019-08-09 12:15:57 +00:00
|
|
|
enum class Section {
|
|
|
|
History,
|
|
|
|
Scheduled,
|
|
|
|
};
|
2017-04-27 21:17:00 +00:00
|
|
|
|
2019-07-24 11:13:51 +00:00
|
|
|
TopBarWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller);
|
2018-05-10 10:16:21 +00:00
|
|
|
~TopBarWidget();
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
Main::Session &session() const;
|
2019-07-24 11:13:51 +00:00
|
|
|
|
2017-04-28 17:16:14 +00:00
|
|
|
void updateControlsVisibility();
|
2017-12-02 10:22:48 +00:00
|
|
|
void finishAnimating();
|
2017-04-27 21:17:00 +00:00
|
|
|
void showSelected(SelectedState state);
|
2017-11-13 08:05:56 +00:00
|
|
|
rpl::producer<bool> membersShowAreaActive() const {
|
|
|
|
return _membersShowAreaActive.events();
|
|
|
|
}
|
2018-01-09 17:08:31 +00:00
|
|
|
void setAnimatingMode(bool enabled);
|
2016-06-17 18:18:01 +00:00
|
|
|
|
2019-08-09 12:15:57 +00:00
|
|
|
void setActiveChat(Dialogs::Key chat, Section section);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2018-01-26 15:40:11 +00:00
|
|
|
rpl::producer<> forwardSelectionRequest() const {
|
|
|
|
return _forwardSelection.events();
|
|
|
|
}
|
2019-08-09 17:58:58 +00:00
|
|
|
rpl::producer<> sendNowSelectionRequest() const {
|
|
|
|
return _sendNowSelection.events();
|
|
|
|
}
|
2018-01-26 15:40:11 +00:00
|
|
|
rpl::producer<> deleteSelectionRequest() const {
|
|
|
|
return _deleteSelection.events();
|
|
|
|
}
|
|
|
|
rpl::producer<> clearSelectionRequest() const {
|
|
|
|
return _clearSelection.events();
|
|
|
|
}
|
|
|
|
|
2016-06-17 18:18:01 +00:00
|
|
|
protected:
|
2016-11-19 09:22:53 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2016-06-17 18:18:01 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
|
|
|
|
2018-01-22 17:39:20 +00:00
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
|
2016-11-05 08:36:24 +00:00
|
|
|
private:
|
2018-01-30 14:31:25 +00:00
|
|
|
void refreshInfoButton();
|
2017-05-30 15:21:05 +00:00
|
|
|
void refreshLang();
|
2019-08-16 09:32:42 +00:00
|
|
|
void updateSearchVisibility();
|
2016-12-26 22:46:36 +00:00
|
|
|
void updateControlsGeometry();
|
|
|
|
void selectedShowCallback();
|
2017-09-16 16:53:41 +00:00
|
|
|
void updateInfoToggleActive();
|
2016-12-26 22:46:36 +00:00
|
|
|
|
2017-04-19 18:06:01 +00:00
|
|
|
void onCall();
|
2016-04-12 21:31:28 +00:00
|
|
|
void onSearch();
|
2016-11-05 08:36:24 +00:00
|
|
|
void showMenu();
|
2017-09-16 16:53:41 +00:00
|
|
|
void toggleInfoSection();
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2018-05-10 10:16:21 +00:00
|
|
|
void updateConnectingState();
|
2016-08-27 04:49:18 +00:00
|
|
|
void updateAdaptiveLayout();
|
2016-12-26 22:46:36 +00:00
|
|
|
int countSelectedButtonsTop(float64 selectedShown);
|
2019-04-01 17:44:54 +00:00
|
|
|
void connectingAnimationCallback();
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
void paintTopBar(Painter &p);
|
2018-05-10 10:16:21 +00:00
|
|
|
void paintStatus(
|
|
|
|
Painter &p,
|
|
|
|
int left,
|
|
|
|
int top,
|
|
|
|
int availableWidth,
|
|
|
|
int outerWidth);
|
2019-04-02 09:13:30 +00:00
|
|
|
bool paintConnectingState(Painter &p, int left, int top, int outerWidth);
|
2017-11-13 08:05:56 +00:00
|
|
|
QRect getMembersShowAreaGeometry() const;
|
|
|
|
void updateMembersShowArea();
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateOnlineDisplayTimer();
|
2019-02-19 06:57:53 +00:00
|
|
|
void updateOnlineDisplayIn(crl::time timeout);
|
2017-11-13 08:05:56 +00:00
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
void infoClicked();
|
|
|
|
void backClicked();
|
|
|
|
|
2019-04-24 14:12:35 +00:00
|
|
|
void refreshUnreadBadge();
|
2017-11-17 14:54:01 +00:00
|
|
|
void updateUnreadBadge();
|
|
|
|
|
2019-08-09 12:15:57 +00:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
2018-01-22 17:39:20 +00:00
|
|
|
Dialogs::Key _activeChat;
|
2019-08-09 12:15:57 +00:00
|
|
|
Section _section = Section::History;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2016-12-26 22:46:36 +00:00
|
|
|
int _selectedCount = 0;
|
2016-06-22 17:11:35 +00:00
|
|
|
bool _canDelete = false;
|
2017-04-27 21:17:00 +00:00
|
|
|
bool _canForward = false;
|
2019-08-09 17:58:58 +00:00
|
|
|
bool _canSendNow = false;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _selectedShown;
|
2016-12-26 22:46:36 +00:00
|
|
|
|
2018-01-26 15:40:11 +00:00
|
|
|
object_ptr<Ui::RoundButton> _clear;
|
2019-08-09 17:58:58 +00:00
|
|
|
object_ptr<Ui::RoundButton> _forward, _sendNow, _delete;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
object_ptr<Ui::IconButton> _back;
|
2017-12-17 11:04:47 +00:00
|
|
|
object_ptr<Ui::UnreadBadge> _unreadBadge = { nullptr };
|
2018-01-30 14:31:25 +00:00
|
|
|
object_ptr<Ui::AbstractButton> _info = { nullptr };
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2017-04-19 18:06:01 +00:00
|
|
|
object_ptr<Ui::IconButton> _call;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _search;
|
2017-09-16 16:53:41 +00:00
|
|
|
object_ptr<Ui::IconButton> _infoToggle;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _menuToggle;
|
|
|
|
object_ptr<Ui::DropdownMenu> _menu = { nullptr };
|
2016-11-05 08:36:24 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<TWidget> _membersShowArea = { nullptr };
|
2017-11-13 08:05:56 +00:00
|
|
|
rpl::event_stream<bool> _membersShowAreaActive;
|
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _titlePeerText;
|
2017-11-13 08:05:56 +00:00
|
|
|
bool _titlePeerTextOnline = false;
|
2017-11-16 15:24:01 +00:00
|
|
|
int _leftTaken = 0;
|
|
|
|
int _rightTaken = 0;
|
2018-01-09 17:08:31 +00:00
|
|
|
bool _animatingMode = false;
|
2018-05-10 10:16:21 +00:00
|
|
|
std::unique_ptr<Ui::InfiniteRadialAnimation> _connecting;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
int _unreadCounterSubscription = 0;
|
2017-11-13 08:05:56 +00:00
|
|
|
base::Timer _onlineUpdater;
|
2016-11-06 17:23:13 +00:00
|
|
|
|
2018-01-26 15:40:11 +00:00
|
|
|
rpl::event_stream<> _forwardSelection;
|
2019-08-09 17:58:58 +00:00
|
|
|
rpl::event_stream<> _sendNowSelection;
|
2018-01-26 15:40:11 +00:00
|
|
|
rpl::event_stream<> _deleteSelection;
|
|
|
|
rpl::event_stream<> _clearSelection;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
};
|
2018-01-09 17:08:31 +00:00
|
|
|
|
|
|
|
} // namespace HistoryView
|