mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Merge branch 'master' into player
Conflicts: Telegram/SourceFiles/core/observer.h Telegram/SourceFiles/mainwindow.h Telegram/SourceFiles/media/view/media_clip_playback.cpp Telegram/SourceFiles/media/view/media_clip_playback.h
This commit is contained in:
@@ -163,9 +163,11 @@ void BackgroundRow::updateImage() {
|
||||
}
|
||||
|
||||
BackgroundWidget::BackgroundWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_background)) {
|
||||
FileDialog::registerObserver(this, &BackgroundWidget::notifyFileQueryUpdated);
|
||||
createControls();
|
||||
|
||||
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
|
||||
notifyFileQueryUpdated(update);
|
||||
});
|
||||
subscribe(Window::chatBackground(), [this](const Window::ChatBackgroundUpdate &update) {
|
||||
using Update = Window::ChatBackgroundUpdate;
|
||||
if (update.type == Update::Type::New) {
|
||||
|
@@ -32,7 +32,7 @@ class WidgetSlideWrap;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class BlockWidget : public ScrolledWidget, public Notify::Observer, protected base::Subscriber {
|
||||
class BlockWidget : public ScrolledWidget, protected base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@@ -57,8 +57,12 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent,
|
||||
connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName()));
|
||||
|
||||
auto observeEvents = Notify::PeerUpdate::Flag::NameChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &CoverWidget::notifyPeerUpdated);
|
||||
FileDialog::registerObserver(this, &CoverWidget::notifyFileQueryUpdated);
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
|
||||
notifyPeerUpdated(update);
|
||||
}));
|
||||
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
|
||||
notifyFileQueryUpdated(update);
|
||||
});
|
||||
|
||||
connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUploadStatusChanged(PeerId)));
|
||||
connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUploadStatusChanged(PeerId)));
|
||||
@@ -217,7 +221,7 @@ void CoverWidget::dragEnterEvent(QDragEnterEvent *e) {
|
||||
|
||||
void CoverWidget::dragLeaveEvent(QDragLeaveEvent *e) {
|
||||
if (_dropArea && !_dropArea->hiding()) {
|
||||
_dropArea->hideAnimated(func(this, &CoverWidget::dropAreaHidden));
|
||||
_dropArea->hideAnimated([this](Profile::CoverDropArea *area) { dropAreaHidden(area); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +232,7 @@ void CoverWidget::dropEvent(QDropEvent *e) {
|
||||
if (mimeData->hasImage()) {
|
||||
img = qvariant_cast<QImage>(mimeData->imageData());
|
||||
} else {
|
||||
const auto &urls = mimeData->urls();
|
||||
auto urls = mimeData->urls();
|
||||
if (urls.size() == 1) {
|
||||
auto &url = urls.at(0);
|
||||
if (url.isLocalFile()) {
|
||||
@@ -238,7 +242,7 @@ void CoverWidget::dropEvent(QDropEvent *e) {
|
||||
}
|
||||
|
||||
if (!_dropArea->hiding()) {
|
||||
_dropArea->hideAnimated(func(this, &CoverWidget::dropAreaHidden));
|
||||
_dropArea->hideAnimated([this](Profile::CoverDropArea *area) { dropAreaHidden(area); });
|
||||
}
|
||||
e->acceptProposedAction();
|
||||
|
||||
|
@@ -171,7 +171,9 @@ GeneralWidget::GeneralWidget(QWidget *parent, UserData *self) : BlockWidget(pare
|
||||
, _changeLanguage(this, lang(lng_settings_change_lang), st::defaultBoxLinkButton) {
|
||||
connect(_changeLanguage, SIGNAL(clicked()), this, SLOT(onChangeLanguage()));
|
||||
subscribe(Global::RefChooseCustomLang(), [this]() { chooseCustomLang(); });
|
||||
FileDialog::registerObserver(this, &GeneralWidget::notifyFileQueryUpdated);
|
||||
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
|
||||
notifyFileQueryUpdated(update);
|
||||
});
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,9 @@ using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
|
||||
InfoWidget::InfoWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_info)) {
|
||||
auto observeEvents = UpdateFlag::UsernameChanged | UpdateFlag::UserPhoneChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &InfoWidget::notifyPeerUpdated);
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
|
||||
notifyPeerUpdated(update);
|
||||
}));
|
||||
|
||||
createControls();
|
||||
}
|
||||
@@ -81,7 +83,10 @@ void InfoWidget::refreshUsername() {
|
||||
usernameText.entities.push_back(EntityInText(EntityInTextCustomUrl, 0, usernameText.text.size(), qsl("https://telegram.me/") + self()->username));
|
||||
setLabeledText(_username, lang(lng_profile_username), usernameText, TextWithEntities(), copyText);
|
||||
if (auto text = _username->entity()->textLabel()) {
|
||||
text->setClickHandlerHook(func(this, &InfoWidget::usernameClickHandlerHook));
|
||||
text->setClickHandlerHook([](const ClickHandlerPtr &handler, Qt::MouseButton button) {
|
||||
Ui::showLayer(new UsernameBox());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,19 +101,20 @@ void InfoWidget::refreshLink() {
|
||||
}
|
||||
setLabeledText(_link, lang(lng_profile_link), linkText, linkTextShort, QString());
|
||||
if (auto text = _link->entity()->textLabel()) {
|
||||
text->setClickHandlerHook(func(this, &InfoWidget::usernameClickHandlerHook));
|
||||
text->setClickHandlerHook([](const ClickHandlerPtr &handler, Qt::MouseButton button) {
|
||||
Ui::showLayer(new UsernameBox());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (auto shortText = _link->entity()->shortTextLabel()) {
|
||||
shortText->setExpandLinksMode(ExpandLinksUrlOnly);
|
||||
shortText->setClickHandlerHook(func(this, &InfoWidget::usernameClickHandlerHook));
|
||||
shortText->setClickHandlerHook([](const ClickHandlerPtr &handler, Qt::MouseButton button) {
|
||||
Ui::showLayer(new UsernameBox());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoWidget::usernameClickHandlerHook(const ClickHandlerPtr &handler, Qt::MouseButton button) {
|
||||
Ui::showLayer(new UsernameBox());
|
||||
return false;
|
||||
}
|
||||
|
||||
void InfoWidget::setLabeledText(ChildWidget<LabeledWrap> &row, const QString &label, const TextWithEntities &textWithEntities, const TextWithEntities &shortTextWithEntities, const QString ©Text) {
|
||||
if (textWithEntities.text.isEmpty()) {
|
||||
row->slideUp();
|
||||
|
@@ -38,8 +38,6 @@ private:
|
||||
// Observed notifications.
|
||||
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
||||
|
||||
bool usernameClickHandlerHook(const ClickHandlerPtr &handler, Qt::MouseButton button);
|
||||
|
||||
void createControls();
|
||||
void refreshControls();
|
||||
void refreshMobileNumber();
|
||||
|
@@ -59,6 +59,7 @@ void InnerWidget::selfUpdated() {
|
||||
void InnerWidget::refreshBlocks() {
|
||||
_cover.destroyDelayed();
|
||||
for_const (auto block, _blocks) {
|
||||
block->hide();
|
||||
block->deleteLater();
|
||||
}
|
||||
_blocks.clear();
|
||||
@@ -81,6 +82,9 @@ void InnerWidget::refreshBlocks() {
|
||||
|
||||
if (_cover) {
|
||||
_cover->show();
|
||||
if (_showFinished) {
|
||||
_cover->showFinished();
|
||||
}
|
||||
}
|
||||
for_const (auto block, _blocks) {
|
||||
block->show();
|
||||
@@ -89,6 +93,7 @@ void InnerWidget::refreshBlocks() {
|
||||
}
|
||||
|
||||
void InnerWidget::showFinished() {
|
||||
_showFinished = true;
|
||||
if (_cover) {
|
||||
_cover->showFinished();
|
||||
}
|
||||
|
@@ -65,6 +65,7 @@ private:
|
||||
UserData *_self = nullptr;
|
||||
|
||||
int _contentLeft = 0;
|
||||
bool _showFinished = false;
|
||||
|
||||
int _visibleTop = 0;
|
||||
int _visibleBottom = 0;
|
||||
|
@@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "styles/style_settings.h"
|
||||
#include "ui/scrollarea.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "localstorage.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "application.h"
|
||||
@@ -80,6 +81,11 @@ void fillCodes() {
|
||||
});
|
||||
Ui::showLayer(box.release());
|
||||
});
|
||||
Codes.insert(qsl("getdifference"), []() {
|
||||
if (auto main = App::main()) {
|
||||
main->getDifference();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void codesFeedString(const QString &text) {
|
||||
|
Reference in New Issue
Block a user