diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 461090a2c..2b80c12c9 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -387,21 +387,30 @@ void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) { PinMessageBox::PinMessageBox(QWidget *, ChannelData *channel, MsgId msgId) : _channel(channel) , _msgId(msgId) - , _text(this, lang(lng_pinned_pin_sure), Ui::FlatLabel::InitType::Simple, st::boxLabel) - , _notify(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox) {} + , _text(this, lang(lng_pinned_pin_sure), Ui::FlatLabel::InitType::Simple, st::boxLabel) {} void PinMessageBox::prepare() { + if (_channel->isMegagroup()) { + _notify.create(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox); + } + + auto height = st::boxPadding.top() + _text->height() + st::boxPadding.bottom(); + if (_notify) { + height += st::boxMediumSkip + _notify->heightNoMargins(); + } + addButton(langFactory(lng_pinned_pin), [this] { pinMessage(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); }); - setDimensions(st::boxWidth, st::boxPadding.top() + _text->height() + st::boxMediumSkip + - _notify->heightNoMargins() + st::boxPadding.bottom()); + setDimensions(st::boxWidth, height); } void PinMessageBox::resizeEvent(QResizeEvent *e) { BoxContent::resizeEvent(e); _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top()); - _notify->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); + if (_notify) { + _notify->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); + } } void PinMessageBox::keyPressEvent(QKeyEvent *e) { @@ -416,7 +425,7 @@ void PinMessageBox::pinMessage() { if (_requestId) return; auto flags = MTPchannels_UpdatePinnedMessage::Flags(0); - if (!_notify->checked()) { + if (_notify && !_notify->checked()) { flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent; } _requestId = MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(flags), _channel->inputChannel, MTP_int(_msgId)), diff --git a/Telegram/SourceFiles/boxes/confirm_box.h b/Telegram/SourceFiles/boxes/confirm_box.h index 4d49334a7..100ffd5f2 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.h +++ b/Telegram/SourceFiles/boxes/confirm_box.h @@ -166,7 +166,7 @@ private: MsgId _msgId; object_ptr _text; - object_ptr _notify; + object_ptr _notify = {nullptr}; mtpRequestId _requestId = 0; };