tdesktop/Telegram/SourceFiles/window/themes/window_theme_editor.h

94 lines
2.2 KiB
C
Raw Normal View History

/*
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 "data/data_cloud_themes.h"
2019-09-13 12:22:54 +00:00
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
namespace Ui {
class FlatButton;
class ScrollArea;
class CrossButton;
class MultiSelect;
class PlainShadow;
class DropdownMenu;
class IconButton;
} // namespace Ui
namespace Window {
2019-09-03 08:25:19 +00:00
class Controller;
namespace Theme {
struct Colorizer;
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);
[[nodiscard]] QByteArray WriteCloudToText(const Data::CloudTheme &cloud);
[[nodiscard]] Data::CloudTheme ReadCloudFromText(const QByteArray &text);
[[nodiscard]] QByteArray StripCloudTextFields(const QByteArray &text);
2019-08-26 16:36:23 +00:00
class Editor : public TWidget {
public:
Editor(
QWidget*,
not_null<Window::Controller*> window,
const Data::CloudTheme &cloud);
[[nodiscard]] static QByteArray ColorizeInContent(
QByteArray content,
const Colorizer &colorizer);
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void focusInEvent(QFocusEvent *e) override;
private:
2019-09-03 08:25:19 +00:00
void save();
void showMenu();
void exportTheme();
2019-09-09 20:58:41 +00:00
void importTheme();
void closeEditor();
void closeWithConfirmation();
2019-09-09 20:58:41 +00:00
void updateControlsGeometry();
const not_null<Window::Controller*> _window;
const Data::CloudTheme _cloud;
object_ptr<Ui::ScrollArea> _scroll;
class Inner;
QPointer<Inner> _inner;
object_ptr<Ui::CrossButton> _close;
object_ptr<Ui::IconButton> _menuToggle;
2020-06-05 10:00:06 +00:00
base::unique_qptr<Ui::DropdownMenu> _menu;
object_ptr<Ui::MultiSelect> _select;
object_ptr<Ui::PlainShadow> _leftShadow;
object_ptr<Ui::PlainShadow> _topShadow;
2019-09-03 08:25:19 +00:00
object_ptr<Ui::FlatButton> _save;
bool _saving = false;
};
} // namespace Theme
} // namespace Window