Skip to content

Commit

Permalink
added media overview to linux version, fixed scroll, smooth photos ov…
Browse files Browse the repository at this point in the history
…erview thumbs
  • Loading branch information
john-preston committed Aug 15, 2014
1 parent a472823 commit 5ebe005
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Telegram/SourceFiles/overviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ QPixmap OverviewInner::genPix(PhotoData *photo, int32 size) {
size *= cIntRetinaFactor();
QImage img = (photo->full->loaded() ? photo->full : (photo->medium->loaded() ? photo->medium : photo->thumb))->pix().toImage();
if (img.width() > img.height()) {
img = img.scaled(img.width() * size / img.height(), size, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation);
img = img.scaled(img.width() * size / img.height(), size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
} else {
img = img.scaled(size, img.height() * size / img.width(), Qt::KeepAspectRatioByExpanding, Qt::FastTransformation);
img = img.scaled(size, img.height() * size / img.width(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
}
img.setDevicePixelRatio(cRetinaFactor());
photo->forget();
Expand Down Expand Up @@ -377,14 +377,17 @@ void OverviewInner::contextMenuEvent(QContextMenuEvent *e) {
int32 OverviewInner::resizeToWidth(int32 nwidth, int32 scrollTop, int32 minHeight) {
if (width() == nwidth && minHeight == _minHeight) return scrollTop;
_minHeight = minHeight;
if (_resizeIndex < 0) {
if (_type == OverviewPhotos && _resizeIndex < 0) {
_resizeIndex = _photosInRow * (scrollTop / int32(_vsize + st::overviewPhotoSkip));
_resizeSkip = scrollTop - (scrollTop / int32(_vsize + st::overviewPhotoSkip)) * int32(_vsize + st::overviewPhotoSkip);
}
resize(nwidth, height() > _minHeight ? height() : _minHeight);
showAll();
int32 newRow = _resizeIndex / _photosInRow;
return newRow * int32(_vsize + st::overviewPhotoSkip) + _resizeSkip;
if (_type == OverviewPhotos) {
int32 newRow = _resizeIndex / _photosInRow;
return newRow * int32(_vsize + st::overviewPhotoSkip) + _resizeSkip;
}
return scrollTop;
}

void OverviewInner::dropResizeIndex() {
Expand Down Expand Up @@ -674,7 +677,10 @@ void OverviewWidget::paintEvent(QPaintEvent *e) {
}

void OverviewWidget::scrollBy(int32 add) {
bool wasHidden = _scroll.isHidden();
if (wasHidden) _scroll.show();
_scroll.scrollToY(_scroll.scrollTop() + add);
if (wasHidden) _scroll.hide();
}

void OverviewWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) {
Expand Down
2 changes: 2 additions & 0 deletions Telegram/Telegram.pro
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ SOURCES += \
./SourceFiles/langloaderplain.cpp \
./SourceFiles/layerwidget.cpp \
./SourceFiles/mediaview.cpp \
./SourceFiles/overviewwidget.cpp \
./SourceFiles/profilewidget.cpp \
./SourceFiles/localimageloader.cpp \
./SourceFiles/logs.cpp \
Expand Down Expand Up @@ -158,6 +159,7 @@ HEADERS += \
./SourceFiles/langloaderplain.h \
./SourceFiles/layerwidget.h \
./SourceFiles/mediaview.h \
./SourceFiles/overviewwidget.h \
./SourceFiles/profilewidget.h \
./SourceFiles/localimageloader.h \
./SourceFiles/logs.h \
Expand Down

0 comments on commit 5ebe005

Please sign in to comment.