started media redesign (does not compile!)
This commit is contained in:
parent
0b96dd5362
commit
6bad3b4d7e
|
@ -664,6 +664,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
|||
"lng_save_file" = "Save file";
|
||||
"lng_save_downloaded" = "{ready} / {total} {mb}";
|
||||
"lng_duration_and_size" = "{duration}, {size}";
|
||||
"lng_duration_played" = "{played} / {duration}";
|
||||
"lng_choose_images" = "Choose images";
|
||||
|
||||
"lng_context_view_profile" = "View profile";
|
||||
|
|
|
@ -1165,8 +1165,6 @@ introErrLabelTextStyle: textStyle(defaultTextStyle) {
|
|||
lineHeight: 27px;
|
||||
}
|
||||
|
||||
mediaMaxWidth: 250px;
|
||||
mediaFont: font(fsize);
|
||||
mediaPadding: margins(7px, 6px, 7px, 6px);
|
||||
mediaThumbSize: 48px;
|
||||
mediaNameTop: 3px;
|
||||
|
@ -1191,26 +1189,13 @@ mediaInUnreadColor: #999;
|
|||
mediaInUnreadSelectColor: #7b95aa;
|
||||
mediaUnreadSize: 4px;
|
||||
mediaUnreadSkip: 5px;
|
||||
mediaSaveDelta: 14px; // between bubble and download
|
||||
mediaSaveButton: flatButton(btnDefFlat) {
|
||||
color: #507da2;
|
||||
overColor: #507da2;
|
||||
downColor: #507da2;
|
||||
|
||||
bgColor: white;
|
||||
overBgColor: overBg;
|
||||
downBgColor: overBg;
|
||||
|
||||
width: -28px;
|
||||
height: 34px;
|
||||
|
||||
textTop: 7px;
|
||||
overTextTop: 7px;
|
||||
downTextTop: 8px;
|
||||
|
||||
font: font(fsize);
|
||||
overFont: font(fsize);
|
||||
}
|
||||
msgFileMenuSize: size(36px, 36px);
|
||||
msgFileSize: 44px;
|
||||
msgFilePadding: margins(14px, 12px, 10px, 12px);
|
||||
msgFileThumbSize: 72px;
|
||||
msgFileThumbPadding: margins(10px, 10px, 14px, 10px);
|
||||
msgFileMinWidth: 294px;
|
||||
|
||||
sendPadding: 9px;
|
||||
btnSend: flatButton(btnDefFlat) {
|
||||
|
|
|
@ -148,7 +148,7 @@ void StickerSetInner::paintEvent(QPaintEvent *e) {
|
|||
doc->thumb->load();
|
||||
} else {
|
||||
bool already = !doc->already().isEmpty(), hasdata = !doc->data.isEmpty();
|
||||
if (!doc->loader && doc->status != FileFailed && !already && !hasdata) {
|
||||
if (!already && !hasdata && !doc->loader && doc->status == FileReady) {
|
||||
doc->save(QString());
|
||||
}
|
||||
if (doc->sticker()->img->isNull() && (already || hasdata)) {
|
||||
|
|
|
@ -1332,7 +1332,7 @@ void StickerPanInner::paintEvent(QPaintEvent *e) {
|
|||
sticker->thumb->load();
|
||||
} else {
|
||||
bool already = !sticker->already().isEmpty(), hasdata = !sticker->data.isEmpty();
|
||||
if (!sticker->loader && sticker->status != FileFailed && !already && !hasdata) {
|
||||
if (!already && !hasdata && !sticker->loader && sticker->status == FileReady) {
|
||||
sticker->save(QString());
|
||||
}
|
||||
if (sticker->sticker()->img->isNull() && (already || hasdata)) {
|
||||
|
@ -1521,7 +1521,7 @@ void StickerPanInner::preloadImages() {
|
|||
sticker->thumb->load();
|
||||
} else {
|
||||
bool already = !sticker->already().isEmpty(), hasdata = !sticker->data.isEmpty();
|
||||
if (!sticker->loader && sticker->status != FileFailed && !already && !hasdata) {
|
||||
if (!already && !hasdata && !sticker->loader && sticker->status == FileReady) {
|
||||
sticker->save(QString());
|
||||
}
|
||||
//if (sticker->sticker->img->isNull() && (already || hasdata)) {
|
||||
|
|
|
@ -83,13 +83,13 @@ void FileUploader::currentFailed() {
|
|||
} else if (j->type() == PrepareDocument) {
|
||||
DocumentData *doc = App::document(j->id());
|
||||
if (doc->status == FileUploading) {
|
||||
doc->status = FileFailed;
|
||||
doc->status = FileUploadFailed;
|
||||
}
|
||||
emit documentFailed(j.key());
|
||||
} else if (j->type() == PrepareAudio) {
|
||||
AudioData *audio = App::audio(j->id());
|
||||
if (audio->status == FileUploading) {
|
||||
audio->status = FileFailed;
|
||||
audio->status = FileUploadFailed;
|
||||
}
|
||||
emit audioFailed(j.key());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -108,6 +108,7 @@ enum HistoryMediaType {
|
|||
MediaTypeContact,
|
||||
MediaTypeAudio,
|
||||
MediaTypeDocument,
|
||||
MediaTypeGif,
|
||||
MediaTypeSticker,
|
||||
MediaTypeImageLink,
|
||||
MediaTypeWebPage,
|
||||
|
@ -131,6 +132,7 @@ inline MediaOverviewType mediaToOverviewType(HistoryMediaType t) {
|
|||
case MediaTypePhoto: return OverviewPhotos;
|
||||
case MediaTypeVideo: return OverviewVideos;
|
||||
case MediaTypeDocument: return OverviewDocuments;
|
||||
case MediaTypeGif: return OverviewDocuments;
|
||||
// case MediaTypeSticker: return OverviewDocuments;
|
||||
case MediaTypeAudio: return OverviewAudios;
|
||||
}
|
||||
|
@ -1163,6 +1165,8 @@ public:
|
|||
virtual QString getCaption() const {
|
||||
return QString();
|
||||
}
|
||||
virtual bool needsBubble(const HistoryItem *parent) const = 0;
|
||||
virtual bool customTime() const = 0;
|
||||
|
||||
int32 currentWidth() const {
|
||||
return qMin(w, _maxw);
|
||||
|
@ -1217,6 +1221,12 @@ public:
|
|||
QString getCaption() const {
|
||||
return _caption.original();
|
||||
}
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return !_caption.isEmpty() || parent->toHistoryReply();
|
||||
}
|
||||
bool customTime() const {
|
||||
return _caption.isEmpty();
|
||||
}
|
||||
|
||||
private:
|
||||
int16 pixw, pixh;
|
||||
|
@ -1259,6 +1269,13 @@ public:
|
|||
}
|
||||
ImagePtr replyPreview();
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return !_caption.isEmpty() || parent->toHistoryReply();
|
||||
}
|
||||
bool customTime() const {
|
||||
return _caption.isEmpty();
|
||||
}
|
||||
|
||||
private:
|
||||
VideoData *data;
|
||||
TextLinkPtr _openl, _savel, _cancell;
|
||||
|
@ -1300,6 +1317,13 @@ public:
|
|||
|
||||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return true;
|
||||
}
|
||||
bool customTime() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
AudioData *data;
|
||||
TextLinkPtr _openl, _savel, _cancell;
|
||||
|
@ -1316,6 +1340,10 @@ public:
|
|||
HistoryDocument(DocumentData *document);
|
||||
void initDimensions(const HistoryItem *parent);
|
||||
|
||||
bool withThumb() const {
|
||||
return !_data->song() && !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height();
|
||||
}
|
||||
|
||||
void draw(Painter &p, const HistoryItem *parent, bool selected, int32 width = -1) const;
|
||||
int32 resize(int32 width, const HistoryItem *parent);
|
||||
HistoryMediaType type() const {
|
||||
|
@ -1326,13 +1354,13 @@ public:
|
|||
bool hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||
int32 countHeight(const HistoryItem *parent, int32 width = -1) const;
|
||||
bool uploading() const {
|
||||
return (data->status == FileUploading);
|
||||
return (_data->status == FileUploading);
|
||||
}
|
||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||
HistoryMedia *clone() const;
|
||||
|
||||
DocumentData *document() {
|
||||
return data;
|
||||
return _data;
|
||||
}
|
||||
|
||||
void regItem(HistoryItem *item);
|
||||
|
@ -1341,24 +1369,95 @@ public:
|
|||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
bool hasReplyPreview() const {
|
||||
return !data->thumb->isNull();
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview();
|
||||
|
||||
void drawInPlaylist(Painter &p, const HistoryItem *parent, bool selected, bool over, int32 width) const;
|
||||
TextLinkPtr linkInPlaylist();
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return true;
|
||||
}
|
||||
bool customTime() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
DocumentData *data;
|
||||
DocumentData *_data;
|
||||
TextLinkPtr _openl, _savel, _cancell;
|
||||
|
||||
int32 _namew;
|
||||
QString _name;
|
||||
int32 _thumbw, _thumbx, _thumby;
|
||||
|
||||
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
||||
// < 0 will contain played string, _statusSize = seconds played
|
||||
// 0x7FFFFF0 will contain status for not yet downloaded file
|
||||
// 0x7FFFFF1 will contain status for already downloaded file
|
||||
// 0x7FFFFF2 will contain status for failed to download / upload file
|
||||
mutable int32 _statusSize;
|
||||
mutable QString _statusText;
|
||||
};
|
||||
|
||||
class HistoryGif : public HistoryMedia {
|
||||
public:
|
||||
|
||||
HistoryGif(DocumentData *document);
|
||||
void initDimensions(const HistoryItem *parent);
|
||||
|
||||
void draw(Painter &p, const HistoryItem *parent, bool selected, int32 width = -1) const;
|
||||
int32 resize(int32 width, const HistoryItem *parent);
|
||||
HistoryMediaType type() const {
|
||||
return MediaTypeGif;
|
||||
}
|
||||
const QString inDialogsText() const;
|
||||
const QString inHistoryText() const;
|
||||
bool hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||
int32 countHeight(const HistoryItem *parent, int32 width = -1) const;
|
||||
bool uploading() const {
|
||||
return (_data->status == FileUploading);
|
||||
}
|
||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||
HistoryMedia *clone() const;
|
||||
|
||||
DocumentData *document() {
|
||||
return _data;
|
||||
}
|
||||
|
||||
void regItem(HistoryItem *item);
|
||||
void unregItem(HistoryItem *item);
|
||||
|
||||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
bool hasReplyPreview() const {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview();
|
||||
|
||||
void drawInPlaylist(Painter &p, const HistoryItem *parent, bool selected, bool over, int32 width) const;
|
||||
TextLinkPtr linkInPlaylist();
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return parent->toHistoryReply();
|
||||
}
|
||||
bool customTime() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
DocumentData *_data;
|
||||
TextLinkPtr _openl, _savel, _cancell;
|
||||
|
||||
int32 _namew;
|
||||
QString _name, _size;
|
||||
int32 _thumbw, _thumbx, _thumby;
|
||||
|
||||
mutable QString _dldTextCache, _uplTextCache;
|
||||
mutable int32 _dldDone, _uplDone;
|
||||
mutable QString _statusText;
|
||||
mutable int32 _statusSize; // -1 will contain just size string, -2 will contain "failed" language key
|
||||
|
||||
};
|
||||
|
||||
class HistorySticker : public HistoryMedia {
|
||||
|
@ -1388,6 +1487,13 @@ public:
|
|||
|
||||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return false;
|
||||
}
|
||||
bool customTime() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int16 pixw, pixh;
|
||||
|
@ -1416,6 +1522,13 @@ public:
|
|||
|
||||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return true;
|
||||
}
|
||||
bool customTime() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
int32 userId;
|
||||
int32 phonew;
|
||||
|
@ -1461,6 +1574,13 @@ public:
|
|||
return data;
|
||||
}
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return true;
|
||||
}
|
||||
bool customTime() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
WebPageData *data;
|
||||
TextLinkPtr _openl, _attachl;
|
||||
|
@ -1552,6 +1672,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool needsBubble(const HistoryItem *parent) const {
|
||||
return !_title.isEmpty() || !_description.isEmpty() || parent->toHistoryReply();
|
||||
}
|
||||
bool customTime() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
ImageLinkData *data;
|
||||
Text _title, _description;
|
||||
|
@ -1574,9 +1701,11 @@ public:
|
|||
void fromNameUpdated() const;
|
||||
|
||||
bool justMedia() const {
|
||||
return _media && _text.isEmpty();
|
||||
return _text.isEmpty();
|
||||
}
|
||||
bool drawBubble() const {
|
||||
return _media ? (!justMedia() || _media->needsBubble(this)) : true;
|
||||
}
|
||||
|
||||
bool uploading() const;
|
||||
|
||||
void drawInfo(Painter &p, int32 right, int32 bottom, bool selected, InfoDisplayType type) const;
|
||||
|
|
|
@ -5449,7 +5449,18 @@ void HistoryWidget::onPhotoProgress(const FullMsgId &newId) {
|
|||
void HistoryWidget::onDocumentProgress(const FullMsgId &newId) {
|
||||
if (!MTP::authedId()) return;
|
||||
if (HistoryItem *item = App::histItemById(newId)) {
|
||||
DocumentData *doc = (item->getMedia() && item->getMedia()->type() == MediaTypeDocument) ? static_cast<HistoryDocument*>(item->getMedia())->document() : 0;
|
||||
HistoryMedia *media = item->getMedia();
|
||||
DocumentData *doc = 0;
|
||||
if (media) {
|
||||
HistoryMediaType type = media->type();
|
||||
if (type == MediaTypeDocument) {
|
||||
doc = static_cast<HistoryDocument*>(item->getMedia())->document();
|
||||
} else if (type == MediaTypeGif) {
|
||||
doc = static_cast<HistoryGif*>(item->getMedia())->document();
|
||||
} else if (type == MediaTypeSticker) {
|
||||
doc = static_cast<HistorySticker*>(item->getMedia())->document();
|
||||
}
|
||||
}
|
||||
if (!item->fromChannel()) {
|
||||
updateSendAction(item->history(), SendActionUploadFile, doc ? doc->uploadOffset : 0);
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ QSize StickerPreviewWidget::currentDimensions() const {
|
|||
QPixmap StickerPreviewWidget::currentImage() const {
|
||||
if (_doc && _cacheStatus != CacheLoaded) {
|
||||
bool already = !_doc->already().isEmpty(), hasdata = !_doc->data.isEmpty();
|
||||
if (!_doc->loader && _doc->status != FileFailed && !already && !hasdata) {
|
||||
if (!already && !hasdata && !_doc->loader && _doc->status == FileReady) {
|
||||
_doc->save(QString());
|
||||
}
|
||||
if (_doc->sticker()->img->isNull() && (already || hasdata)) {
|
||||
|
|
|
@ -1654,7 +1654,10 @@ void MainWidget::onDownloadPathSettings() {
|
|||
void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) {
|
||||
loadFailed(loader, started, SLOT(videoLoadRetry()));
|
||||
VideoData *video = App::video(loader->objId());
|
||||
if (video && video->loader) video->finish();
|
||||
if (video) {
|
||||
if (video->loader) video->finish();
|
||||
video->status = FileDownloadFailed;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::videoLoadRetry() {
|
||||
|
@ -1811,7 +1814,7 @@ void MainWidget::audioLoadFailed(mtpFileLoader *loader, bool started) {
|
|||
loadFailed(loader, started, SLOT(audioLoadRetry()));
|
||||
AudioData *audio = App::audio(loader->objId());
|
||||
if (audio) {
|
||||
audio->status = FileFailed;
|
||||
audio->status = FileDownloadFailed;
|
||||
if (audio->loader) audio->finish();
|
||||
}
|
||||
}
|
||||
|
@ -1907,7 +1910,7 @@ void MainWidget::documentLoadFailed(mtpFileLoader *loader, bool started) {
|
|||
DocumentData *document = App::document(loader->objId());
|
||||
if (document) {
|
||||
if (document->loader) document->finish();
|
||||
document->status = FileFailed;
|
||||
document->status = FileDownloadFailed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -435,7 +435,7 @@ void MediaView::step_state(uint64 ms, bool timer) {
|
|||
if (dt < 1) result = true;
|
||||
}
|
||||
if (_doc && _docRadialStart > 0) {
|
||||
float64 prg = _doc->loader ? qMax(_doc->loader->currentProgress(), 0.0001) : (_doc->status == FileFailed ? 0 : (_doc->already().isEmpty() ? 0 : 1));
|
||||
float64 prg = _doc->loader ? qMax(_doc->loader->currentProgress(), 0.0001) : (_doc->status == FileDownloadFailed ? 0 : (_doc->already().isEmpty() ? 0 : 1));
|
||||
if (prg != a_docRadial.to()) {
|
||||
a_docRadial.start(prg);
|
||||
_docRadialStart = _docRadialLast;
|
||||
|
@ -1514,6 +1514,7 @@ void MediaView::moveToNext(int32 delta) {
|
|||
switch (item->getMedia()->type()) {
|
||||
case MediaTypePhoto: displayPhoto(static_cast<HistoryPhoto*>(item->getMedia())->photo(), item); preloadData(delta); break;
|
||||
case MediaTypeDocument: displayDocument(static_cast<HistoryDocument*>(item->getMedia())->document(), item); preloadData(delta); break;
|
||||
case MediaTypeGif: displayDocument(static_cast<HistoryGif*>(item->getMedia())->document(), item); preloadData(delta); break;
|
||||
case MediaTypeSticker: displayDocument(static_cast<HistorySticker*>(item->getMedia())->document(), item); preloadData(delta); break;
|
||||
}
|
||||
} else {
|
||||
|
@ -1561,6 +1562,7 @@ void MediaView::preloadData(int32 delta) {
|
|||
switch (media->type()) {
|
||||
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->full->load(); break;
|
||||
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->document()->thumb->load(); break;
|
||||
case MediaTypeGif: static_cast<HistoryGif*>(media)->document()->thumb->load(); break;
|
||||
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->sticker()->img->load(); break;
|
||||
}
|
||||
}
|
||||
|
@ -1584,6 +1586,7 @@ void MediaView::preloadData(int32 delta) {
|
|||
switch (media->type()) {
|
||||
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->forget(); break;
|
||||
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->document()->forget(); break;
|
||||
case MediaTypeGif: static_cast<HistoryGif*>(media)->document()->forget(); break;
|
||||
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->forget(); break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -784,7 +784,8 @@ private:
|
|||
};
|
||||
|
||||
enum FileStatus {
|
||||
FileFailed = -1,
|
||||
FileDownloadFailed = -2,
|
||||
FileUploadFailed = -1,
|
||||
FileUploading = 0,
|
||||
FileReady = 1,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue