some photo viewer fixes

This commit is contained in:
John Preston 2014-08-17 11:37:24 +04:00
parent 0a69ed37da
commit c6423c0b65
4 changed files with 17 additions and 10 deletions

View file

@ -88,8 +88,6 @@ void HistoryList::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
if (!trivial) { if (!trivial) {
p.setClipRect(r); p.setClipRect(r);
} else {
bool nt = true;
} }
if (hist->isEmpty()) { if (hist->isEmpty()) {

View file

@ -25,7 +25,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "gui/filedialog.h" #include "gui/filedialog.h"
MediaView::MediaView() : QWidget(App::wnd()), MediaView::MediaView() : QWidget(App::wnd()),
_photo(0), _leftNavVisible(false), _rightNavVisible(false), _maxWidth(0), _maxHeight(0), _x(0), _y(0), _w(0), _full(false), _photo(0), _leftNavVisible(false), _rightNavVisible(false), _maxWidth(0), _maxHeight(0), _x(0), _y(0), _w(0), _full(-1),
_history(0), _peer(0), _user(0), _from(0), _index(-1), _msgid(0), _loadRequest(0), _over(OverNone), _down(OverNone), _lastAction(-st::medviewDeltaFromLastAction, -st::medviewDeltaFromLastAction), _history(0), _peer(0), _user(0), _from(0), _index(-1), _msgid(0), _loadRequest(0), _over(OverNone), _down(OverNone), _lastAction(-st::medviewDeltaFromLastAction, -st::medviewDeltaFromLastAction),
_close(this, lang(lng_mediaview_close), st::medviewButton), _close(this, lang(lng_mediaview_close), st::medviewButton),
_save(this, lang(lng_mediaview_save), st::medviewButton), _save(this, lang(lng_mediaview_save), st::medviewButton),
@ -299,7 +299,7 @@ void MediaView::showPhoto(PhotoData *photo) {
_photo = photo; _photo = photo;
MTP::clearLoaderPriorities(); MTP::clearLoaderPriorities();
_photo->full->load(); _photo->full->load();
_full = false; _full = -1;
_current = QPixmap(); _current = QPixmap();
_w = photo->full->width(); _w = photo->full->width();
_down = OverNone; _down = OverNone;
@ -309,6 +309,9 @@ void MediaView::showPhoto(PhotoData *photo) {
case dbisOneAndHalf: _w = qRound(float64(_w) * 1.5 - 0.01); h = qRound(float64(h) * 1.5 - 0.01); break; case dbisOneAndHalf: _w = qRound(float64(_w) * 1.5 - 0.01); h = qRound(float64(h) * 1.5 - 0.01); break;
case dbisTwo: _w *= 2; h *= 2; break; case dbisTwo: _w *= 2; h *= 2; break;
} }
if (isHidden()) {
moveToScreen();
}
if (_w > _maxWidth) { if (_w > _maxWidth) {
h = qRound(h * _maxWidth / float64(_w)); h = qRound(h * _maxWidth / float64(_w));
_w = _maxWidth; _w = _maxWidth;
@ -322,7 +325,6 @@ void MediaView::showPhoto(PhotoData *photo) {
_from = App::user(_photo->user); _from = App::user(_photo->user);
updateControls(); updateControls();
if (isHidden()) { if (isHidden()) {
moveToScreen();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
bool wm = testAttribute(Qt::WA_Mapped), wv = testAttribute(Qt::WA_WState_Visible); bool wm = testAttribute(Qt::WA_Mapped), wv = testAttribute(Qt::WA_WState_Visible);
if (!wm) setAttribute(Qt::WA_Mapped, true); if (!wm) setAttribute(Qt::WA_Mapped, true);
@ -415,11 +417,17 @@ void MediaView::paintEvent(QPaintEvent *e) {
// photo // photo
p.setOpacity(1); p.setOpacity(1);
if (!_full && _photo->full->loaded()) { if (_full <= 0 && _photo->full->loaded()) {
_current = _photo->full->pixNoCache(_w, 0, true); _current = _photo->full->pixNoCache(_w * cIntRetinaFactor(), 0, true);
_full = true; if (cRetina()) _current.setDevicePixelRatio(cRetinaFactor());
_full = 1;
} else if (_full < 0 && _photo->medium->loaded()) {
_current = _photo->medium->pixBlurredNoCache(_w * cIntRetinaFactor());
if (cRetina()) _current.setDevicePixelRatio(cRetinaFactor());
_full = 0;
} else if (_current.isNull() && _photo->thumb->loaded()) { } else if (_current.isNull() && _photo->thumb->loaded()) {
_current = _photo->thumb->pixBlurredNoCache(_w); _current = _photo->thumb->pixBlurredNoCache(_w * cIntRetinaFactor());
if (cRetina()) _current.setDevicePixelRatio(cRetinaFactor());
} }
if (QRect(_x, _y, _current.width() / cIntRetinaFactor(), _current.height() / cIntRetinaFactor()).intersects(r)) { if (QRect(_x, _y, _current.width() / cIntRetinaFactor(), _current.height() / cIntRetinaFactor()).intersects(r)) {
p.drawPixmap(_x, _y, _current); p.drawPixmap(_x, _y, _current);

View file

@ -84,7 +84,7 @@ private:
int32 _maxWidth, _maxHeight, _x, _y, _w; int32 _maxWidth, _maxHeight, _x, _y, _w;
QPixmap _current; QPixmap _current;
bool _full; int32 _full; // -1 - thumb, 0 - medium, 1 - full
History *_history; // if conversation photos overview History *_history; // if conversation photos overview
PeerData *_peer; PeerData *_peer;

View file

@ -733,6 +733,7 @@ int32 OverviewWidget::lastScrollTop() const {
void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTopBarCache, bool back, int32 lastScrollTop) { void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTopBarCache, bool back, int32 lastScrollTop) {
_bgAnimCache = bgAnimCache; _bgAnimCache = bgAnimCache;
_bgAnimTopBarCache = bgAnimTopBarCache; _bgAnimTopBarCache = bgAnimTopBarCache;
resizeEvent(0);
_scroll.scrollToY(lastScrollTop < 0 ? (type() == OverviewPhotos ? 0 : _scroll.scrollTopMax()) : lastScrollTop); _scroll.scrollToY(lastScrollTop < 0 ? (type() == OverviewPhotos ? 0 : _scroll.scrollTopMax()) : lastScrollTop);
_animCache = myGrab(this, rect()); _animCache = myGrab(this, rect());
App::main()->topBar()->stopAnim(); App::main()->topBar()->stopAnim();