Limit transfer formats when PDF tools not installed
This commit is contained in:
parent
13a66f358b
commit
ee0fc56bde
2 changed files with 18 additions and 3 deletions
|
@ -1,12 +1,13 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import "../pages/utils.js" as Utils
|
||||
|
||||
Setting {
|
||||
property var choices
|
||||
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
|
||||
|
||||
|
|
|
@ -146,6 +146,12 @@ function canConvertPdfTo(type)
|
|||
return has(targets, type)
|
||||
}
|
||||
|
||||
function canTransferPdfAs(type)
|
||||
{
|
||||
var targets = ["application/octet-stream", "application/pdf"];
|
||||
return has(targets, type)
|
||||
}
|
||||
|
||||
function canConvertImageTo(type)
|
||||
{
|
||||
var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"];
|
||||
|
@ -158,14 +164,22 @@ function unitsIsDpi(resolution)
|
|||
}
|
||||
|
||||
|
||||
function limitChoices(name, choices, mimeType)
|
||||
function limitChoices(name, choices, mimeType, ConvertChecker)
|
||||
{
|
||||
switch(name) {
|
||||
case "document-format":
|
||||
if(mimeType == "application/pdf")
|
||||
{
|
||||
if(ConvertChecker.pdf)
|
||||
{
|
||||
return choices.filter(canConvertPdfTo)
|
||||
}
|
||||
else
|
||||
{
|
||||
return choices.filter(canTransferPdfAs)
|
||||
}
|
||||
|
||||
}
|
||||
else if(mimeType == "image/jpeg" || mimeType == "image/png")
|
||||
{
|
||||
return choices.filter(canConvertImageTo);
|
||||
|
|
Loading…
Reference in a new issue