diff options
author | Leonard Lee <leonard.lee@digia.com> | 2014-03-25 10:47:29 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-28 22:52:19 +0100 |
commit | 685f8fe550b2360546af8dc7fe4c3f747631645b (patch) | |
tree | 8722706a86a1b63d20128722b3e4bc56315a759c /src/widgets | |
parent | c4d8734c504cf0f313245befa34501e7314b4cd1 (diff) |
Do not rely on the list of standard font sizes for QFontDialog.
QFontDialog should always show the correct size, even if the size
is not available in the list of standard font sizes. Native font
dialogs across common platforms show the correct size at all times.
Inside init() function, the size list requires proper initialization
since the initial value of size is zero.
Task-number: QTBUG-10317
Change-Id: Idc9e922ac95f797ac98bbf6c885e52828c4c48fd
Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qfontdialog.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 94e96a52c5..5a68bfbc66 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -256,8 +256,10 @@ void QFontDialogPrivate::init() } updateFamilies(); - if (familyList->count() != 0) + if (familyList->count() != 0) { familyList->setCurrentItem(0); + sizeList->setCurrentItem(0); + } // grid layout QGridLayout *mainGrid = new QGridLayout(q); @@ -621,16 +623,13 @@ void QFontDialogPrivate::updateSizes() QStringList str_sizes; for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { str_sizes.append(QString::number(*it)); - if (current == -1 && *it >= size) + if (current == -1 && *it == size) current = i; ++i; } sizeList->model()->setStringList(str_sizes); - if (current == -1) { - // we request a size bigger than the ones in the list, select the biggest one - current = sizeList->count() - 1; - } - sizeList->setCurrentItem(current); + if (current != -1) + sizeList->setCurrentItem(current); const QSignalBlocker blocker(sizeEdit); sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); @@ -750,7 +749,10 @@ void QFontDialogPrivate::_q_sizeChanged(const QString &s) break; } const QSignalBlocker blocker(sizeList); - sizeList->setCurrentItem(i); + if (sizeList->text(i).toInt() == this->size) + sizeList->setCurrentItem(i); + else + sizeList->clearSelection(); } _q_updateSample(); } |