[SFOS4] Documents app can't access our files anymore, always use Downloads

This commit is contained in:
Sebastian Wolf 2021-02-08 22:49:34 +01:00
parent 5de6ea4f11
commit 3575e1674c
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
4 changed files with 17 additions and 9 deletions

View file

@ -35,7 +35,7 @@ MessageContentFileInfoBase {
onClicked: {
if(file.isDownloadingCompleted) {
// in this case, the MouseArea should take over
tdLibWrapper.openFileOnDevice(file.path);
tdLibWrapper.copyFileToDownloads(file.path, true);
} else if(!file.isDownloadingActive) {
file.load();
} else {
@ -76,7 +76,7 @@ MessageContentFileInfoBase {
rightMargin: copyButton.width
}
onClicked: {
tdLibWrapper.openFileOnDevice(file.path);
tdLibWrapper.copyFileToDownloads(file.path, true);
}
}
}

View file

@ -1412,17 +1412,25 @@ QString TDLibWrapper::getOptionString(const QString &optionName)
return this->options.value(optionName).toString();
}
void TDLibWrapper::copyFileToDownloads(const QString &filePath)
void TDLibWrapper::copyFileToDownloads(const QString &filePath, bool openAfterCopy)
{
LOG("Copy file to downloads" << filePath);
LOG("Copy file to downloads" << filePath << openAfterCopy);
QFileInfo fileInfo(filePath);
if (fileInfo.exists()) {
QString downloadFilePath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + fileInfo.fileName();
if (QFile::exists(downloadFilePath)) {
if (openAfterCopy) {
this->openFileOnDevice(downloadFilePath);
} else {
emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath);
}
} else {
if (QFile::copy(filePath, downloadFilePath)) {
if (openAfterCopy) {
this->openFileOnDevice(downloadFilePath);
} else {
emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath);
}
} else {
emit copyToDownloadsError(fileInfo.fileName(), downloadFilePath);
}

View file

@ -132,7 +132,7 @@ public:
Q_INVOKABLE QVariantMap getChat(const QString &chatId);
Q_INVOKABLE QVariantMap getSecretChatFromCache(qlonglong secretChatId);
Q_INVOKABLE QString getOptionString(const QString &optionName);
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
Q_INVOKABLE void copyFileToDownloads(const QString &filePath, bool openAfterCopy = false);
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
Q_INVOKABLE void controlScreenSaver(bool enabled);
Q_INVOKABLE bool getJoinChatRequested();

View file

@ -1320,7 +1320,7 @@
</message>
<message>
<source>Quiz Mode</source>
<translation>Režim "kvíz"</translation>
<translation>Režim &quot;kvíz&quot;</translation>
</message>
<message>
<source>Quizzes have one correct answer. Participants can&apos;t revoke their responses.</source>
@ -1536,7 +1536,7 @@
</message>
<message>
<source>Enable online-only mode</source>
<translation>Povoliť režim "iba pripojený"</translation>
<translation>Povoliť režim &quot;iba pripojený&quot;</translation>
</message>
<message>
<source>Disables offline caching. Certain features may be limited or missing in this mode. Changes require a restart of Fernschreiber to take effect.</source>