2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 00:55:12 +00:00

added chat backgrounds

This commit is contained in:
John Preston
2015-02-03 18:02:46 +03:00
parent a8e9c1b9e2
commit 70e85529c7
28 changed files with 1098 additions and 58 deletions

View File

@@ -576,7 +576,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
if (_hist->_overview[_type].isEmpty()) {
QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9);
p.drawPixmap(dogPos, App::sprite(), st::msgDogImg);
p.drawPixmap(dogPos, *cChatDogImage());
return;
}
@@ -721,7 +721,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
width = strwidth;
QRect r(left, st::msgServiceMargin.top(), width, height);
p.setBrush(st::msgServiceBG->b);
p.setBrush(App::msgServiceBG()->b);
p.setPen(Qt::NoPen);
p.drawRoundedRect(r, st::msgServiceRadius, st::msgServiceRadius);
@@ -1533,10 +1533,9 @@ OverviewInner::~OverviewInner() {
}
OverviewWidget::OverviewWidget(QWidget *parent, const PeerData *peer, MediaOverviewType type) : QWidget(parent)
, _scroll(this, st::setScroll, false)
, _scroll(this, st::historyScroll, false)
, _inner(this, &_scroll, peer, type)
, _noDropResizeIndex(false)
, _bg(st::msgBG)
, _showing(false)
, _scrollSetAfterShow(0)
, _scrollDelta(0)
@@ -1591,19 +1590,36 @@ void OverviewWidget::paintEvent(QPaintEvent *e) {
return;
}
bool hasTopBar = !App::main()->topBar()->isHidden();
QRect r(e->rect());
if (type() == OverviewPhotos) {
p.fillRect(r, st::white->b);
} else if (cCatsAndDogs()) {
int32 i_from = r.left() / _bg.width(), i_to = (r.left() + r.width() - 1) / _bg.width() + 1;
int32 j_from = r.top() / _bg.height(), j_to = (r.top() + r.height() - 1) / _bg.height() + 1;
for (int32 i = i_from; i < i_to; ++i) {
for (int32 j = j_from; j < j_to; ++j) {
p.drawPixmap(i * _bg.width(), j * _bg.height(), _bg);
}
} else if (cTileBackground()) {
int left = r.left(), top = r.top(), right = r.left() + r.width(), bottom = r.top() + r.height();
if (right > 0 && bottom > 0) {
QRect fill(left, top + (hasTopBar ? st::topBarHeight : 0), right, bottom + (hasTopBar ? st::topBarHeight : 0));
if (hasTopBar) p.translate(0, -st::topBarHeight);
p.fillRect(fill, QBrush(*cChatBackground()));
if (hasTopBar) p.translate(0, st::topBarHeight);
}
} else {
p.fillRect(r, st::historyBG->b);
QRect fill(0, 0, width(), App::main()->height());
int fromy = hasTopBar ? (-st::topBarHeight) : 0, x = 0, y = 0;
QPixmap cached = App::main()->cachedBackground(fill, x, y);
if (cached.isNull()) {
bool smooth = p.renderHints().testFlag(QPainter::SmoothPixmapTransform);
p.setRenderHint(QPainter::SmoothPixmapTransform);
QRect to, from;
App::main()->backgroundParams(fill, to, from);
to.moveTop(to.top() + fromy);
p.drawPixmap(to, *cChatBackground(), from);
if (!smooth) p.setRenderHint(QPainter::SmoothPixmapTransform, false);
} else {
p.drawPixmap(x, fromy + y, cached);
}
}
}
@@ -1772,6 +1788,10 @@ void OverviewWidget::fillSelectedItems(SelectedItemSet &sel, bool forDelete) {
_inner.fillSelectedItems(sel, forDelete);
}
void OverviewWidget::updateScrollColors() {
_scroll.updateColors(App::historyScrollBarColor(), App::historyScrollBgColor(), App::historyScrollBarOverColor(), App::historyScrollBgOverColor());
}
OverviewWidget::~OverviewWidget() {
onClearSelected();
updateTopBarSelection();