From ee0fc56bdea487c8b366e5907ee95c483332c7a0 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 12:18:10 +0200 Subject: [PATCH] Limit transfer formats when PDF tools not installed --- qml/components/ChoiceSetting.qml | 3 ++- qml/pages/utils.js | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 06fd646..e60f547 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -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 diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 0f7f3cb..257171f 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -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,13 +164,21 @@ function unitsIsDpi(resolution) } -function limitChoices(name, choices, mimeType) +function limitChoices(name, choices, mimeType, ConvertChecker) { switch(name) { case "document-format": 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") {