2016-11-02 14:44:33 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-11-02 14:44:33 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-11-02 14:44:33 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-09-05 10:51:36 +00:00
|
|
|
#include "data/data_cloud_themes.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
#include "base/object_ptr.h"
|
2019-09-05 10:51:36 +00:00
|
|
|
|
2021-09-02 16:58:04 +00:00
|
|
|
namespace style {
|
|
|
|
struct colorizer;
|
|
|
|
} // namespace style
|
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
2017-02-03 20:07:26 +00:00
|
|
|
class FlatButton;
|
|
|
|
class ScrollArea;
|
|
|
|
class CrossButton;
|
|
|
|
class MultiSelect;
|
2017-09-30 18:26:45 +00:00
|
|
|
class PlainShadow;
|
2019-09-09 14:44:08 +00:00
|
|
|
class DropdownMenu;
|
|
|
|
class IconButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
} // namespace Ui
|
2016-11-02 14:44:33 +00:00
|
|
|
|
|
|
|
namespace Window {
|
2019-09-03 08:25:19 +00:00
|
|
|
|
|
|
|
class Controller;
|
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
namespace Theme {
|
|
|
|
|
2019-09-08 16:29:43 +00:00
|
|
|
struct ParsedTheme {
|
|
|
|
QByteArray palette;
|
|
|
|
QByteArray background;
|
|
|
|
bool isPng = false;
|
|
|
|
bool tiled = false;
|
|
|
|
};
|
|
|
|
|
2019-09-08 18:00:31 +00:00
|
|
|
[[nodiscard]] QByteArray ColorHexString(const QColor &color);
|
|
|
|
[[nodiscard]] QByteArray ReplaceValueInPaletteContent(
|
|
|
|
const QByteArray &content,
|
|
|
|
const QByteArray &name,
|
|
|
|
const QByteArray &value);
|
2019-09-05 20:21:44 +00:00
|
|
|
[[nodiscard]] QByteArray WriteCloudToText(const Data::CloudTheme &cloud);
|
|
|
|
[[nodiscard]] Data::CloudTheme ReadCloudFromText(const QByteArray &text);
|
2020-05-12 07:06:44 +00:00
|
|
|
[[nodiscard]] QByteArray StripCloudTextFields(const QByteArray &text);
|
2019-08-26 16:36:23 +00:00
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
class Editor : public TWidget {
|
|
|
|
public:
|
2019-09-05 10:51:36 +00:00
|
|
|
Editor(
|
|
|
|
QWidget*,
|
|
|
|
not_null<Window::Controller*> window,
|
|
|
|
const Data::CloudTheme &cloud);
|
2016-11-02 14:44:33 +00:00
|
|
|
|
2019-09-05 20:21:44 +00:00
|
|
|
[[nodiscard]] static QByteArray ColorizeInContent(
|
|
|
|
QByteArray content,
|
2021-09-02 16:58:04 +00:00
|
|
|
const style::colorizer &colorizer);
|
2019-09-05 20:21:44 +00:00
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2017-02-03 20:07:26 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2016-11-02 14:44:33 +00:00
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
2016-11-02 14:44:33 +00:00
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
private:
|
2019-09-03 08:25:19 +00:00
|
|
|
void save();
|
2019-09-09 14:44:08 +00:00
|
|
|
void showMenu();
|
|
|
|
void exportTheme();
|
2019-09-09 20:58:41 +00:00
|
|
|
void importTheme();
|
2017-02-03 20:07:26 +00:00
|
|
|
void closeEditor();
|
2019-09-08 13:40:15 +00:00
|
|
|
void closeWithConfirmation();
|
2019-09-09 20:58:41 +00:00
|
|
|
void updateControlsGeometry();
|
2017-02-03 20:07:26 +00:00
|
|
|
|
2019-09-05 10:51:36 +00:00
|
|
|
const not_null<Window::Controller*> _window;
|
|
|
|
const Data::CloudTheme _cloud;
|
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
class Inner;
|
|
|
|
QPointer<Inner> _inner;
|
|
|
|
object_ptr<Ui::CrossButton> _close;
|
2019-09-09 14:44:08 +00:00
|
|
|
object_ptr<Ui::IconButton> _menuToggle;
|
2020-06-05 10:00:06 +00:00
|
|
|
base::unique_qptr<Ui::DropdownMenu> _menu;
|
2017-02-03 20:07:26 +00:00
|
|
|
object_ptr<Ui::MultiSelect> _select;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::PlainShadow> _leftShadow;
|
|
|
|
object_ptr<Ui::PlainShadow> _topShadow;
|
2019-09-03 08:25:19 +00:00
|
|
|
object_ptr<Ui::FlatButton> _save;
|
2019-09-05 20:21:44 +00:00
|
|
|
bool _saving = false;
|
2016-11-02 14:44:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|