2021-09-24 15:10:25 +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
|
|
|
|
|
|
|
|
class PeerData;
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
class SessionController;
|
|
|
|
} // namespace Window
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
struct ChatTheme;
|
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class RpWidget;
|
|
|
|
class PlainShadow;
|
|
|
|
class VerticalLayout;
|
|
|
|
|
|
|
|
class ChooseThemeController final {
|
|
|
|
public:
|
|
|
|
ChooseThemeController(
|
|
|
|
not_null<RpWidget*> parent,
|
|
|
|
not_null<Window::SessionController*> window,
|
|
|
|
not_null<PeerData*> peer);
|
|
|
|
~ChooseThemeController();
|
|
|
|
|
|
|
|
[[nodiscard]] bool shouldBeShown() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> shouldBeShownValue() const;
|
|
|
|
[[nodiscard]] int height() const;
|
|
|
|
|
|
|
|
void hide();
|
|
|
|
void show();
|
|
|
|
void raise();
|
2021-09-28 12:23:55 +00:00
|
|
|
void setFocus();
|
2021-09-24 15:10:25 +00:00
|
|
|
|
|
|
|
[[nodiscard]] rpl::lifetime &lifetime();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Entry;
|
|
|
|
|
|
|
|
void init(rpl::producer<QSize> outer);
|
|
|
|
void initButtons();
|
|
|
|
void initList();
|
|
|
|
void fill(const std::vector<Data::ChatTheme> &themes);
|
2021-09-28 12:23:55 +00:00
|
|
|
void close();
|
2021-09-24 15:10:25 +00:00
|
|
|
|
|
|
|
void clearCurrentBackgroundState();
|
|
|
|
void paintEntry(QPainter &p, const Entry &entry);
|
2021-09-28 14:53:34 +00:00
|
|
|
void updateInnerLeft(int now);
|
2021-09-24 15:10:25 +00:00
|
|
|
|
2021-09-28 12:23:55 +00:00
|
|
|
[[nodiscard]] Entry *findChosen();
|
|
|
|
[[nodiscard]] const Entry *findChosen() const;
|
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
|
|
|
const not_null<PeerData*> _peer;
|
|
|
|
const std::unique_ptr<VerticalLayout> _wrap;
|
|
|
|
const std::unique_ptr<PlainShadow> _topShadow;
|
|
|
|
|
|
|
|
const not_null<RpWidget*> _content;
|
|
|
|
const not_null<RpWidget*> _inner;
|
|
|
|
std::vector<Entry> _entries;
|
|
|
|
QString _pressed;
|
|
|
|
QString _chosen;
|
2021-09-28 14:53:34 +00:00
|
|
|
std::optional<QPoint> _pressPosition;
|
|
|
|
std::optional<QPoint> _dragStartPosition;
|
|
|
|
int _dragStartInnerLeft = 0;
|
2021-09-24 15:10:25 +00:00
|
|
|
|
|
|
|
rpl::variable<bool> _shouldBeShown = false;
|
|
|
|
rpl::variable<bool> _forceHidden = false;
|
|
|
|
rpl::variable<bool> _dark = false;
|
|
|
|
rpl::lifetime _cachingLifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|