public links display / edit done in megagroups
This commit is contained in:
		
							parent
							
								
									14a1f7140f
								
							
						
					
					
						commit
						cb78bd1a10
					
				
					 4 changed files with 49 additions and 25 deletions
				
			
		| 
						 | 
					@ -477,6 +477,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
 | 
				
			||||||
"lng_create_public_channel_about" = "Anyone can find the channel in search and join";
 | 
					"lng_create_public_channel_about" = "Anyone can find the channel in search and join";
 | 
				
			||||||
"lng_create_private_channel_title" = "Private Channel";
 | 
					"lng_create_private_channel_title" = "Private Channel";
 | 
				
			||||||
"lng_create_private_channel_about" = "Only people with a special invite link may join";
 | 
					"lng_create_private_channel_about" = "Only people with a special invite link may join";
 | 
				
			||||||
 | 
					"lng_create_public_group_title" = "Public Group";
 | 
				
			||||||
 | 
					"lng_create_public_group_about" = "Anyone can find the group in search and join, all chat history is available to everybody";
 | 
				
			||||||
 | 
					"lng_create_private_group_title" = "Private Group";
 | 
				
			||||||
 | 
					"lng_create_private_group_about" = "Only invited people may join and see the chat history";
 | 
				
			||||||
"lng_create_channel_comments" = "Enable Comments";
 | 
					"lng_create_channel_comments" = "Enable Comments";
 | 
				
			||||||
"lng_create_channel_comments_about" = "If you enable comments, members will be able to discuss your posts in the channel";
 | 
					"lng_create_channel_comments_about" = "If you enable comments, members will be able to discuss your posts in the channel";
 | 
				
			||||||
"lng_create_group_skip" = "Skip";
 | 
					"lng_create_group_skip" = "Skip";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -605,12 +605,12 @@ void GroupInfoBox::onPhotoReady(const QImage &img) {
 | 
				
			||||||
SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : AbstractBox()
 | 
					SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : AbstractBox()
 | 
				
			||||||
, _channel(channel)
 | 
					, _channel(channel)
 | 
				
			||||||
, _existing(existing)
 | 
					, _existing(existing)
 | 
				
			||||||
, _public(this, qsl("channel_privacy"), 0, lang(lng_create_public_channel_title), true)
 | 
					, _public(this, qsl("channel_privacy"), 0, lang(channel->isMegagroup() ? lng_create_public_group_title : lng_create_public_channel_title), true)
 | 
				
			||||||
, _private(this, qsl("channel_privacy"), 1, lang(lng_create_private_channel_title))
 | 
					, _private(this, qsl("channel_privacy"), 1, lang(channel->isMegagroup() ? lng_create_private_group_title : lng_create_private_channel_title))
 | 
				
			||||||
, _comments(this, lang(lng_create_channel_comments), false)
 | 
					, _comments(this, lang(lng_create_channel_comments), false)
 | 
				
			||||||
, _aboutPublicWidth(width() - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultRadiobutton.textPosition.x())
 | 
					, _aboutPublicWidth(width() - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultRadiobutton.textPosition.x())
 | 
				
			||||||
, _aboutPublic(st::normalFont, lang(lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth)
 | 
					, _aboutPublic(st::normalFont, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth)
 | 
				
			||||||
, _aboutPrivate(st::normalFont, lang(lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth)
 | 
					, _aboutPrivate(st::normalFont, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth)
 | 
				
			||||||
, _aboutComments(st::normalFont, lang(lng_create_channel_comments_about), _defaultOptions, _aboutPublicWidth)
 | 
					, _aboutComments(st::normalFont, lang(lng_create_channel_comments_about), _defaultOptions, _aboutPublicWidth)
 | 
				
			||||||
, _link(this, st::defaultInputField, QString(), channel->username, true)
 | 
					, _link(this, st::defaultInputField, QString(), channel->username, true)
 | 
				
			||||||
, _linkOver(false)
 | 
					, _linkOver(false)
 | 
				
			||||||
| 
						 | 
					@ -626,7 +626,7 @@ SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : Abstract
 | 
				
			||||||
	_checkRequestId = MTP::send(MTPchannels_CheckUsername(_channel->inputChannel, MTP_string("preston")), RPCDoneHandlerPtr(), rpcFail(&SetupChannelBox::onFirstCheckFail));
 | 
						_checkRequestId = MTP::send(MTPchannels_CheckUsername(_channel->inputChannel, MTP_string("preston")), RPCDoneHandlerPtr(), rpcFail(&SetupChannelBox::onFirstCheckFail));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_aboutPublicHeight = _aboutPublic.countHeight(_aboutPublicWidth);
 | 
						_aboutPublicHeight = _aboutPublic.countHeight(_aboutPublicWidth);
 | 
				
			||||||
	setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth)/* + st::newGroupSkip + _comments.height() + _aboutComments.countHeight(_aboutPublicWidth)*/ + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top() + _link.height() + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
 | 
						updateMaxHeight();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
 | 
						connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
 | 
				
			||||||
	connect(&_skip, SIGNAL(clicked()), this, SLOT(onClose()));
 | 
						connect(&_skip, SIGNAL(clicked()), this, SLOT(onClose()));
 | 
				
			||||||
| 
						 | 
					@ -669,6 +669,14 @@ void SetupChannelBox::showDone() {
 | 
				
			||||||
	_link.setFocus();
 | 
						_link.setFocus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SetupChannelBox::updateMaxHeight() {
 | 
				
			||||||
 | 
						if (!_channel->isMegagroup() || _public.checked()) {
 | 
				
			||||||
 | 
							setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth)/* + st::newGroupSkip + _comments.height() + _aboutComments.countHeight(_aboutPublicWidth)*/ + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top() + _link.height() + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth)/* + st::newGroupSkip + _comments.height() + _aboutComments.countHeight(_aboutPublicWidth)*/ + st::newGroupSkip + st::newGroupPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SetupChannelBox::keyPressEvent(QKeyEvent *e) {
 | 
					void SetupChannelBox::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
	if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
 | 
						if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
 | 
				
			||||||
		if (_link.hasFocus()) {
 | 
							if (_link.hasFocus()) {
 | 
				
			||||||
| 
						 | 
					@ -699,22 +707,26 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) {
 | 
				
			||||||
	//QRect aboutComments(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _comments.y() + _comments.height(), _aboutPublicWidth, _aboutPublicHeight);
 | 
						//QRect aboutComments(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _comments.y() + _comments.height(), _aboutPublicWidth, _aboutPublicHeight);
 | 
				
			||||||
	//_aboutComments.drawLeft(p, aboutComments.x(), aboutComments.y(), aboutComments.width(), width());
 | 
						//_aboutComments.drawLeft(p, aboutComments.x(), aboutComments.y(), aboutComments.width(), width());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p.setPen(st::black);
 | 
						if (!_channel->isMegagroup() || !_link.isHidden()) {
 | 
				
			||||||
	p.setFont(st::newGroupLinkFont);
 | 
							p.setPen(st::black);
 | 
				
			||||||
	p.drawTextLeft(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, width(), lang(_link.isHidden() ? lng_create_group_invite_link : lng_create_group_link));
 | 
							p.setFont(st::newGroupLinkFont);
 | 
				
			||||||
 | 
							p.drawTextLeft(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, width(), lang(_link.isHidden() ? lng_create_group_invite_link : lng_create_group_link));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_link.isHidden()) {
 | 
						if (_link.isHidden()) {
 | 
				
			||||||
		QTextOption option(style::al_left);
 | 
							if (!_channel->isMegagroup()) {
 | 
				
			||||||
		option.setWrapMode(QTextOption::WrapAnywhere);
 | 
								QTextOption option(style::al_left);
 | 
				
			||||||
		p.setFont(_linkOver ? st::boxTextFont->underline() : st::boxTextFont);
 | 
								option.setWrapMode(QTextOption::WrapAnywhere);
 | 
				
			||||||
		p.setPen(st::btnDefLink.color);
 | 
								p.setFont(_linkOver ? st::boxTextFont->underline() : st::boxTextFont);
 | 
				
			||||||
		p.drawText(_invitationLink, _channel->invitationUrl, option);
 | 
								p.setPen(st::btnDefLink.color);
 | 
				
			||||||
		if (!_goodTextLink.isEmpty() && a_goodOpacity.current() > 0) {
 | 
								p.drawText(_invitationLink, _channel->invitationUrl, option);
 | 
				
			||||||
			p.setOpacity(a_goodOpacity.current());
 | 
								if (!_goodTextLink.isEmpty() && a_goodOpacity.current() > 0) {
 | 
				
			||||||
			p.setPen(st::setGoodColor);
 | 
									p.setOpacity(a_goodOpacity.current());
 | 
				
			||||||
			p.setFont(st::boxTextFont);
 | 
									p.setPen(st::setGoodColor);
 | 
				
			||||||
			p.drawTextRight(st::boxPadding.right(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodTextLink);
 | 
									p.setFont(st::boxTextFont);
 | 
				
			||||||
			p.setOpacity(1);
 | 
									p.drawTextRight(st::boxPadding.right(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodTextLink);
 | 
				
			||||||
 | 
									p.setOpacity(1);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (!_errorText.isEmpty()) {
 | 
							if (!_errorText.isEmpty()) {
 | 
				
			||||||
| 
						 | 
					@ -879,6 +891,9 @@ void SetupChannelBox::onPrivacyChange() {
 | 
				
			||||||
		_link.hide();
 | 
							_link.hide();
 | 
				
			||||||
		setFocus();
 | 
							setFocus();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (_channel->isMegagroup()) {
 | 
				
			||||||
 | 
							updateMaxHeight();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	update();
 | 
						update();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1198,11 +1213,10 @@ void EditChannelBox::showAll() {
 | 
				
			||||||
	_description.show();
 | 
						_description.show();
 | 
				
			||||||
	_save.show();
 | 
						_save.show();
 | 
				
			||||||
	_cancel.show();
 | 
						_cancel.show();
 | 
				
			||||||
 | 
						_publicLink.show();
 | 
				
			||||||
	if (_channel->isMegagroup()) {
 | 
						if (_channel->isMegagroup()) {
 | 
				
			||||||
		_publicLink.hide();
 | 
					 | 
				
			||||||
		_sign.hide();
 | 
							_sign.hide();
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		_publicLink.show();
 | 
					 | 
				
			||||||
		_sign.show();
 | 
							_sign.show();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1259,7 +1273,11 @@ void EditChannelBox::resizeEvent(QResizeEvent *e) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_sign.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description.y() + _description.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top());
 | 
						_sign.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description.y() + _description.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_publicLink.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _sign.y() + _sign.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top());
 | 
						if (_channel->isMegagroup()) {
 | 
				
			||||||
 | 
							_publicLink.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description.y() + _description.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top());
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							_publicLink.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _sign.y() + _sign.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
 | 
						_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
 | 
				
			||||||
	_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
 | 
						_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -211,6 +211,8 @@ private:
 | 
				
			||||||
	bool onCheckFail(const RPCError &error);
 | 
						bool onCheckFail(const RPCError &error);
 | 
				
			||||||
	bool onFirstCheckFail(const RPCError &error);
 | 
						bool onFirstCheckFail(const RPCError &error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void updateMaxHeight();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ChannelData *_channel;
 | 
						ChannelData *_channel;
 | 
				
			||||||
	bool _existing;
 | 
						bool _existing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -841,7 +841,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
 | 
				
			||||||
		addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
							addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
				
			||||||
		p.setPen(st::black->p);
 | 
							p.setPen(st::black->p);
 | 
				
			||||||
		p.drawText(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop + st::linkFont->ascent, '@' + _peerUser->username);
 | 
							p.drawText(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop + st::linkFont->ascent, '@' + _peerUser->username);
 | 
				
			||||||
	} else if (_peerChannel && !_peerChannel->isMegagroup() && (_peerChannel->isPublic() || _amCreator )) {
 | 
						} else if (_peerChannel && (_peerChannel->isPublic() || _amCreator)) {
 | 
				
			||||||
		addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
							addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!_peerChannel || !_peerChannel->canViewParticipants() || _peerChannel->isMegagroup()) {
 | 
						if (!_peerChannel || !_peerChannel->canViewParticipants() || _peerChannel->isMegagroup()) {
 | 
				
			||||||
| 
						 | 
					@ -1337,7 +1337,7 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
 | 
				
			||||||
	// profile
 | 
						// profile
 | 
				
			||||||
	top += st::profilePadding.top();
 | 
						top += st::profilePadding.top();
 | 
				
			||||||
	int32 addbyname = 0;
 | 
						int32 addbyname = 0;
 | 
				
			||||||
	if (_peerChannel && !_peerChannel->isMegagroup() && (_amCreator || _peerChannel->isPublic())) {
 | 
						if (_peerChannel && (_amCreator || _peerChannel->isPublic())) {
 | 
				
			||||||
		_username.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop);
 | 
							_username.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop);
 | 
				
			||||||
		addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
							addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1711,7 +1711,7 @@ void ProfileInner::showAll() {
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			_deleteChannel.hide();
 | 
								_deleteChannel.hide();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!_peerChannel->isMegagroup() && (_peerChannel->isPublic() || _amCreator)) {
 | 
							if (_peerChannel->isPublic() || _amCreator) {
 | 
				
			||||||
			_username.show();
 | 
								_username.show();
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			_username.hide();
 | 
								_username.hide();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue