summaryrefslogtreecommitdiffstats
path: root/src/printsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport')
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix.cpp14
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp26
-rw-r--r--src/printsupport/kernel/qcups.cpp2
-rw-r--r--src/printsupport/kernel/qprintengine_pdf.cpp6
-rw-r--r--src/printsupport/kernel/qprinter.cpp2
-rw-r--r--src/printsupport/widgets/qcupsjobwidget.cpp6
6 files changed, 29 insertions, 27 deletions
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index ab7a2edb67..78e5b8d1ef 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -533,10 +533,10 @@ void QPageSetupWidget::setupPrinter() const
{
m_printer->setPageLayout(m_pageLayout);
#if QT_CONFIG(cups)
- QCUPSSupport::PagesPerSheet pagesPerSheet = m_ui.pagesPerSheetCombo->currentData()
- .value<QCUPSSupport::PagesPerSheet>();
- QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentData()
- .value<QCUPSSupport::PagesPerSheetLayout>();
+ QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+);
+ QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = qvariant_cast<QCUPSSupport::PagesPerSheetLayout>(m_ui.pagesPerSheetLayoutCombo->currentData()
+);
QCUPSSupport::setPagesPerSheetLayout(m_printer, pagesPerSheet, pagesPerSheetLayout);
#endif
#ifdef PSD_ENABLE_PAPERSOURCE
@@ -587,11 +587,11 @@ void QPageSetupWidget::pageSizeChanged()
{
QPageSize pageSize;
if (m_ui.pageSizeCombo->currentIndex() != m_realCustomPageSizeIndex) {
- pageSize = m_ui.pageSizeCombo->currentData().value<QPageSize>();
+ pageSize = qvariant_cast<QPageSize>(m_ui.pageSizeCombo->currentData());
#if QT_CONFIG(cups)
if (m_pageSizePpdOption) {
- ppd_file_t *ppd = m_printDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_printDevice->property(PDPK_PpdFile));
QTextCodec *cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
for (int i = 0; i < m_pageSizePpdOption->num_choices; ++i) {
const ppd_choice_t *choice = &m_pageSizePpdOption->choices[i];
@@ -676,7 +676,7 @@ void QPageSetupWidget::unitChanged()
{
if (m_blockSignals)
return;
- m_units = m_ui.unitCombo->currentData().value<QPageLayout::Unit>();
+ m_units = qvariant_cast<QPageLayout::Unit>(m_ui.unitCombo->currentData());
m_pageLayout.setUnits(m_units);
updateWidget();
}
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index d929367557..bf77666c41 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -426,7 +426,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
{
bool anyWidgetCreated = false;
- ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_currentPrintDevice->property(PDPK_PpdFile));
if (ppd) {
m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
@@ -532,7 +532,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const
{
for (const QComboBox *choicesCb : m_advancedOptionsCombos) {
- const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>();
+ const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty));
// We can't use choicesCb->currentIndex() to know the index of the option in the choices[] array
// because some of them may not be present in the list because they conflict with the
@@ -551,7 +551,7 @@ void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const
void QPrintPropertiesDialog::revertAdvancedOptionsToSavedValues() const
{
for (QComboBox *choicesCb : m_advancedOptionsCombos) {
- const int originallySelectedChoice = choicesCb->property(ppdOriginallySelectedChoiceProperty).value<int>();
+ const int originallySelectedChoice = qvariant_cast<int>(choicesCb->property(ppdOriginallySelectedChoiceProperty));
const int newComboIndexToSelect = choicesCb->findData(originallySelectedChoice);
choicesCb->setCurrentIndex(newComboIndexToSelect);
// The currentIndexChanged lambda takes care of resetting the ppd option
@@ -580,8 +580,8 @@ bool QPrintPropertiesDialog::anyAdvancedOptionConflict() const
bool anyConflicted = false;
for (const QComboBox *choicesCb : m_advancedOptionsCombos) {
- const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>();
- QLabel *warningLabel = choicesCb->property(warningLabelProperty).value<QLabel *>();
+ const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty));
+ QLabel *warningLabel = qvariant_cast<QLabel *>(choicesCb->property(warningLabelProperty));
if (option->conflicted) {
anyConflicted = true;
const int pixmap_size = choicesCb->sizeHint().height() * .75;
@@ -637,8 +637,10 @@ void QPrintDialogPrivate::init()
options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
#else
- for (int i = options.pagesLayout->count() - 1; i >= 0; --i)
- delete options.pagesLayout->itemAt(i)->widget();
+ delete options.pagesRadioButton;
+ delete options.pagesLineEdit;
+ options.pagesRadioButton = nullptr;
+ options.pagesLineEdit = nullptr;
#endif
top->d->setOptionsPane(this);
@@ -727,12 +729,12 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
else
options.pageSetCombo->setEnabled(true);
+#if QT_CONFIG(cups)
// Disable complex page ranges widget when printing to pdf
// It doesn't work since it relies on cups to do the heavy lifting and cups
// is not used when printing to PDF
options.pagesRadioButton->setEnabled(outputFormat != QPrinter::PdfFormat);
-#if QT_CONFIG(cups)
// Disable color options on main dialog if not printing to file, it will be handled by CUPS advanced dialog
options.colorMode->setVisible(outputFormat == QPrinter::PdfFormat);
#endif
@@ -900,7 +902,7 @@ void QPrintDialogPrivate::setupPrinter()
// page set
if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
//If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly
- QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>();
+ QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()));
if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
&& p->printRange() == QPrinter::PageRange
&& (q->fromPage() % 2 == 0)) {
@@ -1323,10 +1325,10 @@ bool QUnixPrintWidgetPrivate::checkFields()
#if QT_CONFIG(cups)
if (propertiesDialog) {
- QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
- ->currentData().value<QCUPSSupport::PagesPerSheet>();
+ QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
+ ->currentData());
- QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>();
+ QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(optionsPane->options.pageSetCombo->currentData());
if (pagesPerSheet != QCUPSSupport::OnePagePerSheet
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 2fc4621960..0fc8cdd1b7 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -149,7 +149,7 @@ QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString
ppd_option_t *QCUPSSupport::findPpdOption(const char *optionName, QPrintDevice *printDevice)
{
- ppd_file_t *ppd = printDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(printDevice->property(PDPK_PpdFile));
if (ppd) {
for (int i = 0; i < ppd->num_groups; ++i) {
diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp
index 3c24e5ac69..7f1c20916b 100644
--- a/src/printsupport/kernel/qprintengine_pdf.cpp
+++ b/src/printsupport/kernel/qprintengine_pdf.cpp
@@ -217,19 +217,19 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
break;
}
case PPK_QPageSize: {
- QPageSize pageSize = value.value<QPageSize>();
+ QPageSize pageSize = qvariant_cast<QPageSize>(value);
if (pageSize.isValid())
d->m_pageLayout.setPageSize(pageSize);
break;
}
case PPK_QPageMargins: {
- QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >();
+ QPair<QMarginsF, QPageLayout::Unit> pair = qvariant_cast<QPair<QMarginsF, QPageLayout::Unit> >(value);
d->m_pageLayout.setUnits(pair.second);
d->m_pageLayout.setMargins(pair.first);
break;
}
case PPK_QPageLayout: {
- QPageLayout pageLayout = value.value<QPageLayout>();
+ QPageLayout pageLayout = qvariant_cast<QPageLayout>(value);
if (pageLayout.isValid())
d->m_pageLayout = pageLayout;
break;
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index ddcd8c4702..fbf5e5c2ba 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -294,7 +294,7 @@ public:
{
QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
- return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
+ return qvariant_cast<QPageLayout>(pd->printEngine->property(QPrintEngine::PPK_QPageLayout));
}
QPrinter *m_printer;
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index dcdb933f73..456ed9db19 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -150,7 +150,7 @@ void QCupsJobWidget::setJobHold(QCUPSSupport::JobHoldUntil jobHold, const QTime
QCUPSSupport::JobHoldUntil QCupsJobWidget::jobHold() const
{
- return m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex()).value<QCUPSSupport::JobHoldUntil>();
+ return qvariant_cast<QCUPSSupport::JobHoldUntil>(m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex()));
}
void QCupsJobWidget::toggleJobHoldTime()
@@ -247,7 +247,7 @@ void QCupsJobWidget::setStartBannerPage(const QCUPSSupport::BannerPage bannerPag
QCUPSSupport::BannerPage QCupsJobWidget::startBannerPage() const
{
- return m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>();
+ return qvariant_cast<QCUPSSupport::BannerPage>(m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()));
}
void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage)
@@ -257,7 +257,7 @@ void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage)
QCUPSSupport::BannerPage QCupsJobWidget::endBannerPage() const
{
- return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>();
+ return qvariant_cast<QCUPSSupport::BannerPage>(m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()));
}
QT_END_NAMESPACE