export_view_settings.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 "export/export_settings.h"
  9. #include "ui/rp_widget.h"
  10. #include "base/object_ptr.h"
  11. namespace Ui {
  12. class VerticalLayout;
  13. class Checkbox;
  14. class ScrollArea;
  15. class BoxContent;
  16. } // namespace Ui
  17. namespace Main {
  18. class Session;
  19. } // namespace Main
  20. namespace Export {
  21. namespace View {
  22. constexpr auto kSizeValueCount = 100;
  23. int64 SizeLimitByIndex(int index);
  24. class SettingsWidget : public Ui::RpWidget {
  25. public:
  26. SettingsWidget(
  27. QWidget *parent,
  28. not_null<Main::Session*> session,
  29. Settings data);
  30. rpl::producer<Settings> value() const;
  31. rpl::producer<Settings> changes() const;
  32. rpl::producer<> startClicks() const;
  33. rpl::producer<> cancelClicks() const;
  34. void setShowBoxCallback(Fn<void(object_ptr<Ui::BoxContent>)> callback) {
  35. _showBoxCallback = std::move(callback);
  36. }
  37. private:
  38. using Type = Settings::Type;
  39. using Types = Settings::Types;
  40. using MediaType = MediaSettings::Type;
  41. using MediaTypes = MediaSettings::Types;
  42. using Format = Output::Format;
  43. void setupContent();
  44. not_null<Ui::RpWidget*> setupButtons(
  45. not_null<Ui::ScrollArea*> scroll,
  46. not_null<Ui::RpWidget*> wrap);
  47. void setupOptions(not_null<Ui::VerticalLayout*> container);
  48. void setupFullExportOptions(not_null<Ui::VerticalLayout*> container);
  49. void setupMediaOptions(not_null<Ui::VerticalLayout*> container);
  50. void setupOtherOptions(not_null<Ui::VerticalLayout*> container);
  51. void setupPathAndFormat(not_null<Ui::VerticalLayout*> container);
  52. void addHeader(
  53. not_null<Ui::VerticalLayout*> container,
  54. const QString &text);
  55. not_null<Ui::Checkbox*> addOption(
  56. not_null<Ui::VerticalLayout*> container,
  57. const QString &text,
  58. Types types);
  59. not_null<Ui::Checkbox*> addOptionWithAbout(
  60. not_null<Ui::VerticalLayout*> container,
  61. const QString &text,
  62. Types types,
  63. const QString &about);
  64. void addChatOption(
  65. not_null<Ui::VerticalLayout*> container,
  66. const QString &text,
  67. Types types);
  68. void addMediaOptions(not_null<Ui::VerticalLayout*> container);
  69. void addMediaOption(
  70. not_null<Ui::VerticalLayout*> container,
  71. const QString &text,
  72. MediaType type);
  73. void addSizeSlider(not_null<Ui::VerticalLayout*> container);
  74. void addLocationLabel(
  75. not_null<Ui::VerticalLayout*> container);
  76. void addFormatAndLocationLabel(
  77. not_null<Ui::VerticalLayout*> container);
  78. void addLimitsLabel(
  79. not_null<Ui::VerticalLayout*> container);
  80. void chooseFolder();
  81. void chooseFormat();
  82. void refreshButtons(
  83. not_null<Ui::RpWidget*> container,
  84. bool canStart);
  85. void editDateLimit(
  86. TimeId current,
  87. TimeId min,
  88. TimeId max,
  89. rpl::producer<QString> resetLabel,
  90. Fn<void(TimeId)> done);
  91. const Settings &readData() const;
  92. template <typename Callback>
  93. void changeData(Callback &&callback);
  94. const not_null<Main::Session*> _session;
  95. PeerId _singlePeerId = 0;
  96. Fn<void(object_ptr<Ui::BoxContent>)> _showBoxCallback;
  97. // Use through readData / changeData wrappers.
  98. Settings _internal_data;
  99. struct Wrap {
  100. Wrap(rpl::producer<> value = nullptr)
  101. : value(std::move(value)) {
  102. }
  103. rpl::producer<> value;
  104. };
  105. rpl::event_stream<Settings> _changes;
  106. rpl::variable<Wrap> _startClicks;
  107. rpl::variable<Wrap> _cancelClicks;
  108. };
  109. } // namespace View
  110. } // namespace Export