mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix default export directory in flatpak
This commit is contained in:
parent
9eb15f7b17
commit
916926bfa6
5 changed files with 14 additions and 12 deletions
|
@ -25,7 +25,7 @@ DownloadPathBox::DownloadPathBox(
|
||||||
, _path(Core::App().settings().downloadPath())
|
, _path(Core::App().settings().downloadPath())
|
||||||
, _pathBookmark(Core::App().settings().downloadPathBookmark())
|
, _pathBookmark(Core::App().settings().downloadPathBookmark())
|
||||||
, _group(std::make_shared<Ui::RadioenumGroup<Directory>>(typeFromPath(_path)))
|
, _group(std::make_shared<Ui::RadioenumGroup<Directory>>(typeFromPath(_path)))
|
||||||
, _default(Core::App().canReadDefaultDownloadPath(true)
|
, _default(Core::App().canReadDefaultDownloadPath()
|
||||||
? object_ptr<Ui::Radioenum<Directory>>(
|
? object_ptr<Ui::Radioenum<Directory>>(
|
||||||
this,
|
this,
|
||||||
_group,
|
_group,
|
||||||
|
@ -149,7 +149,7 @@ void DownloadPathBox::setPathText(const QString &text) {
|
||||||
DownloadPathBox::Directory DownloadPathBox::typeFromPath(
|
DownloadPathBox::Directory DownloadPathBox::typeFromPath(
|
||||||
const QString &path) {
|
const QString &path) {
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
return Core::App().canReadDefaultDownloadPath(true)
|
return Core::App().canReadDefaultDownloadPath()
|
||||||
? Directory::Downloads
|
? Directory::Downloads
|
||||||
: Directory::Temp;
|
: Directory::Temp;
|
||||||
} else if (path == FileDialog::Tmp()) {
|
} else if (path == FileDialog::Tmp()) {
|
||||||
|
|
|
@ -737,14 +737,12 @@ void Application::saveSettings() {
|
||||||
Local::writeSettings();
|
Local::writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::canReadDefaultDownloadPath(bool always) const {
|
bool Application::canReadDefaultDownloadPath() const {
|
||||||
if (KSandbox::isInside()
|
return KSandbox::isInside()
|
||||||
&& (always || settings().downloadPath().isEmpty())) {
|
? base::CanReadDirectory(
|
||||||
const auto path = QStandardPaths::writableLocation(
|
QStandardPaths::writableLocation(
|
||||||
QStandardPaths::DownloadLocation);
|
QStandardPaths::DownloadLocation))
|
||||||
return base::CanReadDirectory(path);
|
: true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::canSaveFileWithoutAskingForPath() const {
|
bool Application::canSaveFileWithoutAskingForPath() const {
|
||||||
|
|
|
@ -209,7 +209,7 @@ public:
|
||||||
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
[[nodiscard]] bool canReadDefaultDownloadPath(bool always = false) const;
|
[[nodiscard]] bool canReadDefaultDownloadPath() const;
|
||||||
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
|
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
|
||||||
|
|
||||||
// Fallback config and proxy.
|
// Fallback config and proxy.
|
||||||
|
|
|
@ -294,7 +294,9 @@ void SettingsWidget::addLocationLabel(
|
||||||
}) | rpl::distinct_until_changed(
|
}) | rpl::distinct_until_changed(
|
||||||
) | rpl::map([=](const QString &path) {
|
) | rpl::map([=](const QString &path) {
|
||||||
const auto text = IsDefaultPath(_session, path)
|
const auto text = IsDefaultPath(_session, path)
|
||||||
|
? Core::App().canReadDefaultDownloadPath()
|
||||||
? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session)
|
? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session)
|
||||||
|
: tr::lng_download_path_temp(tr::now)
|
||||||
: path;
|
: path;
|
||||||
return Ui::Text::Link(
|
return Ui::Text::Link(
|
||||||
QDir::toNativeSeparators(text),
|
QDir::toNativeSeparators(text),
|
||||||
|
@ -341,7 +343,9 @@ void SettingsWidget::addFormatAndLocationLabel(
|
||||||
}) | rpl::distinct_until_changed(
|
}) | rpl::distinct_until_changed(
|
||||||
) | rpl::map([=](const QString &path) {
|
) | rpl::map([=](const QString &path) {
|
||||||
const auto text = IsDefaultPath(_session, path)
|
const auto text = IsDefaultPath(_session, path)
|
||||||
|
? Core::App().canReadDefaultDownloadPath()
|
||||||
? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session)
|
? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session)
|
||||||
|
: tr::lng_download_path_temp(tr::now)
|
||||||
: path;
|
: path;
|
||||||
return Ui::Text::Link(
|
return Ui::Text::Link(
|
||||||
QDir::toNativeSeparators(text),
|
QDir::toNativeSeparators(text),
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ void SetupDataStorage(
|
||||||
auto pathtext = Core::App().settings().downloadPathValue(
|
auto pathtext = Core::App().settings().downloadPathValue(
|
||||||
) | rpl::map([](const QString &text) {
|
) | rpl::map([](const QString &text) {
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return Core::App().canReadDefaultDownloadPath(true)
|
return Core::App().canReadDefaultDownloadPath()
|
||||||
? tr::lng_download_path_default(tr::now)
|
? tr::lng_download_path_default(tr::now)
|
||||||
: tr::lng_download_path_temp(tr::now);
|
: tr::lng_download_path_temp(tr::now);
|
||||||
} else if (text == FileDialog::Tmp()) {
|
} else if (text == FileDialog::Tmp()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue