Example #1
0
void QSearchLineEdit::resizeEvent(QResizeEvent*)
{
    if (parentWidget()) {
        if (parentWidget()->layoutDirection() == Qt::RightToLeft) {
            moveToRight(optionButton);
            moveToLeft(clearButton);
            return;
        }
    }
    moveToRight(clearButton);
    moveToLeft(optionButton);
}
object_ptr<InnerWidget::ListWidget> InnerWidget::setupList(
		RpWidget *parent,
		not_null<PeerListController*> controller) const {
	auto result = object_ptr<ListWidget>(
		parent,
		controller,
		st::infoCommonGroupsList);
	result->scrollToRequests(
	) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
		auto addmin = (request.ymin < 0)
			? 0
			: st::infoCommonGroupsMargin.top();
		auto addmax = (request.ymax < 0)
			? 0
			: st::infoCommonGroupsMargin.top();
		_scrollToRequests.fire({
			request.ymin + addmin,
			request.ymax + addmax });
	}, result->lifetime());
	result->moveToLeft(0, st::infoCommonGroupsMargin.top());
	parent->widthValue(
	) | rpl::start_with_next([list = result.data()](int newWidth) {
		list->resizeToWidth(newWidth);
	}, result->lifetime());
	result->heightValue(
	) | rpl::start_with_next([parent](int listHeight) {
		auto newHeight = st::infoCommonGroupsMargin.top()
			+ listHeight
			+ st::infoCommonGroupsMargin.bottom();
		parent->resize(parent->width(), newHeight);
	}, result->lifetime());
	return result;
}
Example #3
0
void ChangePhoneBox::EnterCode::prepare() {
	setTitle(langFactory(lng_change_phone_title));

	auto descriptionText = lng_change_phone_code_description(lt_phone, textcmdStartSemibold() + App::formatPhone(_phone) + textcmdStopSemibold());
	auto description = object_ptr<Ui::FlatLabel>(this, descriptionText, Ui::FlatLabel::InitType::Rich, st::changePhoneLabel);
	description->moveToLeft(st::boxPadding.left(), 0);

	auto phoneValue = QString();
	_code.create(this, st::defaultInputField, langFactory(lng_change_phone_code_title), phoneValue);
	_code->setAutoSubmit(_codeLength, [=] { submit(); });
	_code->setChangedCallback([=] { hideError(); });

	_code->resize(st::boxWidth - 2 * st::boxPadding.left(), _code->height());
	_code->moveToLeft(st::boxPadding.left(), description->bottomNoMargins());
	connect(_code, &Ui::InputField::submitted, [=] { submit(); });

	setDimensions(st::boxWidth, countHeight());

	if (_callTimeout > 0) {
		_call.setStatus({ SentCodeCall::State::Waiting, _callTimeout });
		updateCall();
	}

	addButton(langFactory(lng_change_phone_new_submit), [=] { submit(); });
	addButton(langFactory(lng_cancel), [=] { closeBox(); });
}
Example #4
0
void InnerDropdown::setOwnedWidget(TWidget *widget) {
	connect(widget, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated()));
	auto container = _scroll->setOwnedWidget(object_ptr<Container>(_scroll, widget, _st));
	container->resizeToWidth(_scroll->width());
	container->moveToLeft(0, 0);
	container->show();
	widget->show();
}
Example #5
0
void InnerDropdown::setOwnedWidget(ScrolledWidget *widget) {
	auto container = new internal::Container(_scroll, widget, _st);
	connect(container, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated()));
	_scroll->setOwnedWidget(container);
	container->resizeToWidth(_scroll->width());
	container->moveToLeft(0, 0);
	container->show();
	widget->show();
}
QPointer<TWidget> InnerDropdown::doSetOwnedWidget(object_ptr<TWidget> widget) {
	auto result = QPointer<TWidget>(widget);
	connect(widget, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated()));
	auto container = _scroll->setOwnedWidget(object_ptr<Container>(_scroll, std::move(widget), _st));
	container->resizeToWidth(_scroll->width());
	container->moveToLeft(0, 0);
	container->show();
	result->show();
	return result;
}
void DeleteDocumentBox::setupControls(
		const QString &text,
		const QString &detailsCheckbox,
		Fn<void(bool withDetails)> submit) {
	const auto label = Ui::CreateChild<Ui::FlatLabel>(
		this,
		text,
		Ui::FlatLabel::InitType::Simple,
		st::boxLabel);
	const auto details = !detailsCheckbox.isEmpty()
		? Ui::CreateChild<Ui::Checkbox>(
			this,
			detailsCheckbox,
			false,
			st::defaultBoxCheckbox)
		: nullptr;

	_height = st::boxPadding.top();
	const auto availableWidth = st::boxWidth
		- st::boxPadding.left()
		- st::boxPadding.right();
	label->resizeToWidth(availableWidth);
	label->moveToLeft(st::boxPadding.left(), _height);
	_height += label->height();

	if (details) {
		_height += st::boxPadding.bottom();
		details->moveToLeft(st::boxPadding.left(), _height);
		_height += details->heightNoMargins();
	}
	_height += st::boxPadding.bottom();

	_submit = [=] {
		submit(details ? details->checked() : false);
	};
}
Example #8
0
void ChangePhoneBox::prepare() {
	setTitle(langFactory(lng_change_phone_title));
	addButton(langFactory(lng_change_phone_button), [] {
		Ui::show(Box<ConfirmBox>(lang(lng_change_phone_warning), [] {
			Ui::show(Box<EnterPhone>());
		}));
	});
	addButton(langFactory(lng_cancel), [this] {
		closeBox();
	});

	auto label = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_description), Ui::FlatLabel::InitType::Rich, st::changePhoneDescription);
	label->moveToLeft((st::boxWideWidth - label->width()) / 2, st::changePhoneDescriptionTop);

	setDimensions(st::boxWideWidth, label->bottomNoMargins() + st::boxLittleSkip);
}
Example #9
0
FloatingIcon::FloatingIcon(
	RpWidget *parent,
	const style::icon &icon,
	QPoint position,
	const Tag &)
: RpWidget(parent)
, _icon(&icon)
, _point(position) {
	resize(
		_point.x() + _icon->width(),
		_point.y() + _icon->height());
	setAttribute(Qt::WA_TransparentForMouseEvents);
	parent->widthValue(
	) | rpl::start_with_next(
		[this] { moveToLeft(0, 0); },
		lifetime());
}
Example #10
0
ConfirmInviteBox::ConfirmInviteBox(const QString &title, const MTPChatPhoto &photo, int count, const QVector<UserData*> &participants) : AbstractBox()
    , _title(this, st::confirmInviteTitle)
    , _status(this, st::confirmInviteStatus)
    , _photo(chatDefPhoto(0))
    , _participants(participants)
    , _join(this, lang(lng_group_invite_join), st::defaultBoxButton)
    , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
    if (_participants.size() > 4) {
        _participants.resize(4);
    }

    _title->setText(title);
    QString status;
    if (_participants.isEmpty() || _participants.size() >= count) {
        status = lng_chat_status_members(lt_count, count);
    } else {
        status = lng_group_invite_members(lt_count, count);
    }
    _status->setText(status);
    if (photo.type() == mtpc_chatPhoto) {
        auto &d = photo.c_chatPhoto();
        auto location = App::imageLocation(160, 160, d.vphoto_small);
        if (!location.isNull()) {
            _photo = ImagePtr(location);
            if (!_photo->loaded()) {
                subscribe(FileDownload::ImageLoaded(), [this] { update(); });
                _photo->load();
            }
        }
    }

    int h = st::confirmInviteStatusTop + _status->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _join->height() + st::boxButtonPadding.bottom();
    if (!_participants.isEmpty()) {
        int skip = (width() - 4 * st::confirmInviteUserPhotoSize) / 5;
        int padding = skip / 2;
        _userWidth = (st::confirmInviteUserPhotoSize + 2 * padding);
        int sumWidth = _participants.size() * _userWidth;
        int left = (width() - sumWidth) / 2;
        for_const (auto user, _participants) {
            auto name = new FlatLabel(this, st::confirmInviteUserName);
            name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
            name->setText(user->firstName.isEmpty() ? App::peerName(user) : user->firstName);
            name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
            left += _userWidth;
        }
Example #11
0
void ChangePhoneBox::EnterPhone::prepare() {
	setTitle(langFactory(lng_change_phone_title));

	auto phoneValue = QString();
	_phone.create(this, st::defaultInputField, langFactory(lng_change_phone_new_title), phoneValue);

	_phone->resize(st::boxWidth - 2 * st::boxPadding.left(), _phone->height());
	_phone->moveToLeft(st::boxPadding.left(), st::boxLittleSkip);
	connect(_phone, &Ui::PhoneInput::submitted, [=] { submit(); });

	auto description = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_new_description), Ui::FlatLabel::InitType::Simple, st::changePhoneLabel);
	auto errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height;
	description->moveToLeft(st::boxPadding.left(), _phone->y() + _phone->height() + errorSkip + st::boxLittleSkip);

	setDimensions(st::boxWidth, description->bottomNoMargins() + st::boxLittleSkip);

	addButton(langFactory(lng_change_phone_new_submit), [this] { submit(); });
	addButton(langFactory(lng_cancel), [this] { closeBox(); });
}