mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Replace BoxContent::closeHook() with boxClosing.
This commit is contained in:
parent
95af8da66a
commit
0bea2620b5
18 changed files with 45 additions and 76 deletions
|
@ -102,8 +102,8 @@ public:
|
|||
virtual void setInnerFocus() {
|
||||
setFocus();
|
||||
}
|
||||
virtual void closeHook() {
|
||||
}
|
||||
|
||||
base::Observable<void> boxClosing;
|
||||
|
||||
void setDelegate(BoxContentDelegate *newDelegate) {
|
||||
_delegate = newDelegate;
|
||||
|
@ -244,7 +244,7 @@ protected:
|
|||
_content->setInnerFocus();
|
||||
}
|
||||
void closeHook() override {
|
||||
_content->closeHook();
|
||||
_content->boxClosing.notify(true);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -501,10 +501,19 @@ void SetupChannelBox::prepare() {
|
|||
rtlupdate(_invitationLink);
|
||||
}
|
||||
}));
|
||||
subscribe(boxClosing, [this] {
|
||||
if (!_existing) {
|
||||
showAddContactsToChannelBox();
|
||||
}
|
||||
});
|
||||
|
||||
updateMaxHeight();
|
||||
}
|
||||
|
||||
void SetupChannelBox::showAddContactsToChannelBox() const {
|
||||
Ui::show(Box<ContactsBox>(_channel));
|
||||
}
|
||||
|
||||
void SetupChannelBox::setInnerFocus() {
|
||||
if (_link->isHidden()) {
|
||||
setFocus();
|
||||
|
@ -617,12 +626,6 @@ void SetupChannelBox::updateSelected(const QPoint &cursorGlobalPosition) {
|
|||
}
|
||||
}
|
||||
|
||||
void SetupChannelBox::closeHook() {
|
||||
if (!_existing) {
|
||||
Ui::show(Box<ContactsBox>(_channel));
|
||||
}
|
||||
}
|
||||
|
||||
void SetupChannelBox::onSave() {
|
||||
if (_privacyGroup->value() == Privacy::Private) {
|
||||
if (_existing) {
|
||||
|
|
|
@ -137,7 +137,6 @@ public:
|
|||
SetupChannelBox(QWidget*, ChannelData *channel, bool existing = false);
|
||||
|
||||
void setInnerFocus() override;
|
||||
void closeHook() override;
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
@ -161,6 +160,7 @@ private:
|
|||
};
|
||||
void privacyChanged(Privacy value);
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
void showAddContactsToChannelBox() const;
|
||||
|
||||
void onUpdateDone(const MTPBool &result);
|
||||
bool onUpdateFail(const RPCError &error);
|
||||
|
|
|
@ -120,6 +120,11 @@ void ConfirmBox::prepare() {
|
|||
if (!_informative) {
|
||||
addButton([this] { return _cancelText; }, [this] { _cancelled = true; closeBox(); });
|
||||
}
|
||||
subscribe(boxClosing, [this] {
|
||||
if (!_confirmed && (!_strictCancel || _cancelled) && _cancelledCallback) {
|
||||
_cancelledCallback();
|
||||
}
|
||||
});
|
||||
textUpdated();
|
||||
}
|
||||
|
||||
|
@ -131,12 +136,6 @@ void ConfirmBox::textUpdated() {
|
|||
setMouseTracking(_text.hasLinks());
|
||||
}
|
||||
|
||||
void ConfirmBox::closeHook() {
|
||||
if (!_confirmed && (!_strictCancel || _cancelled) && _cancelledCallback) {
|
||||
_cancelledCallback();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfirmBox::confirmed() {
|
||||
if (!_confirmed) {
|
||||
_confirmed = true;
|
||||
|
|
|
@ -47,8 +47,6 @@ public:
|
|||
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
||||
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
||||
|
||||
void closeHook() override;
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
|
|
|
@ -194,6 +194,12 @@ void ContactsBox::prepare() {
|
|||
_searchTimer->setSingleShot(true);
|
||||
connect(_searchTimer, SIGNAL(timeout()), this, SLOT(onSearchByUsername()));
|
||||
|
||||
subscribe(boxClosing, [this] {
|
||||
if (_channel && _creating == CreatingGroupChannel) {
|
||||
Ui::showPeerHistory(_channel, ShowAtTheEndMsgId);
|
||||
}
|
||||
});
|
||||
|
||||
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
||||
|
||||
_select->raise();
|
||||
|
@ -351,12 +357,6 @@ void ContactsBox::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void ContactsBox::closeHook() {
|
||||
if (_channel && _creating == CreatingGroupChannel) {
|
||||
Ui::showPeerHistory(_channel, ShowAtTheEndMsgId);
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsBox::onFilterUpdate(const QString &filter) {
|
||||
onScrollToY(0);
|
||||
_inner->updateFilter(filter);
|
||||
|
|
|
@ -85,8 +85,6 @@ public:
|
|||
ContactsBox(QWidget*, ChatData *chat, MembersFilter filter);
|
||||
ContactsBox(QWidget*, UserData *bot);
|
||||
|
||||
void closeHook() override;
|
||||
|
||||
signals:
|
||||
void adminAdded();
|
||||
|
||||
|
|
|
@ -670,6 +670,11 @@ void EditColorBox::prepare() {
|
|||
subscribe(_picker->changed(), [this] { updateFromControls(); });
|
||||
subscribe(_hueSlider->changed(), [this] { updateFromControls(); });
|
||||
subscribe(_opacitySlider->changed(), [this] { updateFromControls(); });
|
||||
subscribe(boxClosing, [this] {
|
||||
if (_cancelCallback) {
|
||||
_cancelCallback();
|
||||
}
|
||||
});
|
||||
updateFromControls();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,12 +40,6 @@ public:
|
|||
updateFromColor(color);
|
||||
}
|
||||
|
||||
void closeHook() override {
|
||||
if (_cancelCallback) {
|
||||
_cancelCallback();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
|
|
|
@ -31,13 +31,8 @@ public:
|
|||
|
||||
int32 mouseState(QPoint p);
|
||||
|
||||
void closeHook() override {
|
||||
emit closed();
|
||||
}
|
||||
|
||||
signals:
|
||||
void ready(const QImage &tosend);
|
||||
void closed();
|
||||
|
||||
private slots:
|
||||
void onReady(const QImage &tosend);
|
||||
|
|
|
@ -253,6 +253,11 @@ void SendFilesBox::prepare() {
|
|||
connect(_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
|
||||
connect(_caption, SIGNAL(cancelled()), this, SLOT(onClose()));
|
||||
}
|
||||
subscribe(boxClosing, [this] {
|
||||
if (!_confirmed && _cancelledCallback) {
|
||||
_cancelledCallback();
|
||||
}
|
||||
});
|
||||
_send->setText(getSendButtonText());
|
||||
updateButtonsGeometry();
|
||||
updateBoxSize();
|
||||
|
@ -444,12 +449,6 @@ void SendFilesBox::onSend(bool ctrlShiftEnter) {
|
|||
closeBox();
|
||||
}
|
||||
|
||||
void SendFilesBox::closeHook() {
|
||||
if (!_confirmed && _cancelledCallback) {
|
||||
_cancelledCallback();
|
||||
}
|
||||
}
|
||||
|
||||
EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) : _msgId(msgId) {
|
||||
Expects(media->canEditCaption());
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ public:
|
|||
_cancelledCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void closeHook() override;
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
void setInnerFocus() override;
|
||||
|
|
|
@ -295,6 +295,9 @@ void StickersBox::prepare() {
|
|||
|
||||
if (_installed.widget()) {
|
||||
connect(_installed.widget(), SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int)));
|
||||
if (!_megagroupSet) {
|
||||
subscribe(boxClosing, [this] { saveChanges(); });
|
||||
}
|
||||
}
|
||||
|
||||
if (_tabs) {
|
||||
|
@ -563,11 +566,7 @@ void StickersBox::rebuildList(Tab *tab) {
|
|||
tab->widget()->setRemovedSets(_localRemoved);
|
||||
}
|
||||
|
||||
void StickersBox::closeHook() {
|
||||
if (!_installed.widget() || _megagroupSet) {
|
||||
return;
|
||||
}
|
||||
|
||||
void StickersBox::saveChanges() {
|
||||
// Make sure that our changes in other tabs are applied in the Installed tab.
|
||||
rebuildList(&_installed);
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
StickersBox(QWidget*, const Stickers::Order &archivedIds);
|
||||
StickersBox(QWidget*, gsl::not_null<ChannelData*> megagroup);
|
||||
|
||||
void closeHook() override;
|
||||
void setInnerFocus() override;
|
||||
|
||||
~StickersBox();
|
||||
|
@ -101,6 +100,7 @@ private:
|
|||
void switchTab();
|
||||
void installSet(uint64 setId);
|
||||
int getTopSkip() const;
|
||||
void saveChanges();
|
||||
|
||||
QPixmap grabContentCache();
|
||||
|
||||
|
|
|
@ -39,10 +39,11 @@ void ShowSearchFromBox(PeerData *peer, base::lambda<void(gsl::not_null<UserData*
|
|||
return nullptr;
|
||||
};
|
||||
if (auto controller = createController()) {
|
||||
auto box = Ui::show(Box<SearchFromBox>(std::move(controller), [](PeerListBox *box) {
|
||||
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
|
||||
auto subscription = std::make_shared<base::Subscription>();
|
||||
auto box = Ui::show(Box<PeerListBox>(std::move(controller), [subscription](gsl::not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_cancel), [box, subscription] { box->closeBox(); });
|
||||
}), KeepOtherLayers);
|
||||
box->setClosedCallback(std::move(closedCallback));
|
||||
*subscription = box->boxClosing.add_subscription(std::move(closedCallback));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,26 +27,6 @@ namespace Dialogs {
|
|||
|
||||
void ShowSearchFromBox(PeerData *peer, base::lambda<void(gsl::not_null<UserData*>)> callback, base::lambda<void()> closedCallback);
|
||||
|
||||
class SearchFromBox : public PeerListBox {
|
||||
public:
|
||||
using PeerListBox::PeerListBox;
|
||||
|
||||
void setClosedCallback(base::lambda<void()> callback) {
|
||||
_closedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
protected:
|
||||
void closeHook() override {
|
||||
if (_closedCallback) {
|
||||
_closedCallback();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
base::lambda<void()> _closedCallback;
|
||||
|
||||
};
|
||||
|
||||
class ChatSearchFromController : public PeerListController, protected base::Subscriber {
|
||||
public:
|
||||
ChatSearchFromController(gsl::not_null<ChatData*> chat, base::lambda<void(gsl::not_null<UserData*>)> callback);
|
||||
|
|
|
@ -524,7 +524,7 @@ void CoverWidget::showSetPhotoBox(const QImage &img) {
|
|||
}
|
||||
|
||||
auto box = Ui::show(Box<PhotoCropBox>(img, _peer));
|
||||
connect(box, SIGNAL(closed()), this, SLOT(onPhotoUploadStatusChanged()));
|
||||
subscribe(box->boxClosing, [this] { onPhotoUploadStatusChanged(); });
|
||||
}
|
||||
|
||||
void CoverWidget::onPhotoUploadStatusChanged(PeerId peerId) {
|
||||
|
|
|
@ -334,7 +334,7 @@ void CoverWidget::showSetPhotoBox(const QImage &img) {
|
|||
}
|
||||
|
||||
auto box = Ui::show(Box<PhotoCropBox>(img, _self));
|
||||
connect(box, SIGNAL(closed()), this, SLOT(onPhotoUploadStatusChanged()));
|
||||
subscribe(box->boxClosing, [this] { onPhotoUploadStatusChanged(); });
|
||||
}
|
||||
|
||||
void CoverWidget::onPhotoUploadStatusChanged(PeerId peerId) {
|
||||
|
|
Loading…
Add table
Reference in a new issue