mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-29 00:39:55 +00:00
Dialog styles moved from basic.style to dialogs.style.
Many minor design improvements in the new profiles. New drafts design in the dialogs list: no icon, red badge. Verified checkbox added to the new profile implementation. Drafts saving to cloud is delayed for 1 second when switching chats. Before quitting the app makes an attempt to save drafts (timeout 1.5s).
This commit is contained in:
@@ -24,7 +24,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
FlatButton::FlatButton(QWidget *parent, const QString &text, const style::flatButton &st) : Button(parent)
|
||||
, _text(text)
|
||||
, _st(st)
|
||||
, _autoFontPadding(0)
|
||||
, a_bg(st.bgColor->c)
|
||||
, a_text(st.color->c)
|
||||
, _a_appearance(animation(this, &FlatButton::step_appearance))
|
||||
@@ -63,35 +62,10 @@ void FlatButton::setWidth(int32 w) {
|
||||
resize(_st.width, height());
|
||||
}
|
||||
|
||||
void FlatButton::setAutoFontSize(int32 padding, const QString &txt) {
|
||||
_autoFontPadding = padding;
|
||||
if (_autoFontPadding) {
|
||||
_textForAutoSize = txt;
|
||||
resizeEvent(0);
|
||||
} else {
|
||||
_textForAutoSize = QString();
|
||||
_autoFont = style::font();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
int32 FlatButton::textWidth() const {
|
||||
return _st.font->width(_text);
|
||||
}
|
||||
|
||||
void FlatButton::resizeEvent(QResizeEvent *e) {
|
||||
if (_autoFontPadding) {
|
||||
_autoFont = _st.font;
|
||||
for (int32 s = _st.font->f.pixelSize(); s >= st::fsize; --s) {
|
||||
_autoFont = style::font(s, _st.font->flags(), _st.font->family());
|
||||
if (2 * _autoFontPadding + _autoFont->width(_textForAutoSize) <= width()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Button::resizeEvent(e);
|
||||
}
|
||||
|
||||
void FlatButton::step_appearance(float64 ms, bool timer) {
|
||||
float64 dt = ms / _st.duration;
|
||||
if (dt >= 1) {
|
||||
@@ -129,12 +103,11 @@ void FlatButton::paintEvent(QPaintEvent *e) {
|
||||
p.setOpacity(_opacity);
|
||||
p.fillRect(r, a_bg.current());
|
||||
|
||||
p.setFont((_autoFont ? _autoFont : ((_state & StateOver) ? _st.overFont : _st.font))->f);
|
||||
p.setFont((_state & StateOver) ? _st.overFont : _st.font);
|
||||
p.setRenderHint(QPainter::TextAntialiasing);
|
||||
p.setPen(a_text.current());
|
||||
|
||||
int32 top = (_state & StateOver) ? ((_state & StateDown) ? _st.downTextTop : _st.overTextTop) : _st.textTop;
|
||||
if (_autoFont) top += (_st.font->height - _autoFont->height) / 2;
|
||||
r.setTop(top);
|
||||
|
||||
p.drawText(r, _text, style::al_top);
|
||||
|
||||
Reference in New Issue
Block a user