Pre-select file if given as argument (suboptimal solution)

This commit is contained in:
Anton Thomasson 2020-01-05 13:24:25 +01:00
parent 5d337b2d29
commit 3e8da3f488
3 changed files with 21 additions and 1 deletions

View file

@ -6,7 +6,7 @@ import "pages"
ApplicationWindow ApplicationWindow
{ {
initialPage: Component { FirstPage { } } initialPage: Component { FirstPage { selectedFile: Qt.application.arguments[1] ? Qt.application.arguments[1] : "" } }
cover: Qt.resolvedUrl("cover/CoverPage.qml") cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: defaultAllowedOrientations allowedOrientations: defaultAllowedOrientations

View file

@ -49,6 +49,21 @@ Page {
Component.onCompleted: { Component.onCompleted: {
discovery.discover(); discovery.discover();
if(selectedFile != "")
{ // Until i can convince FilePickerPage to do its magic without user interaction
if(Utils.endsWith(".pdf", selectedFile))
{
selectedFileType = "application/pdf"
}
else if(Utils.endsWith(".jpg", selectedFile) || Utils.endsWith(".jpeg", selectedFile))
{
selectedFileType = "image/jpeg"
}
else
{
selectedFile = ""
}
}
} }
// To enable PullDownMenu, place our content in a SilicaFlickable // To enable PullDownMenu, place our content in a SilicaFlickable

View file

@ -86,3 +86,8 @@ function ippName(name, value)
} }
return value; return value;
} }
function endsWith(ending, string)
{
return string.lastIndexOf(ending) == (string.length - ending.length);
}