diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2020-04-30 14:23:40 +0200 |
|---|---|---|
| committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-14 07:51:11 +0200 |
| commit | 666b4a485b3ea87842fb475ce8520d2856d821c7 (patch) | |
| tree | 04cff77c6fb0e0a00f71c1b4201997988b1c7fa0 /src/printsupport/dialogs/qpagesetupdialog_unix.cpp | |
| parent | 02980cd01d86344720e7e65862b61cc781d51e95 (diff) | |
Get rid of QTextCodec in the cups support
This should all be utf-8 anyway, but right now simply exchange the
text codec with a string converter.
Change-Id: If0a230776824598b6378bb402d692c941e371104
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/printsupport/dialogs/qpagesetupdialog_unix.cpp')
| -rw-r--r-- | src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index 2b7c0ce6ec0..8142e57c5a9 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -49,7 +49,7 @@ #include "qpainter.h" #include "qprintdialog.h" -#include "qtextcodec.h" +#include "qstringconverter.h" #include "qdialogbuttonbox.h" #include <ui_qpagesetupwidget.h> @@ -592,10 +592,14 @@ void QPageSetupWidget::pageSizeChanged() #if QT_CONFIG(cups) if (m_pageSizePpdOption) { ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_printDevice->property(PDPK_PpdFile)); - QTextCodec *cupsCodec = QTextCodec::codecForName(ppd->lang_encoding); + QStringDecoder toUtf16(ppd->lang_encoding, QStringDecoder::Flag::Stateless); + if (!toUtf16.isValid()) { + qWarning() << "QPrinSupport: Cups uses unsupported encoding" << ppd->lang_encoding; + toUtf16 = QStringDecoder(QStringDecoder::Utf8); + } for (int i = 0; i < m_pageSizePpdOption->num_choices; ++i) { const ppd_choice_t *choice = &m_pageSizePpdOption->choices[i]; - if (cupsCodec->toUnicode(choice->text) == m_ui.pageSizeCombo->currentText()) { + if (toUtf16(choice->text) == m_ui.pageSizeCombo->currentText()) { const auto values = QStringList{} << QString::fromLatin1(m_pageSizePpdOption->keyword) << QString::fromLatin1(choice->choice); m_printDevice->setProperty(PDPK_PpdOption, values); |
