| 1190 | } |
| 1191 | |
| 1192 | Document::Document( |
| 1193 | not_null<Delegate*> delegate, |
| 1194 | not_null<HistoryItem*> parent, |
| 1195 | DocumentFields fields, |
| 1196 | const style::OverviewFileLayout &st) |
| 1197 | : RadialProgressItem(delegate, parent) |
| 1198 | , _data(fields.document) |
| 1199 | , _msgl(parent->isHistoryEntry() |
| 1200 | ? JumpToMessageClickHandler(parent) |
| 1201 | : nullptr) |
| 1202 | , _namel(std::make_shared<DocumentOpenClickHandler>( |
| 1203 | _data, |
| 1204 | crl::guard(this, [=](FullMsgId id) { |
| 1205 | delegate->openDocument(_data, id); |
| 1206 | }), |
| 1207 | parent->fullId())) |
| 1208 | , _st(st) |
| 1209 | , _generic(::Layout::DocumentGenericPreview::Create(_data)) |
| 1210 | , _forceFileLayout(fields.forceFileLayout) |
| 1211 | , _date(langDateTime(base::unixtime::parse(fields.dateOverride |
| 1212 | ? fields.dateOverride |
| 1213 | : parent->date()))) |
| 1214 | , _ext(_generic.ext) |
| 1215 | , _datew(st::normalFont->width(_date)) { |
| 1216 | _name.setMarkedText( |
| 1217 | st::defaultTextStyle, |
| 1218 | (!_forceFileLayout |
| 1219 | ? Ui::Text::FormatSongNameFor(_data).textWithEntities() |
| 1220 | : Ui::Text::FormatDownloadsName(_data)), |
| 1221 | _documentNameOptions); |
| 1222 | |
| 1223 | AddComponents(Info::Bit()); |
| 1224 | |
| 1225 | setDocumentLinks(_data); |
| 1226 | |
| 1227 | _status.update( |
| 1228 | Ui::FileStatusSizeReady, |
| 1229 | _data->size, |
| 1230 | songLayout() ? (_data->duration() / 1000) : -1, |
| 1231 | 0); |
| 1232 | |
| 1233 | if (withThumb()) { |
| 1234 | if (_data->hasThumbnail()) { |
| 1235 | _data->loadThumbnail(parent->fullId()); |
| 1236 | auto tw = style::ConvertScale( |
| 1237 | _data->thumbnailLocation().width()); |
| 1238 | auto th = style::ConvertScale( |
| 1239 | _data->thumbnailLocation().height()); |
| 1240 | if (tw > th) { |
| 1241 | _thumbw = (tw * _st.fileThumbSize) / th; |
| 1242 | } else { |
| 1243 | _thumbw = _st.fileThumbSize; |
| 1244 | } |
| 1245 | } else { |
| 1246 | _thumbw = _st.fileThumbSize; |
| 1247 | } |
| 1248 | } else { |
| 1249 | _thumbw = 0; |
nothing calls this directly
no test coverage detected