2018-05-07 17:44:33 +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 "base/timer.h"
|
2019-02-10 16:29:55 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2018-05-07 17:44:33 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
2019-02-10 16:29:55 +00:00
|
|
|
class RpWidget;
|
2018-05-07 17:44:33 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
class ConnectionState : private base::Subscriber {
|
2018-05-07 17:44:33 +00:00
|
|
|
public:
|
2019-02-10 16:29:55 +00:00
|
|
|
ConnectionState(
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
2018-05-07 17:44:33 +00:00
|
|
|
rpl::producer<bool> shown);
|
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
void raise();
|
|
|
|
void setForceHidden(bool hidden);
|
2018-05-07 17:44:33 +00:00
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
rpl::lifetime &lifetime() {
|
|
|
|
return _lifetime;
|
|
|
|
}
|
2018-05-07 17:44:33 +00:00
|
|
|
|
|
|
|
private:
|
2019-02-10 16:29:55 +00:00
|
|
|
class Widget;
|
2018-05-07 17:44:33 +00:00
|
|
|
struct State {
|
|
|
|
enum class Type {
|
|
|
|
Connected,
|
|
|
|
Connecting,
|
|
|
|
Waiting,
|
|
|
|
};
|
|
|
|
Type type = Type::Connected;
|
|
|
|
bool useProxy = false;
|
|
|
|
bool underCursor = false;
|
2020-01-20 10:57:45 +00:00
|
|
|
bool updateReady = false;
|
2018-05-07 17:44:33 +00:00
|
|
|
int waitTillRetry = 0;
|
|
|
|
|
|
|
|
bool operator==(const State &other) const;
|
|
|
|
|
|
|
|
};
|
|
|
|
struct Layout {
|
|
|
|
bool visible = false;
|
|
|
|
bool hasRetry = false;
|
|
|
|
bool proxyEnabled = false;
|
|
|
|
bool progressShown = false;
|
|
|
|
int contentWidth = 0;
|
|
|
|
QString text;
|
|
|
|
int textWidth = 0;
|
|
|
|
|
|
|
|
};
|
2019-02-10 16:29:55 +00:00
|
|
|
|
|
|
|
void createWidget();
|
|
|
|
void finishAnimating();
|
2018-05-07 17:44:33 +00:00
|
|
|
void refreshState();
|
|
|
|
void applyState(const State &state);
|
|
|
|
void changeVisibilityWithLayout(const Layout &layout);
|
|
|
|
Layout computeLayout(const State &state) const;
|
|
|
|
void setLayout(const Layout &layout);
|
|
|
|
float64 currentVisibility() const;
|
2019-02-10 16:29:55 +00:00
|
|
|
rpl::producer<float64> visibility() const;
|
|
|
|
void updateWidth();
|
|
|
|
void updateVisibility();
|
|
|
|
void refreshProgressVisibility();
|
2018-05-07 17:44:33 +00:00
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
not_null<Ui::RpWidget*> _parent;
|
|
|
|
base::unique_qptr<Widget> _widget;
|
|
|
|
bool _forceHidden = false;
|
2018-05-07 17:44:33 +00:00
|
|
|
base::Timer _refreshTimer;
|
|
|
|
State _state;
|
|
|
|
Layout _currentLayout;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _connectingStartedAt = 0;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _contentWidth;
|
|
|
|
Ui::Animations::Simple _visibility;
|
2018-05-07 17:44:33 +00:00
|
|
|
|
|
|
|
rpl::event_stream<float64> _visibilityValues;
|
2019-02-10 16:29:55 +00:00
|
|
|
rpl::lifetime _lifetime;
|
2018-05-07 17:44:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
rpl::producer<bool> AdaptiveIsOneColumn();
|
|
|
|
|
|
|
|
} // namespace Window
|