mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Revert "Fix crash when asking download path in sandbox environment"
This reverts commit a4b0443047
.
This commit is contained in:
parent
9d59e42b52
commit
ab5792f59f
1 changed files with 19 additions and 23 deletions
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "storage/storage_account.h"
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/base_platform_file_utilities.h"
|
#include "base/platform/base_platform_file_utilities.h"
|
||||||
#include "platform/platform_file_utilities.h"
|
#include "platform/platform_file_utilities.h"
|
||||||
|
@ -174,32 +173,29 @@ QString DefaultDownloadPathFolder(not_null<Main::Session*> session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DefaultDownloadPath(not_null<Main::Session*> session) {
|
QString DefaultDownloadPath(not_null<Main::Session*> session) {
|
||||||
static auto Choosing = false;
|
if (KSandbox::isInside() && Core::App().settings().downloadPath().isEmpty()) {
|
||||||
const auto realDefaultPath = QStandardPaths::writableLocation(
|
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,
|
||||||
|
QString());
|
||||||
|
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 QStandardPaths::writableLocation(
|
||||||
QStandardPaths::DownloadLocation)
|
QStandardPaths::DownloadLocation)
|
||||||
+ '/'
|
+ '/'
|
||||||
+ DefaultDownloadPathFolder(session)
|
+ DefaultDownloadPathFolder(session)
|
||||||
+ '/';
|
+ '/';
|
||||||
if (KSandbox::isInside() && Core::App().settings().downloadPath().isEmpty()) {
|
|
||||||
if (Choosing) {
|
|
||||||
return session->local().tempDirectory();
|
|
||||||
}
|
|
||||||
Choosing = true;
|
|
||||||
FileDialog::GetFolder(
|
|
||||||
nullptr,
|
|
||||||
tr::lng_download_path_choose(tr::now),
|
|
||||||
realDefaultPath,
|
|
||||||
[](const QString &result) {
|
|
||||||
Core::App().settings().setDownloadPath(result.endsWith('/')
|
|
||||||
? result
|
|
||||||
: (result + '/'));
|
|
||||||
Core::App().saveSettings();
|
|
||||||
Choosing = false;
|
|
||||||
},
|
|
||||||
[] { Choosing = false; });
|
|
||||||
return session->local().tempDirectory();
|
|
||||||
}
|
|
||||||
return realDefaultPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
Loading…
Add table
Reference in a new issue