forked from qt-creator/qt-creator
Editor: Allow any point size as font size
...by making the size combobox editable. This way the user can still access the proposed list of point sizes in the combo box. Change-Id: Ia73ccde9277d8960bc2de550f74355b0561d4c8e Fixes: QTCREATORBUG-22536 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -362,6 +362,10 @@ QWidget *FontSettingsPage::widget()
|
||||
d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
|
||||
d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme());
|
||||
|
||||
auto sizeValidator = new QIntValidator(d_ptr->m_ui->sizeComboBox);
|
||||
sizeValidator->setBottom(0);
|
||||
d_ptr->m_ui->sizeComboBox->setValidator(sizeValidator);
|
||||
|
||||
connect(d_ptr->m_ui->fontComboBox, &QFontComboBox::currentFontChanged,
|
||||
this, &FontSettingsPage::fontSelected);
|
||||
connect(d_ptr->m_ui->sizeComboBox,
|
||||
@@ -405,8 +409,11 @@ void FontSettingsPage::updatePointSizes()
|
||||
int idx = -1;
|
||||
int i = 0;
|
||||
for (; i < sizeLst.count(); ++i) {
|
||||
if (idx == -1 && sizeLst.at(i) >= oldSize)
|
||||
if (idx == -1 && sizeLst.at(i) >= oldSize) {
|
||||
idx = i;
|
||||
if (sizeLst.at(i) != oldSize)
|
||||
d_ptr->m_ui->sizeComboBox->addItem(QString::number(oldSize));
|
||||
}
|
||||
d_ptr->m_ui->sizeComboBox->addItem(QString::number(sizeLst.at(i)));
|
||||
}
|
||||
if (idx != -1)
|
||||
@@ -631,6 +638,13 @@ void FontSettingsPage::apply()
|
||||
scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::mainWindow());
|
||||
}
|
||||
|
||||
bool ok;
|
||||
int fontSize = d_ptr->m_ui->sizeComboBox->currentText().toInt(&ok);
|
||||
if (ok && d_ptr->m_value.fontSize() != fontSize) {
|
||||
d_ptr->m_value.setFontSize(fontSize);
|
||||
d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
|
||||
}
|
||||
|
||||
int index = d_ptr->m_ui->schemeComboBox->currentIndex();
|
||||
if (index != -1) {
|
||||
const ColorSchemeEntry &entry = d_ptr->m_schemeListModel->colorSchemeAt(index);
|
||||
|
||||
@@ -132,6 +132,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user