コード例 #1
0
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;
}
コード例 #2
0
ファイル: buttons.cpp プロジェクト: Igevorse/tdesktop
LeftOutlineButton::LeftOutlineButton(QWidget *parent, const QString &text, const style::OutlineButton &st) : RippleButton(parent, st.ripple)
, _text(text)
, _fullText(text)
, _textWidth(st.font->width(_text))
, _fullTextWidth(_textWidth)
, _st(st) {
	resizeToWidth(_textWidth + _st.padding.left() + _st.padding.right());

	setCursor(style::cur_pointer);
}
コード例 #3
0
void PeerListContent::refreshRows() {
	resizeToWidth(width());
	if (_visibleBottom > 0) {
		checkScrollForPreload();
	}
	if (_mouseSelection) {
		selectByMouse(QCursor::pos());
	}
	update();
}
コード例 #4
0
void ManagePeerBox::setupContent() {
	auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
	FillManageBox(controller(), _channel, content);
	widthValue(
	) | rpl::start_with_next([=](int width) {
		content->resizeToWidth(width);
	}, content->lifetime());
	content->heightValue(
	) | rpl::start_with_next([=](int height) {
		setDimensions(st::boxWidth, height);
	}, content->lifetime());
}
コード例 #5
0
void AdvancedWidget::connectionTypeUpdated() {
	const auto connection = [] {
		const auto transport = MTP::dctransport();
		if (!Global::UseProxy()) {
			return transport.isEmpty()
				? lang(lng_connection_auto_connecting)
				: lng_connection_auto(lt_transport, transport);
		} else {
			return transport.isEmpty()
				? lang(lng_connection_proxy_connecting)
				: lng_connection_proxy(lt_transport, transport);
		}
	}();
	_connectionType->link()->setText(connection);
	resizeToWidth(width());
}
コード例 #6
0
void UpdateStateRow::setState(State state, bool force) {
	if (_state != state || force) {
		_state = state;
		switch (state) {
		case State::None: _check->show(); _restart->hide(); break;
		case State::Ready: _check->hide(); _restart->show(); break;
		case State::Check:
		case State::Download:
		case State::Latest:
		case State::Fail: _check->hide(); _restart->hide(); break;
		}
		resizeToWidth(width());
		sendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton);
		update();
	}
}
コード例 #7
0
DownloadPathState::DownloadPathState(QWidget *parent) : TWidget(parent)
, _path(this, lang(lng_download_path_label), downloadPathText(), LabeledLink::Type::Secondary, SLOT(onDownloadPath()))
, _clear(this, lang(lng_download_path_clear)) {
	connect(_clear, SIGNAL(clicked()), this, SLOT(onClear()));
	connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int)));
	connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int)));
	subscribe(Global::RefDownloadPathChanged(), [this]() {
		_path->link()->setText(downloadPathText());
		resizeToWidth(width());
	});
	switch (App::wnd()->tempDirState()) {
	case MainWindow::TempDirEmpty: _state = State::Empty; break;
	case MainWindow::TempDirExists: _state = State::Exists; break;
	case MainWindow::TempDirRemoving: _state = State::Clearing; break;
	}
	updateControls();
}
コード例 #8
0
ファイル: confirmbox.cpp プロジェクト: 2asoft/tdesktop
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;
        }
コード例 #9
0
ファイル: settings_widget.cpp プロジェクト: absalan/tdesktop
void Widget::parentResized() {
	auto parentSize = parentWidget()->size();
	auto windowWidth = parentSize.width();
	auto newWidth = st::settingsMaxWidth;
	auto newContentLeft = st::settingsMaxPadding;
	if (windowWidth <= st::settingsMaxWidth) {
		newWidth = windowWidth;
		newContentLeft = st::settingsMinPadding;
		if (windowWidth > st::windowMinWidth) {
			// Width changes from st::windowMinWidth to st::settingsMaxWidth.
			// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
			newContentLeft += ((newWidth - st::windowMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::windowMinWidth);
		}
	} else if (windowWidth < st::settingsMaxWidth + 2 * st::settingsMargin) {
		newWidth = windowWidth - 2 * st::settingsMargin;
		newContentLeft = st::settingsMinPadding;
		if (windowWidth > st::windowMinWidth) {
			// Width changes from st::windowMinWidth to st::settingsMaxWidth.
			// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
			newContentLeft += ((newWidth - st::windowMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::windowMinWidth);
		}
	}
	resizeToWidth(newWidth, newContentLeft);
}
コード例 #10
0
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);
	};
}
コード例 #11
0
ファイル: discrete_sliders.cpp プロジェクト: i-rinat/tdesktop
void DiscreteSlider::addSection(const QString &label) {
	_sections.push_back(Section(label, getLabelFont()));
	resizeToWidth(width());
}