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