Don't send margins when effecting them locally
This commit is contained in:
parent
ef3b53abdb
commit
e16bfbe7c6
2 changed files with 35 additions and 8 deletions
|
@ -196,6 +196,7 @@ Page {
|
||||||
name: "media-top-margin"
|
name: "media-top-margin"
|
||||||
subkey: "media-col"
|
subkey: "media-col"
|
||||||
prettyName: qsTr("Top")
|
prettyName: qsTr("Top")
|
||||||
|
valid: _valid && Mimer.isImage(selectedFileType)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
visible: marginsButton.active
|
visible: marginsButton.active
|
||||||
|
@ -203,6 +204,7 @@ Page {
|
||||||
name: "media-bottom-margin"
|
name: "media-bottom-margin"
|
||||||
subkey: "media-col"
|
subkey: "media-col"
|
||||||
prettyName: qsTr("Bottom")
|
prettyName: qsTr("Bottom")
|
||||||
|
valid: _valid && Mimer.isImage(selectedFileType)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
visible: marginsButton.active
|
visible: marginsButton.active
|
||||||
|
@ -210,6 +212,7 @@ Page {
|
||||||
name: "media-left-margin"
|
name: "media-left-margin"
|
||||||
subkey: "media-col"
|
subkey: "media-col"
|
||||||
prettyName: qsTr("Left")
|
prettyName: qsTr("Left")
|
||||||
|
valid: _valid && Mimer.isImage(selectedFileType)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
visible: marginsButton.active
|
visible: marginsButton.active
|
||||||
|
@ -217,6 +220,7 @@ Page {
|
||||||
name: "media-right-margin"
|
name: "media-right-margin"
|
||||||
subkey: "media-col"
|
subkey: "media-col"
|
||||||
prettyName: qsTr("Right")
|
prettyName: qsTr("Right")
|
||||||
|
valid: _valid && Mimer.isImage(selectedFileType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,6 +542,37 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
|
||||||
|
|
||||||
QString PaperSize = getAttrOrDefault(jobAttrs, "media").toString();
|
QString PaperSize = getAttrOrDefault(jobAttrs, "media").toString();
|
||||||
|
|
||||||
|
QString documentFormat = getAttrOrDefault(jobAttrs, "document-format").toString();
|
||||||
|
qDebug() << "target format:" << documentFormat;
|
||||||
|
|
||||||
|
QMargins margins(getAttrOrDefault(jobAttrs, "media-left-margin", "media-col").toInt(),
|
||||||
|
getAttrOrDefault(jobAttrs, "media-top-margin", "media-col").toInt(),
|
||||||
|
getAttrOrDefault(jobAttrs, "media-right-margin", "media-col").toInt(),
|
||||||
|
getAttrOrDefault(jobAttrs, "media-bottom-margin", "media-col").toInt());
|
||||||
|
|
||||||
|
// Only keep margin setting for JPEG - but only attemt to remove it if media-col exists
|
||||||
|
if(!(mimeType == Mimer::JPEG && documentFormat == Mimer::JPEG) && jobAttrs.contains("media-col"))
|
||||||
|
{
|
||||||
|
QJsonObject MediaCol = jobAttrs["media-col"].toObject();
|
||||||
|
QJsonObject MediaColValue = MediaCol["value"].toObject();
|
||||||
|
|
||||||
|
MediaColValue.remove("media-left-margin");
|
||||||
|
MediaColValue.remove("media-top-margin");
|
||||||
|
MediaColValue.remove("media-right-margin");
|
||||||
|
MediaColValue.remove("media-bottom-margin");
|
||||||
|
|
||||||
|
if(!MediaColValue.empty())
|
||||||
|
{
|
||||||
|
MediaCol["value"] = MediaColValue;
|
||||||
|
jobAttrs["media-col"] = MediaCol;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jobAttrs.remove("media-col");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(jobAttrs.contains("media-col") && jobAttrs.contains("media"))
|
if(jobAttrs.contains("media-col") && jobAttrs.contains("media"))
|
||||||
{
|
{
|
||||||
qDebug() << "moving media to media-col" << PaperSize;
|
qDebug() << "moving media to media-col" << PaperSize;
|
||||||
|
@ -571,9 +602,6 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
|
||||||
jobAttrs.remove("media");
|
jobAttrs.remove("media");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString documentFormat = getAttrOrDefault(jobAttrs, "document-format").toString();
|
|
||||||
qDebug() << "target format:" << documentFormat;
|
|
||||||
|
|
||||||
// document-format goes in the op-attrs and not the job-attrs
|
// document-format goes in the op-attrs and not the job-attrs
|
||||||
o.insert("document-format", QJsonObject {{"tag", IppMsg::MimeMediaType}, {"value", documentFormat}});
|
o.insert("document-format", QJsonObject {{"tag", IppMsg::MimeMediaType}, {"value", documentFormat}});
|
||||||
jobAttrs.remove("document-format");
|
jobAttrs.remove("document-format");
|
||||||
|
@ -671,11 +699,6 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
|
||||||
}
|
}
|
||||||
else if (Mimer::isImage(mimeType))
|
else if (Mimer::isImage(mimeType))
|
||||||
{
|
{
|
||||||
QMargins margins(getAttrOrDefault(jobAttrs, "media-left-margin", "media-col").toInt(),
|
|
||||||
getAttrOrDefault(jobAttrs, "media-top-margin", "media-col").toInt(),
|
|
||||||
getAttrOrDefault(jobAttrs, "media-right-margin", "media-col").toInt(),
|
|
||||||
getAttrOrDefault(jobAttrs, "media-bottom-margin", "media-col").toInt());
|
|
||||||
|
|
||||||
emit doConvertImage(filename, contents, documentFormat, Colors, Quality,
|
emit doConvertImage(filename, contents, documentFormat, Colors, Quality,
|
||||||
PaperSize, HwResX, HwResY, margins);
|
PaperSize, HwResX, HwResY, margins);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue