Expose more CUPS options via the 'Properties' dialog
On systems with CUPS support users can now choose how many pages from a document are to be printed on paper. This can vary from 1 page per document to 16 pages per document. The page preview changes upon the users selection. Also included in the patch is an option to choose the flow for text. Users can now print documents in the "Right to Left" order or "Bottom to Top", including many other options. [ChangeLog][QtPrintSupport][QPrintDialog] Added support for setting CUPS Pages Per Sheet and Pages Per Sheet Layout options Change-Id: I4e60a4523c6e06d4c15fe9ee9590248fa7ae2038 Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
parent
438912f273
commit
00e50fb97c
@ -158,6 +158,13 @@ public:
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPagePreviewLayout(int columns, int rows)
|
||||||
|
{
|
||||||
|
m_pagePreviewColumns = columns;
|
||||||
|
m_pagePreviewRows = rows;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *)
|
void paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
@ -202,13 +209,27 @@ protected:
|
|||||||
QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."));
|
QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."));
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
text += text;
|
text += text;
|
||||||
p.drawText(marginRect, Qt::TextWordWrap|Qt::AlignVCenter, text);
|
|
||||||
|
const int spacing = pageRect.width() * 0.1;
|
||||||
|
const int textWidth = (marginRect.width() - (spacing * (m_pagePreviewColumns-1))) / m_pagePreviewColumns;
|
||||||
|
const int textHeight = (marginRect.height() - (spacing * (m_pagePreviewRows-1))) / m_pagePreviewRows;
|
||||||
|
|
||||||
|
for (int x = 0 ; x < m_pagePreviewColumns; ++x) {
|
||||||
|
for (int y = 0 ; y < m_pagePreviewRows; ++y) {
|
||||||
|
QRect textRect(marginRect.left() + x * (textWidth + spacing),
|
||||||
|
marginRect.top() + y * (textHeight + spacing),
|
||||||
|
textWidth, textHeight);
|
||||||
|
p.drawText(textRect, Qt::TextWordWrap|Qt::AlignVCenter, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// all these are in points
|
// all these are in points
|
||||||
qreal m_left, m_top, m_right, m_bottom;
|
qreal m_left, m_top, m_right, m_bottom;
|
||||||
|
// specify width / height of one page in preview
|
||||||
|
int m_pagePreviewColumns, m_pagePreviewRows;
|
||||||
QSizeF m_size;
|
QSizeF m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,6 +293,8 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
|
|||||||
QVBoxLayout *lay = new QVBoxLayout(widget.preview);
|
QVBoxLayout *lay = new QVBoxLayout(widget.preview);
|
||||||
widget.preview->setLayout(lay);
|
widget.preview->setLayout(lay);
|
||||||
m_pagePreview = new QPagePreview(widget.preview);
|
m_pagePreview = new QPagePreview(widget.preview);
|
||||||
|
m_pagePreview->setPagePreviewLayout(1, 1);
|
||||||
|
|
||||||
lay->addWidget(m_pagePreview);
|
lay->addWidget(m_pagePreview);
|
||||||
|
|
||||||
setAttribute(Qt::WA_WState_Polished, false);
|
setAttribute(Qt::WA_WState_Polished, false);
|
||||||
@ -288,7 +311,7 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
|
|||||||
widget.reversePortrait->setVisible(false);
|
widget.reversePortrait->setVisible(false);
|
||||||
|
|
||||||
populatePaperSizes(widget.paperSize);
|
populatePaperSizes(widget.paperSize);
|
||||||
|
initPagesPerSheet();
|
||||||
QStringList units;
|
QStringList units;
|
||||||
units << tr("Centimeters (cm)") << tr("Millimeters (mm)") << tr("Inches (in)") << tr("Points (pt)");
|
units << tr("Centimeters (cm)") << tr("Millimeters (mm)") << tr("Inches (in)") << tr("Points (pt)");
|
||||||
widget.unit->addItems(units);
|
widget.unit->addItems(units);
|
||||||
@ -306,6 +329,8 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
|
|||||||
|
|
||||||
connect(widget.portrait, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
|
connect(widget.portrait, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
|
||||||
connect(widget.landscape, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
|
connect(widget.landscape, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
|
||||||
|
connect(widget.pagesPerSheetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(_q_pagesPerSheetChanged()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPageSetupWidget::setPrinter(QPrinter *printer)
|
void QPageSetupWidget::setPrinter(QPrinter *printer)
|
||||||
@ -366,6 +391,14 @@ void QPageSetupWidget::setupPrinter() const
|
|||||||
#endif
|
#endif
|
||||||
m_printer->setPageMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin, QPrinter::Point);
|
m_printer->setPageMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin, QPrinter::Point);
|
||||||
|
|
||||||
|
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||||
|
QCUPSSupport::PagesPerSheet pagesPerSheet = widget.pagesPerSheetCombo->currentData()
|
||||||
|
.value<QCUPSSupport::PagesPerSheet>();
|
||||||
|
QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = widget.pagesPerSheetLayoutCombo->currentData()
|
||||||
|
.value<QCUPSSupport::PagesPerSheetLayout>();
|
||||||
|
|
||||||
|
QCUPSSupport::setPagesPerSheetLayout(m_printer, pagesPerSheet, pagesPerSheetLayout);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPageSetupWidget::selectPrinter()
|
void QPageSetupWidget::selectPrinter()
|
||||||
@ -500,6 +533,36 @@ void QPageSetupWidget::_q_pageOrientationChanged()
|
|||||||
_q_paperSizeChanged();
|
_q_paperSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QPageSetupWidget::_q_pagesPerSheetChanged()
|
||||||
|
{
|
||||||
|
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||||
|
QCUPSSupport::PagesPerSheet pagesPerSheet = widget.pagesPerSheetCombo->currentData()
|
||||||
|
.value<QCUPSSupport::PagesPerSheet>();
|
||||||
|
|
||||||
|
switch (pagesPerSheet) {
|
||||||
|
case QCUPSSupport::TwoPagesPerSheet:
|
||||||
|
m_pagePreview->setPagePreviewLayout(1, 2);
|
||||||
|
break;
|
||||||
|
case QCUPSSupport::FourPagesPerSheet:
|
||||||
|
m_pagePreview->setPagePreviewLayout(2, 2);
|
||||||
|
break;
|
||||||
|
case QCUPSSupport::SixPagesPerSheet:
|
||||||
|
m_pagePreview->setPagePreviewLayout(3, 2);
|
||||||
|
break;
|
||||||
|
case QCUPSSupport::NinePagesPerSheet:
|
||||||
|
m_pagePreview->setPagePreviewLayout(3, 3);
|
||||||
|
break;
|
||||||
|
case QCUPSSupport::SixteenPagesPerSheet:
|
||||||
|
m_pagePreview->setPagePreviewLayout(4, 4);
|
||||||
|
break;
|
||||||
|
case QCUPSSupport::OnePagePerSheet:
|
||||||
|
default:
|
||||||
|
m_pagePreview->setPagePreviewLayout(1, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution);
|
extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution);
|
||||||
|
|
||||||
void QPageSetupWidget::unitChanged(int item)
|
void QPageSetupWidget::unitChanged(int item)
|
||||||
@ -598,6 +661,34 @@ int QPageSetupDialog::exec()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QPageSetupWidget::initPagesPerSheet()
|
||||||
|
{
|
||||||
|
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Left to Right, Top to Bottom"), QVariant::fromValue(QCUPSSupport::LeftToRightTopToBottom));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Left to Right, Bottom to Top"), QVariant::fromValue(QCUPSSupport::LeftToRightBottomToTop));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Right to Left, Bottom to Top"), QVariant::fromValue(QCUPSSupport::RightToLeftBottomToTop));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Right to Left, Top to Bottom"), QVariant::fromValue(QCUPSSupport::RightToLeftTopToBottom));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Bottom to Top, Left to Right"), QVariant::fromValue(QCUPSSupport::BottomToTopLeftToRight));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Bottom to Top, Right to Left"), QVariant::fromValue(QCUPSSupport::BottomToTopRightToLeft));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Top to Bottom, Left to Right"), QVariant::fromValue(QCUPSSupport::TopToBottomLeftToRight));
|
||||||
|
widget.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr("Top to Bottom, Right to Left"), QVariant::fromValue(QCUPSSupport::TopToBottomRightToLeft));
|
||||||
|
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("1 (1x1)"), QVariant::fromValue(QCUPSSupport::OnePagePerSheet));
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("2 (2x1)"), QVariant::fromValue(QCUPSSupport::TwoPagesPerSheet));
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("4 (2x2)"), QVariant::fromValue(QCUPSSupport::FourPagesPerSheet));
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("6 (2x3)"), QVariant::fromValue(QCUPSSupport::SixPagesPerSheet));
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("9 (3x3)"), QVariant::fromValue(QCUPSSupport::NinePagesPerSheet));
|
||||||
|
widget.pagesPerSheetCombo->addItem(QPrintDialog::tr("16 (4x4)"), QVariant::fromValue(QCUPSSupport::SixteenPagesPerSheet));
|
||||||
|
|
||||||
|
// Set the combo to "1 (1x1)" -- QCUPSSupport::OnePagePerSheet
|
||||||
|
widget.pagesPerSheetCombo->setCurrentIndex(0);
|
||||||
|
// Set the layout combo to QCUPSSupport::LeftToRightTopToBottom
|
||||||
|
widget.pagesPerSheetLayoutCombo->setCurrentIndex(0);
|
||||||
|
#else
|
||||||
|
// Disable if CUPS wasn't found
|
||||||
|
widget.pagesPerSheetButtonGroup->hide();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
class QPagePreview;
|
class QPagePreview;
|
||||||
class QCUPSSupport;
|
|
||||||
|
|
||||||
class QPageSetupWidget : public QWidget {
|
class QPageSetupWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -79,6 +78,7 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void _q_pageOrientationChanged();
|
void _q_pageOrientationChanged();
|
||||||
void _q_paperSizeChanged();
|
void _q_paperSizeChanged();
|
||||||
|
void _q_pagesPerSheetChanged();
|
||||||
void unitChanged(int item);
|
void unitChanged(int item);
|
||||||
void setTopMargin(double newValue);
|
void setTopMargin(double newValue);
|
||||||
void setBottomMargin(double newValue);
|
void setBottomMargin(double newValue);
|
||||||
@ -86,6 +86,7 @@ private slots:
|
|||||||
void setRightMargin(double newValue);
|
void setRightMargin(double newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class QUnixPrintWidgetPrivate;
|
||||||
Ui::QPageSetupWidget widget;
|
Ui::QPageSetupWidget widget;
|
||||||
QPagePreview *m_pagePreview;
|
QPagePreview *m_pagePreview;
|
||||||
QPrinter *m_printer;
|
QPrinter *m_printer;
|
||||||
@ -97,6 +98,8 @@ private:
|
|||||||
qreal m_currentMultiplier;
|
qreal m_currentMultiplier;
|
||||||
bool m_blockSignals;
|
bool m_blockSignals;
|
||||||
bool m_cups;
|
bool m_cups;
|
||||||
|
|
||||||
|
void initPagesPerSheet();
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>416</width>
|
<width>416</width>
|
||||||
<height>488</height>
|
<height>515</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -16,38 +16,18 @@
|
|||||||
<property name="margin" >
|
<property name="margin" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" colspan="2" >
|
<item row="1" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4" >
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<item>
|
<property name="title">
|
||||||
<widget class="QComboBox" name="unit" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="2" >
|
|
||||||
<widget class="QGroupBox" name="groupBox_2" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Paper</string>
|
<string>Paper</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2" >
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="pageSizeLabel" >
|
<widget class="QLabel" name="pageSizeLabel">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Page size:</string>
|
<string>Page size:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>paperSize</cstring>
|
<cstring>paperSize</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -122,9 +102,32 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="groupBox_3" >
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="title" >
|
<item>
|
||||||
|
<widget class="QComboBox" name="unit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" rowspan="2">
|
||||||
|
<widget class="QWidget" name="preview" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
<string>Orientation</string>
|
<string>Orientation</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
@ -175,12 +178,9 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item rowspan="2" row="2" column="1" >
|
<item row="3" column="0">
|
||||||
<widget class="QWidget" native="1" name="preview" />
|
<widget class="QGroupBox" name="groupBox">
|
||||||
</item>
|
<property name="title">
|
||||||
<item row="3" column="0" >
|
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Margins</string>
|
<string>Margins</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" >
|
<layout class="QHBoxLayout" name="horizontalLayout_2" >
|
||||||
@ -280,9 +280,25 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="0" column="2">
|
||||||
<widget class="QDoubleSpinBox" name="bottomMargin" >
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="toolTip" >
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="bottomMargin">
|
||||||
|
<property name="toolTip">
|
||||||
<string>bottom margin</string>
|
<string>bottom margin</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="accessibleName" >
|
<property name="accessibleName" >
|
||||||
@ -296,28 +312,15 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" >
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_2" >
|
<spacer name="horizontalSpacer_5">
|
||||||
<property name="orientation" >
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<spacer name="horizontalSpacer_5" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType" >
|
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0" >
|
<property name="sizeHint" stdset="0" >
|
||||||
@ -333,15 +336,57 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" >
|
<item row="5" column="0" colspan="2">
|
||||||
<spacer name="verticalSpacer" >
|
<widget class="QGroupBox" name="pagesPerSheetButtonGroup">
|
||||||
<property name="orientation" >
|
<property name="title">
|
||||||
|
<string>Page Layout</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="pagesPerSheetCombo"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Page order:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="pagesPerSheetLayoutCombo"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pages per sheet:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>0</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -126,6 +126,7 @@ protected:
|
|||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class QUnixPrintWidgetPrivate;
|
||||||
Ui::QPrintPropertiesWidget widget;
|
Ui::QPrintPropertiesWidget widget;
|
||||||
QDialogButtonBox *m_buttons;
|
QDialogButtonBox *m_buttons;
|
||||||
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||||
@ -862,6 +863,20 @@ bool QUnixPrintWidgetPrivate::checkFields()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||||
|
QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->widget.pagesPerSheetCombo->currentData().value<QCUPSSupport::PagesPerSheet>();
|
||||||
|
|
||||||
|
QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>();
|
||||||
|
|
||||||
|
if (propertiesDialogShown
|
||||||
|
&& pagesPerSheet != QCUPSSupport::OnePagePerSheet
|
||||||
|
&& pageSet != QCUPSSupport::AllPages) {
|
||||||
|
QMessageBox::warning(q, q->windowTitle(),
|
||||||
|
QPrintDialog::tr("Options 'Pages Per Sheet' and 'Page Set' cannot be used together.\nPlease turn one of those options off."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Every test passed. Accept the dialog.
|
// Every test passed. Accept the dialog.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -511,6 +511,17 @@ void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet)
|
|||||||
setCupsOptions(printer, cupsOptions);
|
setCupsOptions(printer, cupsOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
|
||||||
|
const PagesPerSheetLayout pagesPerSheetLayout)
|
||||||
|
{
|
||||||
|
QStringList cupsOptions = cupsOptionsList(printer);
|
||||||
|
static const char *pagesPerSheetData[] = { "1", "2", "4", "6", "9", "16", 0 };
|
||||||
|
static const char *pageLayoutData[] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl", 0};
|
||||||
|
setCupsOption(cupsOptions, QStringLiteral("number-up"), pagesPerSheetData[pagesPerSheet]);
|
||||||
|
setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), pageLayoutData[pagesPerSheetLayout]);
|
||||||
|
setCupsOptions(printer, cupsOptions);
|
||||||
|
}
|
||||||
|
|
||||||
bool QCUPSSupport::printerHasPPD(const char *printerName)
|
bool QCUPSSupport::printerHasPPD(const char *printerName)
|
||||||
{
|
{
|
||||||
if (!isAvailable())
|
if (!isAvailable())
|
||||||
|
@ -121,6 +121,28 @@ public:
|
|||||||
EvenPages
|
EvenPages
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Enum for valid number of pages per sheet
|
||||||
|
enum PagesPerSheet {
|
||||||
|
OnePagePerSheet = 0,
|
||||||
|
TwoPagesPerSheet,
|
||||||
|
FourPagesPerSheet,
|
||||||
|
SixPagesPerSheet,
|
||||||
|
NinePagesPerSheet,
|
||||||
|
SixteenPagesPerSheet
|
||||||
|
};
|
||||||
|
|
||||||
|
// Enum for valid layouts of pages per sheet
|
||||||
|
enum PagesPerSheetLayout {
|
||||||
|
LeftToRightTopToBottom = 0,
|
||||||
|
LeftToRightBottomToTop,
|
||||||
|
RightToLeftTopToBottom,
|
||||||
|
RightToLeftBottomToTop,
|
||||||
|
BottomToTopLeftToRight,
|
||||||
|
BottomToTopRightToLeft,
|
||||||
|
TopToBottomLeftToRight,
|
||||||
|
TopToBottomRightToLeft
|
||||||
|
};
|
||||||
|
|
||||||
static bool isAvailable();
|
static bool isAvailable();
|
||||||
static int cupsVersion() { return isAvailable() ? CUPS_VERSION_MAJOR*10000+CUPS_VERSION_MINOR*100+CUPS_VERSION_PATCH : 0; }
|
static int cupsVersion() { return isAvailable() ? CUPS_VERSION_MAJOR*10000+CUPS_VERSION_MINOR*100+CUPS_VERSION_PATCH : 0; }
|
||||||
int availablePrintersCount() const;
|
int availablePrintersCount() const;
|
||||||
@ -151,6 +173,8 @@ public:
|
|||||||
static void setJobPriority(QPrinter *printer, int priority = 50);
|
static void setJobPriority(QPrinter *printer, int priority = 50);
|
||||||
static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
|
static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
|
||||||
static void setPageSet(QPrinter *printer, const PageSet pageSet);
|
static void setPageSet(QPrinter *printer, const PageSet pageSet);
|
||||||
|
static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
|
||||||
|
const PagesPerSheetLayout pagesPerSheetLayout);
|
||||||
|
|
||||||
static bool printerHasPPD(const char *printerName);
|
static bool printerHasPPD(const char *printerName);
|
||||||
|
|
||||||
@ -183,6 +207,8 @@ QT_END_NAMESPACE
|
|||||||
Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil)
|
Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil)
|
||||||
Q_DECLARE_METATYPE(QCUPSSupport::BannerPage)
|
Q_DECLARE_METATYPE(QCUPSSupport::BannerPage)
|
||||||
Q_DECLARE_METATYPE(QCUPSSupport::PageSet)
|
Q_DECLARE_METATYPE(QCUPSSupport::PageSet)
|
||||||
|
Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheetLayout)
|
||||||
|
Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheet)
|
||||||
|
|
||||||
#endif // QT_NO_CUPS
|
#endif // QT_NO_CUPS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user