diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 8101513b3..60a871e45 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -402,6 +402,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_background_text2" = "Sounds awful."; "lng_background_bad_link" = "This background link appears to be invalid."; "lng_background_apply" = "Apply"; +"lng_background_share" = "Share"; +"lng_background_link_copied" = "Link copied to clipboard"; "lng_download_path_ask" = "Ask download path for each file"; "lng_download_path" = "Download path"; diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 65f65bcd6..b9b2ed23f 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -12,12 +12,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "window/themes/window_theme.h" #include "ui/effects/round_checkbox.h" +#include "ui/toast/toast.h" #include "ui/image/image.h" #include "history/history.h" #include "history/history_message.h" #include "history/view/history_view_message.h" #include "auth_session.h" #include "apiwrap.h" +#include "messenger.h" #include "data/data_session.h" #include "data/data_user.h" #include "data/data_document.h" @@ -153,9 +155,10 @@ void BackgroundBox::prepare() { void BackgroundBox::backgroundChosen(int index) { const auto &papers = Auth().data().wallpapers(); if (index >= 0 && index < papers.size()) { - App::main()->setChatBackground(papers[index]); + Ui::show( + Box(papers[index]), + LayerOption::KeepOther); } - closeBox(); } BackgroundBox::Inner::Inner(QWidget *parent) : RpWidget(parent) @@ -305,6 +308,9 @@ void BackgroundPreviewBox::prepare() { addButton(langFactory(lng_background_apply), [=] { apply(); }); addButton(langFactory(lng_cancel), [=] { closeBox(); }); + if (!_paper.slug.isEmpty()) { + addLeftButton(langFactory(lng_background_share), [=] { share(); }); + } _scaled = PrepareScaledFromThumb(_paper.thumb); checkLoadedDocument(); @@ -337,6 +343,14 @@ void BackgroundPreviewBox::apply() { closeBox(); } +void BackgroundPreviewBox::share() { + Expects(!_paper.slug.isEmpty()); + + QApplication::clipboard()->setText( + Messenger::Instance().createInternalLinkFull("bg/" + _paper.slug)); + Ui::Toast::Show(lang(lng_background_link_copied)); +} + void BackgroundPreviewBox::paintEvent(QPaintEvent *e) { Painter p(this); diff --git a/Telegram/SourceFiles/boxes/background_box.h b/Telegram/SourceFiles/boxes/background_box.h index eb84e0314..64c0844ed 100644 --- a/Telegram/SourceFiles/boxes/background_box.h +++ b/Telegram/SourceFiles/boxes/background_box.h @@ -61,6 +61,7 @@ protected: private: void apply(); + void share(); void step_radial(TimeMs ms, bool timer); QRect radialRect() const;