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

82 lines
1.8 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_controller.h"
#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
namespace Export {
struct Environment;
2018-06-02 14:29:21 +00:00
namespace View {
Environment PrepareEnvironment();
2019-09-18 11:19:05 +00:00
QPointer<Ui::BoxContent> SuggestStart();
void ClearSuggestStart();
bool IsDefaultPath(const QString &path);
void ResolveSettings(Settings &settings);
2018-06-22 23:18:43 +00:00
2018-06-02 14:29:21 +00:00
class Panel;
class PanelController {
public:
PanelController(not_null<Controller*> process);
~PanelController();
2018-06-02 14:29:21 +00:00
void activatePanel();
void stopWithConfirmation(FnMut<void()> callback = nullptr);
2018-06-21 00:54:59 +00:00
rpl::producer<> stopRequests() const;
2018-06-02 14:29:21 +00:00
rpl::lifetime &lifetime() {
return _lifetime;
}
auto progressState() const {
return ContentFromState(_process->state());
}
2018-06-02 14:29:21 +00:00
private:
2018-07-23 13:11:56 +00:00
void fillParams(const PasswordCheckState &state);
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();
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;
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;
bool _stopRequested = false;
2018-06-02 14:29:21 +00:00
rpl::lifetime _lifetime;
};
} // namespace View
} // namespace Export