This commit is contained in:
John Preston 2015-05-21 16:52:23 +03:00
commit 962ec1e454
12 changed files with 82 additions and 49 deletions

View File

@ -1,9 +1,9 @@
@echo OFF
set "AppVersion=8016"
set "AppVersionStrSmall=0.8.16"
set "AppVersionStr=0.8.16"
set "AppVersionStrFull=0.8.16.0"
set "AppVersionStrSmall=0.8.17"
set "AppVersionStr=0.8.17"
set "AppVersionStrFull=0.8.17.0"
set "DevChannel=0"
if %DevChannel% neq 0 goto preparedev

View File

@ -666,6 +666,8 @@ void Application::checkMapVersion() {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Video captions are displayed\n\xe2\x80\x94 Photo captions are displayed in photo viewer\n\xe2\x80\x94 Round corners for messages").replace('@', qsl("@") + QChar(0x200D));
} else if (!DevChannel && Local::oldMapVersion() < 8016) {
versionFeatures = lang(lng_new_version_text).trimmed();
} else if (!DevChannel && Local::oldMapVersion() < 8017) {
versionFeatures = lang(lng_new_version_minor).trimmed();
}
if (!versionFeatures.isEmpty()) {
versionFeatures = lng_new_version_wrap(lt_version, QString::fromStdWString(AppVersionStr), lt_changes, versionFeatures, lt_link, qsl("https://desktop.telegram.org/#changelog"));

View File

@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
*/
#pragma once
static const int32 AppVersion = 8016;
static const wchar_t *AppVersionStr = L"0.8.16";
static const int32 AppVersion = 8017;
static const wchar_t *AppVersionStr = L"0.8.17";
static const bool DevChannel = false;
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";

View File

@ -104,26 +104,29 @@ namespace anim {
bool AnimatedGif::animStep(float64 ms) {
int32 f = frame;
while (f < frames.size() && ms > delays[f]) {
while (f < images.size() && ms > delays[f]) {
++f;
if (f == frames.size() && frames.size() < framesCount) {
if (f == images.size() && images.size() < framesCount) {
if (reader->read(&img)) {
int64 d = reader->nextImageDelay(), delay = delays[f - 1];
if (!d) d = 1;
delay += d;
frames.push_back(QPixmap::fromImage(img.size() == QSize(w, h) ? img : img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly));
if (img.size() != QSize(w, h)) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
images.push_back(img);
frames.push_back(QPixmap());
delays.push_back(delay);
for (int32 i = 0; i < frames.size(); ++i) {
if (!frames[i].isNull()) {
for (int32 i = 0; i < images.size(); ++i) {
if (!images[i].isNull() || !frames[i].isNull()) {
images[i] = QImage();
frames[i] = QPixmap();
break;
}
}
} else {
framesCount = frames.size();
framesCount = images.size();
}
}
if (f == frames.size()) {
if (f == images.size()) {
if (!duration) {
duration = delays.isEmpty() ? 1 : delays.back();
}
@ -132,14 +135,16 @@ bool AnimatedGif::animStep(float64 ms) {
for (int32 i = 0, s = delays.size() - 1; i <= s; ++i) {
delays[i] += duration;
}
if (frames[f].isNull()) {
if (images[f].isNull()) {
QString fname = reader->fileName();
delete reader;
reader = new QImageReader(fname);
}
}
if (frames[f].isNull() && reader->read(&img)) {
frames[f] = QPixmap::fromImage(img.size() == QSize(w, h) ? img : img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly);
if (images[f].isNull() && reader->read(&img)) {
if (img.size() != QSize(w, h)) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
images[f] = img;
frames[f] = QPixmap();
}
}
if (frame != f) {
@ -172,12 +177,15 @@ void AnimatedGif::start(HistoryItem *row, const QString &file) {
}
frames.reserve(framesCount);
images.reserve(framesCount);
delays.reserve(framesCount);
int32 sizeLeft = MediaViewImageSizeLimit, delay = 0;
for (bool read = reader->read(&img); read; read = reader->read(&img)) {
sizeLeft -= w * h * 4;
frames.push_back(QPixmap::fromImage(img.size() == s ? img : img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly));
if (img.size() != s) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
images.push_back(img);
frames.push_back(QPixmap());
int32 d = reader->nextImageDelay();
if (!d) d = 1;
delay += d;
@ -202,6 +210,7 @@ void AnimatedGif::stop(bool onItemRemoved) {
HistoryItem *row = msg;
msg = 0;
frames.clear();
images.clear();
delays.clear();
w = h = frame = framesCount = duration = 0;
@ -211,3 +220,16 @@ void AnimatedGif::stop(bool onItemRemoved) {
if (App::main()) App::main()->itemResized(row, true);
}
}
const QPixmap &AnimatedGif::current(int32 width, int32 height, bool rounded) {
if (!width) width = w;
if (!height) height = h;
if ((frames[frame].isNull() || frames[frame].width() != width || frames[frame].height() != height) && !images[frame].isNull()) {
QImage img = images[frame];
if (img.width() != width || img.height() != height) img = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (rounded) imageRound(img);
frames[frame] = QPixmap::fromImage(img, Qt::ColorOnly);
frames[frame].setDevicePixelRatio(cRetinaFactor());
}
return frames[frame];
}

View File

@ -348,6 +348,8 @@ public:
stop(true);
}
const QPixmap &current(int32 width = 0, int32 height = 0, bool rounded = false);
signals:
void updated();
@ -357,7 +359,12 @@ public:
HistoryItem *msg;
QImage img;
QImageReader *reader;
int32 w, h, frame;
private:
QVector<QPixmap> frames;
QVector<QImage> images;
QVector<int64> delays;
int32 w, h, frame, framesCount, duration;
int32 framesCount, duration;
};

View File

@ -2650,21 +2650,25 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, bool selected
bool out = parent->out(), hovered, pressed;
if (parent == animated.msg) {
if (width >= animated.w) {
p.drawPixmap(0, 0, animated.frames[animated.frame]);
if (selected) {
p.fillRect(0, 0, animated.w, animated.h, textstyleCurrent()->selectOverlay->b);
}
} else {
bool s = p.renderHints().testFlag(QPainter::SmoothPixmapTransform);
if (!s) p.setRenderHint(QPainter::SmoothPixmapTransform);
int32 h = (width == w) ? _height : (width * animated.h / animated.w);
if (h < 1) h = 1;
p.drawPixmap(QRect(0, 0, width, h), animated.frames[animated.frame]);
if (!s) p.setRenderHint(QPainter::SmoothPixmapTransform, false);
if (selected) {
p.fillRect(0, 0, width, h, textstyleCurrent()->selectOverlay->b);
}
int32 pw = animated.w, ph = animated.h;
if (width < pw) {
pw = width;
ph = (pw == w) ? _height : (pw * animated.h / animated.w);
if (ph < 1) ph = 1;
}
QPixmap **cors = App::corners(selected ? InSelectedShadowCorners : InShadowCorners);
int32 cw = cors[0]->width() / cIntRetinaFactor(), ch = cors[0]->height() / cIntRetinaFactor();
style::color shadow(selected ? st::msgInSelectShadow : st::msgInShadow);
p.fillRect(cw, ph, pw - 2 * cw, st::msgShadow, shadow->b);
p.fillRect(0, ph - ch, cw, st::msgShadow, shadow->b);
p.fillRect(pw - cw, ph - ch, cw, st::msgShadow, shadow->b);
p.drawPixmap(0, ph - ch + st::msgShadow, *cors[2]);
p.drawPixmap(pw - cw, ph - ch + st::msgShadow, *cors[3]);
p.drawPixmap(0, 0, animated.current(pw, ph, true));
if (selected) {
App::roundRect(p, 0, 0, pw, ph, textstyleCurrent()->selectOverlay, SelectedOverlayCorners);
}
return;
}

View File

@ -701,7 +701,7 @@ void HistoryList::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
_menu->addAction(lang(lng_context_reply_msg), historyWidget, SLOT(onReplyToMessage()));
}
if (item && !isUponSelected && !_contextMenuLnk) {
if (HistorySticker *sticker = dynamic_cast<HistorySticker*>(msg->getMedia())) {
if (HistorySticker *sticker = dynamic_cast<HistorySticker*>(msg ? msg->getMedia() : 0)) {
DocumentData *doc = sticker->document();
if (doc && doc->sticker && doc->sticker->set.type() != mtpc_inputStickerSetEmpty) {
if (!_menu) _menu = new ContextMenu(this);

View File

@ -183,7 +183,6 @@ void MediaView::documentUpdated(DocumentData *doc) {
}
void MediaView::onGifUpdated() {
_currentGif.frames[_currentGif.frame].setDevicePixelRatio(cRetinaFactor());
update(_x, _y, _w, _h);
}
@ -905,9 +904,8 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) {
_w = _current.width() / cIntRetinaFactor();
_h = _current.height() / cIntRetinaFactor();
} else {
_currentGif.frames[_currentGif.frame].setDevicePixelRatio(cRetinaFactor());
_w = _currentGif.frames[_currentGif.frame].width() / cIntRetinaFactor();
_h = _currentGif.frames[_currentGif.frame].height() / cIntRetinaFactor();
_w = _currentGif.w / cIntRetinaFactor();
_h = _currentGif.h / cIntRetinaFactor();
}
if (isHidden()) {
moveToScreen();
@ -1002,7 +1000,7 @@ void MediaView::paintEvent(QPaintEvent *e) {
p.setOpacity(1);
if (_photo || !_current.isNull() || !_currentGif.isNull()) {
QRect imgRect(_x, _y, _w, _h);
const QPixmap *toDraw = _currentGif.isNull() ? &_current : &_currentGif.frames[_currentGif.frame];
const QPixmap *toDraw = _currentGif.isNull() ? &_current : &_currentGif.current(_currentGif.w, _currentGif.h, false);
if (imgRect.intersects(r)) {
if (toDraw->hasAlpha() && (!_doc || !_doc->sticker || _doc->sticker->img->isNull())) {
p.fillRect(imgRect, _transparentBrush);
@ -1315,7 +1313,7 @@ void MediaView::keyPressEvent(QKeyEvent *e) {
newZoom = 0;
}
_x = -_width / 2;
_y = -(((_currentGif.isNull() ? _current.height() : _currentGif.frames[_currentGif.frame].height()) / cIntRetinaFactor()) / 2);
_y = -(((_currentGif.isNull() ? _current.height() : _currentGif.h) / cIntRetinaFactor()) / 2);
float64 z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
if (z >= 0) {
_x = qRound(_x * (z + 1));
@ -1335,8 +1333,8 @@ void MediaView::keyPressEvent(QKeyEvent *e) {
}
if (_zoom != newZoom) {
float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
_w = (_currentGif.isNull() ? _current.width() : _currentGif.frames[_currentGif.frame].width()) / cIntRetinaFactor();
_h = (_currentGif.isNull() ? _current.height() : _currentGif.frames[_currentGif.frame].height()) / cIntRetinaFactor();
_w = (_currentGif.isNull() ? _current.width() : _currentGif.w) / cIntRetinaFactor();
_h = (_currentGif.isNull() ? _current.height() : _currentGif.h) / cIntRetinaFactor();
if (z >= 0) {
nx = (_x - width() / 2.) / (z + 1);
ny = (_y - height() / 2.) / (z + 1);

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.16</string>
<string>0.8.17</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

Binary file not shown.

View File

@ -1693,7 +1693,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.16;
CURRENT_PROJECT_VERSION = 0.8.17;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
@ -1711,7 +1711,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.8.16;
CURRENT_PROJECT_VERSION = 0.8.17;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@ -1737,10 +1737,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.16;
CURRENT_PROJECT_VERSION = 0.8.17;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 0.8;
DYLIB_CURRENT_VERSION = 0.8.16;
DYLIB_CURRENT_VERSION = 0.8.17;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -1879,10 +1879,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.16;
CURRENT_PROJECT_VERSION = 0.8.17;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.8;
DYLIB_CURRENT_VERSION = 0.8.16;
DYLIB_CURRENT_VERSION = 0.8.17;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;

View File

@ -1,2 +1,2 @@
echo 8016 0.8.16 0
echo 8017 0.8.17 0
# AppVersion AppVersionStr DevChannel