From 6bac662ee8cad4e221d5fa271f3419cf4ad229e9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 25 Jan 2023 22:53:35 +0300 Subject: [PATCH] Added ability to change initial color in color editor. --- .../info/userpic/info_userpic_colors_editor.cpp | 4 +++- Telegram/SourceFiles/ui/widgets/color_editor.cpp | 9 +++++++++ Telegram/SourceFiles/ui/widgets/color_editor.h | 5 ++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_colors_editor.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_colors_editor.cpp index 63280d5b4a..d776a3661f 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_colors_editor.cpp +++ b/Telegram/SourceFiles/info/userpic/info_userpic_colors_editor.cpp @@ -274,7 +274,9 @@ object_ptr CreateGradientEditor( buttonsContainer->chosenChanges( ) | rpl::start_with_next([=](ColorsLine::Chosen *chosen) { if (chosen) { - editor->showColor(state->colors[chosen->index()]); + const auto color = state->colors[chosen->index()]; + editor->showColor(color); + editor->setCurrent(color); } }, editor->lifetime()); diff --git a/Telegram/SourceFiles/ui/widgets/color_editor.cpp b/Telegram/SourceFiles/ui/widgets/color_editor.cpp index 94acc3eeda..dc2267adb6 100644 --- a/Telegram/SourceFiles/ui/widgets/color_editor.cpp +++ b/Telegram/SourceFiles/ui/widgets/color_editor.cpp @@ -1270,3 +1270,12 @@ void ColorEditor::setRGB(int red, int green, int blue, int alpha) { updateHSBFields(); update(); } + +void ColorEditor::showColor(QColor color) { + updateFromColor(color); +} + +void ColorEditor::setCurrent(QColor color) { + _current = color; + update(); +} diff --git a/Telegram/SourceFiles/ui/widgets/color_editor.h b/Telegram/SourceFiles/ui/widgets/color_editor.h index 207ad2187b..ff4410f972 100644 --- a/Telegram/SourceFiles/ui/widgets/color_editor.h +++ b/Telegram/SourceFiles/ui/widgets/color_editor.h @@ -27,9 +27,8 @@ public: [[nodiscard]] rpl::producer colorValue() const; [[nodiscard]] rpl::producer<> submitRequests() const; - void showColor(QColor color) { - updateFromColor(color); - } + void showColor(QColor color); + void setCurrent(QColor color); void setInnerFocus() const;