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:
parent
7437d47d92
commit
e8cc80f046
5 changed files with 89 additions and 14 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue