mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show correct error box when sending file > 4GB.
This commit is contained in:
parent
91b7fe5650
commit
0a81246502
8 changed files with 45 additions and 45 deletions
|
@ -2121,7 +2121,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_downloads_delete_in_cloud" = "They will be deleted from your disk, but will remain accessible in the cloud.";
|
"lng_downloads_delete_in_cloud" = "They will be deleted from your disk, but will remain accessible in the cloud.";
|
||||||
|
|
||||||
"lng_send_image_empty" = "Could not send an empty file: {name}";
|
"lng_send_image_empty" = "Could not send an empty file: {name}";
|
||||||
"lng_send_image_too_large" = "Could not send a file, because it is larger than 1500 MB: {name}";
|
|
||||||
"lng_send_images_selected#one" = "{count} image selected";
|
"lng_send_images_selected#one" = "{count} image selected";
|
||||||
"lng_send_images_selected#other" = "{count} images selected";
|
"lng_send_images_selected#other" = "{count} images selected";
|
||||||
"lng_send_photos#one" = "Send {count} photo";
|
"lng_send_photos#one" = "Send {count} photo";
|
||||||
|
|
|
@ -407,6 +407,7 @@ std::unique_ptr<PeerListRow> PublicsController::createRow(
|
||||||
void SimpleLimitBox(
|
void SimpleLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
|
bool premiumPossible,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
rpl::producer<TextWithEntities> text,
|
rpl::producer<TextWithEntities> text,
|
||||||
const QString &refAddition,
|
const QString &refAddition,
|
||||||
|
@ -414,7 +415,6 @@ void SimpleLimitBox(
|
||||||
bool fixed = false) {
|
bool fixed = false) {
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
const auto premiumPossible = session->premiumPossible();
|
|
||||||
const auto top = fixed
|
const auto top = fixed
|
||||||
? box->setPinnedToTopContent(object_ptr<Ui::VerticalLayout>(box))
|
? box->setPinnedToTopContent(object_ptr<Ui::VerticalLayout>(box))
|
||||||
: box->verticalLayout();
|
: box->verticalLayout();
|
||||||
|
@ -469,6 +469,25 @@ void SimpleLimitBox(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
rpl::producer<QString> title,
|
||||||
|
rpl::producer<TextWithEntities> text,
|
||||||
|
const QString &refAddition,
|
||||||
|
const InfographicDescriptor &descriptor,
|
||||||
|
bool fixed = false) {
|
||||||
|
SimpleLimitBox(
|
||||||
|
box,
|
||||||
|
session,
|
||||||
|
session->premiumPossible(),
|
||||||
|
std::move(title),
|
||||||
|
std::move(text),
|
||||||
|
refAddition,
|
||||||
|
descriptor,
|
||||||
|
fixed);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] int PinsCount(not_null<Dialogs::MainList*> list) {
|
[[nodiscard]] int PinsCount(not_null<Dialogs::MainList*> list) {
|
||||||
return list->pinned()->order().size();
|
return list->pinned()->order().size();
|
||||||
}
|
}
|
||||||
|
@ -877,8 +896,6 @@ void FileSizeLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
uint64 fileSizeBytes) {
|
uint64 fileSizeBytes) {
|
||||||
const auto premiumPossible = session->premiumPossible();
|
|
||||||
|
|
||||||
const auto defaultLimit = Limit(
|
const auto defaultLimit = Limit(
|
||||||
session,
|
session,
|
||||||
"upload_max_fileparts_default",
|
"upload_max_fileparts_default",
|
||||||
|
@ -888,14 +905,19 @@ void FileSizeLimitBox(
|
||||||
"upload_max_fileparts_premium",
|
"upload_max_fileparts_premium",
|
||||||
8000);
|
8000);
|
||||||
|
|
||||||
const auto defaultGb = (defaultLimit + 999) / 2000;
|
const auto defaultGb = float64(int(defaultLimit + 999) / 2000);
|
||||||
const auto premiumGb = (premiumLimit + 999) / 2000;
|
const auto premiumGb = float64(int(premiumLimit + 999) / 2000);
|
||||||
|
|
||||||
|
const auto tooLarge = (fileSizeBytes > premiumLimit * 512ULL * 1024);
|
||||||
|
const auto showLimit = tooLarge ? premiumGb : defaultGb;
|
||||||
|
const auto premiumPossible = !tooLarge && session->premiumPossible();
|
||||||
|
|
||||||
const auto current = (fileSizeBytes && premiumPossible)
|
const auto current = (fileSizeBytes && premiumPossible)
|
||||||
? std::clamp(
|
? std::clamp(
|
||||||
float64(((fileSizeBytes / uint64(1024 * 1024)) + 999) / 1000),
|
float64(((fileSizeBytes / uint64(1024 * 1024)) + 499) / 1000),
|
||||||
defaultGb,
|
defaultGb,
|
||||||
premiumGb)
|
premiumGb)
|
||||||
: defaultGb;
|
: showLimit;
|
||||||
const auto gb = [](int count) {
|
const auto gb = [](int count) {
|
||||||
return tr::lng_file_size_limit(tr::now, lt_count, count);
|
return tr::lng_file_size_limit(tr::now, lt_count, count);
|
||||||
};
|
};
|
||||||
|
@ -903,7 +925,7 @@ void FileSizeLimitBox(
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
tr::lng_file_size_limit1(
|
tr::lng_file_size_limit1(
|
||||||
lt_size,
|
lt_size,
|
||||||
rpl::single(Ui::Text::Bold(gb(defaultGb))),
|
rpl::single(Ui::Text::Bold(gb(showLimit))),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
(!premiumPossible
|
(!premiumPossible
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
|
@ -918,13 +940,14 @@ void FileSizeLimitBox(
|
||||||
SimpleLimitBox(
|
SimpleLimitBox(
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
|
premiumPossible,
|
||||||
tr::lng_file_size_limit_title(),
|
tr::lng_file_size_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
"upload_max_fileparts",
|
"upload_max_fileparts",
|
||||||
{
|
{
|
||||||
defaultGb,
|
defaultGb,
|
||||||
current,
|
current,
|
||||||
premiumGb,
|
(tooLarge ? showLimit * 2 : premiumGb),
|
||||||
&st::premiumIconFiles,
|
&st::premiumIconFiles,
|
||||||
tr::lng_file_size_limit
|
tr::lng_file_size_limit
|
||||||
});
|
});
|
||||||
|
|
|
@ -4903,17 +4903,13 @@ bool HistoryWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::TooLargeFile: return tr::lng_send_image_too_large(
|
case Error::TooLargeFile: return u"(toolarge)"_q;
|
||||||
tr::now,
|
|
||||||
lt_name,
|
|
||||||
list.errorData);
|
|
||||||
case Error::PremiumRequired: return u"(premium)"_q;
|
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (text == u"(premium)"_q) {
|
} else if (text == u"(toolarge)"_q) {
|
||||||
const auto fileSize = list.files.back().size;
|
const auto fileSize = list.files.back().size;
|
||||||
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -939,17 +939,13 @@ bool RepliesWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::TooLargeFile: return tr::lng_send_image_too_large(
|
case Error::TooLargeFile: return u"(toolarge)"_q;
|
||||||
tr::now,
|
|
||||||
lt_name,
|
|
||||||
list.errorData);
|
|
||||||
case Error::PremiumRequired: return u"(premium)"_q;
|
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (text == u"(premium)"_q) {
|
} else if (text == u"(toolarge)"_q) {
|
||||||
const auto fileSize = list.files.back().size;
|
const auto fileSize = list.files.back().size;
|
||||||
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -558,17 +558,13 @@ bool ScheduledWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::TooLargeFile: return tr::lng_send_image_too_large(
|
case Error::TooLargeFile: return u"(toolarge)"_q;
|
||||||
tr::now,
|
|
||||||
lt_name,
|
|
||||||
list.errorData);
|
|
||||||
case Error::PremiumRequired: return u"(premium)"_q;
|
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (text == u"(premium)"_q) {
|
} else if (text == u"(toolarge)"_q) {
|
||||||
const auto fileSize = list.files.back().size;
|
const auto fileSize = list.files.back().size;
|
||||||
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
controller()->show(Box(FileSizeLimitBox, &session(), fileSize));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "boxes/send_files_box.h"
|
#include "boxes/send_files_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -1054,16 +1055,10 @@ void FileLoadTask::finish() {
|
||||||
tr::lng_send_image_empty(tr::now, lt_name, _filepath)),
|
tr::lng_send_image_empty(tr::now, lt_name, _filepath)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
removeFromAlbum();
|
removeFromAlbum();
|
||||||
} else if (_result->filesize > kFileSizePremiumLimit) {
|
} else if (_result->filesize > kFileSizePremiumLimit
|
||||||
|
|| (_result->filesize > kFileSizeLimit && !premium)) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Ui::MakeInformBox(
|
Box(FileSizeLimitBox, session, _result->filesize),
|
||||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
removeFromAlbum();
|
|
||||||
} else if (_result->filesize > kFileSizeLimit && !premium) {
|
|
||||||
Ui::show(
|
|
||||||
Ui::MakeInformBox(
|
|
||||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
removeFromAlbum();
|
removeFromAlbum();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -217,14 +217,10 @@ PreparedList PrepareMediaList(
|
||||||
PreparedList::Error::EmptyFile,
|
PreparedList::Error::EmptyFile,
|
||||||
file
|
file
|
||||||
};
|
};
|
||||||
} else if (filesize > kFileSizePremiumLimit) {
|
} else if (filesize > kFileSizePremiumLimit
|
||||||
return {
|
|| (filesize > kFileSizeLimit && !premium)) {
|
||||||
PreparedList::Error::TooLargeFile,
|
|
||||||
file
|
|
||||||
};
|
|
||||||
} else if (filesize > kFileSizeLimit && !premium) {
|
|
||||||
auto errorResult = PreparedList(
|
auto errorResult = PreparedList(
|
||||||
PreparedList::Error::PremiumRequired,
|
PreparedList::Error::TooLargeFile,
|
||||||
QString());
|
QString());
|
||||||
errorResult.files.emplace_back(file);
|
errorResult.files.emplace_back(file);
|
||||||
errorResult.files.back().size = filesize;
|
errorResult.files.back().size = filesize;
|
||||||
|
|
|
@ -91,7 +91,6 @@ struct PreparedList {
|
||||||
Directory,
|
Directory,
|
||||||
EmptyFile,
|
EmptyFile,
|
||||||
TooLargeFile,
|
TooLargeFile,
|
||||||
PremiumRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PreparedList() = default;
|
PreparedList() = default;
|
||||||
|
|
Loading…
Add table
Reference in a new issue