mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Use temp directory for downloads in Linux sandbox by default
This commit is contained in:
parent
c49dac57b7
commit
7307f0b1a5
5 changed files with 10 additions and 35 deletions
Telegram
Resources/langs
SourceFiles
|
@ -755,7 +755,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_download_path" = "Download path";
|
||||
"lng_download_path_temp" = "Temp folder";
|
||||
"lng_download_path_default" = "Default folder";
|
||||
"lng_download_path_unset" = "Unset";
|
||||
"lng_download_path_clear" = "Clear all";
|
||||
"lng_download_path_header" = "Choose download path";
|
||||
"lng_download_path_default_radio" = "Telegram folder in system «Downloads»";
|
||||
|
|
|
@ -147,7 +147,9 @@ void DownloadPathBox::setPathText(const QString &text) {
|
|||
DownloadPathBox::Directory DownloadPathBox::typeFromPath(
|
||||
const QString &path) {
|
||||
if (path.isEmpty()) {
|
||||
return Directory::Downloads;
|
||||
return Core::App().canReadDefaultDownloadPath(true)
|
||||
? Directory::Downloads
|
||||
: Directory::Temp;
|
||||
} else if (path == FileDialog::Tmp()) {
|
||||
return Directory::Temp;
|
||||
}
|
||||
|
|
|
@ -252,15 +252,6 @@ void Application::run() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (KSandbox::isInside()) {
|
||||
const auto path = settings().downloadPath();
|
||||
if (!path.isEmpty()
|
||||
&& path != FileDialog::Tmp()
|
||||
&& !base::CanReadDirectory(path)) {
|
||||
settings().setDownloadPath(QString());
|
||||
}
|
||||
}
|
||||
|
||||
_translator = std::make_unique<Lang::Translator>();
|
||||
QCoreApplication::instance()->installTranslator(_translator.get());
|
||||
|
||||
|
@ -606,8 +597,7 @@ bool Application::canReadDefaultDownloadPath(bool always) const {
|
|||
}
|
||||
|
||||
bool Application::canSaveFileWithoutAskingForPath() const {
|
||||
return !Core::App().settings().askDownloadPath()
|
||||
&& canReadDefaultDownloadPath();
|
||||
return !Core::App().settings().askDownloadPath();
|
||||
}
|
||||
|
||||
MTP::Config &Application::fallbackProductionConfig() const {
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/platform/base_platform_file_utilities.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
|
@ -171,31 +172,14 @@ QString DefaultDownloadPathFolder(not_null<Main::Session*> session) {
|
|||
}
|
||||
|
||||
QString DefaultDownloadPath(not_null<Main::Session*> session) {
|
||||
const auto realDefaultPath = QStandardPaths::writableLocation(
|
||||
if (!Core::App().canReadDefaultDownloadPath()) {
|
||||
return session->local().tempDirectory();
|
||||
}
|
||||
return QStandardPaths::writableLocation(
|
||||
QStandardPaths::DownloadLocation)
|
||||
+ '/'
|
||||
+ DefaultDownloadPathFolder(session)
|
||||
+ '/';
|
||||
if (!Core::App().canReadDefaultDownloadPath()) {
|
||||
QStringList files;
|
||||
QByteArray remoteContent;
|
||||
const auto success = Platform::FileDialog::Get(
|
||||
nullptr,
|
||||
files,
|
||||
remoteContent,
|
||||
tr::lng_download_path_choose(tr::now),
|
||||
QString(),
|
||||
FileDialog::internal::Type::ReadFolder,
|
||||
realDefaultPath);
|
||||
if (success && !files.isEmpty() && !files[0].isEmpty()) {
|
||||
const auto result = files[0].endsWith('/') ? files[0] : (files[0] + '/');
|
||||
Core::App().settings().setDownloadPath(result);
|
||||
Core::App().saveSettings();
|
||||
return result;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
return realDefaultPath;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
|
|
@ -1057,7 +1057,7 @@ void SetupDataStorage(
|
|||
if (text.isEmpty()) {
|
||||
return Core::App().canReadDefaultDownloadPath(true)
|
||||
? tr::lng_download_path_default(tr::now)
|
||||
: tr::lng_download_path_unset(tr::now);
|
||||
: tr::lng_download_path_temp(tr::now);
|
||||
} else if (text == FileDialog::Tmp()) {
|
||||
return tr::lng_download_path_temp(tr::now);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue