mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Remove some more Auth() calls.
This commit is contained in:
parent
ff44094ded
commit
137fa0378c
59 changed files with 840 additions and 460 deletions
|
@ -314,9 +314,8 @@ namespace App {
|
||||||
void quit() {
|
void quit() {
|
||||||
if (quitting()) {
|
if (quitting()) {
|
||||||
return;
|
return;
|
||||||
} else if (Main::Session::Exists()
|
} else if (Core::IsAppLaunched()
|
||||||
&& Auth().data().exportInProgress()) {
|
&& Core::App().exportPreventsQuit()) {
|
||||||
Auth().data().stopExportWithConfirmation([] { App::quit(); });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLaunchState(QuitRequested);
|
setLaunchState(QuitRequested);
|
||||||
|
|
|
@ -29,8 +29,10 @@ constexpr auto kDefaultLimit = 10 * kMegabyte;
|
||||||
|
|
||||||
AutoDownloadBox::AutoDownloadBox(
|
AutoDownloadBox::AutoDownloadBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
Data::AutoDownload::Source source)
|
Data::AutoDownload::Source source)
|
||||||
: _source(source) {
|
: _session(session)
|
||||||
|
, _source(source) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadBox::prepare() {
|
void AutoDownloadBox::prepare() {
|
||||||
|
@ -45,7 +47,7 @@ void AutoDownloadBox::setupContent() {
|
||||||
|
|
||||||
setTitle(tr::lng_media_auto_title());
|
setTitle(tr::lng_media_auto_title());
|
||||||
|
|
||||||
const auto settings = &Auth().settings().autoDownload();
|
const auto settings = &_session->settings().autoDownload();
|
||||||
const auto checked = [=](Source source, Type type) {
|
const auto checked = [=](Source source, Type type) {
|
||||||
return (settings->bytesLimit(source, type) > 0);
|
return (settings->bytesLimit(source, type) > 0);
|
||||||
};
|
};
|
||||||
|
@ -166,11 +168,11 @@ void AutoDownloadBox::setupContent() {
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}
|
}
|
||||||
if (allowMoreTypes.contains(Type::Photo)) {
|
if (allowMoreTypes.contains(Type::Photo)) {
|
||||||
Auth().data().photoLoadSettingsChanged();
|
_session->data().photoLoadSettingsChanged();
|
||||||
}
|
}
|
||||||
if (ranges::find_if(allowMoreTypes, _1 != Type::Photo)
|
if (ranges::find_if(allowMoreTypes, _1 != Type::Photo)
|
||||||
!= allowMoreTypes.end()) {
|
!= allowMoreTypes.end()) {
|
||||||
Auth().data().documentLoadSettingsChanged();
|
_session->data().documentLoadSettingsChanged();
|
||||||
}
|
}
|
||||||
closeBox();
|
closeBox();
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace AutoDownload {
|
namespace AutoDownload {
|
||||||
enum class Source;
|
enum class Source;
|
||||||
|
@ -17,7 +21,10 @@ enum class Source;
|
||||||
|
|
||||||
class AutoDownloadBox : public BoxContent {
|
class AutoDownloadBox : public BoxContent {
|
||||||
public:
|
public:
|
||||||
AutoDownloadBox(QWidget*, Data::AutoDownload::Source source);
|
AutoDownloadBox(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
Data::AutoDownload::Source source);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -25,6 +32,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
Data::AutoDownload::Source _source;
|
Data::AutoDownload::Source _source;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
|
AutoLockBox::AutoLockBox(QWidget*, not_null<Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
void AutoLockBox::prepare() {
|
void AutoLockBox::prepare() {
|
||||||
setTitle(tr::lng_passcode_autolock());
|
setTitle(tr::lng_passcode_autolock());
|
||||||
|
|
||||||
|
@ -39,6 +43,6 @@ void AutoLockBox::durationChanged(int seconds) {
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
Global::RefLocalPasscodeChanged().notify();
|
||||||
|
|
||||||
Auth().checkAutoLock();
|
_session->checkAutoLock();
|
||||||
closeBox();
|
closeBox();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Radiobutton;
|
class Radiobutton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
class AutoLockBox : public BoxContent {
|
class AutoLockBox : public BoxContent {
|
||||||
public:
|
public:
|
||||||
AutoLockBox(QWidget*) {
|
AutoLockBox(QWidget*, not_null<Main::Session*> session);
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -24,6 +27,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
void durationChanged(int seconds);
|
void durationChanged(int seconds);
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
std::vector<object_ptr<Ui::Radiobutton>> _options;
|
std::vector<object_ptr<Ui::Radiobutton>> _options;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,9 @@ class BackgroundBox::Inner
|
||||||
, private MTP::Sender
|
, private MTP::Sender
|
||||||
, private base::Subscriber {
|
, private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
Inner(QWidget *parent);
|
Inner(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Main::Session*> session);
|
||||||
|
|
||||||
rpl::producer<Data::WallPaper> chooseEvents() const;
|
rpl::producer<Data::WallPaper> chooseEvents() const;
|
||||||
rpl::producer<Data::WallPaper> removeRequests() const;
|
rpl::producer<Data::WallPaper> removeRequests() const;
|
||||||
|
@ -107,6 +109,8 @@ private:
|
||||||
int row) const;
|
int row) const;
|
||||||
void validatePaperThumbnail(const Paper &paper) const;
|
void validatePaperThumbnail(const Paper &paper) const;
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
std::vector<Paper> _papers;
|
std::vector<Paper> _papers;
|
||||||
|
|
||||||
Selection _over;
|
Selection _over;
|
||||||
|
@ -118,7 +122,8 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BackgroundBox::BackgroundBox(QWidget*) {
|
BackgroundBox::BackgroundBox(QWidget*, not_null<Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundBox::prepare() {
|
void BackgroundBox::prepare() {
|
||||||
|
@ -128,11 +133,15 @@ void BackgroundBox::prepare() {
|
||||||
|
|
||||||
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
||||||
|
|
||||||
_inner = setInnerWidget(object_ptr<Inner>(this), st::backgroundScroll);
|
_inner = setInnerWidget(
|
||||||
|
object_ptr<Inner>(this, _session),
|
||||||
|
st::backgroundScroll);
|
||||||
|
|
||||||
_inner->chooseEvents(
|
_inner->chooseEvents(
|
||||||
) | rpl::start_with_next([](const Data::WallPaper &paper) {
|
) | rpl::start_with_next([=](const Data::WallPaper &paper) {
|
||||||
Ui::show(Box<BackgroundPreviewBox>(paper), LayerOption::KeepOther);
|
Ui::show(
|
||||||
|
Box<BackgroundPreviewBox>(_session, paper),
|
||||||
|
LayerOption::KeepOther);
|
||||||
}, _inner->lifetime());
|
}, _inner->lifetime());
|
||||||
|
|
||||||
_inner->removeRequests(
|
_inner->removeRequests(
|
||||||
|
@ -143,6 +152,7 @@ void BackgroundBox::prepare() {
|
||||||
|
|
||||||
void BackgroundBox::removePaper(const Data::WallPaper &paper) {
|
void BackgroundBox::removePaper(const Data::WallPaper &paper) {
|
||||||
const auto box = std::make_shared<QPointer<BoxContent>>();
|
const auto box = std::make_shared<QPointer<BoxContent>>();
|
||||||
|
const auto session = _session;
|
||||||
const auto remove = [=, weak = make_weak(this)]{
|
const auto remove = [=, weak = make_weak(this)]{
|
||||||
if (*box) {
|
if (*box) {
|
||||||
(*box)->closeBox();
|
(*box)->closeBox();
|
||||||
|
@ -150,8 +160,8 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) {
|
||||||
if (weak) {
|
if (weak) {
|
||||||
weak->_inner->removePaper(paper);
|
weak->_inner->removePaper(paper);
|
||||||
}
|
}
|
||||||
Auth().data().removeWallpaper(paper);
|
session->data().removeWallpaper(paper);
|
||||||
Auth().api().request(MTPaccount_SaveWallPaper(
|
session->api().request(MTPaccount_SaveWallPaper(
|
||||||
paper.mtpInput(),
|
paper.mtpInput(),
|
||||||
MTP_bool(true),
|
MTP_bool(true),
|
||||||
paper.mtpSettings()
|
paper.mtpSettings()
|
||||||
|
@ -166,17 +176,21 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) {
|
||||||
LayerOption::KeepOther);
|
LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundBox::Inner::Inner(QWidget *parent) : RpWidget(parent)
|
BackgroundBox::Inner::Inner(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Main::Session*> session)
|
||||||
|
: RpWidget(parent)
|
||||||
|
, _session(session)
|
||||||
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
|
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
|
||||||
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
|
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
|
||||||
if (Auth().data().wallpapers().empty()) {
|
if (_session->data().wallpapers().empty()) {
|
||||||
resize(st::boxWideWidth, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
|
resize(st::boxWideWidth, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
|
||||||
} else {
|
} else {
|
||||||
updatePapers();
|
updatePapers();
|
||||||
}
|
}
|
||||||
requestPapers();
|
requestPapers();
|
||||||
|
|
||||||
subscribe(Auth().downloaderTaskFinished(), [=] { update(); });
|
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
|
||||||
using Update = Window::Theme::BackgroundUpdate;
|
using Update = Window::Theme::BackgroundUpdate;
|
||||||
subscribe(Window::Theme::Background(), [=](const Update &update) {
|
subscribe(Window::Theme::Background(), [=](const Update &update) {
|
||||||
if (update.paletteChanged()) {
|
if (update.paletteChanged()) {
|
||||||
|
@ -192,9 +206,9 @@ BackgroundBox::Inner::Inner(QWidget *parent) : RpWidget(parent)
|
||||||
|
|
||||||
void BackgroundBox::Inner::requestPapers() {
|
void BackgroundBox::Inner::requestPapers() {
|
||||||
request(MTPaccount_GetWallPapers(
|
request(MTPaccount_GetWallPapers(
|
||||||
MTP_int(Auth().data().wallpapersHash())
|
MTP_int(_session->data().wallpapersHash())
|
||||||
)).done([=](const MTPaccount_WallPapers &result) {
|
)).done([=](const MTPaccount_WallPapers &result) {
|
||||||
if (Auth().data().updateWallpapers(result)) {
|
if (_session->data().updateWallpapers(result)) {
|
||||||
updatePapers();
|
updatePapers();
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
|
@ -220,7 +234,7 @@ void BackgroundBox::Inner::sortPapers() {
|
||||||
void BackgroundBox::Inner::updatePapers() {
|
void BackgroundBox::Inner::updatePapers() {
|
||||||
_over = _overDown = Selection();
|
_over = _overDown = Selection();
|
||||||
|
|
||||||
_papers = Auth().data().wallpapers(
|
_papers = _session->data().wallpapers(
|
||||||
) | ranges::view::filter([](const Data::WallPaper &paper) {
|
) | ranges::view::filter([](const Data::WallPaper &paper) {
|
||||||
return !paper.isPattern() || paper.backgroundColor().has_value();
|
return !paper.isPattern() || paper.backgroundColor().has_value();
|
||||||
}) | ranges::view::transform([](const Data::WallPaper &paper) {
|
}) | ranges::view::transform([](const Data::WallPaper &paper) {
|
||||||
|
|
|
@ -9,13 +9,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class WallPaper;
|
class WallPaper;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
class BackgroundBox : public BoxContent {
|
class BackgroundBox : public BoxContent {
|
||||||
public:
|
public:
|
||||||
BackgroundBox(QWidget*);
|
BackgroundBox(QWidget*, not_null<Main::Session*> session);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -25,6 +29,8 @@ private:
|
||||||
|
|
||||||
void removePaper(const Data::WallPaper &paper);
|
void removePaper(const Data::WallPaper &paper);
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
QPointer<Inner> _inner;
|
QPointer<Inner> _inner;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -387,20 +387,24 @@ QImage PrepareScaledFromFull(
|
||||||
|
|
||||||
BackgroundPreviewBox::BackgroundPreviewBox(
|
BackgroundPreviewBox::BackgroundPreviewBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const Data::WallPaper &paper)
|
const Data::WallPaper &paper)
|
||||||
: _text1(GenerateTextItem(
|
: _session(session)
|
||||||
|
, _text1(GenerateTextItem(
|
||||||
delegate(),
|
delegate(),
|
||||||
Auth().data().history(peerFromUser(PeerData::kServiceNotificationsId)),
|
_session->data().history(
|
||||||
|
peerFromUser(PeerData::kServiceNotificationsId)),
|
||||||
tr::lng_background_text1(tr::now),
|
tr::lng_background_text1(tr::now),
|
||||||
false))
|
false))
|
||||||
, _text2(GenerateTextItem(
|
, _text2(GenerateTextItem(
|
||||||
delegate(),
|
delegate(),
|
||||||
Auth().data().history(peerFromUser(PeerData::kServiceNotificationsId)),
|
_session->data().history(
|
||||||
|
peerFromUser(PeerData::kServiceNotificationsId)),
|
||||||
tr::lng_background_text2(tr::now),
|
tr::lng_background_text2(tr::now),
|
||||||
true))
|
true))
|
||||||
, _paper(paper)
|
, _paper(paper)
|
||||||
, _radial([=](crl::time now) { radialAnimationCallback(now); }) {
|
, _radial([=](crl::time now) { radialAnimationCallback(now); }) {
|
||||||
subscribe(Auth().downloaderTaskFinished(), [=] { update(); });
|
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
|
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
|
||||||
|
@ -483,7 +487,7 @@ void BackgroundPreviewBox::apply() {
|
||||||
&& Data::IsCloudWallPaper(_paper);
|
&& Data::IsCloudWallPaper(_paper);
|
||||||
App::main()->setChatBackground(_paper, std::move(_full));
|
App::main()->setChatBackground(_paper, std::move(_full));
|
||||||
if (install) {
|
if (install) {
|
||||||
Auth().api().request(MTPaccount_InstallWallPaper(
|
_session->api().request(MTPaccount_InstallWallPaper(
|
||||||
_paper.mtpInput(),
|
_paper.mtpInput(),
|
||||||
_paper.mtpSettings()
|
_paper.mtpSettings()
|
||||||
)).send();
|
)).send();
|
||||||
|
@ -736,18 +740,23 @@ void BackgroundPreviewBox::checkLoadedDocument() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BackgroundPreviewBox::Start(
|
bool BackgroundPreviewBox::Start(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const QString &slug,
|
const QString &slug,
|
||||||
const QMap<QString, QString> ¶ms) {
|
const QMap<QString, QString> ¶ms) {
|
||||||
if (const auto paper = Data::WallPaper::FromColorSlug(slug)) {
|
if (const auto paper = Data::WallPaper::FromColorSlug(slug)) {
|
||||||
Ui::show(Box<BackgroundPreviewBox>(paper->withUrlParams(params)));
|
Ui::show(Box<BackgroundPreviewBox>(
|
||||||
|
session,
|
||||||
|
paper->withUrlParams(params)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!IsValidWallPaperSlug(slug)) {
|
if (!IsValidWallPaperSlug(slug)) {
|
||||||
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Auth().api().requestWallPaper(slug, [=](const Data::WallPaper &result) {
|
session->api().requestWallPaper(slug, [=](const Data::WallPaper &result) {
|
||||||
Ui::show(Box<BackgroundPreviewBox>(result.withUrlParams(params)));
|
Ui::show(Box<BackgroundPreviewBox>(
|
||||||
|
session,
|
||||||
|
result.withUrlParams(params)));
|
||||||
}, [](const RPCError &error) {
|
}, [](const RPCError &error) {
|
||||||
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Checkbox;
|
class Checkbox;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -23,9 +27,13 @@ class BackgroundPreviewBox
|
||||||
: public BoxContent
|
: public BoxContent
|
||||||
, private HistoryView::SimpleElementDelegate {
|
, private HistoryView::SimpleElementDelegate {
|
||||||
public:
|
public:
|
||||||
BackgroundPreviewBox(QWidget*, const Data::WallPaper &paper);
|
BackgroundPreviewBox(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const Data::WallPaper &paper);
|
||||||
|
|
||||||
static bool Start(
|
static bool Start(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const QString &slug,
|
const QString &slug,
|
||||||
const QMap<QString, QString> ¶ms);
|
const QMap<QString, QString> ¶ms);
|
||||||
|
|
||||||
|
@ -58,6 +66,7 @@ private:
|
||||||
void startFadeInFrom(QPixmap previous);
|
void startFadeInFrom(QPixmap previous);
|
||||||
void checkBlurAnimationStart();
|
void checkBlurAnimationStart();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
AdminLog::OwnedItem _text1;
|
AdminLog::OwnedItem _text1;
|
||||||
AdminLog::OwnedItem _text2;
|
AdminLog::OwnedItem _text2;
|
||||||
Data::WallPaper _paper;
|
Data::WallPaper _paper;
|
||||||
|
|
|
@ -60,8 +60,7 @@ void createErrorLabel(
|
||||||
|
|
||||||
class ChangePhoneBox::EnterPhone : public BoxContent {
|
class ChangePhoneBox::EnterPhone : public BoxContent {
|
||||||
public:
|
public:
|
||||||
EnterPhone(QWidget*) {
|
EnterPhone(QWidget*, not_null<Main::Session*> session);
|
||||||
}
|
|
||||||
|
|
||||||
void setInnerFocus() override {
|
void setInnerFocus() override {
|
||||||
_phone->setFocusFast();
|
_phone->setFocusFast();
|
||||||
|
@ -79,6 +78,7 @@ private:
|
||||||
showError(QString());
|
showError(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
object_ptr<Ui::PhoneInput> _phone = { nullptr };
|
object_ptr<Ui::PhoneInput> _phone = { nullptr };
|
||||||
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _error = { nullptr };
|
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _error = { nullptr };
|
||||||
mtpRequestId _requestId = 0;
|
mtpRequestId _requestId = 0;
|
||||||
|
@ -87,7 +87,13 @@ private:
|
||||||
|
|
||||||
class ChangePhoneBox::EnterCode : public BoxContent {
|
class ChangePhoneBox::EnterCode : public BoxContent {
|
||||||
public:
|
public:
|
||||||
EnterCode(QWidget*, const QString &phone, const QString &hash, int codeLength, int callTimeout);
|
EnterCode(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const QString &phone,
|
||||||
|
const QString &hash,
|
||||||
|
int codeLength,
|
||||||
|
int callTimeout);
|
||||||
|
|
||||||
void setInnerFocus() override {
|
void setInnerFocus() override {
|
||||||
_code->setFocusFast();
|
_code->setFocusFast();
|
||||||
|
@ -107,6 +113,8 @@ private:
|
||||||
}
|
}
|
||||||
int countHeight();
|
int countHeight();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
QString _phone;
|
QString _phone;
|
||||||
QString _hash;
|
QString _hash;
|
||||||
int _codeLength = 0;
|
int _codeLength = 0;
|
||||||
|
@ -119,6 +127,12 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChangePhoneBox::EnterPhone::EnterPhone(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
void ChangePhoneBox::EnterPhone::prepare() {
|
void ChangePhoneBox::EnterPhone::prepare() {
|
||||||
setTitle(tr::lng_change_phone_title());
|
setTitle(tr::lng_change_phone_title());
|
||||||
|
|
||||||
|
@ -188,6 +202,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(const QString &phoneNumber, const
|
||||||
}
|
}
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Box<EnterCode>(
|
Box<EnterCode>(
|
||||||
|
_session,
|
||||||
phoneNumber,
|
phoneNumber,
|
||||||
phoneCodeHash,
|
phoneCodeHash,
|
||||||
codeLength,
|
codeLength,
|
||||||
|
@ -229,8 +244,15 @@ void ChangePhoneBox::EnterPhone::showError(const QString &text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangePhoneBox::EnterCode::EnterCode(QWidget*, const QString &phone, const QString &hash, int codeLength, int callTimeout)
|
ChangePhoneBox::EnterCode::EnterCode(
|
||||||
: _phone(phone)
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const QString &phone,
|
||||||
|
const QString &hash,
|
||||||
|
int codeLength,
|
||||||
|
int callTimeout)
|
||||||
|
: _session(session)
|
||||||
|
, _phone(phone)
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _codeLength(codeLength)
|
, _codeLength(codeLength)
|
||||||
, _callTimeout(callTimeout)
|
, _callTimeout(callTimeout)
|
||||||
|
@ -279,13 +301,15 @@ void ChangePhoneBox::EnterCode::submit() {
|
||||||
}
|
}
|
||||||
hideError();
|
hideError();
|
||||||
|
|
||||||
|
const auto session = _session;
|
||||||
const auto code = _code->getDigitsOnly();
|
const auto code = _code->getDigitsOnly();
|
||||||
|
const auto weak = make_weak(this);
|
||||||
_requestId = MTP::send(MTPaccount_ChangePhone(
|
_requestId = MTP::send(MTPaccount_ChangePhone(
|
||||||
MTP_string(_phone),
|
MTP_string(_phone),
|
||||||
MTP_string(_hash),
|
MTP_string(_hash),
|
||||||
MTP_string(code)
|
MTP_string(code)
|
||||||
), rpcDone([weak = make_weak(this)](const MTPUser &result) {
|
), rpcDone([=](const MTPUser &result) {
|
||||||
Auth().data().processUser(result);
|
session->data().processUser(result);
|
||||||
if (weak) {
|
if (weak) {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
}
|
}
|
||||||
|
@ -342,11 +366,17 @@ bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangePhoneBox::ChangePhoneBox(QWidget*, not_null<Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
void ChangePhoneBox::prepare() {
|
void ChangePhoneBox::prepare() {
|
||||||
|
const auto session = _session;
|
||||||
|
|
||||||
setTitle(tr::lng_change_phone_title());
|
setTitle(tr::lng_change_phone_title());
|
||||||
addButton(tr::lng_change_phone_button(), [] {
|
addButton(tr::lng_change_phone_button(), [=] {
|
||||||
Ui::show(Box<ConfirmBox>(tr::lng_change_phone_warning(tr::now), [] {
|
Ui::show(Box<ConfirmBox>(tr::lng_change_phone_warning(tr::now), [=] {
|
||||||
Ui::show(Box<EnterPhone>());
|
Ui::show(Box<EnterPhone>(session));
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
addButton(tr::lng_cancel(), [this] {
|
addButton(tr::lng_cancel(), [this] {
|
||||||
|
|
|
@ -9,10 +9,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
class ChangePhoneBox : public BoxContent {
|
class ChangePhoneBox : public BoxContent {
|
||||||
public:
|
public:
|
||||||
ChangePhoneBox(QWidget*) {
|
ChangePhoneBox(QWidget*, not_null<Main::Session*> session);
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -23,5 +26,7 @@ private:
|
||||||
class EnterPhone;
|
class EnterPhone;
|
||||||
class EnterCode;
|
class EnterCode;
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -459,7 +459,8 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
bool suggestModerateActions)
|
bool suggestModerateActions)
|
||||||
: _ids(1, item->fullId()) {
|
: _session(&item->history()->session())
|
||||||
|
, _ids(1, item->fullId()) {
|
||||||
if (suggestModerateActions) {
|
if (suggestModerateActions) {
|
||||||
_moderateBan = item->suggestBanReport();
|
_moderateBan = item->suggestBanReport();
|
||||||
_moderateDeleteAll = item->suggestDeleteAllReport();
|
_moderateDeleteAll = item->suggestDeleteAllReport();
|
||||||
|
@ -472,8 +473,10 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||||
|
|
||||||
DeleteMessagesBox::DeleteMessagesBox(
|
DeleteMessagesBox::DeleteMessagesBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
MessageIdsList &&selected)
|
MessageIdsList &&selected)
|
||||||
: _ids(std::move(selected)) {
|
: _session(session)
|
||||||
|
, _ids(std::move(selected)) {
|
||||||
Expects(!_ids.empty());
|
Expects(!_ids.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +484,8 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool justClear)
|
bool justClear)
|
||||||
: _wipeHistoryPeer(peer)
|
: _session(&peer->session())
|
||||||
|
, _wipeHistoryPeer(peer)
|
||||||
, _wipeHistoryJustClear(justClear) {
|
, _wipeHistoryJustClear(justClear) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +583,7 @@ void DeleteMessagesBox::prepare() {
|
||||||
PeerData *DeleteMessagesBox::checkFromSinglePeer() const {
|
PeerData *DeleteMessagesBox::checkFromSinglePeer() const {
|
||||||
auto result = (PeerData*)nullptr;
|
auto result = (PeerData*)nullptr;
|
||||||
for (const auto fullId : std::as_const(_ids)) {
|
for (const auto fullId : std::as_const(_ids)) {
|
||||||
if (const auto item = Auth().data().message(fullId)) {
|
if (const auto item = _session->data().message(fullId)) {
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = peer;
|
result = peer;
|
||||||
|
@ -762,7 +766,7 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||||
|
|
||||||
base::flat_map<not_null<PeerData*>, QVector<MTPint>> idsByPeer;
|
base::flat_map<not_null<PeerData*>, QVector<MTPint>> idsByPeer;
|
||||||
for (const auto itemId : _ids) {
|
for (const auto itemId : _ids) {
|
||||||
if (const auto item = Auth().data().message(itemId)) {
|
if (const auto item = _session->data().message(itemId)) {
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
const auto wasOnServer = IsServerMsgId(item->id);
|
const auto wasOnServer = IsServerMsgId(item->id);
|
||||||
const auto wasLast = (history->lastMessage() == item);
|
const auto wasLast = (history->lastMessage() == item);
|
||||||
|
@ -780,18 +784,21 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||||
for (const auto &[peer, ids] : idsByPeer) {
|
for (const auto &[peer, ids] : idsByPeer) {
|
||||||
peer->session().api().deleteMessages(peer, ids, revoke);
|
peer->session().api().deleteMessages(peer, ids, revoke);
|
||||||
}
|
}
|
||||||
|
const auto session = _session;
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
Auth().data().sendHistoryChangeNotifications();
|
session->data().sendHistoryChangeNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmInviteBox::ConfirmInviteBox(
|
ConfirmInviteBox::ConfirmInviteBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const MTPDchatInvite &data,
|
const MTPDchatInvite &data,
|
||||||
Fn<void()> submit)
|
Fn<void()> submit)
|
||||||
: _submit(std::move(submit))
|
: _session(session)
|
||||||
|
, _submit(std::move(submit))
|
||||||
, _title(this, st::confirmInviteTitle)
|
, _title(this, st::confirmInviteTitle)
|
||||||
, _status(this, st::confirmInviteStatus)
|
, _status(this, st::confirmInviteStatus)
|
||||||
, _participants(GetParticipants(data))
|
, _participants(GetParticipants(_session, data))
|
||||||
, _isChannel(data.is_channel() && !data.is_megagroup()) {
|
, _isChannel(data.is_channel() && !data.is_megagroup()) {
|
||||||
const auto title = qs(data.vtitle());
|
const auto title = qs(data.vtitle());
|
||||||
const auto count = data.vparticipants_count().v;
|
const auto count = data.vparticipants_count().v;
|
||||||
|
@ -807,11 +814,11 @@ ConfirmInviteBox::ConfirmInviteBox(
|
||||||
_title->setText(title);
|
_title->setText(title);
|
||||||
_status->setText(status);
|
_status->setText(status);
|
||||||
|
|
||||||
const auto photo = Auth().data().processPhoto(data.vphoto());
|
const auto photo = _session->data().processPhoto(data.vphoto());
|
||||||
if (!photo->isNull()) {
|
if (!photo->isNull()) {
|
||||||
_photo = photo->thumbnail();
|
_photo = photo->thumbnail();
|
||||||
if (!_photo->loaded()) {
|
if (!_photo->loaded()) {
|
||||||
subscribe(Auth().downloaderTaskFinished(), [=] {
|
subscribe(_session->downloaderTaskFinished(), [=] {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
_photo->load(Data::FileOrigin());
|
_photo->load(Data::FileOrigin());
|
||||||
|
@ -824,6 +831,7 @@ ConfirmInviteBox::ConfirmInviteBox(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
|
std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const MTPDchatInvite &data) {
|
const MTPDchatInvite &data) {
|
||||||
const auto participants = data.vparticipants();
|
const auto participants = data.vparticipants();
|
||||||
if (!participants) {
|
if (!participants) {
|
||||||
|
@ -833,7 +841,7 @@ std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
|
||||||
auto result = std::vector<not_null<UserData*>>();
|
auto result = std::vector<not_null<UserData*>>();
|
||||||
result.reserve(v.size());
|
result.reserve(v.size());
|
||||||
for (const auto &participant : v) {
|
for (const auto &participant : v) {
|
||||||
if (const auto user = Auth().data().processUser(participant)) {
|
if (const auto user = session->data().processUser(participant)) {
|
||||||
result.push_back(user);
|
result.push_back(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Checkbox;
|
class Checkbox;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
|
@ -150,7 +154,10 @@ public:
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
bool suggestModerateActions);
|
bool suggestModerateActions);
|
||||||
DeleteMessagesBox(QWidget*, MessageIdsList &&selected);
|
DeleteMessagesBox(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
MessageIdsList &&selected);
|
||||||
DeleteMessagesBox(QWidget*, not_null<PeerData*> peer, bool justClear);
|
DeleteMessagesBox(QWidget*, not_null<PeerData*> peer, bool justClear);
|
||||||
|
|
||||||
void setDeleteConfirmedCallback(Fn<void()> callback) {
|
void setDeleteConfirmedCallback(Fn<void()> callback) {
|
||||||
|
@ -172,6 +179,8 @@ private:
|
||||||
PeerData *checkFromSinglePeer() const;
|
PeerData *checkFromSinglePeer() const;
|
||||||
std::optional<RevokeConfig> revokeText(not_null<PeerData*> peer) const;
|
std::optional<RevokeConfig> revokeText(not_null<PeerData*> peer) const;
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
PeerData * const _wipeHistoryPeer = nullptr;
|
PeerData * const _wipeHistoryPeer = nullptr;
|
||||||
const bool _wipeHistoryJustClear = false;
|
const bool _wipeHistoryJustClear = false;
|
||||||
const MessageIdsList _ids;
|
const MessageIdsList _ids;
|
||||||
|
@ -194,6 +203,7 @@ class ConfirmInviteBox : public BoxContent, public RPCSender {
|
||||||
public:
|
public:
|
||||||
ConfirmInviteBox(
|
ConfirmInviteBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const MTPDchatInvite &data,
|
const MTPDchatInvite &data,
|
||||||
Fn<void()> submit);
|
Fn<void()> submit);
|
||||||
~ConfirmInviteBox();
|
~ConfirmInviteBox();
|
||||||
|
@ -206,8 +216,11 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::vector<not_null<UserData*>> GetParticipants(
|
static std::vector<not_null<UserData*>> GetParticipants(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const MTPDchatInvite &data);
|
const MTPDchatInvite &data);
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
Fn<void()> _submit;
|
Fn<void()> _submit;
|
||||||
object_ptr<Ui::FlatLabel> _title;
|
object_ptr<Ui::FlatLabel> _title;
|
||||||
object_ptr<Ui::FlatLabel> _status;
|
object_ptr<Ui::FlatLabel> _status;
|
||||||
|
|
|
@ -232,7 +232,7 @@ EditCaptionBox::EditCaptionBox(
|
||||||
_thumbnailImageLoaded = _thumbnailImage
|
_thumbnailImageLoaded = _thumbnailImage
|
||||||
? _thumbnailImage->loaded()
|
? _thumbnailImage->loaded()
|
||||||
: true;
|
: true;
|
||||||
subscribe(Auth().downloaderTaskFinished(), [=] {
|
subscribe(_controller->session().downloaderTaskFinished(), [=] {
|
||||||
if (!_thumbnailImageLoaded
|
if (!_thumbnailImageLoaded
|
||||||
&& _thumbnailImage
|
&& _thumbnailImage
|
||||||
&& _thumbnailImage->loaded()) {
|
&& _thumbnailImage->loaded()) {
|
||||||
|
@ -876,7 +876,7 @@ void EditCaptionBox::setInnerFocus() {
|
||||||
void EditCaptionBox::save() {
|
void EditCaptionBox::save() {
|
||||||
if (_saveRequestId) return;
|
if (_saveRequestId) return;
|
||||||
|
|
||||||
const auto item = Auth().data().message(_msgId);
|
const auto item = _controller->session().data().message(_msgId);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
_error = tr::lng_edit_deleted(tr::now);
|
_error = tr::lng_edit_deleted(tr::now);
|
||||||
update();
|
update();
|
||||||
|
@ -894,7 +894,7 @@ void EditCaptionBox::save() {
|
||||||
};
|
};
|
||||||
const auto prepareFlags = Ui::ItemTextOptions(
|
const auto prepareFlags = Ui::ItemTextOptions(
|
||||||
item->history(),
|
item->history(),
|
||||||
Auth().user()).flags;
|
_controller->session().user()).flags;
|
||||||
TextUtilities::PrepareForSending(sending, prepareFlags);
|
TextUtilities::PrepareForSending(sending, prepareFlags);
|
||||||
TextUtilities::Trim(sending);
|
TextUtilities::Trim(sending);
|
||||||
|
|
||||||
|
@ -913,7 +913,7 @@ void EditCaptionBox::save() {
|
||||||
};
|
};
|
||||||
item->setText(sending);
|
item->setText(sending);
|
||||||
|
|
||||||
Auth().api().editMedia(
|
_controller->session().api().editMedia(
|
||||||
std::move(_preparedList),
|
std::move(_preparedList),
|
||||||
(!_asFile && _photo) ? SendMediaType::Photo : SendMediaType::File,
|
(!_asFile && _photo) ? SendMediaType::Photo : SendMediaType::File,
|
||||||
_field->getTextWithAppliedMarkdown(),
|
_field->getTextWithAppliedMarkdown(),
|
||||||
|
@ -938,21 +938,24 @@ void EditCaptionBox::save() {
|
||||||
|
|
||||||
void EditCaptionBox::saveDone(const MTPUpdates &updates) {
|
void EditCaptionBox::saveDone(const MTPUpdates &updates) {
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
|
const auto controller = _controller;
|
||||||
closeBox();
|
closeBox();
|
||||||
Auth().api().applyUpdates(updates);
|
controller->session().api().applyUpdates(updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditCaptionBox::saveFail(const RPCError &error) {
|
bool EditCaptionBox::saveFail(const RPCError &error) {
|
||||||
if (MTP::isDefaultHandledError(error)) return false;
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
_saveRequestId = 0;
|
_saveRequestId = 0;
|
||||||
QString err = error.type();
|
const auto &type = error.type();
|
||||||
if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) {
|
if (type == qstr("MESSAGE_ID_INVALID")
|
||||||
|
|| type == qstr("CHAT_ADMIN_REQUIRED")
|
||||||
|
|| type == qstr("MESSAGE_EDIT_TIME_EXPIRED")) {
|
||||||
_error = tr::lng_edit_error(tr::now);
|
_error = tr::lng_edit_error(tr::now);
|
||||||
} else if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
} else if (type == qstr("MESSAGE_NOT_MODIFIED")) {
|
||||||
closeBox();
|
closeBox();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == qstr("MESSAGE_EMPTY")) {
|
} else if (type == qstr("MESSAGE_EMPTY")) {
|
||||||
_field->setFocus();
|
_field->setFocus();
|
||||||
_field->showError();
|
_field->showError();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
|
@ -113,9 +114,11 @@ QString EditPrivacyController::optionLabel(Option option) {
|
||||||
|
|
||||||
EditPrivacyBox::EditPrivacyBox(
|
EditPrivacyBox::EditPrivacyBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Window::SessionController*> window,
|
||||||
std::unique_ptr<EditPrivacyController> controller,
|
std::unique_ptr<EditPrivacyController> controller,
|
||||||
const Value &value)
|
const Value &value)
|
||||||
: _controller(std::move(controller))
|
: _window(window)
|
||||||
|
, _controller(std::move(controller))
|
||||||
, _value(value) {
|
, _value(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +353,7 @@ void EditPrivacyBox::setupContent() {
|
||||||
addLabel(content, _controller->exceptionsDescription());
|
addLabel(content, _controller->exceptionsDescription());
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
|
|
||||||
if (auto below = _controller->setupBelowWidget(content)) {
|
if (auto below = _controller->setupBelowWidget(_window, content)) {
|
||||||
content->add(std::move(below));
|
content->add(std::move(below));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +361,7 @@ void EditPrivacyBox::setupContent() {
|
||||||
const auto someAreDisallowed = (_value.option != Option::Everyone)
|
const auto someAreDisallowed = (_value.option != Option::Everyone)
|
||||||
|| !_value.never.empty();
|
|| !_value.never.empty();
|
||||||
_controller->confirmSave(someAreDisallowed, crl::guard(this, [=] {
|
_controller->confirmSave(someAreDisallowed, crl::guard(this, [=] {
|
||||||
Auth().api().savePrivacy(
|
_window->session().api().savePrivacy(
|
||||||
_controller->apiKey(),
|
_controller->apiKey(),
|
||||||
collectResult());
|
collectResult());
|
||||||
closeBox();
|
closeBox();
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
return { nullptr };
|
return { nullptr };
|
||||||
}
|
}
|
||||||
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupBelowWidget(
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupBelowWidget(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<QWidget*> parent) {
|
not_null<QWidget*> parent) {
|
||||||
return { nullptr };
|
return { nullptr };
|
||||||
}
|
}
|
||||||
|
@ -95,6 +96,7 @@ public:
|
||||||
|
|
||||||
EditPrivacyBox(
|
EditPrivacyBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
not_null<Window::SessionController*> window,
|
||||||
std::unique_ptr<EditPrivacyController> controller,
|
std::unique_ptr<EditPrivacyController> controller,
|
||||||
const Value &value);
|
const Value &value);
|
||||||
|
|
||||||
|
@ -117,6 +119,7 @@ private:
|
||||||
void editExceptions(Exception exception, Fn<void()> done);
|
void editExceptions(Exception exception, Fn<void()> done);
|
||||||
std::vector<not_null<PeerData*>> &exceptions(Exception exception);
|
std::vector<not_null<PeerData*>> &exceptions(Exception exception);
|
||||||
|
|
||||||
|
const not_null<Window::SessionController*> _window;
|
||||||
std::unique_ptr<EditPrivacyController> _controller;
|
std::unique_ptr<EditPrivacyController> _controller;
|
||||||
Value _value;
|
Value _value;
|
||||||
|
|
||||||
|
|
|
@ -265,11 +265,11 @@ QString LocalStorageBox::Row::sizeText(const Database::TaggedSummary &data) cons
|
||||||
|
|
||||||
LocalStorageBox::LocalStorageBox(
|
LocalStorageBox::LocalStorageBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<Database*> db,
|
not_null<Main::Session*> session,
|
||||||
not_null<Database*> dbBig,
|
|
||||||
CreateTag)
|
CreateTag)
|
||||||
: _db(db)
|
: _session(session)
|
||||||
, _dbBig(dbBig) {
|
, _db(&session->data().cache())
|
||||||
|
, _dbBig(&session->data().cacheBigFile()) {
|
||||||
const auto &settings = Local::cacheSettings();
|
const auto &settings = Local::cacheSettings();
|
||||||
const auto &settingsBig = Local::cacheBigFileSettings();
|
const auto &settingsBig = Local::cacheBigFileSettings();
|
||||||
_totalSizeLimit = settings.totalSizeLimit + settingsBig.totalSizeLimit;
|
_totalSizeLimit = settings.totalSizeLimit + settingsBig.totalSizeLimit;
|
||||||
|
@ -277,15 +277,13 @@ LocalStorageBox::LocalStorageBox(
|
||||||
_timeLimit = settings.totalTimeLimit;
|
_timeLimit = settings.totalTimeLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalStorageBox::Show(
|
void LocalStorageBox::Show(not_null<::Main::Session*> session) {
|
||||||
not_null<Database*> db,
|
|
||||||
not_null<Database*> dbBig) {
|
|
||||||
auto shared = std::make_shared<object_ptr<LocalStorageBox>>(
|
auto shared = std::make_shared<object_ptr<LocalStorageBox>>(
|
||||||
Box<LocalStorageBox>(db, dbBig, CreateTag()));
|
Box<LocalStorageBox>(session, CreateTag()));
|
||||||
const auto weak = shared->data();
|
const auto weak = shared->data();
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
db->statsOnMain(),
|
session->data().cache().statsOnMain(),
|
||||||
dbBig->statsOnMain()
|
session->data().cacheBigFile().statsOnMain()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
Database::Stats &&stats,
|
Database::Stats &&stats,
|
||||||
Database::Stats &&statsBig) {
|
Database::Stats &&statsBig) {
|
||||||
|
@ -592,7 +590,7 @@ void LocalStorageBox::save() {
|
||||||
updateBig.totalSizeLimit = _mediaSizeLimit;
|
updateBig.totalSizeLimit = _mediaSizeLimit;
|
||||||
updateBig.totalTimeLimit = _timeLimit;
|
updateBig.totalTimeLimit = _timeLimit;
|
||||||
Local::updateCacheSettings(update, updateBig);
|
Local::updateCacheSettings(update, updateBig);
|
||||||
Auth().data().cache().updateSettings(update);
|
_session->data().cache().updateSettings(update);
|
||||||
closeBox();
|
closeBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "storage/cache/storage_cache_database.h"
|
#include "storage/cache/storage_cache_database.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Cache {
|
namespace Cache {
|
||||||
class Database;
|
class Database;
|
||||||
|
@ -33,11 +37,10 @@ public:
|
||||||
|
|
||||||
LocalStorageBox(
|
LocalStorageBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<Database*> db,
|
not_null<Main::Session*> session,
|
||||||
not_null<Database*> dbBig,
|
|
||||||
CreateTag);
|
CreateTag);
|
||||||
|
|
||||||
static void Show(not_null<Database*> db, not_null<Database*> dbBig);
|
static void Show(not_null<Main::Session*> session);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -80,8 +83,10 @@ private:
|
||||||
Value currentValue,
|
Value currentValue,
|
||||||
Callback &&callback);
|
Callback &&callback);
|
||||||
|
|
||||||
not_null<Storage::Cache::Database*> _db;
|
const not_null<Main::Session*> _session;
|
||||||
not_null<Storage::Cache::Database*> _dbBig;
|
const not_null<Storage::Cache::Database*> _db;
|
||||||
|
const not_null<Storage::Cache::Database*> _dbBig;
|
||||||
|
|
||||||
Database::Stats _stats;
|
Database::Stats _stats;
|
||||||
Database::Stats _statsBig;
|
Database::Stats _statsBig;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ Copyright (C) 2017, Nicholas Guriev <guriev-ns@ya.ru>
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
|
@ -73,7 +74,7 @@ void MuteSettingsBox::prepare() {
|
||||||
|
|
||||||
_save = [=] {
|
_save = [=] {
|
||||||
const auto muteForSeconds = group->value() * 3600;
|
const auto muteForSeconds = group->value() * 3600;
|
||||||
Auth().data().updateNotifySettings(
|
_peer->session().data().updateNotifySettings(
|
||||||
_peer,
|
_peer,
|
||||||
muteForSeconds);
|
muteForSeconds);
|
||||||
closeBox();
|
closeBox();
|
||||||
|
|
|
@ -40,8 +40,12 @@ PasscodeBox::CloudFields PasscodeBox::CloudFields::From(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PasscodeBox::PasscodeBox(QWidget*, bool turningOff)
|
PasscodeBox::PasscodeBox(
|
||||||
: _turningOff(turningOff)
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
bool turningOff)
|
||||||
|
: _session(session)
|
||||||
|
, _turningOff(turningOff)
|
||||||
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
||||||
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
|
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
|
||||||
, _newPasscode(this, st::defaultInputField, Global::LocalPasscode() ? tr::lng_passcode_enter_new() : tr::lng_passcode_enter_first())
|
, _newPasscode(this, st::defaultInputField, Global::LocalPasscode() ? tr::lng_passcode_enter_new() : tr::lng_passcode_enter_first())
|
||||||
|
@ -51,8 +55,12 @@ PasscodeBox::PasscodeBox(QWidget*, bool turningOff)
|
||||||
, _recover(this, tr::lng_signin_recover(tr::now)) {
|
, _recover(this, tr::lng_signin_recover(tr::now)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PasscodeBox::PasscodeBox(QWidget*, const CloudFields &fields)
|
PasscodeBox::PasscodeBox(
|
||||||
: _turningOff(fields.turningOff)
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const CloudFields &fields)
|
||||||
|
: _session(session)
|
||||||
|
, _turningOff(fields.turningOff)
|
||||||
, _cloudPwd(true)
|
, _cloudPwd(true)
|
||||||
, _cloudFields(fields)
|
, _cloudFields(fields)
|
||||||
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
||||||
|
@ -506,7 +514,7 @@ void PasscodeBox::save(bool force) {
|
||||||
const auto weak = make_weak(this);
|
const auto weak = make_weak(this);
|
||||||
cSetPasscodeBadTries(0);
|
cSetPasscodeBadTries(0);
|
||||||
Local::setPasscode(pwd.toUtf8());
|
Local::setPasscode(pwd.toUtf8());
|
||||||
Auth().localPasscodeChanged();
|
_session->localPasscodeChanged();
|
||||||
if (weak) {
|
if (weak) {
|
||||||
closeBox();
|
closeBox();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "core/core_cloud_password.h"
|
#include "core/core_cloud_password.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class InputField;
|
class InputField;
|
||||||
class PasswordInput;
|
class PasswordInput;
|
||||||
|
@ -23,7 +27,7 @@ struct CloudPasswordState;
|
||||||
|
|
||||||
class PasscodeBox : public BoxContent, private MTP::Sender {
|
class PasscodeBox : public BoxContent, private MTP::Sender {
|
||||||
public:
|
public:
|
||||||
PasscodeBox(QWidget*, bool turningOff);
|
PasscodeBox(QWidget*, not_null<Main::Session*> session, bool turningOff);
|
||||||
|
|
||||||
struct CloudFields {
|
struct CloudFields {
|
||||||
static CloudFields From(const Core::CloudPasswordState ¤t);
|
static CloudFields From(const Core::CloudPasswordState ¤t);
|
||||||
|
@ -42,7 +46,10 @@ public:
|
||||||
std::optional<QString> customDescription;
|
std::optional<QString> customDescription;
|
||||||
rpl::producer<QString> customSubmitButton;
|
rpl::producer<QString> customSubmitButton;
|
||||||
};
|
};
|
||||||
PasscodeBox(QWidget*, const CloudFields &fields);
|
PasscodeBox(
|
||||||
|
QWidget*,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const CloudFields &fields);
|
||||||
|
|
||||||
rpl::producer<QByteArray> newPasswordSet() const;
|
rpl::producer<QByteArray> newPasswordSet() const;
|
||||||
rpl::producer<> passwordReloadNeeded() const;
|
rpl::producer<> passwordReloadNeeded() const;
|
||||||
|
@ -122,6 +129,8 @@ private:
|
||||||
void passwordChecked();
|
void passwordChecked();
|
||||||
void serverError();
|
void serverError();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
QString _pattern;
|
QString _pattern;
|
||||||
|
|
||||||
QPointer<BoxContent> _replacedBy;
|
QPointer<BoxContent> _replacedBy;
|
||||||
|
|
|
@ -57,7 +57,7 @@ void SetCloudPassword(not_null<GenericBox*> box, not_null<UserData*> user) {
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
const auto weak = make_weak(box);
|
const auto weak = make_weak(box);
|
||||||
if (CheckEditCloudPassword()) {
|
if (CheckEditCloudPassword(&user->session())) {
|
||||||
box->getDelegate()->show(
|
box->getDelegate()->show(
|
||||||
EditCloudPasswordBox(&user->session()));
|
EditCloudPasswordBox(&user->session()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -566,7 +566,9 @@ void EditAdminBox::requestTransferPassword(not_null<ChannelData*> channel) {
|
||||||
const Core::CloudPasswordResult &result) {
|
const Core::CloudPasswordResult &result) {
|
||||||
sendTransferRequestFrom(*box, channel, result);
|
sendTransferRequestFrom(*box, channel, result);
|
||||||
});
|
});
|
||||||
*box = getDelegate()->show(Box<PasscodeBox>(fields));
|
*box = getDelegate()->show(Box<PasscodeBox>(
|
||||||
|
&channel->session(),
|
||||||
|
fields));
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -480,6 +480,17 @@ void Application::writeInstallBetaVersionsSetting() {
|
||||||
_launcher->writeInstallBetaVersionsSetting();
|
_launcher->writeInstallBetaVersionsSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::exportPreventsQuit() {
|
||||||
|
if (!activeAccount().sessionExists()
|
||||||
|
|| !activeAccount().session().data().exportInProgress()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
activeAccount().session().data().stopExportWithConfirmation([] {
|
||||||
|
App::quit();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int Application::unreadBadge() const {
|
int Application::unreadBadge() const {
|
||||||
return activeAccount().sessionExists()
|
return activeAccount().sessionExists()
|
||||||
? activeAccount().session().data().unreadBadge()
|
? activeAccount().session().data().unreadBadge()
|
||||||
|
@ -551,12 +562,15 @@ bool Application::openLocalUrl(const QString &url, QVariant context) {
|
||||||
}
|
}
|
||||||
auto command = urlTrimmed.midRef(protocol.size());
|
auto command = urlTrimmed.midRef(protocol.size());
|
||||||
|
|
||||||
|
const auto session = activeAccount().sessionExists()
|
||||||
|
? &activeAccount().session()
|
||||||
|
: nullptr;
|
||||||
using namespace qthelp;
|
using namespace qthelp;
|
||||||
const auto options = RegExOption::CaseInsensitive;
|
const auto options = RegExOption::CaseInsensitive;
|
||||||
for (const auto &[expression, handler] : LocalUrlHandlers()) {
|
for (const auto &[expression, handler] : LocalUrlHandlers()) {
|
||||||
const auto match = regex_match(expression, command, options);
|
const auto match = regex_match(expression, command, options);
|
||||||
if (match) {
|
if (match) {
|
||||||
return handler(match, context);
|
return handler(session, match, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -130,17 +130,18 @@ public:
|
||||||
void badMtprotoConfigurationError();
|
void badMtprotoConfigurationError();
|
||||||
|
|
||||||
// Databases.
|
// Databases.
|
||||||
Storage::Databases &databases() {
|
[[nodiscard]] Storage::Databases &databases() {
|
||||||
return *_databases;
|
return *_databases;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account component.
|
// Account component.
|
||||||
Main::Account &activeAccount() const {
|
[[nodiscard]] Main::Account &activeAccount() const {
|
||||||
return *_account;
|
return *_account;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] bool exportPreventsQuit();
|
||||||
|
|
||||||
// Main::Session component.
|
// Main::Session component.
|
||||||
int unreadBadge() const;
|
[[nodiscard]] int unreadBadge() const;
|
||||||
bool unreadBadgeMuted() const;
|
bool unreadBadgeMuted() const;
|
||||||
|
|
||||||
// Media component.
|
// Media component.
|
||||||
|
|
|
@ -33,19 +33,22 @@ namespace {
|
||||||
|
|
||||||
using Match = qthelp::RegularExpressionMatch;
|
using Match = qthelp::RegularExpressionMatch;
|
||||||
|
|
||||||
bool JoinGroupByHash(const Match &match, const QVariant &context) {
|
bool JoinGroupByHash(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto hash = match->captured(1);
|
const auto hash = match->captured(1);
|
||||||
Auth().api().checkChatInvite(hash, [=](const MTPChatInvite &result) {
|
session->api().checkChatInvite(hash, [=](const MTPChatInvite &result) {
|
||||||
Core::App().hideMediaView();
|
Core::App().hideMediaView();
|
||||||
result.match([=](const MTPDchatInvite &data) {
|
result.match([=](const MTPDchatInvite &data) {
|
||||||
Ui::show(Box<ConfirmInviteBox>(data, [=] {
|
Ui::show(Box<ConfirmInviteBox>(session, data, [=] {
|
||||||
Auth().api().importChatInvite(hash);
|
session->api().importChatInvite(hash);
|
||||||
}));
|
}));
|
||||||
}, [=](const MTPDchatInviteAlready &data) {
|
}, [=](const MTPDchatInviteAlready &data) {
|
||||||
if (const auto chat = Auth().data().processChat(data.vchat())) {
|
if (const auto chat = session->data().processChat(data.vchat())) {
|
||||||
App::wnd()->sessionController()->showPeerHistory(
|
App::wnd()->sessionController()->showPeerHistory(
|
||||||
chat,
|
chat,
|
||||||
Window::SectionShow::Way::Forward);
|
Window::SectionShow::Way::Forward);
|
||||||
|
@ -61,8 +64,11 @@ bool JoinGroupByHash(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowStickerSet(const Match &match, const QVariant &context) {
|
bool ShowStickerSet(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Core::App().hideMediaView();
|
Core::App().hideMediaView();
|
||||||
|
@ -72,14 +78,20 @@ bool ShowStickerSet(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetLanguage(const Match &match, const QVariant &context) {
|
bool SetLanguage(
|
||||||
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
const auto languageId = match->captured(1);
|
const auto languageId = match->captured(1);
|
||||||
Lang::CurrentCloudManager().switchWithWarning(languageId);
|
Lang::CurrentCloudManager().switchWithWarning(languageId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShareUrl(const Match &match, const QVariant &context) {
|
bool ShareUrl(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto params = url_parse_params(
|
auto params = url_parse_params(
|
||||||
|
@ -93,8 +105,11 @@ bool ShareUrl(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfirmPhone(const Match &match, const QVariant &context) {
|
bool ConfirmPhone(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto params = url_parse_params(
|
auto params = url_parse_params(
|
||||||
|
@ -109,8 +124,11 @@ bool ConfirmPhone(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShareGameScore(const Match &match, const QVariant &context) {
|
bool ShareGameScore(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
|
@ -120,7 +138,10 @@ bool ShareGameScore(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplySocksProxy(const Match &match, const QVariant &context) {
|
bool ApplySocksProxy(
|
||||||
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
auto params = url_parse_params(
|
auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
|
@ -128,7 +149,10 @@ bool ApplySocksProxy(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplyMtprotoProxy(const Match &match, const QVariant &context) {
|
bool ApplyMtprotoProxy(
|
||||||
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
auto params = url_parse_params(
|
auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
|
@ -160,26 +184,36 @@ bool ShowPassportForm(const QMap<QString, QString> ¶ms) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowPassport(const Match &match, const QVariant &context) {
|
bool ShowPassport(
|
||||||
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
return ShowPassportForm(url_parse_params(
|
return ShowPassportForm(url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower));
|
qthelp::UrlParamNameTransform::ToLower));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowWallPaper(const Match &match, const QVariant &context) {
|
bool ShowWallPaper(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
return BackgroundPreviewBox::Start(
|
return BackgroundPreviewBox::Start(
|
||||||
|
session,
|
||||||
params.value(qsl("slug")),
|
params.value(qsl("slug")),
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResolveUsername(const Match &match, const QVariant &context) {
|
bool ResolveUsername(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
|
@ -228,8 +262,11 @@ bool ResolveUsername(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResolvePrivatePost(const Match &match, const QVariant &context) {
|
bool ResolvePrivatePost(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
|
@ -249,18 +286,17 @@ bool ResolvePrivatePost(const Match &match, const QVariant &context) {
|
||||||
const auto fail = [=] {
|
const auto fail = [=] {
|
||||||
Ui::show(Box<InformBox>(tr::lng_error_post_link_invalid(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_error_post_link_invalid(tr::now)));
|
||||||
};
|
};
|
||||||
const auto auth = &Auth();
|
if (const auto channel = session->data().channelLoaded(channelId)) {
|
||||||
if (const auto channel = auth->data().channelLoaded(channelId)) {
|
|
||||||
done(channel);
|
done(channel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auth->api().request(MTPchannels_GetChannels(
|
session->api().request(MTPchannels_GetChannels(
|
||||||
MTP_vector<MTPInputChannel>(
|
MTP_vector<MTPInputChannel>(
|
||||||
1,
|
1,
|
||||||
MTP_inputChannel(MTP_int(channelId), MTP_long(0)))
|
MTP_inputChannel(MTP_int(channelId), MTP_long(0)))
|
||||||
)).done([=](const MTPmessages_Chats &result) {
|
)).done([=](const MTPmessages_Chats &result) {
|
||||||
result.match([&](const auto &data) {
|
result.match([&](const auto &data) {
|
||||||
const auto peer = auth->data().processChats(data.vchats());
|
const auto peer = session->data().processChats(data.vchats());
|
||||||
if (peer && peer->id == peerFromChannel(channelId)) {
|
if (peer && peer->id == peerFromChannel(channelId)) {
|
||||||
done(peer);
|
done(peer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -273,8 +309,11 @@ bool ResolvePrivatePost(const Match &match, const QVariant &context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleUnknown(const Match &match, const QVariant &context) {
|
bool HandleUnknown(
|
||||||
if (!Main::Session::Exists()) {
|
Main::Session *session,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto request = match->captured(1);
|
const auto request = match->captured(1);
|
||||||
|
@ -298,7 +337,7 @@ bool HandleUnknown(const Match &match, const QVariant &context) {
|
||||||
Ui::show(Box<InformBox>(text));
|
Ui::show(Box<InformBox>(text));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Auth().api().requestDeepLinkInfo(request, callback);
|
session->api().requestDeepLinkInfo(request, callback);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,16 @@ namespace qthelp {
|
||||||
class RegularExpressionMatch;
|
class RegularExpressionMatch;
|
||||||
} // namespace qthelp
|
} // namespace qthelp
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
struct LocalUrlHandler {
|
struct LocalUrlHandler {
|
||||||
QString expression;
|
QString expression;
|
||||||
Fn<bool(
|
Fn<bool(
|
||||||
|
Main::Session *session,
|
||||||
const qthelp::RegularExpressionMatch &match,
|
const qthelp::RegularExpressionMatch &match,
|
||||||
const QVariant &context)> handler;
|
const QVariant &context)> handler;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3012,6 +3012,7 @@ void HistoryInner::deleteAsGroup(FullMsgId itemId) {
|
||||||
return deleteItem(item);
|
return deleteItem(item);
|
||||||
}
|
}
|
||||||
Ui::show(Box<DeleteMessagesBox>(
|
Ui::show(Box<DeleteMessagesBox>(
|
||||||
|
&session(),
|
||||||
session().data().itemsToIds(group->items)));
|
session().data().itemsToIds(group->items)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6131,7 +6131,9 @@ void HistoryWidget::confirmDeleteSelected() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto weak = make_weak(this);
|
const auto weak = make_weak(this);
|
||||||
const auto box = Ui::show(Box<DeleteMessagesBox>(std::move(items)));
|
const auto box = Ui::show(Box<DeleteMessagesBox>(
|
||||||
|
&session(),
|
||||||
|
std::move(items)));
|
||||||
box->setDeleteConfirmedCallback([=] {
|
box->setDeleteConfirmedCallback([=] {
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->clearSelected();
|
strong->clearSelected();
|
||||||
|
|
|
@ -298,10 +298,13 @@ bool AddDeleteSelectedAction(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto session = request.session;
|
||||||
menu->addAction(tr::lng_context_delete_selected(tr::now), [=] {
|
menu->addAction(tr::lng_context_delete_selected(tr::now), [=] {
|
||||||
const auto weak = make_weak(list);
|
const auto weak = make_weak(list);
|
||||||
auto items = ExtractIdsList(request.selectedItems);
|
auto items = ExtractIdsList(request.selectedItems);
|
||||||
const auto box = Ui::show(Box<DeleteMessagesBox>(std::move(items)));
|
const auto box = Ui::show(Box<DeleteMessagesBox>(
|
||||||
|
session,
|
||||||
|
std::move(items)));
|
||||||
box->setDeleteConfirmedCallback([=] {
|
box->setDeleteConfirmedCallback([=] {
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->cancelSelection();
|
strong->cancelSelection();
|
||||||
|
@ -338,6 +341,7 @@ bool AddDeleteMessageAction(
|
||||||
if (asGroup) {
|
if (asGroup) {
|
||||||
if (const auto group = owner->groups().find(item)) {
|
if (const auto group = owner->groups().find(item)) {
|
||||||
Ui::show(Box<DeleteMessagesBox>(
|
Ui::show(Box<DeleteMessagesBox>(
|
||||||
|
&owner->session(),
|
||||||
owner->itemsToIds(group->items)));
|
owner->itemsToIds(group->items)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -439,6 +443,10 @@ void AddCopyLinkAction(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
ContextMenuRequest::ContextMenuRequest(not_null<Main::Session*> session)
|
||||||
|
: session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
not_null<ListWidget*> list,
|
not_null<ListWidget*> list,
|
||||||
const ContextMenuRequest &request) {
|
const ContextMenuRequest &request) {
|
||||||
|
|
|
@ -13,6 +13,10 @@ namespace Ui {
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
enum class PointState : char;
|
enum class PointState : char;
|
||||||
|
@ -22,6 +26,9 @@ struct SelectedItem;
|
||||||
using SelectedItems = std::vector<SelectedItem>;
|
using SelectedItems = std::vector<SelectedItem>;
|
||||||
|
|
||||||
struct ContextMenuRequest {
|
struct ContextMenuRequest {
|
||||||
|
explicit ContextMenuRequest(not_null<Main::Session*> session);
|
||||||
|
|
||||||
|
const not_null<Main::Session*> session;
|
||||||
ClickHandlerPtr link;
|
ClickHandlerPtr link;
|
||||||
Element *view = nullptr;
|
Element *view = nullptr;
|
||||||
HistoryItem *item = nullptr;
|
HistoryItem *item = nullptr;
|
||||||
|
|
|
@ -1611,7 +1611,8 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
mouseActionUpdate(e->globalPos());
|
mouseActionUpdate(e->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextMenuRequest request;
|
auto request = ContextMenuRequest(&_controller->session());
|
||||||
|
|
||||||
request.link = ClickHandler::getActive();
|
request.link = ClickHandler::getActive();
|
||||||
request.view = _overElement;
|
request.view = _overElement;
|
||||||
request.item = _overItemExact
|
request.item = _overItemExact
|
||||||
|
|
|
@ -35,9 +35,11 @@ namespace Info {
|
||||||
|
|
||||||
TopBar::TopBar(
|
TopBar::TopBar(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const style::InfoTopBar &st,
|
const style::InfoTopBar &st,
|
||||||
SelectedItems &&selectedItems)
|
SelectedItems &&selectedItems)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
|
, _session(session)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _selectedItems(Section::MediaType::kCount) {
|
, _selectedItems(Section::MediaType::kCount) {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
@ -516,8 +518,8 @@ MessageIdsList TopBar::collectItems() const {
|
||||||
_selectedItems.list
|
_selectedItems.list
|
||||||
) | ranges::view::transform([](auto &&item) {
|
) | ranges::view::transform([](auto &&item) {
|
||||||
return item.msgId;
|
return item.msgId;
|
||||||
}) | ranges::view::filter([](FullMsgId msgId) {
|
}) | ranges::view::filter([&](FullMsgId msgId) {
|
||||||
return Auth().data().message(msgId) != nullptr;
|
return _session->data().message(msgId) != nullptr;
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +543,9 @@ void TopBar::performDelete() {
|
||||||
if (items.empty()) {
|
if (items.empty()) {
|
||||||
_cancelSelectionClicks.fire({});
|
_cancelSelectionClicks.fire({});
|
||||||
} else {
|
} else {
|
||||||
const auto box = Ui::show(Box<DeleteMessagesBox>(std::move(items)));
|
const auto box = Ui::show(Box<DeleteMessagesBox>(
|
||||||
|
_session,
|
||||||
|
std::move(items)));
|
||||||
box->setDeleteConfirmedCallback([weak = make_weak(this)] {
|
box->setDeleteConfirmedCallback([weak = make_weak(this)] {
|
||||||
if (weak) {
|
if (weak) {
|
||||||
weak->_cancelSelectionClicks.fire({});
|
weak->_cancelSelectionClicks.fire({});
|
||||||
|
|
|
@ -39,6 +39,7 @@ class TopBar : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
TopBar(
|
TopBar(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
const style::InfoTopBar &st,
|
const style::InfoTopBar &st,
|
||||||
SelectedItems &&items);
|
SelectedItems &&items);
|
||||||
|
|
||||||
|
@ -130,6 +131,8 @@ private:
|
||||||
template <typename Widget, typename IsVisible>
|
template <typename Widget, typename IsVisible>
|
||||||
void registerToggleControlCallback(Widget *widget, IsVisible &&callback);
|
void registerToggleControlCallback(Widget *widget, IsVisible &&callback);
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
const style::InfoTopBar &_st;
|
const style::InfoTopBar &_st;
|
||||||
Ui::Animations::Simple _a_highlight;
|
Ui::Animations::Simple _a_highlight;
|
||||||
bool _highlight = false;
|
bool _highlight = false;
|
||||||
|
|
|
@ -353,7 +353,11 @@ void WrapWidget::createTopBar() {
|
||||||
auto selectedItems = _topBar
|
auto selectedItems = _topBar
|
||||||
? _topBar->takeSelectedItems()
|
? _topBar->takeSelectedItems()
|
||||||
: SelectedItems(Section::MediaType::kCount);
|
: SelectedItems(Section::MediaType::kCount);
|
||||||
_topBar.create(this, TopBarStyle(wrapValue), std::move(selectedItems));
|
_topBar.create(
|
||||||
|
this,
|
||||||
|
&session(),
|
||||||
|
TopBarStyle(wrapValue),
|
||||||
|
std::move(selectedItems));
|
||||||
_topBar->cancelSelectionRequests(
|
_topBar->cancelSelectionRequests(
|
||||||
) | rpl::start_with_next([this] {
|
) | rpl::start_with_next([this] {
|
||||||
_content->cancelSelection();
|
_content->cancelSelection();
|
||||||
|
@ -582,7 +586,7 @@ void WrapWidget::showTopBarMenu() {
|
||||||
_topBarMenu = nullptr;
|
_topBarMenu = nullptr;
|
||||||
controller->showSettings(type);
|
controller->showSettings(type);
|
||||||
};
|
};
|
||||||
::Settings::FillMenu(showOther, addAction);
|
::Settings::FillMenu(&self->session(), showOther, addAction);
|
||||||
} else {
|
} else {
|
||||||
_topBarMenu = nullptr;
|
_topBarMenu = nullptr;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1422,7 +1422,9 @@ void ListWidget::deleteItem(UniversalMsgId universalId) {
|
||||||
DeleteMessagesBox *ListWidget::deleteItems(MessageIdsList &&items) {
|
DeleteMessagesBox *ListWidget::deleteItems(MessageIdsList &&items) {
|
||||||
if (!items.empty()) {
|
if (!items.empty()) {
|
||||||
const auto box = Ui::show(
|
const auto box = Ui::show(
|
||||||
Box<DeleteMessagesBox>(std::move(items))).data();
|
Box<DeleteMessagesBox>(
|
||||||
|
&_controller->session(),
|
||||||
|
std::move(items))).data();
|
||||||
setActionBoxWeak(box);
|
setActionBoxWeak(box);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,7 @@ Widget::Widget(
|
||||||
, _inner(setInnerWidget(::Settings::CreateSection(
|
, _inner(setInnerWidget(::Settings::CreateSection(
|
||||||
_type,
|
_type,
|
||||||
this,
|
this,
|
||||||
controller->parentController(),
|
controller->parentController()))) {
|
||||||
_self))) {
|
|
||||||
_inner->sectionShowOther(
|
_inner->sectionShowOther(
|
||||||
) | rpl::start_with_next([=](Type type) {
|
) | rpl::start_with_next([=](Type type) {
|
||||||
controller->showSettings(type);
|
controller->showSettings(type);
|
||||||
|
|
|
@ -325,6 +325,10 @@ public:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
const FormRequest &request);
|
const FormRequest &request);
|
||||||
|
|
||||||
|
not_null<Window::SessionController*> window() const {
|
||||||
|
return _controller;
|
||||||
|
}
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
UserData *bot() const;
|
UserData *bot() const;
|
||||||
QString privacyPolicyUrl() const;
|
QString privacyPolicyUrl() const;
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "boxes/passcode_box.h"
|
#include "boxes/passcode_box.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/countryinput.h"
|
#include "ui/countryinput.h"
|
||||||
|
@ -723,7 +724,7 @@ void PanelController::setupPassword() {
|
||||||
auto fields = PasscodeBox::CloudFields();
|
auto fields = PasscodeBox::CloudFields();
|
||||||
fields.newAlgo = settings.newAlgo;
|
fields.newAlgo = settings.newAlgo;
|
||||||
fields.newSecureSecretAlgo = settings.newSecureAlgo;
|
fields.newSecureSecretAlgo = settings.newSecureAlgo;
|
||||||
auto box = show(Box<PasscodeBox>(fields));
|
auto box = show(Box<PasscodeBox>(&_form->window()->session(), fields));
|
||||||
box->newPasswordSet(
|
box->newPasswordSet(
|
||||||
) | rpl::filter([=](const QByteArray &password) {
|
) | rpl::filter([=](const QByteArray &password) {
|
||||||
return !password.isEmpty();
|
return !password.isEmpty();
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_button.h"
|
#include "info/profile/info_profile_button.h"
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "platform/platform_info.h"
|
#include "platform/platform_info.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -418,7 +419,9 @@ void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPerformance(not_null<Ui::VerticalLayout*> container) {
|
void SetupPerformance(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
SetupAnimations(container);
|
SetupAnimations(container);
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -430,10 +433,10 @@ void SetupPerformance(not_null<Ui::VerticalLayout*> container) {
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([](bool enabled) {
|
) | rpl::filter([](bool enabled) {
|
||||||
return (enabled != cAutoPlayGif());
|
return (enabled != cAutoPlayGif());
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
cSetAutoPlayGif(enabled);
|
cSetAutoPlayGif(enabled);
|
||||||
if (!cAutoPlayGif()) {
|
if (!cAutoPlayGif()) {
|
||||||
Auth().data().stopAutoplayAnimations();
|
controller->session().data().stopAutoplayAnimations();
|
||||||
}
|
}
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -456,16 +459,18 @@ void SetupSystemIntegration(
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
Advanced::Advanced(QWidget *parent, UserData *self)
|
Advanced::Advanced(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
: Section(parent) {
|
: Section(parent) {
|
||||||
setupContent();
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<Type> Advanced::sectionShowOther() {
|
rpl::producer<Type> Advanced::sectionShowOther() {
|
||||||
return _showOther.events();
|
return _showOther.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Advanced::setupContent() {
|
void Advanced::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
auto empty = true;
|
auto empty = true;
|
||||||
|
@ -495,8 +500,8 @@ void Advanced::setupContent() {
|
||||||
SetupConnectionType(content);
|
SetupConnectionType(content);
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
}
|
}
|
||||||
SetupDataStorage(content);
|
SetupDataStorage(controller, content);
|
||||||
SetupAutoDownload(content);
|
SetupAutoDownload(controller, content);
|
||||||
SetupSystemIntegration(content, [=](Type type) {
|
SetupSystemIntegration(content, [=](Type type) {
|
||||||
_showOther.fire_copy(type);
|
_showOther.fire_copy(type);
|
||||||
});
|
});
|
||||||
|
@ -504,7 +509,7 @@ void Advanced::setupContent() {
|
||||||
AddDivider(content);
|
AddDivider(content);
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
AddSubsectionTitle(content, tr::lng_settings_performance());
|
AddSubsectionTitle(content, tr::lng_settings_performance());
|
||||||
SetupPerformance(content);
|
SetupPerformance(controller, content);
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
|
|
||||||
if (cAutoUpdate()) {
|
if (cAutoUpdate()) {
|
||||||
|
|
|
@ -21,12 +21,14 @@ void SetupAnimations(not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
class Advanced : public Section {
|
class Advanced : public Section {
|
||||||
public:
|
public:
|
||||||
explicit Advanced(QWidget *parent, UserData *self = nullptr);
|
Advanced(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
rpl::producer<Type> sectionShowOther() override;
|
rpl::producer<Type> sectionShowOther() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
rpl::event_stream<Type> _showOther;
|
rpl::event_stream<Type> _showOther;
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
Calls::Calls(QWidget *parent, UserData *self)
|
Calls::Calls(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
: Section(parent) {
|
: Section(parent) {
|
||||||
setupContent();
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
Calls::~Calls() {
|
Calls::~Calls() {
|
||||||
|
@ -56,7 +58,7 @@ void Calls::sectionSaveChanges(FnMut<void()> done) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calls::setupContent() {
|
void Calls::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
using namespace tgvoip;
|
using namespace tgvoip;
|
||||||
|
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
|
@ -11,27 +11,28 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
|
||||||
namespace Calls {
|
namespace Calls {
|
||||||
class Call;
|
class Call;
|
||||||
} // namespace Calls
|
} // namespace Calls
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class LevelMeter;
|
class LevelMeter;
|
||||||
}
|
} // namespace Ui
|
||||||
|
|
||||||
namespace tgvoip {
|
namespace tgvoip {
|
||||||
class AudioInputTester;
|
class AudioInputTester;
|
||||||
}
|
} // namespace tgvoip
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
class Calls : public Section {
|
class Calls : public Section {
|
||||||
public:
|
public:
|
||||||
explicit Calls(QWidget *parent, UserData *self = nullptr);
|
Calls(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||||
virtual ~Calls();
|
~Calls();
|
||||||
virtual void sectionSaveChanges(FnMut<void()> done) override;
|
|
||||||
|
void sectionSaveChanges(FnMut<void()> done) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
void requestPermissionAndStartTestingMicrophone();
|
void requestPermissionAndStartTestingMicrophone();
|
||||||
void startTestingMicrophone();
|
void startTestingMicrophone();
|
||||||
void stopTestingMicrophone();
|
void stopTestingMicrophone();
|
||||||
|
@ -43,6 +44,7 @@ private:
|
||||||
std::unique_ptr<tgvoip::AudioInputTester> _micTester;
|
std::unique_ptr<tgvoip::AudioInputTester> _micTester;
|
||||||
Ui::LevelMeter *_micTestLevel = nullptr;
|
Ui::LevelMeter *_micTestLevel = nullptr;
|
||||||
base::Timer _levelUpdateTimer;
|
base::Timer _levelUpdateTimer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "window/themes/window_theme_editor.h"
|
#include "window/themes/window_theme_editor.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "info/profile/info_profile_button.h"
|
#include "info/profile/info_profile_button.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
|
@ -44,7 +45,9 @@ namespace Settings {
|
||||||
|
|
||||||
class BackgroundRow : public Ui::RpWidget {
|
class BackgroundRow : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
BackgroundRow(QWidget *parent);
|
BackgroundRow(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@ -106,9 +109,14 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ChooseFromFile(not_null<QWidget*> parent);
|
void ChooseFromFile(
|
||||||
|
not_null<::Main::Session*> session,
|
||||||
|
not_null<QWidget*> parent);
|
||||||
|
|
||||||
BackgroundRow::BackgroundRow(QWidget *parent) : RpWidget(parent)
|
BackgroundRow::BackgroundRow(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
|
: RpWidget(parent)
|
||||||
, _chooseFromGallery(
|
, _chooseFromGallery(
|
||||||
this,
|
this,
|
||||||
tr::lng_settings_bg_from_gallery(tr::now),
|
tr::lng_settings_bg_from_gallery(tr::now),
|
||||||
|
@ -117,11 +125,11 @@ BackgroundRow::BackgroundRow(QWidget *parent) : RpWidget(parent)
|
||||||
, _radial([=](crl::time now) { radialAnimationCallback(now); }) {
|
, _radial([=](crl::time now) { radialAnimationCallback(now); }) {
|
||||||
updateImage();
|
updateImage();
|
||||||
|
|
||||||
_chooseFromGallery->addClickHandler([] {
|
_chooseFromGallery->addClickHandler([=] {
|
||||||
Ui::show(Box<BackgroundBox>());
|
Ui::show(Box<BackgroundBox>(&controller->session()));
|
||||||
});
|
});
|
||||||
_chooseFromFile->addClickHandler([=] {
|
_chooseFromFile->addClickHandler([=] {
|
||||||
ChooseFromFile(this);
|
ChooseFromFile(&controller->session(), this);
|
||||||
});
|
});
|
||||||
|
|
||||||
using Update = const Window::Theme::BackgroundUpdate;
|
using Update = const Window::Theme::BackgroundUpdate;
|
||||||
|
@ -361,14 +369,17 @@ void DefaultTheme::checkedChangedHook(anim::type animated) {
|
||||||
_radio.setChecked(checked(), animated);
|
_radio.setChecked(checked(), animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChooseFromFile(not_null<QWidget*> parent) {
|
void ChooseFromFile(
|
||||||
|
not_null<::Main::Session*> session,
|
||||||
|
not_null<QWidget*> parent) {
|
||||||
const auto &imgExtensions = cImgExtensions();
|
const auto &imgExtensions = cImgExtensions();
|
||||||
auto filters = QStringList(
|
auto filters = QStringList(
|
||||||
qsl("Theme files (*.tdesktop-theme *.tdesktop-palette *")
|
qsl("Theme files (*.tdesktop-theme *.tdesktop-palette *")
|
||||||
+ imgExtensions.join(qsl(" *"))
|
+ imgExtensions.join(qsl(" *"))
|
||||||
+ qsl(")"));
|
+ qsl(")"));
|
||||||
filters.push_back(FileDialog::AllFilesFilter());
|
filters.push_back(FileDialog::AllFilesFilter());
|
||||||
const auto callback = [=](const FileDialog::OpenResult &result) {
|
const auto callback = crl::guard(session, [=](
|
||||||
|
const FileDialog::OpenResult &result) {
|
||||||
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -396,8 +407,8 @@ void ChooseFromFile(not_null<QWidget*> parent) {
|
||||||
std::make_unique<Images::ImageSource>(
|
std::make_unique<Images::ImageSource>(
|
||||||
std::move(image),
|
std::move(image),
|
||||||
"JPG")));
|
"JPG")));
|
||||||
Ui::show(Box<BackgroundPreviewBox>(local));
|
Ui::show(Box<BackgroundPreviewBox>(session, local));
|
||||||
};
|
});
|
||||||
FileDialog::GetOpenPath(
|
FileDialog::GetOpenPath(
|
||||||
parent.get(),
|
parent.get(),
|
||||||
tr::lng_choose_image(tr::now),
|
tr::lng_choose_image(tr::now),
|
||||||
|
@ -492,7 +503,9 @@ void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupMessages(not_null<Ui::VerticalLayout*> container) {
|
void SetupMessages(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
|
@ -512,7 +525,7 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
|
||||||
QMargins(0, skip, 0, skip)));
|
QMargins(0, skip, 0, skip)));
|
||||||
|
|
||||||
const auto group = std::make_shared<Ui::RadioenumGroup<SendByType>>(
|
const auto group = std::make_shared<Ui::RadioenumGroup<SendByType>>(
|
||||||
Auth().settings().sendSubmitWay());
|
controller->session().settings().sendSubmitWay());
|
||||||
const auto add = [&](SendByType value, const QString &text) {
|
const auto add = [&](SendByType value, const QString &text) {
|
||||||
inner->add(
|
inner->add(
|
||||||
object_ptr<Ui::Radioenum<SendByType>>(
|
object_ptr<Ui::Radioenum<SendByType>>(
|
||||||
|
@ -532,8 +545,8 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
|
||||||
? tr::lng_settings_send_cmdenter(tr::now)
|
? tr::lng_settings_send_cmdenter(tr::now)
|
||||||
: tr::lng_settings_send_ctrlenter(tr::now)));
|
: tr::lng_settings_send_ctrlenter(tr::now)));
|
||||||
|
|
||||||
group->setChangedCallback([](SendByType value) {
|
group->setChangedCallback([=](SendByType value) {
|
||||||
Auth().settings().setSendSubmitWay(value);
|
controller->session().settings().setSendSubmitWay(value);
|
||||||
if (App::main()) {
|
if (App::main()) {
|
||||||
App::main()->ctrlEnterSubmitUpdated();
|
App::main()->ctrlEnterSubmitUpdated();
|
||||||
}
|
}
|
||||||
|
@ -543,33 +556,38 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(inner, st::settingsCheckboxesSkip);
|
AddSkip(inner, st::settingsCheckboxesSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupExport(not_null<Ui::VerticalLayout*> container) {
|
void SetupExport(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
tr::lng_settings_export_data(),
|
tr::lng_settings_export_data(),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
|
const auto session = &controller->session();
|
||||||
Ui::hideSettingsAndLayer();
|
Ui::hideSettingsAndLayer();
|
||||||
App::CallDelayed(
|
App::CallDelayed(
|
||||||
st::boxDuration,
|
st::boxDuration,
|
||||||
&Auth(),
|
session,
|
||||||
[] { Auth().data().startExport(); });
|
[=] { session->data().startExport(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupLocalStorage(not_null<Ui::VerticalLayout*> container) {
|
void SetupLocalStorage(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
tr::lng_settings_manage_local_storage(),
|
tr::lng_settings_manage_local_storage(),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
LocalStorageBox::Show(
|
LocalStorageBox::Show(&controller->session());
|
||||||
&Auth().data().cache(),
|
|
||||||
&Auth().data().cacheBigFile());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
|
void SetupDataStorage(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
|
@ -623,13 +641,15 @@ void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
}, ask->lifetime());
|
}, ask->lifetime());
|
||||||
|
|
||||||
SetupLocalStorage(container);
|
SetupLocalStorage(controller, container);
|
||||||
SetupExport(container);
|
SetupExport(controller, container);
|
||||||
|
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupAutoDownload(not_null<Ui::VerticalLayout*> container) {
|
void SetupAutoDownload(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
|
@ -642,7 +662,7 @@ void SetupAutoDownload(not_null<Ui::VerticalLayout*> container) {
|
||||||
std::move(label),
|
std::move(label),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<AutoDownloadBox>(source));
|
Ui::show(Box<AutoDownloadBox>(&controller->session(), source));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
add(tr::lng_media_auto_in_private(), Source::User);
|
add(tr::lng_media_auto_in_private(), Source::User);
|
||||||
|
@ -652,14 +672,16 @@ void SetupAutoDownload(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupChatBackground(not_null<Ui::VerticalLayout*> container) {
|
void SetupChatBackground(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::lng_settings_section_background());
|
AddSubsectionTitle(container, tr::lng_settings_section_background());
|
||||||
|
|
||||||
container->add(
|
container->add(
|
||||||
object_ptr<BackgroundRow>(container),
|
object_ptr<BackgroundRow>(container, controller),
|
||||||
st::settingsBackgroundPadding);
|
st::settingsBackgroundPadding);
|
||||||
|
|
||||||
const auto skipTop = st::settingsCheckbox.margin.top();
|
const auto skipTop = st::settingsCheckbox.margin.top();
|
||||||
|
@ -925,10 +947,12 @@ void SetupThemeOptions(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSupportSwitchSettings(not_null<Ui::VerticalLayout*> container) {
|
void SetupSupportSwitchSettings(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
using SwitchType = Support::SwitchSettings;
|
using SwitchType = Support::SwitchSettings;
|
||||||
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
||||||
Auth().settings().supportSwitch());
|
controller->session().settings().supportSwitch());
|
||||||
const auto add = [&](SwitchType value, const QString &label) {
|
const auto add = [&](SwitchType value, const QString &label) {
|
||||||
container->add(
|
container->add(
|
||||||
object_ptr<Ui::Radioenum<SwitchType>>(
|
object_ptr<Ui::Radioenum<SwitchType>>(
|
||||||
|
@ -942,13 +966,15 @@ void SetupSupportSwitchSettings(not_null<Ui::VerticalLayout*> container) {
|
||||||
add(SwitchType::None, "Just send the reply");
|
add(SwitchType::None, "Just send the reply");
|
||||||
add(SwitchType::Next, "Send and switch to next");
|
add(SwitchType::Next, "Send and switch to next");
|
||||||
add(SwitchType::Previous, "Send and switch to previous");
|
add(SwitchType::Previous, "Send and switch to previous");
|
||||||
group->setChangedCallback([](SwitchType value) {
|
group->setChangedCallback([=](SwitchType value) {
|
||||||
Auth().settings().setSupportSwitch(value);
|
controller->session().settings().setSupportSwitch(value);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSupportChatsLimitSlice(not_null<Ui::VerticalLayout*> container) {
|
void SetupSupportChatsLimitSlice(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
constexpr auto kDayDuration = 24 * 60 * 60;
|
constexpr auto kDayDuration = 24 * 60 * 60;
|
||||||
struct Option {
|
struct Option {
|
||||||
int days = 0;
|
int days = 0;
|
||||||
|
@ -961,7 +987,7 @@ void SetupSupportChatsLimitSlice(not_null<Ui::VerticalLayout*> container) {
|
||||||
{ 365, "1 year" },
|
{ 365, "1 year" },
|
||||||
{ 0, "All of them" },
|
{ 0, "All of them" },
|
||||||
};
|
};
|
||||||
const auto current = Auth().settings().supportChatsTimeSlice();
|
const auto current = controller->session().settings().supportChatsTimeSlice();
|
||||||
const auto days = current / kDayDuration;
|
const auto days = current / kDayDuration;
|
||||||
const auto best = ranges::min_element(
|
const auto best = ranges::min_element(
|
||||||
options,
|
options,
|
||||||
|
@ -980,12 +1006,15 @@ void SetupSupportChatsLimitSlice(not_null<Ui::VerticalLayout*> container) {
|
||||||
st::settingsSendTypePadding);
|
st::settingsSendTypePadding);
|
||||||
}
|
}
|
||||||
group->setChangedCallback([=](int days) {
|
group->setChangedCallback([=](int days) {
|
||||||
Auth().settings().setSupportChatsTimeSlice(days * kDayDuration);
|
controller->session().settings().setSupportChatsTimeSlice(
|
||||||
|
days * kDayDuration);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSupport(not_null<Ui::VerticalLayout*> container) {
|
void SetupSupport(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
AddSubsectionTitle(container, rpl::single(qsl("Support settings")));
|
AddSubsectionTitle(container, rpl::single(qsl("Support settings")));
|
||||||
|
@ -1001,7 +1030,7 @@ void SetupSupport(not_null<Ui::VerticalLayout*> container) {
|
||||||
std::move(wrap),
|
std::move(wrap),
|
||||||
QMargins(0, skip, 0, skip)));
|
QMargins(0, skip, 0, skip)));
|
||||||
|
|
||||||
SetupSupportSwitchSettings(inner);
|
SetupSupportSwitchSettings(controller, inner);
|
||||||
|
|
||||||
AddSkip(inner, st::settingsCheckboxesSkip);
|
AddSkip(inner, st::settingsCheckboxesSkip);
|
||||||
|
|
||||||
|
@ -1009,12 +1038,13 @@ void SetupSupport(not_null<Ui::VerticalLayout*> container) {
|
||||||
object_ptr<Ui::Checkbox>(
|
object_ptr<Ui::Checkbox>(
|
||||||
inner,
|
inner,
|
||||||
"Enable templates autocomplete",
|
"Enable templates autocomplete",
|
||||||
Auth().settings().supportTemplatesAutocomplete(),
|
controller->session().settings().supportTemplatesAutocomplete(),
|
||||||
st::settingsCheckbox),
|
st::settingsCheckbox),
|
||||||
st::settingsSendTypePadding
|
st::settingsSendTypePadding
|
||||||
)->checkedChanges(
|
)->checkedChanges(
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
) | rpl::start_with_next([=](bool checked) {
|
||||||
Auth().settings().setSupportTemplatesAutocomplete(checked);
|
controller->session().settings().setSupportTemplatesAutocomplete(
|
||||||
|
checked);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}, inner->lifetime());
|
}, inner->lifetime());
|
||||||
|
|
||||||
|
@ -1022,26 +1052,25 @@ void SetupSupport(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
AddSubsectionTitle(inner, rpl::single(qsl("Load chats for a period")));
|
AddSubsectionTitle(inner, rpl::single(qsl("Load chats for a period")));
|
||||||
|
|
||||||
SetupSupportChatsLimitSlice(inner);
|
SetupSupportChatsLimitSlice(controller, inner);
|
||||||
|
|
||||||
AddSkip(inner, st::settingsCheckboxesSkip);
|
AddSkip(inner, st::settingsCheckboxesSkip);
|
||||||
|
|
||||||
AddSkip(inner);
|
AddSkip(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat::Chat(QWidget *parent, not_null<UserData*> self)
|
Chat::Chat(QWidget *parent, not_null<Window::SessionController*> controller)
|
||||||
: Section(parent)
|
: Section(parent) {
|
||||||
, _self(self) {
|
setupContent(controller);
|
||||||
setupContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chat::setupContent() {
|
void Chat::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupThemeOptions(content);
|
SetupThemeOptions(content);
|
||||||
SetupChatBackground(content);
|
SetupChatBackground(controller, content);
|
||||||
SetupStickersEmoji(content);
|
SetupStickersEmoji(content);
|
||||||
SetupMessages(content);
|
SetupMessages(controller, content);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
void SetupDataStorage(not_null<Ui::VerticalLayout*> container);
|
void SetupDataStorage(
|
||||||
void SetupAutoDownload(not_null<Ui::VerticalLayout*> container);
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container);
|
||||||
|
void SetupAutoDownload(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container);
|
||||||
void SetupDefaultThemes(not_null<Ui::VerticalLayout*> container);
|
void SetupDefaultThemes(not_null<Ui::VerticalLayout*> container);
|
||||||
void SetupSupport(not_null<Ui::VerticalLayout*> container);
|
void SetupSupport(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
class Chat : public Section {
|
class Chat : public Section {
|
||||||
public:
|
public:
|
||||||
Chat(QWidget *parent, not_null<UserData*> self);
|
Chat(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
not_null<UserData*> _self;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
auto GenerateCodes() {
|
auto GenerateCodes() {
|
||||||
auto codes = std::map<QString, Fn<void()>>();
|
auto codes = std::map<QString, Fn<void(::Main::Session*)>>();
|
||||||
codes.emplace(qsl("debugmode"), [] {
|
codes.emplace(qsl("debugmode"), [](::Main::Session *session) {
|
||||||
QString text = Logs::DebugEnabled()
|
QString text = Logs::DebugEnabled()
|
||||||
? qsl("Do you want to disable DEBUG logs?")
|
? qsl("Do you want to disable DEBUG logs?")
|
||||||
: qsl("Do you want to enable DEBUG logs?\n\n"
|
: qsl("Do you want to enable DEBUG logs?\n\n"
|
||||||
|
@ -37,24 +37,24 @@ auto GenerateCodes() {
|
||||||
Core::App().switchDebugMode();
|
Core::App().switchDebugMode();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("viewlogs"), [] {
|
codes.emplace(qsl("viewlogs"), [](::Main::Session *session) {
|
||||||
File::ShowInFolder(cWorkingDir() + "log.txt");
|
File::ShowInFolder(cWorkingDir() + "log.txt");
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("testmode"), [] {
|
codes.emplace(qsl("testmode"), [](::Main::Session *session) {
|
||||||
auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
|
auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
|
||||||
Ui::show(Box<ConfirmBox>(text, [] {
|
Ui::show(Box<ConfirmBox>(text, [] {
|
||||||
Core::App().switchTestMode();
|
Core::App().switchTestMode();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
if (!Core::UpdaterDisabled()) {
|
if (!Core::UpdaterDisabled()) {
|
||||||
codes.emplace(qsl("testupdate"), [] {
|
codes.emplace(qsl("testupdate"), [](::Main::Session *session) {
|
||||||
Core::UpdateChecker().test();
|
Core::UpdateChecker().test();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
codes.emplace(qsl("loadlang"), [] {
|
codes.emplace(qsl("loadlang"), [](::Main::Session *session) {
|
||||||
Lang::CurrentCloudManager().switchToLanguage({ qsl("#custom") });
|
Lang::CurrentCloudManager().switchToLanguage({ qsl("#custom") });
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("debugfiles"), [] {
|
codes.emplace(qsl("debugfiles"), [](::Main::Session *session) {
|
||||||
if (!Logs::DebugEnabled()) {
|
if (!Logs::DebugEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -65,39 +65,39 @@ auto GenerateCodes() {
|
||||||
}
|
}
|
||||||
Ui::show(Box<InformBox>(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
|
Ui::show(Box<InformBox>(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("crashplease"), [] {
|
codes.emplace(qsl("crashplease"), [](::Main::Session *session) {
|
||||||
Unexpected("Crashed in Settings!");
|
Unexpected("Crashed in Settings!");
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("workmode"), [] {
|
codes.emplace(qsl("workmode"), [](::Main::Session *session) {
|
||||||
auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?");
|
auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?");
|
||||||
Ui::show(Box<ConfirmBox>(text, [] {
|
Ui::show(Box<ConfirmBox>(text, [] {
|
||||||
Core::App().switchWorkMode();
|
Core::App().switchWorkMode();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("moderate"), [] {
|
codes.emplace(qsl("moderate"), [](::Main::Session *session) {
|
||||||
auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
|
auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
|
||||||
Ui::show(Box<ConfirmBox>(text, []() {
|
Ui::show(Box<ConfirmBox>(text, [] {
|
||||||
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
|
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("getdifference"), [] {
|
codes.emplace(qsl("getdifference"), [](::Main::Session *session) {
|
||||||
if (auto main = App::main()) {
|
if (auto main = App::main()) {
|
||||||
main->getDifference();
|
main->getDifference();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("loadcolors"), [] {
|
codes.emplace(qsl("loadcolors"), [](::Main::Session *session) {
|
||||||
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open palette file", "Palette (*.tdesktop-palette)", [](const FileDialog::OpenResult &result) {
|
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open palette file", "Palette (*.tdesktop-palette)", [](const FileDialog::OpenResult &result) {
|
||||||
if (!result.paths.isEmpty()) {
|
if (!result.paths.isEmpty()) {
|
||||||
Window::Theme::Apply(result.paths.front());
|
Window::Theme::Apply(result.paths.front());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("edittheme"), [] {
|
codes.emplace(qsl("edittheme"), [](::Main::Session *session) {
|
||||||
Window::Theme::Editor::Start();
|
Window::Theme::Editor::Start();
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("videoplayer"), [] {
|
codes.emplace(qsl("videoplayer"), [](::Main::Session *session) {
|
||||||
auto text = cUseExternalVideoPlayer() ? qsl("Use internal video player?") : qsl("Use external video player?");
|
auto text = cUseExternalVideoPlayer() ? qsl("Use internal video player?") : qsl("Use external video player?");
|
||||||
Ui::show(Box<ConfirmBox>(text, [] {
|
Ui::show(Box<ConfirmBox>(text, [] {
|
||||||
cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
|
cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
|
||||||
|
@ -105,7 +105,7 @@ auto GenerateCodes() {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("endpoints"), [] {
|
codes.emplace(qsl("endpoints"), [](::Main::Session *session) {
|
||||||
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open DC endpoints", "DC Endpoints (*.tdesktop-endpoints)", [](const FileDialog::OpenResult &result) {
|
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open DC endpoints", "DC Endpoints (*.tdesktop-endpoints)", [](const FileDialog::OpenResult &result) {
|
||||||
if (!result.paths.isEmpty()) {
|
if (!result.paths.isEmpty()) {
|
||||||
if (!Core::App().dcOptions()->loadFromFile(result.paths.front())) {
|
if (!Core::App().dcOptions()->loadFromFile(result.paths.front())) {
|
||||||
|
@ -114,12 +114,12 @@ auto GenerateCodes() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("registertg"), [] {
|
codes.emplace(qsl("registertg"), [](::Main::Session *session) {
|
||||||
Platform::RegisterCustomScheme();
|
Platform::RegisterCustomScheme();
|
||||||
Ui::Toast::Show("Forced custom scheme register.");
|
Ui::Toast::Show("Forced custom scheme register.");
|
||||||
});
|
});
|
||||||
codes.emplace(qsl("export"), [] {
|
codes.emplace(qsl("export"), [](::Main::Session *session) {
|
||||||
Auth().data().startExport();
|
session->data().startExport();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
|
auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
|
||||||
|
@ -132,28 +132,28 @@ auto GenerateCodes() {
|
||||||
qsl("call_end"),
|
qsl("call_end"),
|
||||||
};
|
};
|
||||||
for (auto &key : audioKeys) {
|
for (auto &key : audioKeys) {
|
||||||
codes.emplace(key, [audioFilters, key] {
|
codes.emplace(key, [=](::Main::Session *session) {
|
||||||
if (!Main::Session::Exists()) {
|
if (!session) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open audio file", audioFilters, [key](const FileDialog::OpenResult &result) {
|
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open audio file", audioFilters, crl::guard(session, [=](const FileDialog::OpenResult &result) {
|
||||||
if (Main::Session::Exists() && !result.paths.isEmpty()) {
|
if (Main::Session::Exists() && !result.paths.isEmpty()) {
|
||||||
auto track = Media::Audio::Current().createTrack();
|
auto track = Media::Audio::Current().createTrack();
|
||||||
track->fillFromFile(result.paths.front());
|
track->fillFromFile(result.paths.front());
|
||||||
if (track->failed()) {
|
if (track->failed()) {
|
||||||
Ui::show(Box<InformBox>("Could not audio :( Errors in 'log.txt'."));
|
Ui::show(Box<InformBox>("Could not audio :( Errors in 'log.txt'."));
|
||||||
} else {
|
} else {
|
||||||
Auth().settings().setSoundOverride(key, result.paths.front());
|
session->settings().setSoundOverride(key, result.paths.front());
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
codes.emplace(qsl("sounds_reset"), [] {
|
codes.emplace(qsl("sounds_reset"), [](::Main::Session *session) {
|
||||||
if (Main::Session::Exists()) {
|
if (session) {
|
||||||
Auth().settings().clearSoundOverrides();
|
session->settings().clearSoundOverrides();
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
Ui::show(Box<InformBox>("All sound overrides were reset."));
|
Ui::show(Box<InformBox>("All sound overrides were reset."));
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ auto GenerateCodes() {
|
||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodesFeedString(const QString &text) {
|
void CodesFeedString(::Main::Session *session, const QString &text) {
|
||||||
static const auto codes = GenerateCodes();
|
static const auto codes = GenerateCodes();
|
||||||
static auto secret = QString();
|
static auto secret = QString();
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ void CodesFeedString(const QString &text) {
|
||||||
auto found = false;
|
auto found = false;
|
||||||
for (const auto &[key, method] : codes) {
|
for (const auto &[key, method] : codes) {
|
||||||
if (piece == key) {
|
if (piece == key) {
|
||||||
method();
|
method(session);
|
||||||
from = size;
|
from = size;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -7,8 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
void CodesFeedString(const QString &text);
|
void CodesFeedString(::Main::Session *session, const QString &text);
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
|
@ -30,23 +30,22 @@ namespace Settings {
|
||||||
object_ptr<Section> CreateSection(
|
object_ptr<Section> CreateSection(
|
||||||
Type type,
|
Type type,
|
||||||
not_null<QWidget*> parent,
|
not_null<QWidget*> parent,
|
||||||
Window::SessionController *controller,
|
not_null<Window::SessionController*> controller) {
|
||||||
UserData *self) {
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::Main:
|
case Type::Main:
|
||||||
return object_ptr<Main>(parent, controller, self);
|
return object_ptr<Main>(parent, controller);
|
||||||
case Type::Information:
|
case Type::Information:
|
||||||
return object_ptr<Information>(parent, controller, self);
|
return object_ptr<Information>(parent, controller);
|
||||||
case Type::Notifications:
|
case Type::Notifications:
|
||||||
return object_ptr<Notifications>(parent, self);
|
return object_ptr<Notifications>(parent, controller);
|
||||||
case Type::PrivacySecurity:
|
case Type::PrivacySecurity:
|
||||||
return object_ptr<PrivacySecurity>(parent, self);
|
return object_ptr<PrivacySecurity>(parent, controller);
|
||||||
case Type::Advanced:
|
case Type::Advanced:
|
||||||
return object_ptr<Advanced>(parent, self);
|
return object_ptr<Advanced>(parent, controller);
|
||||||
case Type::Chat:
|
case Type::Chat:
|
||||||
return object_ptr<Chat>(parent, self);
|
return object_ptr<Chat>(parent, controller);
|
||||||
case Type::Calls:
|
case Type::Calls:
|
||||||
return object_ptr<Calls>(parent, self);
|
return object_ptr<Calls>(parent, controller);
|
||||||
}
|
}
|
||||||
Unexpected("Settings section type in Widget::createInnerWidget.");
|
Unexpected("Settings section type in Widget::createInnerWidget.");
|
||||||
}
|
}
|
||||||
|
@ -170,8 +169,11 @@ void AddSubsectionTitle(
|
||||||
st::settingsSubsectionTitlePadding);
|
st::settingsSubsectionTitlePadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillMenu(Fn<void(Type)> showOther, MenuCallback addAction) {
|
void FillMenu(
|
||||||
if (!Auth().supportMode()) {
|
not_null<::Main::Session*> session,
|
||||||
|
Fn<void(Type)> showOther,
|
||||||
|
MenuCallback addAction) {
|
||||||
|
if (!session->supportMode()) {
|
||||||
addAction(
|
addAction(
|
||||||
tr::lng_settings_information(tr::now),
|
tr::lng_settings_information(tr::now),
|
||||||
[=] { showOther(Type::Information); });
|
[=] { showOther(Type::Information); });
|
||||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class VerticalLayout;
|
class VerticalLayout;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -60,8 +64,7 @@ public:
|
||||||
object_ptr<Section> CreateSection(
|
object_ptr<Section> CreateSection(
|
||||||
Type type,
|
Type type,
|
||||||
not_null<QWidget*> parent,
|
not_null<QWidget*> parent,
|
||||||
Window::SessionController *controller = nullptr,
|
not_null<Window::SessionController*> controller);
|
||||||
UserData *self = nullptr);
|
|
||||||
|
|
||||||
void AddSkip(not_null<Ui::VerticalLayout*> container);
|
void AddSkip(not_null<Ui::VerticalLayout*> container);
|
||||||
void AddSkip(not_null<Ui::VerticalLayout*> container, int skip);
|
void AddSkip(not_null<Ui::VerticalLayout*> container, int skip);
|
||||||
|
@ -96,6 +99,7 @@ using MenuCallback = Fn<QAction*(
|
||||||
Fn<void()> handler)>;
|
Fn<void()> handler)>;
|
||||||
|
|
||||||
void FillMenu(
|
void FillMenu(
|
||||||
|
not_null<::Main::Session*> session,
|
||||||
Fn<void(Type)> showOther,
|
Fn<void(Type)> showOther,
|
||||||
MenuCallback addAction);
|
MenuCallback addAction);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_button.h"
|
#include "info/profile/info_profile_button.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
@ -79,7 +80,9 @@ void SetupPhoto(
|
||||||
Box<PhotoCropBox>(image, tr::lng_settings_crop_profile(tr::now)));
|
Box<PhotoCropBox>(image, tr::lng_settings_crop_profile(tr::now)));
|
||||||
box->ready(
|
box->ready(
|
||||||
) | rpl::start_with_next([=](QImage &&image) {
|
) | rpl::start_with_next([=](QImage &&image) {
|
||||||
Auth().api().uploadPeerPhoto(self, std::move(image));
|
self->session().api().uploadPeerPhoto(
|
||||||
|
self,
|
||||||
|
std::move(image));
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
};
|
};
|
||||||
FileDialog::GetOpenPath(
|
FileDialog::GetOpenPath(
|
||||||
|
@ -229,7 +232,7 @@ void SetupRows(
|
||||||
tr::lng_settings_phone_label(),
|
tr::lng_settings_phone_label(),
|
||||||
Info::Profile::PhoneValue(self),
|
Info::Profile::PhoneValue(self),
|
||||||
tr::lng_profile_copy_phone(tr::now),
|
tr::lng_profile_copy_phone(tr::now),
|
||||||
[] { Ui::show(Box<ChangePhoneBox>()); },
|
[=] { Ui::show(Box<ChangePhoneBox>(&self->session())); },
|
||||||
st::settingsInfoPhone);
|
st::settingsInfoPhone);
|
||||||
|
|
||||||
auto username = Info::Profile::UsernameValue(self);
|
auto username = Info::Profile::UsernameValue(self);
|
||||||
|
@ -333,7 +336,7 @@ BioManager SetupBio(
|
||||||
countdown->setText(QString::number(countLeft));
|
countdown->setText(QString::number(countLeft));
|
||||||
};
|
};
|
||||||
const auto save = [=](FnMut<void()> done) {
|
const auto save = [=](FnMut<void()> done) {
|
||||||
Auth().api().saveSelfBio(
|
self->session().api().saveSelfBio(
|
||||||
TextUtilities::PrepareForSending(bio->getLastText()),
|
TextUtilities::PrepareForSending(bio->getLastText()),
|
||||||
std::move(done));
|
std::move(done));
|
||||||
};
|
};
|
||||||
|
@ -408,10 +411,8 @@ BioManager SetupBio(
|
||||||
|
|
||||||
Information::Information(
|
Information::Information(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller)
|
||||||
not_null<UserData*> self)
|
: Section(parent) {
|
||||||
: Section(parent)
|
|
||||||
, _self(self) {
|
|
||||||
setupContent(controller);
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,13 +424,15 @@ Information::Information(
|
||||||
// _save(std::move(done));
|
// _save(std::move(done));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void Information::setupContent(not_null<Window::SessionController*> controller) {
|
void Information::setupContent(
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupPhoto(content, controller, _self);
|
const auto self = controller->session().user();
|
||||||
SetupRows(content, _self);
|
SetupPhoto(content, controller, self);
|
||||||
SetupBio(content, _self);
|
SetupRows(content, self);
|
||||||
//auto manager = SetupBio(content, _self);
|
SetupBio(content, self);
|
||||||
|
//auto manager = SetupBio(content, self);
|
||||||
//_canSaveChanges = std::move(manager.canSave);
|
//_canSaveChanges = std::move(manager.canSave);
|
||||||
//_save = std::move(manager.save);
|
//_save = std::move(manager.save);
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,11 @@ class Information : public Section {
|
||||||
public:
|
public:
|
||||||
Information(
|
Information(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller);
|
||||||
not_null<UserData*> self);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent(not_null<Window::SessionController*> controller);
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
not_null<UserData*> _self;
|
|
||||||
//rpl::variable<bool> _canSaveChanges;
|
//rpl::variable<bool> _canSaveChanges;
|
||||||
//Fn<void(FnMut<void()> done)> _save;
|
//Fn<void(FnMut<void()> done)> _save;
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ void IntroWidget::resizeEvent(QResizeEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntroWidget::keyPressEvent(QKeyEvent *e) {
|
void IntroWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
CodesFeedString(e->text());
|
CodesFeedString(nullptr, e->text());
|
||||||
return RpWidget::keyPressEvent(e);
|
return RpWidget::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ void SetupLanguageButton(
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSections(
|
void SetupSections(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
Fn<void(Type)> showOther) {
|
Fn<void(Type)> showOther) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
|
@ -71,8 +72,8 @@ void SetupSections(
|
||||||
icon
|
icon
|
||||||
)->addClickHandler([=] { showOther(type); });
|
)->addClickHandler([=] { showOther(type); });
|
||||||
};
|
};
|
||||||
if (Auth().supportMode()) {
|
if (controller->session().supportMode()) {
|
||||||
SetupSupport(container);
|
SetupSupport(controller, container);
|
||||||
|
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
@ -227,51 +228,50 @@ void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
|
||||||
)->addClickHandler(OpenFaq);
|
)->addClickHandler(OpenFaq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupHelp(not_null<Ui::VerticalLayout*> container) {
|
void SetupHelp(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
SetupFaq(container);
|
SetupFaq(container);
|
||||||
|
|
||||||
if (::Main::Session::Exists()) {
|
const auto button = AddButton(
|
||||||
const auto button = AddButton(
|
container,
|
||||||
container,
|
tr::lng_settings_ask_question(),
|
||||||
tr::lng_settings_ask_question(),
|
st::settingsSectionButton);
|
||||||
st::settingsSectionButton);
|
button->addClickHandler([=] {
|
||||||
button->addClickHandler([=] {
|
const auto ready = crl::guard(button, [=](const MTPUser &data) {
|
||||||
const auto ready = crl::guard(button, [](const MTPUser &data) {
|
if (const auto user = controller->session().data().processUser(data)) {
|
||||||
if (const auto user = Auth().data().processUser(data)) {
|
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
||||||
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
const auto sure = crl::guard(button, [=] {
|
|
||||||
Auth().api().requestSupportContact(ready);
|
|
||||||
});
|
|
||||||
auto box = Box<ConfirmBox>(
|
|
||||||
tr::lng_settings_ask_sure(tr::now),
|
|
||||||
tr::lng_settings_ask_ok(tr::now),
|
|
||||||
tr::lng_settings_faq_button(tr::now),
|
|
||||||
sure,
|
|
||||||
OpenFaq);
|
|
||||||
box->setStrictCancel(true);
|
|
||||||
Ui::show(std::move(box));
|
|
||||||
});
|
});
|
||||||
}
|
const auto sure = crl::guard(button, [=] {
|
||||||
|
controller->session().api().requestSupportContact(ready);
|
||||||
|
});
|
||||||
|
auto box = Box<ConfirmBox>(
|
||||||
|
tr::lng_settings_ask_sure(tr::now),
|
||||||
|
tr::lng_settings_ask_ok(tr::now),
|
||||||
|
tr::lng_settings_faq_button(tr::now),
|
||||||
|
sure,
|
||||||
|
OpenFaq);
|
||||||
|
box->setStrictCancel(true);
|
||||||
|
Ui::show(std::move(box));
|
||||||
|
});
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
Main::Main(
|
Main::Main(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller)
|
||||||
not_null<UserData*> self)
|
|
||||||
: Section(parent)
|
: Section(parent)
|
||||||
, _self(self) {
|
, _controller(controller) {
|
||||||
setupContent(controller);
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::keyPressEvent(QKeyEvent *e) {
|
void Main::keyPressEvent(QKeyEvent *e) {
|
||||||
CodesFeedString(e->text());
|
CodesFeedString(&_controller->session(), e->text());
|
||||||
return Section::keyPressEvent(e);
|
return Section::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,11 +280,11 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
|
|
||||||
const auto cover = content->add(object_ptr<Info::Profile::Cover>(
|
const auto cover = content->add(object_ptr<Info::Profile::Cover>(
|
||||||
content,
|
content,
|
||||||
_self,
|
controller->session().user(),
|
||||||
controller));
|
controller));
|
||||||
cover->setOnlineCount(rpl::single(0));
|
cover->setOnlineCount(rpl::single(0));
|
||||||
|
|
||||||
SetupSections(content, [=](Type type) {
|
SetupSections(controller, content, [=](Type type) {
|
||||||
_showOther.fire_copy(type);
|
_showOther.fire_copy(type);
|
||||||
});
|
});
|
||||||
if (HasInterfaceScale()) {
|
if (HasInterfaceScale()) {
|
||||||
|
@ -293,7 +293,7 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
SetupInterfaceScale(content);
|
SetupInterfaceScale(content);
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
}
|
}
|
||||||
SetupHelp(content);
|
SetupHelp(controller, content);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,7 @@ void SetupFaq(
|
||||||
|
|
||||||
class Main : public Section {
|
class Main : public Section {
|
||||||
public:
|
public:
|
||||||
Main(
|
Main(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||||
QWidget *parent,
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<UserData*> self);
|
|
||||||
|
|
||||||
rpl::producer<Type> sectionShowOther() override;
|
rpl::producer<Type> sectionShowOther() override;
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void setupContent(not_null<Window::SessionController*> controller);
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
not_null<UserData*> _self;
|
const not_null<Window::SessionController*> _controller;
|
||||||
rpl::event_stream<Type> _showOther;
|
rpl::event_stream<Type> _showOther;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_button.h"
|
#include "info/profile/info_profile_button.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "platform/platform_info.h"
|
#include "platform/platform_info.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -42,7 +43,9 @@ using ChangeType = Window::Notifications::ChangeType;
|
||||||
|
|
||||||
class NotificationsCount : public Ui::RpWidget {
|
class NotificationsCount : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
NotificationsCount(QWidget *parent);
|
NotificationsCount(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
void setCount(int count);
|
void setCount(int count);
|
||||||
|
|
||||||
|
@ -72,6 +75,8 @@ private:
|
||||||
void prepareNotificationSampleLarge();
|
void prepareNotificationSampleLarge();
|
||||||
void prepareNotificationSampleUserpic();
|
void prepareNotificationSampleUserpic();
|
||||||
|
|
||||||
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
QPixmap _notificationSampleUserpic;
|
QPixmap _notificationSampleUserpic;
|
||||||
QPixmap _notificationSampleSmall;
|
QPixmap _notificationSampleSmall;
|
||||||
QPixmap _notificationSampleLarge;
|
QPixmap _notificationSampleLarge;
|
||||||
|
@ -114,8 +119,11 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationsCount::NotificationsCount(QWidget *parent)
|
NotificationsCount::NotificationsCount(
|
||||||
: _chosenCorner(Global::NotificationsCorner())
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
|
: _controller(controller)
|
||||||
|
, _chosenCorner(Global::NotificationsCorner())
|
||||||
, _oldCount(CurrentCount()) {
|
, _oldCount(CurrentCount()) {
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -176,7 +184,8 @@ void NotificationsCount::setCount(int count) {
|
||||||
|
|
||||||
if (count != Global::NotificationsCount()) {
|
if (count != Global::NotificationsCount()) {
|
||||||
Global::SetNotificationsCount(count);
|
Global::SetNotificationsCount(count);
|
||||||
Auth().notifications().settingsChanged().notify(ChangeType::MaxCount);
|
_controller->session().notifications().settingsChanged().notify(
|
||||||
|
ChangeType::MaxCount);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,7 +349,8 @@ void NotificationsCount::setOverCorner(Notify::ScreenCorner corner) {
|
||||||
_isOverCorner = true;
|
_isOverCorner = true;
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
Global::SetNotificationsDemoIsShown(true);
|
Global::SetNotificationsDemoIsShown(true);
|
||||||
Auth().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
|
_controller->session().notifications().settingsChanged().notify(
|
||||||
|
ChangeType::DemoIsShown);
|
||||||
}
|
}
|
||||||
_overCorner = corner;
|
_overCorner = corner;
|
||||||
|
|
||||||
|
@ -375,10 +385,10 @@ void NotificationsCount::clearOverCorner() {
|
||||||
_isOverCorner = false;
|
_isOverCorner = false;
|
||||||
setCursor(style::cur_default);
|
setCursor(style::cur_default);
|
||||||
Global::SetNotificationsDemoIsShown(false);
|
Global::SetNotificationsDemoIsShown(false);
|
||||||
Auth().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
|
_controller->session().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
|
||||||
|
|
||||||
for_const (auto &samples, _cornerSamples) {
|
for_const (const auto &samples, _cornerSamples) {
|
||||||
for_const (auto widget, samples) {
|
for_const (const auto widget, samples) {
|
||||||
widget->hideFast();
|
widget->hideFast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,13 +402,17 @@ void NotificationsCount::mousePressEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
void NotificationsCount::mouseReleaseEvent(QMouseEvent *e) {
|
void NotificationsCount::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
auto isDownCorner = base::take(_isDownCorner);
|
auto isDownCorner = base::take(_isDownCorner);
|
||||||
if (isDownCorner && _isOverCorner && _downCorner == _overCorner && _downCorner != _chosenCorner) {
|
if (isDownCorner
|
||||||
|
&& _isOverCorner
|
||||||
|
&& _downCorner == _overCorner
|
||||||
|
&& _downCorner != _chosenCorner) {
|
||||||
_chosenCorner = _downCorner;
|
_chosenCorner = _downCorner;
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if (_chosenCorner != Global::NotificationsCorner()) {
|
if (_chosenCorner != Global::NotificationsCorner()) {
|
||||||
Global::SetNotificationsCorner(_chosenCorner);
|
Global::SetNotificationsCorner(_chosenCorner);
|
||||||
Auth().notifications().settingsChanged().notify(ChangeType::Corner);
|
_controller->session().notifications().settingsChanged().notify(
|
||||||
|
ChangeType::Corner);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +501,9 @@ void NotificationsCount::SampleWidget::destroyDelayed() {
|
||||||
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
|
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
|
void SetupAdvancedNotifications(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
@ -495,7 +511,7 @@ void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
|
||||||
const auto position = container->add(
|
const auto position = container->add(
|
||||||
object_ptr<NotificationsCount>(container));
|
object_ptr<NotificationsCount>(container, controller));
|
||||||
|
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_notifications_count());
|
AddSubsectionTitle(container, tr::lng_settings_notifications_count());
|
||||||
|
@ -514,9 +530,12 @@ void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
void SetupNotificationsContent(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSubsectionTitle(container, tr::lng_settings_notify_title());
|
AddSubsectionTitle(container, tr::lng_settings_notify_title());
|
||||||
|
|
||||||
|
const auto session = &controller->session();
|
||||||
const auto checkbox = [&](const QString &label, bool checked) {
|
const auto checkbox = [&](const QString &label, bool checked) {
|
||||||
return object_ptr<Ui::Checkbox>(
|
return object_ptr<Ui::Checkbox>(
|
||||||
container,
|
container,
|
||||||
|
@ -556,10 +575,10 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
const auto muted = addCheckbox(
|
const auto muted = addCheckbox(
|
||||||
tr::lng_settings_include_muted(tr::now),
|
tr::lng_settings_include_muted(tr::now),
|
||||||
Auth().settings().includeMutedCounter());
|
session->settings().includeMutedCounter());
|
||||||
const auto count = addCheckbox(
|
const auto count = addCheckbox(
|
||||||
tr::lng_settings_count_unread(tr::now),
|
tr::lng_settings_count_unread(tr::now),
|
||||||
Auth().settings().countUnreadMessages());
|
session->settings().countUnreadMessages());
|
||||||
|
|
||||||
|
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
@ -569,32 +588,32 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
const auto joined = addCheckbox(
|
const auto joined = addCheckbox(
|
||||||
tr::lng_settings_events_joined(tr::now),
|
tr::lng_settings_events_joined(tr::now),
|
||||||
!Auth().api().contactSignupSilentCurrent().value_or(false));
|
!session->api().contactSignupSilentCurrent().value_or(false));
|
||||||
Auth().api().contactSignupSilent(
|
session->api().contactSignupSilent(
|
||||||
) | rpl::start_with_next([=](bool silent) {
|
) | rpl::start_with_next([=](bool silent) {
|
||||||
joined->setChecked(!silent);
|
joined->setChecked(!silent);
|
||||||
}, joined->lifetime());
|
}, joined->lifetime());
|
||||||
joined->checkedChanges(
|
joined->checkedChanges(
|
||||||
) | rpl::filter([](bool enabled) {
|
) | rpl::filter([=](bool enabled) {
|
||||||
const auto silent = Auth().api().contactSignupSilentCurrent();
|
const auto silent = session->api().contactSignupSilentCurrent();
|
||||||
return (enabled == silent.value_or(false));
|
return (enabled == silent.value_or(false));
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
Auth().api().saveContactSignupSilent(!enabled);
|
session->api().saveContactSignupSilent(!enabled);
|
||||||
}, joined->lifetime());
|
}, joined->lifetime());
|
||||||
|
|
||||||
const auto pinned = addCheckbox(
|
const auto pinned = addCheckbox(
|
||||||
tr::lng_settings_events_pinned(tr::now),
|
tr::lng_settings_events_pinned(tr::now),
|
||||||
Auth().settings().notifyAboutPinned());
|
session->settings().notifyAboutPinned());
|
||||||
Auth().settings().notifyAboutPinnedChanges(
|
session->settings().notifyAboutPinnedChanges(
|
||||||
) | rpl::start_with_next([=](bool notify) {
|
) | rpl::start_with_next([=](bool notify) {
|
||||||
pinned->setChecked(notify);
|
pinned->setChecked(notify);
|
||||||
}, pinned->lifetime());
|
}, pinned->lifetime());
|
||||||
pinned->checkedChanges(
|
pinned->checkedChanges(
|
||||||
) | rpl::filter([](bool notify) {
|
) | rpl::filter([=](bool notify) {
|
||||||
return (notify != Auth().settings().notifyAboutPinned());
|
return (notify != session->settings().notifyAboutPinned());
|
||||||
}) | rpl::start_with_next([=](bool notify) {
|
}) | rpl::start_with_next([=](bool notify) {
|
||||||
Auth().settings().setNotifyAboutPinned(notify);
|
session->settings().setNotifyAboutPinned(notify);
|
||||||
Auth().saveSettingsDelayed();
|
session->saveSettingsDelayed();
|
||||||
}, joined->lifetime());
|
}, joined->lifetime());
|
||||||
|
|
||||||
const auto nativeText = [&] {
|
const auto nativeText = [&] {
|
||||||
|
@ -629,7 +648,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
? advancedSlide->entity()
|
? advancedSlide->entity()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (advancedWrap) {
|
if (advancedWrap) {
|
||||||
SetupAdvancedNotifications(advancedWrap);
|
SetupAdvancedNotifications(controller, advancedWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name->entity()->checked()) {
|
if (!name->entity()->checked()) {
|
||||||
|
@ -644,9 +663,9 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
using Change = Window::Notifications::ChangeType;
|
using Change = Window::Notifications::ChangeType;
|
||||||
const auto changed = [](Change change) {
|
const auto changed = [=](Change change) {
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
Auth().notifications().settingsChanged().notify(change);
|
session->notifications().settingsChanged().notify(change);
|
||||||
};
|
};
|
||||||
desktop->checkedChanges(
|
desktop->checkedChanges(
|
||||||
) | rpl::filter([](bool checked) {
|
) | rpl::filter([](bool checked) {
|
||||||
|
@ -695,23 +714,23 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
}, sound->lifetime());
|
}, sound->lifetime());
|
||||||
|
|
||||||
muted->checkedChanges(
|
muted->checkedChanges(
|
||||||
) | rpl::filter([](bool checked) {
|
) | rpl::filter([=](bool checked) {
|
||||||
return (checked != Auth().settings().includeMutedCounter());
|
return (checked != session->settings().includeMutedCounter());
|
||||||
}) | rpl::start_with_next([=](bool checked) {
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
Auth().settings().setIncludeMutedCounter(checked);
|
session->settings().setIncludeMutedCounter(checked);
|
||||||
changed(Change::IncludeMuted);
|
changed(Change::IncludeMuted);
|
||||||
}, muted->lifetime());
|
}, muted->lifetime());
|
||||||
|
|
||||||
count->checkedChanges(
|
count->checkedChanges(
|
||||||
) | rpl::filter([](bool checked) {
|
) | rpl::filter([=](bool checked) {
|
||||||
return (checked != Auth().settings().countUnreadMessages());
|
return (checked != session->settings().countUnreadMessages());
|
||||||
}) | rpl::start_with_next([=](bool checked) {
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
Auth().settings().setCountUnreadMessages(checked);
|
session->settings().setCountUnreadMessages(checked);
|
||||||
changed(Change::CountMessages);
|
changed(Change::CountMessages);
|
||||||
}, count->lifetime());
|
}, count->lifetime());
|
||||||
|
|
||||||
base::ObservableViewer(
|
base::ObservableViewer(
|
||||||
Auth().notifications().settingsChanged()
|
session->notifications().settingsChanged()
|
||||||
) | rpl::start_with_next([=](Change change) {
|
) | rpl::start_with_next([=](Change change) {
|
||||||
if (change == Change::DesktopEnabled) {
|
if (change == Change::DesktopEnabled) {
|
||||||
desktop->setChecked(Global::DesktopNotify());
|
desktop->setChecked(Global::DesktopNotify());
|
||||||
|
@ -734,7 +753,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
Global::SetNativeNotifications(checked);
|
Global::SetNativeNotifications(checked);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
|
|
||||||
Auth().notifications().createManager();
|
session->notifications().createManager();
|
||||||
|
|
||||||
if (advancedSlide) {
|
if (advancedSlide) {
|
||||||
advancedSlide->toggle(
|
advancedSlide->toggle(
|
||||||
|
@ -745,11 +764,13 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupNotifications(not_null<Ui::VerticalLayout*> container) {
|
void SetupNotifications(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
|
||||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||||
SetupNotificationsContent(wrap.data());
|
SetupNotificationsContent(controller, wrap.data());
|
||||||
|
|
||||||
container->add(object_ptr<Ui::OverrideMargins>(
|
container->add(object_ptr<Ui::OverrideMargins>(
|
||||||
container,
|
container,
|
||||||
|
@ -760,16 +781,18 @@ void SetupNotifications(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Notifications::Notifications(QWidget *parent, not_null<UserData*> self)
|
Notifications::Notifications(
|
||||||
: Section(parent)
|
QWidget *parent,
|
||||||
, _self(self) {
|
not_null<Window::SessionController*> controller)
|
||||||
setupContent();
|
: Section(parent) {
|
||||||
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notifications::setupContent() {
|
void Notifications::setupContent(
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupNotifications(content);
|
SetupNotifications(controller, content);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ namespace Settings {
|
||||||
|
|
||||||
class Notifications : public Section {
|
class Notifications : public Section {
|
||||||
public:
|
public:
|
||||||
Notifications(QWidget *parent, not_null<UserData*> self);
|
Notifications(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
not_null<UserData*> _self;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "window/section_widget.h"
|
#include "window/section_widget.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "settings/settings_privacy_security.h"
|
#include "settings/settings_privacy_security.h"
|
||||||
|
@ -154,6 +155,11 @@ AdminLog::OwnedItem GenerateForwardedItem(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
BlockedBoxController::BlockedBoxController(
|
||||||
|
not_null<Window::SessionController*> window)
|
||||||
|
: _window(window) {
|
||||||
|
}
|
||||||
|
|
||||||
void BlockedBoxController::prepare() {
|
void BlockedBoxController::prepare() {
|
||||||
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
|
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
|
||||||
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
||||||
|
@ -166,7 +172,7 @@ void BlockedBoxController::prepare() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_loadRequestId = -1;
|
_loadRequestId = -1;
|
||||||
Auth().api().blockedUsersSlice(
|
_window->session().api().blockedUsersSlice(
|
||||||
) | rpl::take(
|
) | rpl::take(
|
||||||
1
|
1
|
||||||
) | rpl::start_with_next([=](const ApiWrap::BlockedUsersSlice &result) {
|
) | rpl::start_with_next([=](const ApiWrap::BlockedUsersSlice &result) {
|
||||||
|
@ -193,8 +199,8 @@ void BlockedBoxController::loadMoreRows() {
|
||||||
)).done([=](const MTPcontacts_Blocked &result) {
|
)).done([=](const MTPcontacts_Blocked &result) {
|
||||||
_loadRequestId = 0;
|
_loadRequestId = 0;
|
||||||
|
|
||||||
auto handleContactsBlocked = [](auto &list) {
|
auto handleContactsBlocked = [&](auto &list) {
|
||||||
Auth().data().processUsers(list.vusers());
|
_window->session().data().processUsers(list.vusers());
|
||||||
return list.vblocked().v;
|
return list.vblocked().v;
|
||||||
};
|
};
|
||||||
switch (result.type()) {
|
switch (result.type()) {
|
||||||
|
@ -222,7 +228,7 @@ void BlockedBoxController::rowActionClicked(not_null<PeerListRow*> row) {
|
||||||
auto user = row->peer()->asUser();
|
auto user = row->peer()->asUser();
|
||||||
Expects(user != nullptr);
|
Expects(user != nullptr);
|
||||||
|
|
||||||
Auth().api().unblockUser(user);
|
_window->session().api().unblockUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedBoxController::receivedUsers(const QVector<MTPContactBlocked> &result) {
|
void BlockedBoxController::receivedUsers(const QVector<MTPContactBlocked> &result) {
|
||||||
|
@ -233,7 +239,7 @@ void BlockedBoxController::receivedUsers(const QVector<MTPContactBlocked> &resul
|
||||||
_offset += result.size();
|
_offset += result.size();
|
||||||
for (const auto &item : result) {
|
for (const auto &item : result) {
|
||||||
item.match([&](const MTPDcontactBlocked &data) {
|
item.match([&](const MTPDcontactBlocked &data) {
|
||||||
if (const auto user = Auth().data().userLoaded(data.vuser_id().v)) {
|
if (const auto user = _window->session().data().userLoaded(data.vuser_id().v)) {
|
||||||
appendRow(user);
|
appendRow(user);
|
||||||
user->setIsBlocked(true);
|
user->setIsBlocked(true);
|
||||||
}
|
}
|
||||||
|
@ -254,11 +260,13 @@ void BlockedBoxController::handleBlockedEvent(not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedBoxController::BlockNewUser() {
|
void BlockedBoxController::BlockNewUser(
|
||||||
|
not_null<Window::SessionController*> window) {
|
||||||
auto controller = std::make_unique<BlockUserBoxController>();
|
auto controller = std::make_unique<BlockUserBoxController>();
|
||||||
auto initBox = [controller = controller.get()](not_null<PeerListBox*> box) {
|
auto initBox = [=, controller = controller.get()](
|
||||||
controller->setBlockUserCallback([box](not_null<UserData*> user) {
|
not_null<PeerListBox*> box) {
|
||||||
Auth().api().blockUser(user);
|
controller->setBlockUserCallback([=](not_null<UserData*> user) {
|
||||||
|
window->session().api().blockUser(user);
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
|
||||||
|
@ -346,6 +354,11 @@ rpl::producer<QString> PhoneNumberPrivacyController::exceptionsDescription() {
|
||||||
return tr::lng_edit_privacy_phone_number_exceptions();
|
return tr::lng_edit_privacy_phone_number_exceptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LastSeenPrivacyController::LastSeenPrivacyController(
|
||||||
|
not_null<::Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
ApiWrap::Privacy::Key LastSeenPrivacyController::key() {
|
ApiWrap::Privacy::Key LastSeenPrivacyController::key() {
|
||||||
return Key::LastSeen;
|
return Key::LastSeen;
|
||||||
}
|
}
|
||||||
|
@ -391,14 +404,15 @@ rpl::producer<QString> LastSeenPrivacyController::exceptionsDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LastSeenPrivacyController::confirmSave(bool someAreDisallowed, FnMut<void()> saveCallback) {
|
void LastSeenPrivacyController::confirmSave(bool someAreDisallowed, FnMut<void()> saveCallback) {
|
||||||
if (someAreDisallowed && !Auth().settings().lastSeenWarningSeen()) {
|
if (someAreDisallowed && !_session->settings().lastSeenWarningSeen()) {
|
||||||
|
const auto session = _session;
|
||||||
auto weakBox = std::make_shared<QPointer<ConfirmBox>>();
|
auto weakBox = std::make_shared<QPointer<ConfirmBox>>();
|
||||||
auto callback = [weakBox, saveCallback = std::move(saveCallback)]() mutable {
|
auto callback = [=, saveCallback = std::move(saveCallback)]() mutable {
|
||||||
if (auto box = *weakBox) {
|
if (auto box = *weakBox) {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
}
|
}
|
||||||
saveCallback();
|
saveCallback();
|
||||||
Auth().settings().setLastSeenWarningSeen(true);
|
session->settings().setLastSeenWarningSeen(true);
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
};
|
};
|
||||||
auto box = Box<ConfirmBox>(
|
auto box = Box<ConfirmBox>(
|
||||||
|
@ -494,6 +508,7 @@ rpl::producer<QString> CallsPrivacyController::exceptionsDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> CallsPrivacyController::setupBelowWidget(
|
object_ptr<Ui::RpWidget> CallsPrivacyController::setupBelowWidget(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<QWidget*> parent) {
|
not_null<QWidget*> parent) {
|
||||||
auto result = object_ptr<Ui::VerticalLayout>(parent);
|
auto result = object_ptr<Ui::VerticalLayout>(parent);
|
||||||
const auto content = result.data();
|
const auto content = result.data();
|
||||||
|
@ -502,6 +517,7 @@ object_ptr<Ui::RpWidget> CallsPrivacyController::setupBelowWidget(
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
AddSubsectionTitle(content, tr::lng_settings_calls_peer_to_peer_title());
|
AddSubsectionTitle(content, tr::lng_settings_calls_peer_to_peer_title());
|
||||||
Settings::AddPrivacyButton(
|
Settings::AddPrivacyButton(
|
||||||
|
controller,
|
||||||
content,
|
content,
|
||||||
tr::lng_settings_calls_peer_to_peer_button(),
|
tr::lng_settings_calls_peer_to_peer_button(),
|
||||||
ApiWrap::Privacy::Key::CallsPeer2Peer,
|
ApiWrap::Privacy::Key::CallsPeer2Peer,
|
||||||
|
@ -563,6 +579,11 @@ rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionsDescription()
|
||||||
return tr::lng_edit_privacy_calls_p2p_exceptions();
|
return tr::lng_edit_privacy_calls_p2p_exceptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForwardsPrivacyController::ForwardsPrivacyController(
|
||||||
|
not_null<::Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
ApiWrap::Privacy::Key ForwardsPrivacyController::key() {
|
ApiWrap::Privacy::Key ForwardsPrivacyController::key() {
|
||||||
return Key::Forwards;
|
return Key::Forwards;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +634,7 @@ object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
|
||||||
|
|
||||||
auto message = GenerateForwardedItem(
|
auto message = GenerateForwardedItem(
|
||||||
delegate(),
|
delegate(),
|
||||||
Auth().data().history(
|
_session->data().history(
|
||||||
peerFromUser(PeerData::kServiceNotificationsId)),
|
peerFromUser(PeerData::kServiceNotificationsId)),
|
||||||
tr::lng_edit_privacy_forwards_sample_message(tr::now));
|
tr::lng_edit_privacy_forwards_sample_message(tr::now));
|
||||||
const auto view = message.get();
|
const auto view = message.get();
|
||||||
|
|
|
@ -16,12 +16,15 @@ namespace Settings {
|
||||||
|
|
||||||
class BlockedBoxController : public PeerListController, private base::Subscriber, private MTP::Sender {
|
class BlockedBoxController : public PeerListController, private base::Subscriber, private MTP::Sender {
|
||||||
public:
|
public:
|
||||||
|
explicit BlockedBoxController(
|
||||||
|
not_null<Window::SessionController*> window);
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
void rowClicked(not_null<PeerListRow*> row) override;
|
void rowClicked(not_null<PeerListRow*> row) override;
|
||||||
void rowActionClicked(not_null<PeerListRow*> row) override;
|
void rowActionClicked(not_null<PeerListRow*> row) override;
|
||||||
void loadMoreRows() override;
|
void loadMoreRows() override;
|
||||||
|
|
||||||
static void BlockNewUser();
|
static void BlockNewUser(not_null<Window::SessionController*> window);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void receivedUsers(const QVector<MTPContactBlocked> &result);
|
void receivedUsers(const QVector<MTPContactBlocked> &result);
|
||||||
|
@ -31,6 +34,8 @@ private:
|
||||||
bool prependRow(not_null<UserData*> user);
|
bool prependRow(not_null<UserData*> user);
|
||||||
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const;
|
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const;
|
||||||
|
|
||||||
|
const not_null<Window::SessionController*> _window;
|
||||||
|
|
||||||
int _offset = 0;
|
int _offset = 0;
|
||||||
mtpRequestId _loadRequestId = 0;
|
mtpRequestId _loadRequestId = 0;
|
||||||
bool _allLoaded = false;
|
bool _allLoaded = false;
|
||||||
|
@ -60,6 +65,8 @@ public:
|
||||||
using Option = EditPrivacyBox::Option;
|
using Option = EditPrivacyBox::Option;
|
||||||
using Exception = EditPrivacyBox::Exception;
|
using Exception = EditPrivacyBox::Exception;
|
||||||
|
|
||||||
|
explicit LastSeenPrivacyController(not_null<::Main::Session*> session);
|
||||||
|
|
||||||
Key key() override;
|
Key key() override;
|
||||||
MTPInputPrivacyKey apiKey() override;
|
MTPInputPrivacyKey apiKey() override;
|
||||||
|
|
||||||
|
@ -75,6 +82,9 @@ public:
|
||||||
bool someAreDisallowed,
|
bool someAreDisallowed,
|
||||||
FnMut<void()> saveCallback) override;
|
FnMut<void()> saveCallback) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const not_null<::Main::Session*> _session;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupsInvitePrivacyController : public EditPrivacyController {
|
class GroupsInvitePrivacyController : public EditPrivacyController {
|
||||||
|
@ -111,6 +121,7 @@ public:
|
||||||
rpl::producer<QString> exceptionsDescription() override;
|
rpl::producer<QString> exceptionsDescription() override;
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> setupBelowWidget(
|
object_ptr<Ui::RpWidget> setupBelowWidget(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<QWidget*> parent) override;
|
not_null<QWidget*> parent) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -141,6 +152,8 @@ public:
|
||||||
using Option = EditPrivacyBox::Option;
|
using Option = EditPrivacyBox::Option;
|
||||||
using Exception = EditPrivacyBox::Exception;
|
using Exception = EditPrivacyBox::Exception;
|
||||||
|
|
||||||
|
explicit ForwardsPrivacyController(not_null<::Main::Session*> session);
|
||||||
|
|
||||||
Key key() override;
|
Key key() override;
|
||||||
MTPInputPrivacyKey apiKey() override;
|
MTPInputPrivacyKey apiKey() override;
|
||||||
|
|
||||||
|
@ -166,6 +179,8 @@ private:
|
||||||
not_null<HistoryView::Element*> view,
|
not_null<HistoryView::Element*> view,
|
||||||
Option value);
|
Option value);
|
||||||
|
|
||||||
|
const not_null<::Main::Session*> _session;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProfilePhotoPrivacyController : public EditPrivacyController {
|
class ProfilePhotoPrivacyController : public EditPrivacyController {
|
||||||
|
|
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
@ -72,9 +73,11 @@ QString PrivacyBase(Privacy::Key key, Privacy::Option option) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> PrivacyString(Privacy::Key key) {
|
rpl::producer<QString> PrivacyString(
|
||||||
Auth().api().reloadPrivacy(key);
|
not_null<::Main::Session*> session,
|
||||||
return Auth().api().privacyValue(
|
Privacy::Key key) {
|
||||||
|
session->api().reloadPrivacy(key);
|
||||||
|
return session->api().privacyValue(
|
||||||
key
|
key
|
||||||
) | rpl::map([=](const Privacy &value) {
|
) | rpl::map([=](const Privacy &value) {
|
||||||
auto add = QStringList();
|
auto add = QStringList();
|
||||||
|
@ -93,20 +96,23 @@ rpl::producer<QString> PrivacyString(Privacy::Key key) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> BlockedUsersCount() {
|
rpl::producer<int> BlockedUsersCount(not_null<::Main::Session*> session) {
|
||||||
Auth().api().reloadBlockedUsers();
|
session->api().reloadBlockedUsers();
|
||||||
return Auth().api().blockedUsersSlice(
|
return session->api().blockedUsersSlice(
|
||||||
) | rpl::map([=](const ApiWrap::BlockedUsersSlice &data) {
|
) | rpl::map([=](const ApiWrap::BlockedUsersSlice &data) {
|
||||||
return data.total;
|
return data.total;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
void SetupPrivacy(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container, st::settingsPrivacySkip);
|
AddSkip(container, st::settingsPrivacySkip);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_privacy_title());
|
AddSubsectionTitle(container, tr::lng_settings_privacy_title());
|
||||||
|
|
||||||
|
const auto session = &controller->session();
|
||||||
auto count = rpl::combine(
|
auto count = rpl::combine(
|
||||||
BlockedUsersCount(),
|
BlockedUsersCount(session),
|
||||||
tr::lng_settings_no_blocked_users()
|
tr::lng_settings_no_blocked_users()
|
||||||
) | rpl::map([](int count, const QString &none) {
|
) | rpl::map([](int count, const QString &none) {
|
||||||
return count ? QString::number(count) : none;
|
return count ? QString::number(count) : none;
|
||||||
|
@ -116,17 +122,17 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||||
tr::lng_settings_blocked_users(),
|
tr::lng_settings_blocked_users(),
|
||||||
std::move(count),
|
std::move(count),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
const auto initBox = [](not_null<PeerListBox*> box) {
|
const auto initBox = [=](not_null<PeerListBox*> box) {
|
||||||
box->addButton(tr::lng_close(), [=] {
|
box->addButton(tr::lng_close(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
box->addLeftButton(tr::lng_blocked_list_add(), [] {
|
box->addLeftButton(tr::lng_blocked_list_add(), [=] {
|
||||||
BlockedBoxController::BlockNewUser();
|
BlockedBoxController::BlockNewUser(controller);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Ui::show(Box<PeerListBox>(
|
Ui::show(Box<PeerListBox>(
|
||||||
std::make_unique<BlockedBoxController>(),
|
std::make_unique<BlockedBoxController>(controller),
|
||||||
initBox));
|
initBox));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,8 +140,13 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||||
const auto add = [&](
|
const auto add = [&](
|
||||||
rpl::producer<QString> label,
|
rpl::producer<QString> label,
|
||||||
Key key,
|
Key key,
|
||||||
auto controller) {
|
auto controllerFactory) {
|
||||||
AddPrivacyButton(container, std::move(label), key, controller);
|
AddPrivacyButton(
|
||||||
|
controller,
|
||||||
|
container,
|
||||||
|
std::move(label),
|
||||||
|
key,
|
||||||
|
controllerFactory);
|
||||||
};
|
};
|
||||||
add(
|
add(
|
||||||
tr::lng_settings_phone_number_privacy(),
|
tr::lng_settings_phone_number_privacy(),
|
||||||
|
@ -144,11 +155,11 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||||
add(
|
add(
|
||||||
tr::lng_settings_last_seen(),
|
tr::lng_settings_last_seen(),
|
||||||
Key::LastSeen,
|
Key::LastSeen,
|
||||||
[] { return std::make_unique<LastSeenPrivacyController>(); });
|
[=] { return std::make_unique<LastSeenPrivacyController>(session); });
|
||||||
add(
|
add(
|
||||||
tr::lng_settings_forwards_privacy(),
|
tr::lng_settings_forwards_privacy(),
|
||||||
Key::Forwards,
|
Key::Forwards,
|
||||||
[] { return std::make_unique<ForwardsPrivacyController>(); });
|
[=] { return std::make_unique<ForwardsPrivacyController>(session); });
|
||||||
add(
|
add(
|
||||||
tr::lng_settings_profile_photo_privacy(),
|
tr::lng_settings_profile_photo_privacy(),
|
||||||
Key::ProfilePhoto,
|
Key::ProfilePhoto,
|
||||||
|
@ -175,7 +186,9 @@ not_null<Ui::SlideWrap<Ui::PlainShadow>*> AddSeparator(
|
||||||
st::settingsSeparatorPadding));
|
st::settingsSeparatorPadding));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
|
void SetupLocalPasscode(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
|
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
|
||||||
|
|
||||||
|
@ -195,8 +208,8 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
|
||||||
container,
|
container,
|
||||||
std::move(text),
|
std::move(text),
|
||||||
st::settingsButton)
|
st::settingsButton)
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<PasscodeBox>(false));
|
Ui::show(Box<PasscodeBox>(&controller->session(), false));
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto wrap = container->add(
|
const auto wrap = container->add(
|
||||||
|
@ -209,8 +222,8 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
|
||||||
inner,
|
inner,
|
||||||
tr::lng_settings_passcode_disable(),
|
tr::lng_settings_passcode_disable(),
|
||||||
st::settingsButton)
|
st::settingsButton)
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<PasscodeBox>(true));
|
Ui::show(Box<PasscodeBox>(&controller->session(), true));
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto label = Platform::LastUserInputTimeSupported()
|
const auto label = Platform::LastUserInputTimeSupported()
|
||||||
|
@ -229,8 +242,8 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
|
||||||
label(),
|
label(),
|
||||||
std::move(value),
|
std::move(value),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<AutoLockBox>());
|
Ui::show(Box<AutoLockBox>(&controller->session()));
|
||||||
});
|
});
|
||||||
|
|
||||||
wrap->toggleOn(base::duplicate(has));
|
wrap->toggleOn(base::duplicate(has));
|
||||||
|
@ -238,7 +251,9 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
void SetupCloudPassword(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
using State = Core::CloudPasswordState;
|
using State = Core::CloudPasswordState;
|
||||||
|
|
||||||
|
@ -246,15 +261,16 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_password_title());
|
AddSubsectionTitle(container, tr::lng_settings_password_title());
|
||||||
|
|
||||||
|
const auto session = &controller->session();
|
||||||
auto has = rpl::single(
|
auto has = rpl::single(
|
||||||
false
|
false
|
||||||
) | rpl::then(Auth().api().passwordState(
|
) | rpl::then(controller->session().api().passwordState(
|
||||||
) | rpl::map([](const State &state) {
|
) | rpl::map([](const State &state) {
|
||||||
return state.request
|
return state.request
|
||||||
|| state.unknownAlgorithm
|
|| state.unknownAlgorithm
|
||||||
|| !state.unconfirmedPattern.isEmpty();
|
|| !state.unconfirmedPattern.isEmpty();
|
||||||
})) | rpl::distinct_until_changed();
|
})) | rpl::distinct_until_changed();
|
||||||
auto pattern = Auth().api().passwordState(
|
auto pattern = session->api().passwordState(
|
||||||
) | rpl::map([](const State &state) {
|
) | rpl::map([](const State &state) {
|
||||||
return state.unconfirmedPattern;
|
return state.unconfirmedPattern;
|
||||||
});
|
});
|
||||||
|
@ -318,9 +334,9 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
) | rpl::map(
|
) | rpl::map(
|
||||||
!_1
|
!_1
|
||||||
))->setDuration(0);
|
))->setDuration(0);
|
||||||
change->entity()->addClickHandler([] {
|
change->entity()->addClickHandler([=] {
|
||||||
if (CheckEditCloudPassword()) {
|
if (CheckEditCloudPassword(session)) {
|
||||||
Ui::show(EditCloudPasswordBox(&Auth()));
|
Ui::show(EditCloudPasswordBox(session));
|
||||||
} else {
|
} else {
|
||||||
Ui::show(CloudPasswordAppOutdatedBox());
|
Ui::show(CloudPasswordAppOutdatedBox());
|
||||||
}
|
}
|
||||||
|
@ -338,8 +354,8 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
) | rpl::then(rpl::duplicate(
|
) | rpl::then(rpl::duplicate(
|
||||||
unconfirmed
|
unconfirmed
|
||||||
)))->setDuration(0);
|
)))->setDuration(0);
|
||||||
confirm->entity()->addClickHandler([] {
|
confirm->entity()->addClickHandler([=] {
|
||||||
const auto state = Auth().api().passwordStateCurrent();
|
const auto state = session->api().passwordStateCurrent();
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -347,22 +363,22 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
std::move(
|
std::move(
|
||||||
validation.reloadRequests
|
validation.reloadRequests
|
||||||
) | rpl::start_with_next([] {
|
) | rpl::start_with_next([=] {
|
||||||
Auth().api().reloadPasswordState();
|
session->api().reloadPasswordState();
|
||||||
}, validation.box->lifetime());
|
}, validation.box->lifetime());
|
||||||
|
|
||||||
std::move(
|
std::move(
|
||||||
validation.cancelRequests
|
validation.cancelRequests
|
||||||
) | rpl::start_with_next([] {
|
) | rpl::start_with_next([=] {
|
||||||
Auth().api().clearUnconfirmedPassword();
|
session->api().clearUnconfirmedPassword();
|
||||||
}, validation.box->lifetime());
|
}, validation.box->lifetime());
|
||||||
|
|
||||||
Ui::show(std::move(validation.box));
|
Ui::show(std::move(validation.box));
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto remove = [] {
|
const auto remove = [=] {
|
||||||
if (CheckEditCloudPassword()) {
|
if (CheckEditCloudPassword(session)) {
|
||||||
RemoveCloudPassword();
|
RemoveCloudPassword(session);
|
||||||
} else {
|
} else {
|
||||||
Ui::show(CloudPasswordAppOutdatedBox());
|
Ui::show(CloudPasswordAppOutdatedBox());
|
||||||
}
|
}
|
||||||
|
@ -395,7 +411,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
const auto reloadOnActivation = [=](Qt::ApplicationState state) {
|
const auto reloadOnActivation = [=](Qt::ApplicationState state) {
|
||||||
if (label->toggled() && state == Qt::ApplicationActive) {
|
if (label->toggled() && state == Qt::ApplicationActive) {
|
||||||
Auth().api().reloadPasswordState();
|
controller->session().api().reloadPasswordState();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
@ -404,19 +420,23 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
|
||||||
label,
|
label,
|
||||||
reloadOnActivation);
|
reloadOnActivation);
|
||||||
|
|
||||||
Auth().api().reloadPasswordState();
|
session->api().reloadPasswordState();
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
|
void SetupSelfDestruction(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_destroy_title());
|
AddSubsectionTitle(container, tr::lng_settings_destroy_title());
|
||||||
|
|
||||||
Auth().api().reloadSelfDestruct();
|
const auto session = &controller->session();
|
||||||
const auto label = [] {
|
|
||||||
return Auth().api().selfDestructValue(
|
session->api().reloadSelfDestruct();
|
||||||
|
const auto label = [&] {
|
||||||
|
return session->api().selfDestructValue(
|
||||||
) | rpl::map(
|
) | rpl::map(
|
||||||
SelfDestructionBox::DaysLabel
|
SelfDestructionBox::DaysLabel
|
||||||
);
|
);
|
||||||
|
@ -427,14 +447,16 @@ void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
|
||||||
tr::lng_settings_destroy_if(),
|
tr::lng_settings_destroy_if(),
|
||||||
label(),
|
label(),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<SelfDestructionBox>(Auth().api().selfDestructValue()));
|
Ui::show(Box<SelfDestructionBox>(session->api().selfDestructValue()));
|
||||||
});
|
});
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSessionsList(not_null<Ui::VerticalLayout*> container) {
|
void SetupSessionsList(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_sessions_title());
|
AddSubsectionTitle(container, tr::lng_settings_sessions_title());
|
||||||
|
|
||||||
|
@ -463,8 +485,8 @@ int ExceptionUsersCount(const std::vector<not_null<PeerData*>> &exceptions) {
|
||||||
return ranges::accumulate(exceptions, 0, add);
|
return ranges::accumulate(exceptions, 0, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckEditCloudPassword() {
|
bool CheckEditCloudPassword(not_null<::Main::Session*> session) {
|
||||||
const auto current = Auth().api().passwordStateCurrent();
|
const auto current = session->api().passwordStateCurrent();
|
||||||
Assert(current.has_value());
|
Assert(current.has_value());
|
||||||
|
|
||||||
if (!current->unknownAlgorithm
|
if (!current->unknownAlgorithm
|
||||||
|
@ -479,7 +501,9 @@ object_ptr<BoxContent> EditCloudPasswordBox(not_null<Main::Session*> session) {
|
||||||
const auto current = session->api().passwordStateCurrent();
|
const auto current = session->api().passwordStateCurrent();
|
||||||
Assert(current.has_value());
|
Assert(current.has_value());
|
||||||
|
|
||||||
auto result = Box<PasscodeBox>(PasscodeBox::CloudFields::From(*current));
|
auto result = Box<PasscodeBox>(
|
||||||
|
session,
|
||||||
|
PasscodeBox::CloudFields::From(*current));
|
||||||
const auto box = result.data();
|
const auto box = result.data();
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
|
@ -497,29 +521,29 @@ object_ptr<BoxContent> EditCloudPasswordBox(not_null<Main::Session*> session) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveCloudPassword() {
|
void RemoveCloudPassword(not_null<::Main::Session*> session) {
|
||||||
const auto current = Auth().api().passwordStateCurrent();
|
const auto current = session->api().passwordStateCurrent();
|
||||||
Assert(current.has_value());
|
Assert(current.has_value());
|
||||||
|
|
||||||
if (!current->request) {
|
if (!current->request) {
|
||||||
Auth().api().clearUnconfirmedPassword();
|
session->api().clearUnconfirmedPassword();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto fields = PasscodeBox::CloudFields::From(*current);
|
auto fields = PasscodeBox::CloudFields::From(*current);
|
||||||
fields.turningOff = true;
|
fields.turningOff = true;
|
||||||
const auto box = Ui::show(Box<PasscodeBox>(fields));
|
const auto box = Ui::show(Box<PasscodeBox>(session, fields));
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
box->newPasswordSet(
|
box->newPasswordSet(
|
||||||
) | rpl::map([] { return rpl::empty_value(); }),
|
) | rpl::map([] { return rpl::empty_value(); }),
|
||||||
box->passwordReloadNeeded()
|
box->passwordReloadNeeded()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
Auth().api().reloadPasswordState();
|
session->api().reloadPasswordState();
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
|
||||||
box->clearUnconfirmedPassword(
|
box->clearUnconfirmedPassword(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
Auth().api().clearUnconfirmedPassword();
|
session->api().clearUnconfirmedPassword();
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,43 +562,47 @@ object_ptr<BoxContent> CloudPasswordAppOutdatedBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPrivacyButton(
|
void AddPrivacyButton(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
rpl::producer<QString> label,
|
rpl::producer<QString> label,
|
||||||
Privacy::Key key,
|
Privacy::Key key,
|
||||||
Fn<std::unique_ptr<EditPrivacyController>()> controller) {
|
Fn<std::unique_ptr<EditPrivacyController>()> controllerFactory) {
|
||||||
const auto shower = Ui::CreateChild<rpl::lifetime>(container.get());
|
const auto shower = Ui::CreateChild<rpl::lifetime>(container.get());
|
||||||
|
const auto session = &controller->session();
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
std::move(label),
|
std::move(label),
|
||||||
PrivacyString(key),
|
PrivacyString(session, key),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
*shower = Auth().api().privacyValue(
|
*shower = session->api().privacyValue(
|
||||||
key
|
key
|
||||||
) | rpl::take(
|
) | rpl::take(
|
||||||
1
|
1
|
||||||
) | rpl::start_with_next([=](const Privacy &value) {
|
) | rpl::start_with_next([=](const Privacy &value) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Box<EditPrivacyBox>(controller(), value),
|
Box<EditPrivacyBox>(controller, controllerFactory(), value),
|
||||||
LayerOption::KeepOther);
|
LayerOption::KeepOther);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivacySecurity::PrivacySecurity(QWidget *parent, not_null<UserData*> self)
|
PrivacySecurity::PrivacySecurity(
|
||||||
: Section(parent)
|
QWidget *parent,
|
||||||
, _self(self) {
|
not_null<Window::SessionController*> controller)
|
||||||
setupContent();
|
: Section(parent) {
|
||||||
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrivacySecurity::setupContent() {
|
void PrivacySecurity::setupContent(
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupPrivacy(content);
|
SetupPrivacy(controller, content);
|
||||||
SetupSessionsList(content);
|
SetupSessionsList(controller, content);
|
||||||
SetupLocalPasscode(content);
|
SetupLocalPasscode(controller, content);
|
||||||
SetupCloudPassword(content);
|
SetupCloudPassword(controller, content);
|
||||||
SetupSelfDestruction(content);
|
SetupSelfDestruction(controller, content);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,26 +16,27 @@ namespace Settings {
|
||||||
|
|
||||||
int ExceptionUsersCount(const std::vector<not_null<PeerData*>> &exceptions);
|
int ExceptionUsersCount(const std::vector<not_null<PeerData*>> &exceptions);
|
||||||
|
|
||||||
bool CheckEditCloudPassword();
|
bool CheckEditCloudPassword(not_null<::Main::Session*> session);
|
||||||
object_ptr<BoxContent> EditCloudPasswordBox(
|
object_ptr<BoxContent> EditCloudPasswordBox(
|
||||||
not_null<::Main::Session*> session);
|
not_null<::Main::Session*> session);
|
||||||
void RemoveCloudPassword();
|
void RemoveCloudPassword(not_null<::Main::Session*> session);
|
||||||
object_ptr<BoxContent> CloudPasswordAppOutdatedBox();
|
object_ptr<BoxContent> CloudPasswordAppOutdatedBox();
|
||||||
|
|
||||||
void AddPrivacyButton(
|
void AddPrivacyButton(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
rpl::producer<QString> label,
|
rpl::producer<QString> label,
|
||||||
ApiWrap::Privacy::Key key,
|
ApiWrap::Privacy::Key key,
|
||||||
Fn<std::unique_ptr<EditPrivacyController>()> controller);
|
Fn<std::unique_ptr<EditPrivacyController>()> controllerFactory);
|
||||||
|
|
||||||
class PrivacySecurity : public Section {
|
class PrivacySecurity : public Section {
|
||||||
public:
|
public:
|
||||||
PrivacySecurity(QWidget *parent, not_null<UserData*> self);
|
PrivacySecurity(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
not_null<UserData*> _self;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue