Esempio n. 1
0
void FlatInput::paintEvent(QPaintEvent *e) {
	Painter p(this);
	p.fillRect(rect(), a_bgColor.current());
	if (_st.borderWidth) {
		QBrush b(a_borderColor.current());
		p.fillRect(0, 0, width() - _st.borderWidth, _st.borderWidth, b);
		p.fillRect(width() - _st.borderWidth, 0, _st.borderWidth, height() - _st.borderWidth, b);
		p.fillRect(_st.borderWidth, height() - _st.borderWidth, width() - _st.borderWidth, _st.borderWidth, b);
		p.fillRect(0, _st.borderWidth, _st.borderWidth, height() - _st.borderWidth, b);
	}
	if (_st.imgRect.pxWidth()) {
		p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect);
	}

	bool phDraw = _phVisible;
	if (animating()) {
		p.setOpacity(a_phAlpha.current());
		phDraw = true;
	}
	if (phDraw) {
		p.save();
		p.setClipRect(rect());
		QRect phRect(placeholderRect());
		phRect.moveLeft(phRect.left() + a_phLeft.current());
		phPrepare(p);
		p.drawText(phRect, _ph, QTextOption(_st.phAlign));
		p.restore();
	}
	QLineEdit::paintEvent(e);
}
Esempio n. 2
0
void PhoneInput::paintEvent(QPaintEvent *e) {
    FlatInput::paintEvent(e);

    Painter p(this);
    QString t(text());
    if (!pattern.isEmpty() && !t.isEmpty()) {
        QString ph = placeholder().mid(t.size());
        if (!ph.isEmpty()) {
            p.setClipRect(rect());
            QRect phRect(placeholderRect());
            int tw = phFont()->m.width(t);
            if (tw < phRect.width()) {
                phRect.setLeft(phRect.left() + tw);
                phPrepare(p);
                p.drawText(phRect, ph, style::al_left);
            }
        }
    }
}