mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Use nice media names in Downloads.
This commit is contained in:
parent
dde4868540
commit
bff8313a37
@ -467,7 +467,7 @@ calendarPrevious: IconButton {
|
||||
icon: icon {{ "calendar_down-flip_vertical", boxTitleFg }};
|
||||
iconPosition: point(-1px, -1px);
|
||||
|
||||
rippleAreaPosition: point(6px, 6px);
|
||||
rippleAreaPosition: point(2px, 2px);
|
||||
rippleAreaSize: 44px;
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: windowBgOver;
|
||||
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/application.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "ui/controls/download_bar.h"
|
||||
#include "ui/text/format_song_document_name.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
@ -822,8 +823,9 @@ rpl::producer<Ui::DownloadBarContent> MakeDownloadBarContent() {
|
||||
) | rpl::map([=, &manager] {
|
||||
auto result = Ui::DownloadBarContent();
|
||||
for (const auto id : manager.loadingList()) {
|
||||
if (result.singleName.isEmpty()) {
|
||||
result.singleName = id->object.document->filename();
|
||||
if (result.singleName.text.isEmpty()) {
|
||||
const auto document = id->object.document;
|
||||
result.singleName = Ui::Text::FormatDownloadsName(document);
|
||||
result.singleThumbnail = QImage();
|
||||
}
|
||||
++result.count;
|
||||
|
@ -215,7 +215,7 @@ void Provider::performRefresh() {
|
||||
_postponedRefresh = false;
|
||||
_fullCount = _elements.size();
|
||||
if (base::take(_postponedRefreshSort)) {
|
||||
ranges::sort(_elements, ranges::greater(), &Element::started);
|
||||
ranges::sort(_elements, ranges::less(), &Element::started);
|
||||
}
|
||||
_refreshed.fire({});
|
||||
}
|
||||
@ -255,7 +255,7 @@ std::vector<ListSection> Provider::fillSections(
|
||||
1,
|
||||
ListSection(Type::File, sectionDelegate()));
|
||||
auto §ion = result.back();
|
||||
for (const auto &element : _elements) {
|
||||
for (const auto &element : ranges::views::reverse(_elements)) {
|
||||
if (auto layout = getLayout(element, delegate)) {
|
||||
section.addItem(layout);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ infoLayerTopBarForward: IconButton(infoLayerTopBarBack) {
|
||||
icon: icon {{ "info/info_media_forward", boxTitleCloseFg }};
|
||||
iconOver: icon {{ "info/info_media_forward", boxTitleCloseFgOver }};
|
||||
iconPosition: point(11px, -1px);
|
||||
rippleAreaPosition: point(3px, 4px);
|
||||
rippleAreaPosition: point(3px, 8px);
|
||||
}
|
||||
infoLayerTopBarDelete: IconButton(infoLayerTopBarForward) {
|
||||
icon: icon {{ "info/info_media_delete", boxTitleCloseFg }};
|
||||
|
@ -1069,6 +1069,11 @@ void ListWidget::deleteItems(SelectedItems &&items, Fn<void()> confirmed) {
|
||||
? tr::lng_downloads_delete_sure_one(tr::now)
|
||||
: tr::lng_downloads_delete_sure(tr::now, lt_count, count);
|
||||
const auto deleteSure = [=] {
|
||||
Ui::PostponeCall(this, [=] {
|
||||
if (const auto box = _actionBoxWeak.data()) {
|
||||
box->closeBox();
|
||||
}
|
||||
});
|
||||
const auto ids = ranges::views::all(
|
||||
items.list
|
||||
) | ranges::views::transform([](const SelectedItem &item) {
|
||||
@ -1076,9 +1081,6 @@ void ListWidget::deleteItems(SelectedItems &&items, Fn<void()> confirmed) {
|
||||
}) | ranges::to_vector;
|
||||
Core::App().downloadManager().deleteFiles(ids);
|
||||
confirmed();
|
||||
if (const auto box = _actionBoxWeak.data()) {
|
||||
box->closeBox();
|
||||
}
|
||||
};
|
||||
setActionBoxWeak(window->show(Box<Ui::ConfirmBox>(
|
||||
phrase,
|
||||
|
@ -941,9 +941,9 @@ Document::Document(
|
||||
, _datew(st::normalFont->width(_date)) {
|
||||
_name.setMarkedText(
|
||||
st::defaultTextStyle,
|
||||
(_forceFileLayout
|
||||
? Ui::Text::Bold(_data->filename())
|
||||
: Ui::Text::FormatSongNameFor(_data).textWithEntities()),
|
||||
(!_forceFileLayout
|
||||
? Ui::Text::FormatSongNameFor(_data).textWithEntities()
|
||||
: Ui::Text::FormatDownloadsName(_data)),
|
||||
_documentNameOptions);
|
||||
|
||||
AddComponents(Info::Bit());
|
||||
|
@ -56,9 +56,10 @@ void DownloadBar::show(DownloadBarContent &&content) {
|
||||
_radial.start(computeProgress());
|
||||
}
|
||||
_content = content;
|
||||
_title.setText(st::semiboldTextStyle,
|
||||
_title.setMarkedText(st::defaultTextStyle,
|
||||
(content.count > 1
|
||||
? tr::lng_profile_files(tr::now, lt_count, content.count)
|
||||
? Ui::Text::Bold(
|
||||
tr::lng_profile_files(tr::now, lt_count, content.count))
|
||||
: content.singleName));
|
||||
refreshInfo(_progress.current());
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ struct DownloadBarProgress {
|
||||
};
|
||||
|
||||
struct DownloadBarContent {
|
||||
QString singleName;
|
||||
TextWithEntities singleName;
|
||||
QImage singleThumbnail;
|
||||
int count = 0;
|
||||
int done = 0;
|
||||
|
@ -7,7 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "ui/text/format_song_document_name.h"
|
||||
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "data/data_document.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
||||
namespace Ui::Text {
|
||||
|
||||
@ -20,4 +22,21 @@ FormatSongName FormatSongNameFor(not_null<DocumentData*> document) {
|
||||
song ? song->performer : QString());
|
||||
}
|
||||
|
||||
TextWithEntities FormatDownloadsName(not_null<DocumentData*> document) {
|
||||
return document->isVideoFile()
|
||||
? Bold(tr::lng_in_dlg_video(tr::now))
|
||||
: document->isVoiceMessage()
|
||||
? Bold(tr::lng_in_dlg_audio(tr::now))
|
||||
: document->isVideoMessage()
|
||||
? Bold(tr::lng_in_dlg_video_message(tr::now))
|
||||
: document->sticker()
|
||||
? Bold(document->sticker()->alt.isEmpty()
|
||||
? tr::lng_in_dlg_sticker(tr::now)
|
||||
: tr::lng_in_dlg_sticker_emoji(
|
||||
tr::now,
|
||||
lt_emoji,
|
||||
document->sticker()->alt))
|
||||
: FormatSongNameFor(document).textWithEntities();
|
||||
}
|
||||
|
||||
} // namespace Ui::Text
|
||||
|
@ -16,4 +16,7 @@ namespace Ui::Text {
|
||||
[[nodiscard]] FormatSongName FormatSongNameFor(
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
[[nodiscard]] TextWithEntities FormatDownloadsName(
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
} // namespace Ui::Text
|
||||
|
Loading…
Reference in New Issue
Block a user