2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Hide default download folder option if it's not available

This commit is contained in:
Ilya Fedin
2022-12-29 12:49:03 +04:00
committed by John Preston
parent 7a64725045
commit 0eec470387
6 changed files with 30 additions and 18 deletions

View File

@@ -595,11 +595,9 @@ void Application::saveSettings() {
Local::writeSettings();
}
bool Application::canSaveFileWithoutAskingForPath() const {
if (Core::App().settings().askDownloadPath()) {
return false;
} else if (KSandbox::isInside()
&& Core::App().settings().downloadPath().isEmpty()) {
bool Application::canReadDefaultDownloadPath(bool always) const {
if (KSandbox::isInside()
&& (always || Core::App().settings().downloadPath().isEmpty())) {
const auto path = QStandardPaths::writableLocation(
QStandardPaths::DownloadLocation);
return base::CanReadDirectory(path);
@@ -607,6 +605,11 @@ bool Application::canSaveFileWithoutAskingForPath() const {
return true;
}
bool Application::canSaveFileWithoutAskingForPath() const {
return !Core::App().settings().askDownloadPath()
&& canReadDefaultDownloadPath();
}
MTP::Config &Application::fallbackProductionConfig() const {
if (!_fallbackProductionConfig) {
_fallbackProductionConfig = std::make_unique<MTP::Config>(

View File

@@ -178,6 +178,8 @@ public:
[[nodiscard]] Settings &settings();
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
void saveSettings();
[[nodiscard]] bool canReadDefaultDownloadPath(bool always = false) const;
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
// Fallback config and proxy.

View File

@@ -24,8 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QStandardPaths>
#include <QtGui/QDesktopServices>
#include <ksandbox.h>
bool filedialogGetSaveFile(
QPointer<QWidget> parent,
QString &file,
@@ -173,15 +171,12 @@ QString DefaultDownloadPathFolder(not_null<Main::Session*> session) {
}
QString DefaultDownloadPath(not_null<Main::Session*> session) {
const auto standardLocation = QStandardPaths::writableLocation(
QStandardPaths::DownloadLocation);
const auto realDefaultPath = standardLocation
const auto realDefaultPath = QStandardPaths::writableLocation(
QStandardPaths::DownloadLocation)
+ '/'
+ DefaultDownloadPathFolder(session)
+ '/';
if (KSandbox::isInside()
&& Core::App().settings().downloadPath().isEmpty()
&& !base::CanReadDirectory(standardLocation)) {
if (!Core::App().canReadDefaultDownloadPath()) {
QStringList files;
QByteArray remoteContent;
const auto success = Platform::FileDialog::Get(