settings_recipients_helper.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "base/required.h"
  9. #include "data/business/data_business_common.h"
  10. #include "settings/settings_common_session.h"
  11. class FilterChatsPreview;
  12. namespace Ui {
  13. class VerticalLayout;
  14. } // namespace Ui
  15. namespace Window {
  16. class SessionController;
  17. } // namespace Window
  18. namespace Settings {
  19. template <typename SectionType>
  20. class BusinessSection : public Section<SectionType> {
  21. public:
  22. BusinessSection(
  23. QWidget *parent,
  24. not_null<Window::SessionController*> controller)
  25. : Section<SectionType>(parent)
  26. , _controller(controller) {
  27. }
  28. [[nodiscard]] not_null<Window::SessionController*> controller() const {
  29. return _controller;
  30. }
  31. [[nodiscard]] rpl::producer<> showFinishes() const {
  32. return _showFinished.events();
  33. }
  34. private:
  35. void showFinished() override {
  36. _showFinished.fire({});
  37. }
  38. const not_null<Window::SessionController*> _controller;
  39. rpl::event_stream<> _showFinished;
  40. };
  41. struct BusinessChatsDescriptor {
  42. Data::BusinessChats current;
  43. Fn<void(const Data::BusinessChats&)> save;
  44. bool usersOnly = false;
  45. bool include = false;
  46. };
  47. void EditBusinessChats(
  48. not_null<Window::SessionController*> window,
  49. BusinessChatsDescriptor &&descriptor);
  50. not_null<FilterChatsPreview*> SetupBusinessChatsPreview(
  51. not_null<Ui::VerticalLayout*> container,
  52. not_null<rpl::variable<Data::BusinessChats>*> data);
  53. struct BusinessRecipientsSelectorDescriptor {
  54. not_null<Window::SessionController*> controller;
  55. rpl::producer<QString> title;
  56. not_null<rpl::variable<Data::BusinessRecipients>*> data;
  57. base::required<Data::BusinessRecipientsType> type;
  58. };
  59. void AddBusinessRecipientsSelector(
  60. not_null<Ui::VerticalLayout*> container,
  61. BusinessRecipientsSelectorDescriptor &&descriptor);
  62. [[nodiscard]] int ShortcutsCount(not_null<::Main::Session*> session);
  63. [[nodiscard]] rpl::producer<int> ShortcutsCountValue(
  64. not_null<::Main::Session*> session);
  65. [[nodiscard]] int ShortcutMessagesCount(
  66. not_null<::Main::Session*> session,
  67. const QString &name);
  68. [[nodiscard]] rpl::producer<int> ShortcutMessagesCountValue(
  69. not_null<::Main::Session*> session,
  70. const QString &name);
  71. [[nodiscard]] bool ShortcutExists(
  72. not_null<::Main::Session*> session,
  73. const QString &name);
  74. [[nodiscard]] rpl::producer<bool> ShortcutExistsValue(
  75. not_null<::Main::Session*> session,
  76. const QString &name);
  77. [[nodiscard]] int ShortcutsLimit(not_null<::Main::Session*> session);
  78. [[nodiscard]] rpl::producer<int> ShortcutsLimitValue(
  79. not_null<::Main::Session*> session);
  80. [[nodiscard]] int ShortcutMessagesLimit(not_null<::Main::Session*> session);
  81. [[nodiscard]] rpl::producer<int> ShortcutMessagesLimitValue(
  82. not_null<::Main::Session*> session);
  83. [[nodiscard]] BusinessShortcutId LookupShortcutId(
  84. not_null<::Main::Session*> session,
  85. const QString &name);
  86. } // namespace Settings