mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Remove some code duplication.
This commit is contained in:
parent
4b09050061
commit
031233ea98
2 changed files with 431 additions and 435 deletions
File diff suppressed because it is too large
Load diff
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/effects/animations.h"
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
class PeerListContent;
|
||||
|
||||
namespace Data {
|
||||
class Thread;
|
||||
} // namespace Data
|
||||
|
@ -67,17 +69,19 @@ public:
|
|||
}
|
||||
[[nodiscard]] auto recentPeerChosen() const
|
||||
-> rpl::producer<not_null<PeerData*>> {
|
||||
return _recentPeerChosen.events();
|
||||
return _recent->chosen.events();
|
||||
}
|
||||
[[nodiscard]] auto myChannelChosen() const
|
||||
-> rpl::producer<not_null<PeerData*>> {
|
||||
return _myChannelChosen.events();
|
||||
return _myChannels->chosen.events();
|
||||
}
|
||||
[[nodiscard]] auto recommendationChosen() const
|
||||
-> rpl::producer<not_null<PeerData*>> {
|
||||
return _recommendationChosen.events();
|
||||
return _recommendations->chosen.events();
|
||||
}
|
||||
|
||||
class ObjectListController;
|
||||
|
||||
private:
|
||||
enum class Tab : uchar {
|
||||
Chats,
|
||||
|
@ -89,6 +93,17 @@ private:
|
|||
AppliedAndOut,
|
||||
};
|
||||
|
||||
struct ObjectList {
|
||||
not_null<Ui::SlideWrap<PeerListContent>*> wrap;
|
||||
rpl::variable<int> count;
|
||||
Fn<bool()> choose;
|
||||
Fn<JumpResult(Qt::Key, int)> selectJump;
|
||||
Fn<uint64(QPoint)> updateFromParentDrag;
|
||||
Fn<void()> dragLeft;
|
||||
Fn<bool(not_null<QTouchEvent*>)> processTouch;
|
||||
rpl::event_stream<not_null<PeerData*>> chosen;
|
||||
};
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
|
@ -104,14 +119,22 @@ private:
|
|||
QPoint globalPosition);
|
||||
[[nodiscard]] Data::Thread *fromListId(uint64 peerListRowId);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupRecentPeers(
|
||||
[[nodiscard]] std::unique_ptr<ObjectList> setupRecentPeers(
|
||||
RecentPeersList recentPeers);
|
||||
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupEmptyRecent();
|
||||
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupMyChannels();
|
||||
[[nodiscard]] auto setupRecommendations()
|
||||
[[nodiscard]] auto setupEmptyRecent()
|
||||
-> object_ptr<Ui::SlideWrap<Ui::RpWidget>>;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ObjectList> setupMyChannels();
|
||||
[[nodiscard]] std::unique_ptr<ObjectList> setupRecommendations();
|
||||
[[nodiscard]] auto setupEmptyChannels()
|
||||
-> object_ptr<Ui::SlideWrap<Ui::RpWidget>>;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ObjectList> setupObjectList(
|
||||
not_null<Ui::ElasticScroll*> scroll,
|
||||
not_null<Ui::VerticalLayout*> parent,
|
||||
not_null<ObjectListController*> controller,
|
||||
Fn<int()> addToScroll = nullptr);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupEmpty(
|
||||
not_null<QWidget*> parent,
|
||||
SearchEmptyIcon icon,
|
||||
|
@ -131,44 +154,23 @@ private:
|
|||
|
||||
const std::unique_ptr<Ui::ElasticScroll> _chatsScroll;
|
||||
const not_null<Ui::VerticalLayout*> _chatsContent;
|
||||
|
||||
const not_null<Ui::SlideWrap<TopPeersStrip>*> _topPeersWrap;
|
||||
const not_null<TopPeersStrip*> _topPeers;
|
||||
rpl::event_stream<not_null<PeerData*>> _topPeerChosen;
|
||||
|
||||
const std::unique_ptr<ObjectList> _recent;
|
||||
|
||||
rpl::variable<int> _recentCount;
|
||||
Fn<bool()> _recentPeersChoose;
|
||||
Fn<JumpResult(Qt::Key, int)> _recentSelectJump;
|
||||
Fn<uint64(QPoint)> _recentUpdateFromParentDrag;
|
||||
Fn<void()> _recentDragLeft;
|
||||
Fn<bool(not_null<QTouchEvent*>)> _recentProcessTouch;
|
||||
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _recentPeers;
|
||||
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _emptyRecent;
|
||||
|
||||
const std::unique_ptr<Ui::ElasticScroll> _channelsScroll;
|
||||
const not_null<Ui::VerticalLayout*> _channelsContent;
|
||||
|
||||
rpl::variable<int> _myChannelsCount;
|
||||
Fn<bool()> _myChannelsChoose;
|
||||
Fn<JumpResult(Qt::Key, int)> _myChannelsSelectJump;
|
||||
Fn<uint64(QPoint)> _myChannelsUpdateFromParentDrag;
|
||||
Fn<void()> _myChannelsDragLeft;
|
||||
Fn<bool(not_null<QTouchEvent*>)> _myChannelsProcessTouch;
|
||||
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _myChannels;
|
||||
|
||||
rpl::variable<int> _recommendationsCount;
|
||||
Fn<bool()> _recommendationsChoose;
|
||||
Fn<JumpResult(Qt::Key, int)> _recommendationsSelectJump;
|
||||
Fn<uint64(QPoint)> _recommendationsUpdateFromParentDrag;
|
||||
Fn<void()> _recommendationsDragLeft;
|
||||
Fn<bool(not_null<QTouchEvent*>)> _recommendationsProcessTouch;
|
||||
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _recommendations;
|
||||
const std::unique_ptr<ObjectList> _myChannels;
|
||||
const std::unique_ptr<ObjectList> _recommendations;
|
||||
|
||||
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _emptyChannels;
|
||||
|
||||
rpl::event_stream<not_null<PeerData*>> _topPeerChosen;
|
||||
rpl::event_stream<not_null<PeerData*>> _recentPeerChosen;
|
||||
rpl::event_stream<not_null<PeerData*>> _myChannelChosen;
|
||||
rpl::event_stream<not_null<PeerData*>> _recommendationChosen;
|
||||
|
||||
Ui::Animations::Simple _shownAnimation;
|
||||
Fn<void()> _showFinished;
|
||||
bool _hidden = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue