diff --git a/Telegram/SourceFiles/boxes/download_path_box.cpp b/Telegram/SourceFiles/boxes/download_path_box.cpp index f61c0e6e7d23e0..a5e15f317f2410 100644 --- a/Telegram/SourceFiles/boxes/download_path_box.cpp +++ b/Telegram/SourceFiles/boxes/download_path_box.cpp @@ -25,7 +25,7 @@ DownloadPathBox::DownloadPathBox( , _path(Core::App().settings().downloadPath()) , _pathBookmark(Core::App().settings().downloadPathBookmark()) , _group(std::make_shared>(typeFromPath(_path))) -, _default(Core::App().canReadDefaultDownloadPath(true) +, _default(Core::App().canReadDefaultDownloadPath() ? object_ptr>( this, _group, @@ -149,7 +149,7 @@ void DownloadPathBox::setPathText(const QString &text) { DownloadPathBox::Directory DownloadPathBox::typeFromPath( const QString &path) { if (path.isEmpty()) { - return Core::App().canReadDefaultDownloadPath(true) + return Core::App().canReadDefaultDownloadPath() ? Directory::Downloads : Directory::Temp; } else if (path == FileDialog::Tmp()) { diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 39b7ac32fe2183..bd1a17475f9a62 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -737,14 +737,12 @@ void Application::saveSettings() { Local::writeSettings(); } -bool Application::canReadDefaultDownloadPath(bool always) const { - if (KSandbox::isInside() - && (always || settings().downloadPath().isEmpty())) { - const auto path = QStandardPaths::writableLocation( - QStandardPaths::DownloadLocation); - return base::CanReadDirectory(path); - } - return true; +bool Application::canReadDefaultDownloadPath() const { + return KSandbox::isInside() + ? base::CanReadDirectory( + QStandardPaths::writableLocation( + QStandardPaths::DownloadLocation)) + : true; } bool Application::canSaveFileWithoutAskingForPath() const { diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 373ba3546a6c51..bfb330d351673d 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -209,7 +209,7 @@ class Application final : public QObject { void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay); void saveSettings(); - [[nodiscard]] bool canReadDefaultDownloadPath(bool always = false) const; + [[nodiscard]] bool canReadDefaultDownloadPath() const; [[nodiscard]] bool canSaveFileWithoutAskingForPath() const; // Fallback config and proxy. diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index 6cd12298fd445b..73c8908a3899fa 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -294,7 +294,9 @@ void SettingsWidget::addLocationLabel( }) | rpl::distinct_until_changed( ) | rpl::map([=](const QString &path) { const auto text = IsDefaultPath(_session, path) + ? Core::App().canReadDefaultDownloadPath() ? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session) + : tr::lng_download_path_temp(tr::now) : path; return Ui::Text::Link( QDir::toNativeSeparators(text), @@ -341,7 +343,9 @@ void SettingsWidget::addFormatAndLocationLabel( }) | rpl::distinct_until_changed( ) | rpl::map([=](const QString &path) { const auto text = IsDefaultPath(_session, path) + ? Core::App().canReadDefaultDownloadPath() ? u"Downloads/"_q + File::DefaultDownloadPathFolder(_session) + : tr::lng_download_path_temp(tr::now) : path; return Ui::Text::Link( QDir::toNativeSeparators(text), diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 9b2222b0e44266..9d6203c1382ffa 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -1106,7 +1106,7 @@ void SetupDataStorage( auto pathtext = Core::App().settings().downloadPathValue( ) | rpl::map([](const QString &text) { if (text.isEmpty()) { - return Core::App().canReadDefaultDownloadPath(true) + return Core::App().canReadDefaultDownloadPath() ? tr::lng_download_path_default(tr::now) : tr::lng_download_path_temp(tr::now); } else if (text == FileDialog::Tmp()) {