tdesktop/Telegram/SourceFiles/export/view/export_view_settings.h

130 lines
3.3 KiB
C
Raw Normal View History

2018-06-02 14:29:21 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "export/export_settings.h"
#include "ui/rp_widget.h"
2019-09-13 12:22:54 +00:00
#include "base/object_ptr.h"
2018-06-02 14:29:21 +00:00
2018-06-15 18:56:17 +00:00
namespace Ui {
class VerticalLayout;
class Checkbox;
class ScrollArea;
2019-09-18 11:19:05 +00:00
class BoxContent;
2018-06-15 18:56:17 +00:00
} // namespace Ui
2020-06-08 15:17:33 +00:00
namespace Main {
class Session;
} // namespace Main
2018-06-02 14:29:21 +00:00
namespace Export {
namespace View {
2020-07-06 08:18:11 +00:00
constexpr auto kSizeValueCount = 90;
2018-12-06 15:47:28 +00:00
int SizeLimitByIndex(int index);
2018-06-02 14:29:21 +00:00
class SettingsWidget : public Ui::RpWidget {
public:
2020-06-08 15:17:33 +00:00
SettingsWidget(
QWidget *parent,
not_null<Main::Session*> session,
Settings data);
2018-06-02 14:29:21 +00:00
2018-06-22 21:32:00 +00:00
rpl::producer<Settings> value() const;
rpl::producer<Settings> changes() const;
rpl::producer<> startClicks() const;
2018-06-02 14:29:21 +00:00
rpl::producer<> cancelClicks() const;
2019-09-18 11:19:05 +00:00
void setShowBoxCallback(Fn<void(object_ptr<Ui::BoxContent>)> callback) {
2018-10-06 11:06:07 +00:00
_showBoxCallback = std::move(callback);
}
2018-06-02 14:29:21 +00:00
private:
using Type = Settings::Type;
using Types = Settings::Types;
using MediaType = MediaSettings::Type;
using MediaTypes = MediaSettings::Types;
using Format = Output::Format;
2018-06-02 14:29:21 +00:00
void setupContent();
not_null<Ui::RpWidget*> setupButtons(
not_null<Ui::ScrollArea*> scroll,
not_null<Ui::RpWidget*> wrap);
void setupOptions(not_null<Ui::VerticalLayout*> container);
2018-07-23 13:11:56 +00:00
void setupFullExportOptions(not_null<Ui::VerticalLayout*> container);
void setupMediaOptions(not_null<Ui::VerticalLayout*> container);
2018-07-23 13:11:56 +00:00
void setupOtherOptions(not_null<Ui::VerticalLayout*> container);
void setupPathAndFormat(not_null<Ui::VerticalLayout*> container);
void addHeader(
not_null<Ui::VerticalLayout*> container,
2019-06-19 15:09:03 +00:00
const QString &text);
not_null<Ui::Checkbox*> addOption(
not_null<Ui::VerticalLayout*> container,
2019-06-19 15:09:03 +00:00
const QString &text,
Types types);
2018-06-24 00:33:47 +00:00
not_null<Ui::Checkbox*> addOptionWithAbout(
2018-06-22 23:53:03 +00:00
not_null<Ui::VerticalLayout*> container,
2019-06-19 15:09:03 +00:00
const QString &text,
2018-06-22 23:53:03 +00:00
Types types,
2019-06-19 15:09:03 +00:00
const QString &about);
void addChatOption(
not_null<Ui::VerticalLayout*> container,
2019-06-19 15:09:03 +00:00
const QString &text,
Types types);
2018-07-23 13:11:56 +00:00
void addMediaOptions(not_null<Ui::VerticalLayout*> container);
void addMediaOption(
not_null<Ui::VerticalLayout*> container,
2019-06-19 15:09:03 +00:00
const QString &text,
MediaType type);
void addSizeSlider(not_null<Ui::VerticalLayout*> container);
void addLocationLabel(
not_null<Ui::VerticalLayout*> container);
void addFormatAndLocationLabel(
not_null<Ui::VerticalLayout*> container);
2018-10-06 11:06:07 +00:00
void addLimitsLabel(
not_null<Ui::VerticalLayout*> container);
2018-06-20 18:12:47 +00:00
void chooseFolder();
void chooseFormat();
2018-06-22 21:32:00 +00:00
void refreshButtons(
not_null<Ui::RpWidget*> container,
bool canStart);
2018-10-06 11:06:07 +00:00
void editDateLimit(
TimeId current,
TimeId min,
TimeId max,
rpl::producer<QString> resetLabel,
2018-10-06 11:06:07 +00:00
Fn<void(TimeId)> done);
2018-06-22 21:32:00 +00:00
const Settings &readData() const;
template <typename Callback>
void changeData(Callback &&callback);
2020-06-08 15:17:33 +00:00
const not_null<Main::Session*> _session;
2018-07-23 13:11:56 +00:00
PeerId _singlePeerId = 0;
2019-09-18 11:19:05 +00:00
Fn<void(object_ptr<Ui::BoxContent>)> _showBoxCallback;
2018-07-23 13:11:56 +00:00
2018-06-22 21:32:00 +00:00
// Use through readData / changeData wrappers.
Settings _internal_data;
2018-06-02 14:29:21 +00:00
struct Wrap {
Wrap(rpl::producer<> value = nullptr)
2018-06-02 14:29:21 +00:00
: value(std::move(value)) {
}
rpl::producer<> value;
};
2018-06-22 21:32:00 +00:00
rpl::event_stream<Settings> _changes;
rpl::variable<Wrap> _startClicks;
2018-06-02 14:29:21 +00:00
rpl::variable<Wrap> _cancelClicks;
};
} // namespace View
} // namespace Export