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>
This commit is contained in:
parent
02980cd01d
commit
666b4a485b
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#include "qpainter.h"
|
#include "qpainter.h"
|
||||||
#include "qprintdialog.h"
|
#include "qprintdialog.h"
|
||||||
#include "qtextcodec.h"
|
#include "qstringconverter.h"
|
||||||
#include "qdialogbuttonbox.h"
|
#include "qdialogbuttonbox.h"
|
||||||
#include <ui_qpagesetupwidget.h>
|
#include <ui_qpagesetupwidget.h>
|
||||||
|
|
||||||
@ -592,10 +592,14 @@ void QPageSetupWidget::pageSizeChanged()
|
|||||||
#if QT_CONFIG(cups)
|
#if QT_CONFIG(cups)
|
||||||
if (m_pageSizePpdOption) {
|
if (m_pageSizePpdOption) {
|
||||||
ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_printDevice->property(PDPK_PpdFile));
|
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) {
|
for (int i = 0; i < m_pageSizePpdOption->num_choices; ++i) {
|
||||||
const ppd_choice_t *choice = &m_pageSizePpdOption->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)
|
const auto values = QStringList{} << QString::fromLatin1(m_pageSizePpdOption->keyword)
|
||||||
<< QString::fromLatin1(choice->choice);
|
<< QString::fromLatin1(choice->choice);
|
||||||
m_printDevice->setProperty(PDPK_PpdOption, values);
|
m_printDevice->setProperty(PDPK_PpdOption, values);
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/qtextcodec.h>
|
#include <QtCore/qstringconverter.h>
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
#if QT_CONFIG(filesystemmodel)
|
#if QT_CONFIG(filesystemmodel)
|
||||||
#include <QtWidgets/qfilesystemmodel.h>
|
#include <QtWidgets/qfilesystemmodel.h>
|
||||||
@ -164,7 +164,8 @@ private:
|
|||||||
bool anyAdvancedOptionConflict() const;
|
bool anyAdvancedOptionConflict() const;
|
||||||
|
|
||||||
QPrintDevice *m_currentPrintDevice;
|
QPrintDevice *m_currentPrintDevice;
|
||||||
QTextCodec *m_cupsCodec = nullptr;
|
|
||||||
|
QStringDecoder toUnicode;
|
||||||
QVector<QComboBox*> m_advancedOptionsCombos;
|
QVector<QComboBox*> m_advancedOptionsCombos;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -434,7 +435,11 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
|
|||||||
ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_currentPrintDevice->property(PDPK_PpdFile));
|
ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_currentPrintDevice->property(PDPK_PpdFile));
|
||||||
|
|
||||||
if (ppd) {
|
if (ppd) {
|
||||||
m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
|
toUnicode = QStringDecoder(ppd->lang_encoding, QStringDecoder::Flag::Stateless);
|
||||||
|
if (!toUnicode.isValid()) {
|
||||||
|
qWarning() << "QPrinSupport: Cups uses unsupported encoding" << ppd->lang_encoding;
|
||||||
|
toUnicode = QStringDecoder(QStringDecoder::Utf8, QStringDecoder::Flag::Stateless);
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *holdingWidget = new QWidget();
|
QWidget *holdingWidget = new QWidget();
|
||||||
QVBoxLayout *layout = new QVBoxLayout(holdingWidget);
|
QVBoxLayout *layout = new QVBoxLayout(holdingWidget);
|
||||||
@ -471,7 +476,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
|
|||||||
if (choiceIsInstallableConflict && static_cast<int>(choice->marked) == 1) {
|
if (choiceIsInstallableConflict && static_cast<int>(choice->marked) == 1) {
|
||||||
markedChoiceNotAvailable = true;
|
markedChoiceNotAvailable = true;
|
||||||
} else if (!choiceIsInstallableConflict) {
|
} else if (!choiceIsInstallableConflict) {
|
||||||
choicesCb->addItem(m_cupsCodec->toUnicode(choice->text), i);
|
choicesCb->addItem(toUnicode(choice->text), i);
|
||||||
if (static_cast<int>(choice->marked) == 1) {
|
if (static_cast<int>(choice->marked) == 1) {
|
||||||
choicesCb->setCurrentIndex(choicesCb->count() - 1);
|
choicesCb->setCurrentIndex(choicesCb->count() - 1);
|
||||||
choicesCb->setProperty(ppdOriginallySelectedChoiceProperty, QVariant(i));
|
choicesCb->setProperty(ppdOriginallySelectedChoiceProperty, QVariant(i));
|
||||||
@ -502,7 +507,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
|
|||||||
choicesCbWithLabelLayout->addWidget(choicesCb);
|
choicesCbWithLabelLayout->addWidget(choicesCb);
|
||||||
choicesCbWithLabelLayout->addWidget(warningLabel);
|
choicesCbWithLabelLayout->addWidget(warningLabel);
|
||||||
|
|
||||||
QLabel *optionLabel = new QLabel(m_cupsCodec->toUnicode(option->text));
|
QLabel *optionLabel = new QLabel(toUnicode(option->text));
|
||||||
groupLayout->addRow(optionLabel, choicesCbWithLabel);
|
groupLayout->addRow(optionLabel, choicesCbWithLabel);
|
||||||
anyWidgetCreated = true;
|
anyWidgetCreated = true;
|
||||||
choicesCb->setProperty(ppdOptionProperty, QVariant::fromValue(option));
|
choicesCb->setProperty(ppdOptionProperty, QVariant::fromValue(option));
|
||||||
@ -515,7 +520,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (groupLayout->rowCount() > 0) {
|
if (groupLayout->rowCount() > 0) {
|
||||||
QGroupBox *groupBox = new QGroupBox(m_cupsCodec->toUnicode(group->text));
|
QGroupBox *groupBox = new QGroupBox(toUnicode(group->text));
|
||||||
groupBox->setLayout(groupLayout);
|
groupBox->setLayout(groupLayout);
|
||||||
layout->addWidget(groupBox);
|
layout->addWidget(groupBox);
|
||||||
} else {
|
} else {
|
||||||
@ -528,9 +533,6 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
|
|||||||
widget.scrollArea->setWidget(holdingWidget);
|
widget.scrollArea->setWidget(holdingWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cupsCodec)
|
|
||||||
m_cupsCodec = QTextCodec::codecForLocale();
|
|
||||||
|
|
||||||
return anyWidgetCreated;
|
return anyWidgetCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user