Limit transfer formats when PDF tools not installed

This commit is contained in:
Anton Thomasson 2020-06-07 12:18:10 +02:00
parent 13a66f358b
commit ee0fc56bde
2 changed files with 18 additions and 3 deletions

View file

@ -1,12 +1,13 @@
import QtQuick 2.0 import QtQuick 2.0
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import seaprint.convertchecker 1.0
import "../pages/utils.js" as Utils import "../pages/utils.js" as Utils
Setting { Setting {
property var choices property var choices
property string mime_type property string mime_type
property var limited_choices: Utils.limitChoices(name, choices, mime_type) property var limited_choices: Utils.limitChoices(name, choices, mime_type, ConvertChecker)
property int num_large_choices: 8 property int num_large_choices: 8

View file

@ -146,6 +146,12 @@ function canConvertPdfTo(type)
return has(targets, type) return has(targets, type)
} }
function canTransferPdfAs(type)
{
var targets = ["application/octet-stream", "application/pdf"];
return has(targets, type)
}
function canConvertImageTo(type) function canConvertImageTo(type)
{ {
var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"]; var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"];
@ -158,13 +164,21 @@ function unitsIsDpi(resolution)
} }
function limitChoices(name, choices, mimeType) function limitChoices(name, choices, mimeType, ConvertChecker)
{ {
switch(name) { switch(name) {
case "document-format": case "document-format":
if(mimeType == "application/pdf") if(mimeType == "application/pdf")
{ {
return choices.filter(canConvertPdfTo) if(ConvertChecker.pdf)
{
return choices.filter(canConvertPdfTo)
}
else
{
return choices.filter(canTransferPdfAs)
}
} }
else if(mimeType == "image/jpeg" || mimeType == "image/png") else if(mimeType == "image/jpeg" || mimeType == "image/png")
{ {