Share background from preview.

This commit is contained in:
John Preston 2019-01-21 15:08:26 +04:00
parent bf87de3706
commit e7804d014d
3 changed files with 19 additions and 2 deletions

View File

@ -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";

View File

@ -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<BackgroundPreviewBox>(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);

View File

@ -61,6 +61,7 @@ protected:
private:
void apply();
void share();
void step_radial(TimeMs ms, bool timer);
QRect radialRect() const;