Skip to content
Browse files

Reverse printing option

  • Loading branch information...
1 parent 8d93732 commit 1ca74c1d6225c9c9dfc96eb86be7dd7661da0fcf @SokoloffA SokoloffA committed Feb 11, 2013
View
14 gui/kernel/printer.cpp
@@ -115,6 +115,7 @@ void Printer::init()
mDeviceUri = "";
mDuplex = false;
+ mReverseOrder = false;
mPaperSize = QSizeF(A4_WIDTH_PT, A4_HEIGHT_PT);
mLeftMargin = 0;
mRightMargin = 0;
@@ -198,6 +199,8 @@ void Printer::readSettings()
{
mDuplex = settings->printerDuplex(mPrinterInfo.printerName(), mDuplex);
mDrawBorder = settings->printerBorder(mPrinterInfo.printerName(), mDrawBorder);
+ mReverseOrder = settings->printerReverseOrder(mPrinterInfo.printerName(), mReverseOrder);
+
mLeftMargin = settings->printerMargin(mPrinterInfo.printerName(), "Left", mLeftMargin);
mRightMargin = settings->printerMargin(mPrinterInfo.printerName(), "Right", mRightMargin);
mTopMargin = settings->printerMargin(mPrinterInfo.printerName(), "Top", mTopMargin);
@@ -213,6 +216,8 @@ void Printer::saveSettings()
{
settings->setPrinterDuplex(mPrinterInfo.printerName(), mDuplex);
settings->setPrinterBorder(mPrinterInfo.printerName(), mDrawBorder);
+ settings->setPrinterReverseOrder(mPrinterInfo.printerName(), mReverseOrder);
+
settings->setPrinterMargin(mPrinterInfo.printerName(), "Left", mLeftMargin);
settings->setPrinterMargin(mPrinterInfo.printerName(), "Right", mRightMargin);
settings->setPrinterMargin(mPrinterInfo.printerName(), "Top", mTopMargin);
@@ -383,6 +388,15 @@ void Printer::setDuplex(bool duplex)
/************************************************
************************************************/
+void Printer::setReverseOrder(bool value)
+{
+ mReverseOrder = value;
+}
+
+
+/************************************************
+
+ ************************************************/
void Printer::print(const QString &fileName, const QString &jobName, int numCopies)
{
QStringList args;
View
4 gui/kernel/printer.h
@@ -86,6 +86,9 @@ class Printer
bool duplex() const { return mDuplex; }
void setDuplex(bool duplex);
+ bool reverseOrder() const { return mReverseOrder; }
+ void setReverseOrder(bool value);
+
void print(const QString &fileName, const QString &jobName, int numCopies);
QString deviceUri() const { return mDeviceUri; }
@@ -103,6 +106,7 @@ class Printer
qreal mInternalMargin;
bool mDuplex;
bool mDrawBorder;
+ bool mReverseOrder;
void init();
void initFromCups();
View
2 gui/kernel/psproject.cpp
@@ -228,7 +228,7 @@ void PsProject::writeDocument(PsProject::PagesType pages, PsProject::PagesOrder
}
else
{
- for (int i=end; i >=start; i -= inc)
+ for (int i=end-1; i >=start; i -= inc)
sheets << mSheets.at(i);
}
View
6 gui/mainwindow.cpp
@@ -444,7 +444,8 @@ void MainWindow::print()
return;
QTextStream stream(file);
- mProject->writeDocument(PsProject::AllPages, &stream);
+ PsProject::PagesOrder order = (mProject->printer()->reverseOrder() ? PsProject::BackOrder : PsProject::ForwardOrder);
+ mProject->writeDocument(PsProject::AllPages, order, &stream);
file->close();
mProject->printer()->print(file->fileName(), "", 1);
@@ -459,7 +460,8 @@ void MainWindow::print()
return;
QTextStream stream(file);
- mProject->writeDocument(PsProject::OddPages, &stream);
+ PsProject::PagesOrder order = (mProject->printer()->reverseOrder() ? PsProject::BackOrder : PsProject::ForwardOrder);
+ mProject->writeDocument(PsProject::OddPages, order, &stream);
file->close();
mProject->printer()->print(file->fileName(), "", 1);
View
2 gui/printersettings/printersettings.cpp
@@ -136,6 +136,7 @@ void PrinterSettings::updateWidgets()
{
ui->duplexCbx->setChecked(mPrinter->duplex());
ui->borderCbx->setChecked(mPrinter->drawBorder());
+ ui->reverseOrderCbx->setChecked(mPrinter->reverseOrder());
ui->leftMarginSpin->setValue(mPrinter->leftMargin(mUnit));
ui->rightMarginSpin->setValue(mPrinter->rightMargin(mUnit));
@@ -161,6 +162,7 @@ void PrinterSettings::btnClicked(QAbstractButton *button)
mPrinter->setDuplex(ui->duplexCbx->isChecked());
mPrinter->setDrawBorder(ui->borderCbx->isChecked());
+ mPrinter->setReverseOrder(ui->reverseOrderCbx->isChecked());
if (ui->buttonBox->standardButton(button) == QDialogButtonBox::Ok)
close();
View
13 gui/printersettings/printersettings.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>358</width>
- <height>277</height>
+ <height>302</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -111,14 +111,14 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QCheckBox" name="borderCbx">
<property name="text">
<string>Draw border</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -131,6 +131,13 @@
</property>
</spacer>
</item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="reverseOrderCbx">
+ <property name="text">
+ <string>Print in reverse order</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
View
20 gui/settings.cpp
@@ -179,7 +179,25 @@ bool Settings::printerBorder(const QString &printerName, bool defaultValue)
************************************************/
void Settings::setPrinterBorder(const QString &printerName, bool value)
{
- mSettings.setValue(printersKey(printerName, "Border") , value);
+ mSettings.setValue(printersKey(printerName, "Border") , value);
+}
+
+
+/************************************************
+
+ ************************************************/
+bool Settings::printerReverseOrder(const QString &printerName, bool defaultValue)
+{
+ return mSettings.value(printersKey(printerName, "ReverseOrder"), defaultValue).toBool();
+}
+
+
+/************************************************
+
+ ************************************************/
+void Settings::setPrinterReverseOrder(const QString &printerName, bool value)
+{
+ mSettings.setValue(printersKey(printerName, "ReverseOrder") , value);
}
View
3 gui/settings.h
@@ -54,6 +54,9 @@ class Settings
bool printerBorder(const QString &printerName, bool defaultValue);
void setPrinterBorder(const QString &printerName, bool value);
+ bool printerReverseOrder(const QString &printerName, bool defaultValue);
+ void setPrinterReverseOrder(const QString &printerName, bool value);
+
QSize printerPageSize(const QString &printerName, QSize defaultValue);
void setPrinterPageSize(const QString &printerName, QSize value);

0 comments on commit 1ca74c1

Please sign in to comment.
Something went wrong with that request. Please try again.