Save settings per document type
This commit is contained in:
parent
80d5783620
commit
576f6a616f
11 changed files with 140 additions and 11 deletions
|
@ -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] );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
|
@ -450,6 +450,10 @@
|
|||
<source>Save default settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default settings for %1 on this printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RangeSetting</name>
|
||||
|
@ -515,6 +519,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>harbour-seaprint</name>
|
||||
<message>
|
||||
<source>images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>documents</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>utils</name>
|
||||
<message>
|
||||
|
|
Loading…
Reference in a new issue