47 m_ui(
new QT_PREPEND_NAMESPACE(Ui)::DeviceProfileDialog),
53 const auto standardFontSizes = QFontDatabase::standardSizes();
54 populateNumericCombo(standardFontSizes.constBegin(), standardFontSizes.constEnd(), m_ui->m_systemFontSizeCombo);
57 const int maxPointSize = qMax(288, standardFontSizes.constLast());
58 m_ui->m_systemFontSizeCombo->setValidator(
new QIntValidator(1, maxPointSize,
59 m_ui->m_systemFontSizeCombo));
62 const QStringList styles = QStyleFactory::keys();
63 m_ui->m_styleCombo->addItem(tr(
"Default"), QVariant(QString()));
64 for (
const auto &s : styles)
65 m_ui->m_styleCombo->addItem(s, s);
67 connect(m_ui->m_nameLineEdit, &QLineEdit::textChanged,
this, &DeviceProfileDialog::nameChanged);
68 connect(m_ui->buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
69 connect(m_ui->buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
70 this, &QDialog::accept);
72 connect(m_ui->buttonBox->button(QDialogButtonBox::Save), &QAbstractButton::clicked,
73 this, &DeviceProfileDialog::save);
74 connect(m_ui->buttonBox->button(QDialogButtonBox::Open), &QAbstractButton::clicked,
75 this, &DeviceProfileDialog::open);
86 rc.setName(m_ui->m_nameLineEdit->text());
87 rc.setFontFamily(m_ui->m_systemFontComboBox->currentFont().family());
88 rc.setFontPointSize(m_ui->m_systemFontSizeCombo->itemData(m_ui->m_systemFontSizeCombo->currentIndex()).toInt());
91 m_ui->m_dpiChooser->getDPI(&dpiX, &dpiY);
95 rc.setStyle(m_ui->m_styleCombo->itemData(m_ui->m_styleCombo->currentIndex()).toString());
102 m_ui->m_nameLineEdit->setText(s.name());
103 m_ui->m_systemFontComboBox->setCurrentFont(QFont(s.fontFamily()));
104 const int fontSizeIndex = m_ui->m_systemFontSizeCombo->findData(QVariant(s.fontPointSize()));
105 m_ui->m_systemFontSizeCombo->setCurrentIndex(fontSizeIndex != -1 ? fontSizeIndex : 0);
106 m_ui->m_dpiChooser->setDPI(s.dpiX(), s.dpiY());
107 const int styleIndex = m_ui->m_styleCombo->findData(s.style());
108 m_ui->m_styleCombo->setCurrentIndex(styleIndex != -1 ? styleIndex : 0);
132 QString fn = m_dlgGui->getSaveFileName(
this, tr(
"Save Profile"), QString(), fileFilter());
148 const QString fn = m_dlgGui->getOpenFileName(
this, tr(
"Open profile"), QString(), fileFilter());
153 if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
154 critical(tr(
"Open Profile - Error"), tr(
"Unable to open the file '%1' for reading: %2").arg(fn, file.errorString()));
157 QString errorMessage;
158 DeviceProfile newSettings;
159 if (!newSettings.fromXml(QString::fromUtf8(file.readAll()), &errorMessage)) {
160 critical(tr(
"Open Profile - Error"), tr(
"'%1' is not a valid profile: %2").arg(fn, errorMessage));
168 m_dlgGui->message(
this, QDesignerDialogGuiInterface::OtherMessage, QMessageBox::Critical, title, msg);