mirror of
https://github.com/outbackdingo/amnezia-client.git
synced 2026-01-27 10:18:14 +00:00
Refactor Android open file method
Fix some bugs with mimetype filters when the Qt mimetype database does not match the Android database
This commit is contained in:
@@ -60,6 +60,11 @@ QString SystemController::getFileName(const QString &acceptLabel, const QString
|
||||
const QString &selectedFile, const bool isSaveMode, const QString &defaultSuffix)
|
||||
{
|
||||
QString fileName;
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_ASSERT(!isSaveMode);
|
||||
return AndroidController::instance()->openFile(nameFilter);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
|
||||
MobileUtils mobileUtils;
|
||||
@@ -108,20 +113,6 @@ QString SystemController::getFileName(const QString &acceptLabel, const QString
|
||||
}
|
||||
|
||||
fileName = mainFileDialog->property("selectedFile").toString();
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
// patch for files containing spaces etc
|
||||
const QString sep { "raw%3A%2F" };
|
||||
if (fileName.startsWith("content://") && fileName.contains(sep)) {
|
||||
QString contentUrl = fileName.split(sep).at(0);
|
||||
QString rawUrl = fileName.split(sep).at(1);
|
||||
rawUrl.replace(" ", "%20");
|
||||
fileName = contentUrl + sep + rawUrl;
|
||||
}
|
||||
|
||||
return fileName;
|
||||
#endif
|
||||
|
||||
return QUrl(fileName).toLocalFile();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user