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_controller.h"
|
2018-06-20 00:02:36 +00:00
|
|
|
#include "export/view/export_view_content.h"
|
2018-06-02 14:29:21 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2018-06-22 21:32:00 +00:00
|
|
|
#include "base/timer.h"
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class SeparatePanel;
|
2019-09-18 11:19:05 +00:00
|
|
|
class BoxContent;
|
2018-06-02 14:29:21 +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-06-08 15:17:33 +00:00
|
|
|
QPointer<Ui::BoxContent> SuggestStart(not_null<Main::Session*> session);
|
|
|
|
void ClearSuggestStart(not_null<Main::Session*> session);
|
|
|
|
bool IsDefaultPath(not_null<Main::Session*> session, const QString &path);
|
|
|
|
void ResolveSettings(not_null<Main::Session*> session, Settings &settings);
|
2018-06-22 23:18:43 +00:00
|
|
|
|
2018-06-02 14:29:21 +00:00
|
|
|
class Panel;
|
|
|
|
|
|
|
|
class PanelController {
|
|
|
|
public:
|
2020-06-08 15:17:33 +00:00
|
|
|
PanelController(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
not_null<Controller*> process);
|
2019-09-09 07:51:59 +00:00
|
|
|
~PanelController();
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2020-06-25 07:14:05 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const {
|
|
|
|
return *_session;
|
|
|
|
}
|
|
|
|
|
2018-06-20 00:02:36 +00:00
|
|
|
void activatePanel();
|
2018-06-20 17:30:57 +00:00
|
|
|
void stopWithConfirmation(FnMut<void()> callback = nullptr);
|
2018-06-20 00:02:36 +00:00
|
|
|
|
2020-06-25 07:14:05 +00:00
|
|
|
[[nodiscard]] rpl::producer<> stopRequests() const;
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2020-06-25 07:14:05 +00:00
|
|
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
2018-06-20 00:02:36 +00:00
|
|
|
return _lifetime;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto progressState() const {
|
2020-06-25 09:02:02 +00:00
|
|
|
return ContentFromState(
|
|
|
|
_settings.get(),
|
|
|
|
rpl::single(_state) | rpl::then(_process->state()));
|
2018-06-20 00:02:36 +00:00
|
|
|
}
|
|
|
|
|
2018-06-02 14:29:21 +00:00
|
|
|
private:
|
2018-07-23 13:11:56 +00:00
|
|
|
void fillParams(const PasswordCheckState &state);
|
2018-06-20 15:54:13 +00:00
|
|
|
void stopExport();
|
2018-06-02 14:29:21 +00:00
|
|
|
void createPanel();
|
|
|
|
void updateState(State &&state);
|
|
|
|
void showSettings();
|
2018-06-19 18:31:30 +00:00
|
|
|
void showProgress();
|
2018-06-19 10:42:21 +00:00
|
|
|
void showError(const ApiErrorState &error);
|
|
|
|
void showError(const OutputErrorState &error);
|
|
|
|
void showError(const QString &text);
|
2018-06-21 00:54:59 +00:00
|
|
|
void showCriticalError(const QString &text);
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2018-06-22 21:32:00 +00:00
|
|
|
void saveSettings() const;
|
|
|
|
|
2020-06-08 15:17:33 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
|
|
|
const not_null<Controller*> _process;
|
2018-06-22 21:32:00 +00:00
|
|
|
std::unique_ptr<Settings> _settings;
|
|
|
|
base::Timer _saveSettingsTimer;
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
base::unique_qptr<Ui::SeparatePanel> _panel;
|
|
|
|
|
|
|
|
State _state;
|
2019-09-18 11:19:05 +00:00
|
|
|
QPointer<Ui::BoxContent> _confirmStopBox;
|
2018-06-02 14:29:21 +00:00
|
|
|
rpl::event_stream<rpl::producer<>> _panelCloseEvents;
|
2018-06-20 15:54:13 +00:00
|
|
|
bool _stopRequested = false;
|
2018-06-02 14:29:21 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace View
|
|
|
|
} // namespace Export
|