Exemplo n.º 1
0
void MembersBox::Inner::paintEvent(QPaintEvent *e) {
	QRect r(e->rect());
	Painter p(this);

	_time = unixtime();
	p.fillRect(r, st::contactsBg);

	auto ms = getms();
	auto yFrom = r.y() - st::membersMarginTop;
	auto yTo = r.y() + r.height() - st::membersMarginTop;
	p.translate(0, st::membersMarginTop);
	if (_rows.isEmpty()) {
		p.setFont(st::noContactsFont);
		p.setPen(st::noContactsColor);
		p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
	} else {
		int32 from = floorclamp(yFrom, _rowHeight, 0, _rows.size());
		int32 to = ceilclamp(yTo, _rowHeight, 0, _rows.size());
		p.translate(0, from * _rowHeight);
		for (; from < to; ++from) {
			auto selected = (_pressed >= 0) ? (from == _pressed) : (from == _selected);
			auto kickSelected = (_pressed >= 0) ? (from == _kickPressed && from == _kickSelected) : (from == _kickSelected);
			paintDialog(p, ms, _rows[from], data(from), selected, kickSelected);
			p.translate(0, _rowHeight);
		}
		if (to == _rows.size() && _filter == MembersFilter::Recent && (_rows.size() < _channel->membersCount() || _rows.size() >= Global::ChatSizeMax())) {
			p.setPen(st::membersAboutLimitFg);
			_about.draw(p, st::contactsPadding.left(), st::membersAboutLimitPadding.top(), _aboutWidth, style::al_center);
		}
	}
}
Exemplo n.º 2
0
void SessionsInner::paintEvent(QPaintEvent *e) {
	QRect r(e->rect());
	Painter p(this);

	p.fillRect(r, st::white->b);
	p.setFont(st::linkFont->f);
	int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
	int32 w = width();
	int32 count = _list->size();
	int32 from = floorclamp(r.y(), st::sessionHeight, 0, count);
	int32 to = ceilclamp(r.y() + r.height(), st::sessionHeight, 0, count);
	p.translate(0, from * st::sessionHeight);
	for (int32 i = from; i < to; ++i) {
		const SessionData &auth(_list->at(i));

		p.setFont(st::sessionNameFont->f);
		p.setPen(st::black->p);
		p.drawTextLeft(x, st::sessionPadding.top(), w, auth.name, auth.nameWidth);

		p.setFont(st::sessionActiveFont->f);
		p.setPen(st::sessionActiveColor->p);
		p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth);

		p.setFont(st::sessionInfoFont->f);
		p.setPen(st::black->p);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, auth.info, auth.infoWidth);
		p.setPen(st::sessionInfoColor->p);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, auth.ip, auth.ipWidth);

		p.translate(0, st::sessionHeight);
	}
}
Exemplo n.º 3
0
void PeerListWidget::preloadPhotos() {
	int top = getListTop();
	int preloadFor = (_visibleBottom - _visibleTop) * PreloadHeightsCount;
	int from = floorclamp(_visibleTop - top, _st.height, 0, _items.size());
	int to = ceilclamp(_visibleBottom + preloadFor - top, _st.height, 0, _items.size());
	for (int i = from; i < to; ++i) {
		_items[i]->peer->loadUserpic();
	}
}
Exemplo n.º 4
0
void PeerListWidget::paintContents(Painter &p) {
	auto ms = getms();
	auto left = getListLeft();
	auto top = getListTop();
	auto memberRowWidth = rowWidth();

	auto from = floorclamp(_visibleTop - top, _st.height, 0, _items.size());
	auto to = ceilclamp(_visibleBottom - top, _st.height, 0, _items.size());
	for (auto i = from; i < to; ++i) {
		auto y = top + i * _st.height;
		auto selected = (_pressed >= 0) ? (i == _pressed) : (i == _selected);
		auto selectedRemove = selected && _selectedRemove;
		if (_pressed >= 0 && !_pressedRemove) {
			selectedRemove = false;
		}
		paintItem(p, left, y, _items[i], selected, selectedRemove, ms);
	}
}
Exemplo n.º 5
0
void CountrySelectInner::paintEvent(QPaintEvent *e) {
	Painter p(this);
	QRect r(e->rect());
	p.setClipRect(r);

	int l = countriesNow->size();
	if (l) {
		if (r.intersects(QRect(0, 0, width(), st::countriesSkip))) {
			p.fillRect(r.intersected(QRect(0, 0, width(), st::countriesSkip)), st::white->b);
		}
		int32 from = floorclamp(r.y() - st::countriesSkip, _rowHeight, 0, l);
		int32 to = ceilclamp(r.y() + r.height() - st::countriesSkip, _rowHeight, 0, l);
		for (int32 i = from; i < to; ++i) {
			bool sel = (i == _sel);
			int32 y = st::countriesSkip + i * _rowHeight;

			p.fillRect(0, y, width(), _rowHeight, (sel ? st::countryRowBgOver : st::white)->b);

			QString code = QString("+") + (*countriesNow)[i]->code;
			int32 codeWidth = st::countryRowCodeFont->width(code);

			QString name = QString::fromUtf8((*countriesNow)[i]->name);
			int32 nameWidth = st::countryRowNameFont->width(name);
			int32 availWidth = width() - st::countryRowPadding.left() - st::countryRowPadding.right() - codeWidth - st::contactsScroll.width;
			if (nameWidth > availWidth) {
				name = st::countryRowNameFont->elided(name, availWidth);
				nameWidth = st::countryRowNameFont->width(name);
			}

			p.setFont(st::countryRowNameFont);
			p.setPen(st::black);
			p.drawTextLeft(st::countryRowPadding.left(), y + st::countryRowPadding.top(), width(), name);
			p.setFont(st::countryRowCodeFont);
			p.setPen(sel ? st::countryRowCodeFgOver : st::countryRowCodeFg);
			p.drawTextLeft(st::countryRowPadding.left() + nameWidth + st::countryRowPadding.right(), y + st::countryRowPadding.top(), width(), code);
		}
	} else {
		p.fillRect(r, st::white->b);
		p.setFont(st::noContactsFont->f);
		p.setPen(st::noContactsColor->p);
		p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_country_none), style::al_center);
	}
}
Exemplo n.º 6
0
void SessionsBox::Inner::paintEvent(QPaintEvent *e) {
	QRect r(e->rect());
	Painter p(this);

	p.fillRect(r, st::boxBg);
	int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPosition.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
	int32 w = width();

	if (_current->active.isEmpty() && _list->isEmpty()) {
		p.setFont(st::noContactsFont->f);
		p.setPen(st::noContactsColor->p);
		p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
		return;
	}

	if (r.y() <= st::sessionCurrentHeight) {
		p.translate(0, st::sessionCurrentPadding.top());
		p.setFont(st::sessionNameFont);
		p.setPen(st::sessionNameFg);
		p.drawTextLeft(x, st::sessionPadding.top(), w, _current->name, _current->nameWidth);

		p.setFont(st::sessionWhenFont);
		p.setPen(st::sessionWhenFg);
		p.drawTextRight(x, st::sessionPadding.top(), w, _current->active, _current->activeWidth);

		p.setFont(st::sessionInfoFont);
		p.setPen(st::boxTextFg);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, _current->info, _current->infoWidth);
		p.setPen(st::sessionInfoFg);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, _current->ip, _current->ipWidth);
	}
	p.translate(0, st::sessionCurrentHeight - st::sessionCurrentPadding.top());
	if (_list->isEmpty()) {
		p.setFont(st::sessionInfoFont);
		p.setPen(st::sessionInfoFg);
		p.drawText(QRect(st::sessionPadding.left(), 0, width() - st::sessionPadding.left() - st::sessionPadding.right(), st::noContactsHeight), lang(lng_sessions_other_desc), style::al_topleft);
		return;
	}

	p.setFont(st::linkFont->f);
	int32 count = _list->size();
	int32 from = floorclamp(r.y() - st::sessionCurrentHeight, st::sessionHeight, 0, count);
	int32 to = ceilclamp(r.y() + r.height() - st::sessionCurrentHeight, st::sessionHeight, 0, count);
	p.translate(0, from * st::sessionHeight);
	for (int32 i = from; i < to; ++i) {
		const SessionsBox::Data &auth(_list->at(i));

		p.setFont(st::sessionNameFont);
		p.setPen(st::sessionNameFg);
		p.drawTextLeft(x, st::sessionPadding.top(), w, auth.name, auth.nameWidth);

		p.setFont(st::sessionWhenFont);
		p.setPen(st::sessionWhenFg);
		p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth);

		p.setFont(st::sessionInfoFont);
		p.setPen(st::boxTextFg);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, auth.info, auth.infoWidth);
		p.setPen(st::sessionInfoFg);
		p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, auth.ip, auth.ipWidth);

		p.translate(0, st::sessionHeight);
	}
}