mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Ask download path first time in Linux sandbox
This allows to have less sandbox holes in flatpak and allows snap users to specify a normal folder to download to (as opposed to $HOME/snap/$SNAP_NAME/current/Downloads)
This commit is contained in:
parent
4b859828c8
commit
8f1a8f909d
1 changed files with 20 additions and 0 deletions
|
@ -24,6 +24,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtCore/QStandardPaths>
|
#include <QtCore/QStandardPaths>
|
||||||
#include <QtGui/QDesktopServices>
|
#include <QtGui/QDesktopServices>
|
||||||
|
|
||||||
|
#include <ksandbox.h>
|
||||||
|
|
||||||
bool filedialogGetSaveFile(
|
bool filedialogGetSaveFile(
|
||||||
QPointer<QWidget> parent,
|
QPointer<QWidget> parent,
|
||||||
QString &file,
|
QString &file,
|
||||||
|
@ -171,6 +173,24 @@ QString DefaultDownloadPathFolder(not_null<Main::Session*> session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DefaultDownloadPath(not_null<Main::Session*> session) {
|
QString DefaultDownloadPath(not_null<Main::Session*> session) {
|
||||||
|
if (KSandbox::isInside() && Core::App().settings().downloadPath().isEmpty()) {
|
||||||
|
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(
|
return QStandardPaths::writableLocation(
|
||||||
QStandardPaths::DownloadLocation)
|
QStandardPaths::DownloadLocation)
|
||||||
+ '/'
|
+ '/'
|
||||||
|
|
Loading…
Add table
Reference in a new issue