Improve accounts limit box.
This commit is contained in:
		
							parent
							
								
									6d8012f13a
								
							
						
					
					
						commit
						4de71408a2
					
				
					 3 changed files with 37 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -977,13 +977,21 @@ void AccountsLimitBox(
 | 
			
		|||
		BoxShowFinishes(box),
 | 
			
		||||
		0,
 | 
			
		||||
		current,
 | 
			
		||||
		(current > defaultLimit) ? current : (defaultLimit * 2),
 | 
			
		||||
		(!premiumPossible
 | 
			
		||||
			? (current * 2)
 | 
			
		||||
			: (current > defaultLimit)
 | 
			
		||||
			? (current + 1)
 | 
			
		||||
			: (defaultLimit * 2)),
 | 
			
		||||
		premiumPossible,
 | 
			
		||||
		std::nullopt,
 | 
			
		||||
		&st::premiumIconAccounts);
 | 
			
		||||
	Settings::AddSkip(top, st::premiumLineTextSkip);
 | 
			
		||||
	if (premiumPossible) {
 | 
			
		||||
		Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit);
 | 
			
		||||
		Ui::Premium::AddLimitRow(
 | 
			
		||||
			top,
 | 
			
		||||
			(QString::number(std::max(current, defaultLimit) + 1)
 | 
			
		||||
				+ ((current + 1 == premiumLimit) ? "" : "+")),
 | 
			
		||||
			QString::number(defaultLimit));
 | 
			
		||||
		Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
 | 
			
		||||
	}
 | 
			
		||||
	box->setTitle(tr::lng_accounts_limit_title());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -454,6 +454,7 @@ public:
 | 
			
		|||
		int max,
 | 
			
		||||
		TextFactory textFactory,
 | 
			
		||||
		int min);
 | 
			
		||||
	Line(not_null<Ui::RpWidget*> parent, QString max, QString min);
 | 
			
		||||
 | 
			
		||||
	void setColorOverride(QBrush brush);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -483,11 +484,18 @@ Line::Line(
 | 
			
		|||
	int max,
 | 
			
		||||
	TextFactory textFactory,
 | 
			
		||||
	int min)
 | 
			
		||||
: Line(
 | 
			
		||||
	parent,
 | 
			
		||||
	max ? textFactory(max) : QString(),
 | 
			
		||||
	min ? textFactory(min) : QString()) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Line::Line(not_null<Ui::RpWidget*> parent, QString max, QString min)
 | 
			
		||||
: Ui::RpWidget(parent)
 | 
			
		||||
, _leftText(st::semiboldTextStyle, tr::lng_premium_free(tr::now))
 | 
			
		||||
, _rightText(st::semiboldTextStyle, tr::lng_premium(tr::now))
 | 
			
		||||
, _rightLabel(st::semiboldTextStyle, max ? textFactory(max) : QString())
 | 
			
		||||
, _leftLabel(st::semiboldTextStyle, min ? textFactory(min) : QString()) {
 | 
			
		||||
, _rightLabel(st::semiboldTextStyle, max)
 | 
			
		||||
, _leftLabel(st::semiboldTextStyle, min) {
 | 
			
		||||
	resize(width(), st::requestsAcceptButton.height);
 | 
			
		||||
 | 
			
		||||
	sizeValue(
 | 
			
		||||
| 
						 | 
				
			
			@ -626,14 +634,23 @@ void AddBubbleRow(
 | 
			
		|||
	}, bubble->lifetime());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AddLimitRow(
 | 
			
		||||
		not_null<Ui::VerticalLayout*> parent,
 | 
			
		||||
		QString max,
 | 
			
		||||
		QString min) {
 | 
			
		||||
	parent->add(object_ptr<Line>(parent, max, min), st::boxRowPadding);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AddLimitRow(
 | 
			
		||||
		not_null<Ui::VerticalLayout*> parent,
 | 
			
		||||
		int max,
 | 
			
		||||
		std::optional<tr::phrase<lngtag_count>> phrase,
 | 
			
		||||
		int min) {
 | 
			
		||||
	parent->add(
 | 
			
		||||
		object_ptr<Line>(parent, max, ProcessTextFactory(phrase), min),
 | 
			
		||||
		st::boxRowPadding);
 | 
			
		||||
	const auto factory = ProcessTextFactory(phrase);
 | 
			
		||||
	AddLimitRow(
 | 
			
		||||
		parent,
 | 
			
		||||
		max ? factory(max) : QString(),
 | 
			
		||||
		min ? factory(min) : QString());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AddAccountsRow(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,11 @@ void AddBubbleRow(
 | 
			
		|||
	std::optional<tr::phrase<lngtag_count>> phrase,
 | 
			
		||||
	const style::icon *icon);
 | 
			
		||||
 | 
			
		||||
void AddLimitRow(
 | 
			
		||||
	not_null<Ui::VerticalLayout*> parent,
 | 
			
		||||
	QString max,
 | 
			
		||||
	QString min = {});
 | 
			
		||||
 | 
			
		||||
void AddLimitRow(
 | 
			
		||||
	not_null<Ui::VerticalLayout*> parent,
 | 
			
		||||
	int max,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue