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