diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index addeac5..e505033 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -3,6 +3,7 @@ import Sailfish.Silica 1.0 import QtQuick.LocalStorage 2.0 import Nemo.Notifications 1.0 import Nemo.Configuration 1.0 +import seaprint.mimer 1.0 import "pages" import "components" @@ -29,7 +30,7 @@ ApplicationWindow db_conn = LocalStorage.openDatabaseSync("SeaprintDB", "1.0", "Seaprint storage", 100000) db_conn.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS Favourites (ssid STRING, url STRING)'); - tx.executeSql('CREATE TABLE IF NOT EXISTS JobSettings (uuid STRING UNIQUE, data STRING)'); + tx.executeSql('CREATE TABLE IF NOT EXISTS JobSettings (uuid STRING, type STRING, data STRING)'); }); } @@ -71,16 +72,31 @@ ApplicationWindow }); } - function setJobSettings(uuid, settings) { + function simplifyType(mimetype) { + if(Mimer.isImage(mimetype)) + { + return {simple: "image", translatable: qsTr("images")}; + } + else + { + return {simple: "document", translatable: qsTr("documents")}; + + } + } + + function setJobSettings(uuid, mimetype, settings) { + var type = simplifyType(mimetype).simple; db_conn.transaction(function (tx) { - tx.executeSql('REPLACE INTO JobSettings VALUES(?, ?)', [uuid, settings] ); + tx.executeSql('DELETE FROM JobSettings WHERE uuid=? AND type=?', [uuid, type] ); + tx.executeSql('INSERT INTO JobSettings VALUES(?, ?, ?)', [uuid, type, settings] ); }); } - function getJobSettings(uuid) { + function getJobSettings(uuid, mimetype) { + var type = simplifyType(mimetype).simple; var settings = "{}"; db_conn.transaction(function (tx) { - var res = tx.executeSql('SELECT * FROM JobSettings WHERE uuid=?', [uuid]); + var res = tx.executeSql('SELECT * FROM JobSettings WHERE uuid=? AND type=?', [uuid, type]); if (res.rows.length) { settings = res.rows.item(0).data @@ -89,9 +105,10 @@ ApplicationWindow return settings } - function removeJobSettings(uuid) { + function removeJobSettings(uuid, mimetype) { + var type = simplifyType(mimetype).simple; db_conn.transaction(function (tx) { - tx.executeSql('DELETE FROM JobSettings WHERE uuid=?', [uuid] ); + tx.executeSql('DELETE FROM JobSettings WHERE uuid=? AND type=?', [uuid, type] ); }); } } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 85ffc61..2f1b031 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -186,7 +186,7 @@ Page { { if(printer.attrs.hasOwnProperty("printer-uuid")) { - return JSON.parse(db.getJobSettings(printer.attrs["printer-uuid"].value)); + return JSON.parse(db.getJobSettings(printer.attrs["printer-uuid"].value, selectedFileType)); } else { diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 1d22803..1487518 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -45,11 +45,16 @@ Page { // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView PullDownMenu { + MenuLabel { + text: qsTr("Default settings for %1 on this printer").arg(db.simplifyType(selectedFileType).translatable) + visible: printer.attrs.hasOwnProperty("printer-uuid") + } + MenuItem { text: qsTr("Clear default settings") visible: printer.attrs.hasOwnProperty("printer-uuid") onClicked: { - db.removeJobSettings(printer.attrs["printer-uuid"].value); + db.removeJobSettings(printer.attrs["printer-uuid"].value, selectedFileType); pageStack.pop(); } } @@ -59,9 +64,9 @@ Page { visible: printer.attrs.hasOwnProperty("printer-uuid") onClicked: { var tmp = jobParams; - // Support vries between formats and values varies between documents, would be confusing to save + // Support varies between formats and values varies between documents, would be confusing to save tmp["page-ranges"] = undefined; - db.setJobSettings(printer.attrs["printer-uuid"].value, JSON.stringify(tmp)) + db.setJobSettings(printer.attrs["printer-uuid"].value, selectedFileType, JSON.stringify(tmp)) } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 4740a8a..bad42be 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -111,6 +111,8 @@ void IppPrinter::refresh() { QJsonDocument JsonDocument = QJsonDocument::fromJson(file.readAll()); _attrs = JsonDocument.object(); + // These won't load anyway...r + _attrs.remove("printer-icons"); file.close(); } emit attrsChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 2289a0c..57bd014 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index c2427d8..d8a1b97 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 5e69025..4b8416f 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint-nl.ts b/translations/harbour-seaprint-nl.ts index aac7e5e..d771fa5 100644 --- a/translations/harbour-seaprint-nl.ts +++ b/translations/harbour-seaprint-nl.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts index 77dd5eb..cdc0c84 100644 --- a/translations/harbour-seaprint-pl.ts +++ b/translations/harbour-seaprint-pl.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 15395b4..c2d28d6 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 149e7b0..44a4275 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -450,6 +450,10 @@ Save default settings + + Default settings for %1 on this printer + + RangeSetting @@ -515,6 +519,17 @@ + + harbour-seaprint + + images + + + + documents + + + utils