mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
gif size decreased, error message added for gif errors, enable many gifs playing at the same time
This commit is contained in:
parent
fdb93f700d
commit
ae78d13284
8 changed files with 44 additions and 26 deletions
|
@ -108,6 +108,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
"lng_server_error" = "Internal server error.";
|
"lng_server_error" = "Internal server error.";
|
||||||
"lng_flood_error" = "Too many tries. Please try again later.";
|
"lng_flood_error" = "Too many tries. Please try again later.";
|
||||||
|
"lng_gif_error" = "An error has occured while reading GIF animation :(";
|
||||||
"lng_deleted" = "Unknown";
|
"lng_deleted" = "Unknown";
|
||||||
"lng_deleted_message" = "Deleted message";
|
"lng_deleted_message" = "Deleted message";
|
||||||
|
|
||||||
|
|
|
@ -2191,6 +2191,7 @@ mediaviewLoaderSkip: 9px;
|
||||||
minPhotoSize: 104px;
|
minPhotoSize: 104px;
|
||||||
maxMediaSize: 420px;
|
maxMediaSize: 420px;
|
||||||
maxStickerSize: 256px;
|
maxStickerSize: 256px;
|
||||||
|
maxGifSize: 256px;
|
||||||
|
|
||||||
downloadPathSkip: 10px;
|
downloadPathSkip: 10px;
|
||||||
|
|
||||||
|
|
|
@ -2444,7 +2444,7 @@ namespace App {
|
||||||
if (!::gifItems.isEmpty()) {
|
if (!::gifItems.isEmpty()) {
|
||||||
if (HistoryItem *playing = ::gifItems.begin().value()) {
|
if (HistoryItem *playing = ::gifItems.begin().value()) {
|
||||||
if (playing->getMedia() && playing->getMedia()->type() == MediaTypeGif) {
|
if (playing->getMedia() && playing->getMedia()->type() == MediaTypeGif) {
|
||||||
static_cast<HistoryGif*>(playing->getMedia())->stop(playing);
|
// static_cast<HistoryGif*>(playing->getMedia())->stop(playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ void Application::startUpdateCheck(bool forceWait) {
|
||||||
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
|
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
|
||||||
|
|
||||||
int32 constDelay = cBetaVersion() ? 600 : UpdateDelayConstPart, randDelay = cBetaVersion() ? 300 : UpdateDelayRandPart;
|
int32 constDelay = cBetaVersion() ? 600 : UpdateDelayConstPart, randDelay = cBetaVersion() ? 300 : UpdateDelayRandPart;
|
||||||
int32 updateInSecs = cLastUpdateCheck() + constDelay + (rand() % randDelay) - unixtime();
|
int32 updateInSecs = cLastUpdateCheck() + constDelay + int32(MTP::nonce<uint32>() % randDelay) - unixtime();
|
||||||
bool sendRequest = (updateInSecs <= 0 || updateInSecs > (constDelay + randDelay));
|
bool sendRequest = (updateInSecs <= 0 || updateInSecs > (constDelay + randDelay));
|
||||||
if (!sendRequest && !forceWait) {
|
if (!sendRequest && !forceWait) {
|
||||||
QDir updates(cWorkingDir() + "tupdates");
|
QDir updates(cWorkingDir() + "tupdates");
|
||||||
|
|
|
@ -51,7 +51,7 @@ void UpdateDownloader::initOutput() {
|
||||||
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
|
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
|
||||||
}
|
}
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
fileName = qsl("tupdate-%1").arg(rand());
|
fileName = qsl("tupdate-%1").arg(MTP::nonce<uint32>() % 1000000);
|
||||||
}
|
}
|
||||||
QString dirStr = cWorkingDir() + qsl("tupdates/");
|
QString dirStr = cWorkingDir() + qsl("tupdates/");
|
||||||
fileName = dirStr + fileName;
|
fileName = dirStr + fileName;
|
||||||
|
|
|
@ -79,7 +79,11 @@ namespace Ui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLayer(LayeredWidget *box, ShowLayerOptions options) {
|
void showLayer(LayeredWidget *box, ShowLayerOptions options) {
|
||||||
if (Window *w = App::wnd()) w->ui_showLayer(box, options);
|
if (Window *w = App::wnd()) {
|
||||||
|
w->ui_showLayer(box, options);
|
||||||
|
} else {
|
||||||
|
delete box;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideLayer(bool fast) {
|
void hideLayer(bool fast) {
|
||||||
|
|
|
@ -122,10 +122,12 @@ void AnimationManager::clipReinit(ClipReader *reader) {
|
||||||
const GifItems &items(App::gifItems());
|
const GifItems &items(App::gifItems());
|
||||||
GifItems::const_iterator it = items.constFind(reader);
|
GifItems::const_iterator it = items.constFind(reader);
|
||||||
if (it != items.cend()) {
|
if (it != items.cend()) {
|
||||||
it.value()->initDimensions();
|
HistoryItem *item = it.value();
|
||||||
if (App::main()) emit App::main()->itemResized(it.value(), true);
|
|
||||||
|
|
||||||
Notify::historyItemLayoutChanged(it.value());
|
item->initDimensions(); // can delete reader and items entry it
|
||||||
|
if (App::main()) emit App::main()->itemResized(item, true);
|
||||||
|
|
||||||
|
Notify::historyItemLayoutChanged(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +341,7 @@ ClipReader::ClipReader(const FileLocation &location, const QByteArray &data) : _
|
||||||
_clipManagers.push_back(new ClipReadManager(_clipThreads.back()));
|
_clipManagers.push_back(new ClipReadManager(_clipThreads.back()));
|
||||||
_clipThreads.back()->start();
|
_clipThreads.back()->start();
|
||||||
} else {
|
} else {
|
||||||
_threadIndex = rand() % _clipThreads.size();
|
_threadIndex = int32(MTP::nonce<uint32>() % _clipThreads.size());
|
||||||
int32 loadLevel = 0x7FFFFFFF;
|
int32 loadLevel = 0x7FFFFFFF;
|
||||||
for (int32 i = 0, l = _clipThreads.size(); i < l; ++i) {
|
for (int32 i = 0, l = _clipThreads.size(); i < l; ++i) {
|
||||||
int32 level = _clipManagers.at(i)->loadLevel();
|
int32 level = _clipManagers.at(i)->loadLevel();
|
||||||
|
@ -690,6 +692,8 @@ bool ClipReadManager::handleProcessResult(ClipReaderPrivate *reader, ClipProcess
|
||||||
if (result == ClipProcessError) {
|
if (result == ClipProcessError) {
|
||||||
if (it != _readerPointers.cend()) {
|
if (it != _readerPointers.cend()) {
|
||||||
it.key()->error();
|
it.key()->error();
|
||||||
|
emit reinit(it.key());
|
||||||
|
|
||||||
_readerPointers.erase(it);
|
_readerPointers.erase(it);
|
||||||
it = _readerPointers.end();
|
it = _readerPointers.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
#include "gui/filedialog.h"
|
#include "gui/filedialog.h"
|
||||||
|
|
||||||
#include "boxes/addcontactbox.h"
|
#include "boxes/addcontactbox.h"
|
||||||
|
#include "boxes/confirmbox.h"
|
||||||
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "localstorage.h"
|
#include "localstorage.h"
|
||||||
|
@ -4557,6 +4558,13 @@ HistoryGif::HistoryGif(DocumentData *document) : HistoryFileMedia()
|
||||||
void HistoryGif::initDimensions(const HistoryItem *parent) {
|
void HistoryGif::initDimensions(const HistoryItem *parent) {
|
||||||
bool bubble = parent->hasBubble();
|
bool bubble = parent->hasBubble();
|
||||||
int32 tw = 0, th = 0;
|
int32 tw = 0, th = 0;
|
||||||
|
if (_gif && _gif->state() == ClipError) {
|
||||||
|
Ui::showLayer(new InformBox(lang(lng_gif_error)));
|
||||||
|
App::unregGifItem(_gif);
|
||||||
|
delete _gif;
|
||||||
|
_gif = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (_gif && _gif->ready()) {
|
if (_gif && _gif->ready()) {
|
||||||
tw = convertScale(_gif->width());
|
tw = convertScale(_gif->width());
|
||||||
th = convertScale(_gif->height());
|
th = convertScale(_gif->height());
|
||||||
|
@ -4567,13 +4575,13 @@ void HistoryGif::initDimensions(const HistoryItem *parent) {
|
||||||
th = convertScale(_data->thumb->height());
|
th = convertScale(_data->thumb->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tw > st::maxMediaSize) {
|
if (tw > st::maxGifSize) {
|
||||||
th = (st::maxMediaSize * th) / tw;
|
th = (st::maxGifSize * th) / tw;
|
||||||
tw = st::maxMediaSize;
|
tw = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (th > st::maxMediaSize) {
|
if (th > st::maxGifSize) {
|
||||||
tw = (st::maxMediaSize * tw) / th;
|
tw = (st::maxGifSize * tw) / th;
|
||||||
th = st::maxMediaSize;
|
th = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (!tw || !th) {
|
if (!tw || !th) {
|
||||||
tw = th = 1;
|
tw = th = 1;
|
||||||
|
@ -4737,13 +4745,13 @@ int32 HistoryGif::resize(int32 width, const HistoryItem *parent) {
|
||||||
th = convertScale(_data->thumb->height());
|
th = convertScale(_data->thumb->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tw > st::maxMediaSize) {
|
if (tw > st::maxGifSize) {
|
||||||
th = (st::maxMediaSize * th) / tw;
|
th = (st::maxGifSize * th) / tw;
|
||||||
tw = st::maxMediaSize;
|
tw = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (th > st::maxMediaSize) {
|
if (th > st::maxGifSize) {
|
||||||
tw = (st::maxMediaSize * tw) / th;
|
tw = (st::maxGifSize * tw) / th;
|
||||||
th = st::maxMediaSize;
|
th = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (!tw || !th) {
|
if (!tw || !th) {
|
||||||
tw = th = 1;
|
tw = th = 1;
|
||||||
|
@ -4809,13 +4817,13 @@ int32 HistoryGif::countHeight(const HistoryItem *parent, int32 width) const {
|
||||||
th = convertScale(_data->thumb->height());
|
th = convertScale(_data->thumb->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tw > st::maxMediaSize) {
|
if (tw > st::maxGifSize) {
|
||||||
th = (st::maxMediaSize * th) / tw;
|
th = (st::maxGifSize * th) / tw;
|
||||||
tw = st::maxMediaSize;
|
tw = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (th > st::maxMediaSize) {
|
if (th > st::maxGifSize) {
|
||||||
tw = (st::maxMediaSize * tw) / th;
|
tw = (st::maxGifSize * tw) / th;
|
||||||
th = st::maxMediaSize;
|
th = st::maxGifSize;
|
||||||
}
|
}
|
||||||
if (!tw || !th) {
|
if (!tw || !th) {
|
||||||
tw = th = 1;
|
tw = th = 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue