QComboBox: update focus policy when setting a new line edit
On OS X, the focus policy of QComboBox is different when editable or not. Task-number: QTBUG-39650 Change-Id: I394564f8a1a6d462e86d2497fe8874e6107a8a58 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
This commit is contained in:
parent
ebc729b3c3
commit
6b15a5a869
@ -1085,6 +1085,19 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
|
||||
lineEdit->setPalette(q->palette());
|
||||
}
|
||||
|
||||
void QComboBoxPrivate::updateFocusPolicy()
|
||||
{
|
||||
#ifdef Q_OS_OSX
|
||||
Q_Q(QComboBox);
|
||||
|
||||
// See comment in QComboBoxPrivate::init()
|
||||
if (q->isEditable())
|
||||
q->setFocusPolicy(Qt::WheelFocus);
|
||||
else
|
||||
q->setFocusPolicy(Qt::TabFocus);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Initialize \a option with the values from this QComboBox. This method
|
||||
is useful for subclasses when they need a QStyleOptionComboBox, but don't want
|
||||
@ -1691,10 +1704,6 @@ void QComboBox::setEditable(bool editable)
|
||||
}
|
||||
QLineEdit *le = new QLineEdit(this);
|
||||
setLineEdit(le);
|
||||
#ifdef Q_OS_MAC
|
||||
// See comment in QComboBoxPrivate::init()
|
||||
setFocusPolicy(Qt::WheelFocus);
|
||||
#endif
|
||||
} else {
|
||||
if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
|
||||
d->viewContainer()->updateScrollers();
|
||||
@ -1704,12 +1713,10 @@ void QComboBox::setEditable(bool editable)
|
||||
d->lineEdit->hide();
|
||||
d->lineEdit->deleteLater();
|
||||
d->lineEdit = 0;
|
||||
#ifdef Q_OS_MAC
|
||||
// See comment in QComboBoxPrivate::init()
|
||||
setFocusPolicy(Qt::TabFocus);
|
||||
#endif
|
||||
}
|
||||
|
||||
d->updateFocusPolicy();
|
||||
|
||||
d->viewContainer()->updateTopBottomMargin();
|
||||
if (!testAttribute(Qt::WA_Resized))
|
||||
adjustSize();
|
||||
@ -1743,6 +1750,7 @@ void QComboBox::setLineEdit(QLineEdit *edit)
|
||||
connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(currentTextChanged(QString)));
|
||||
d->lineEdit->setFrame(false);
|
||||
d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
d->updateFocusPolicy();
|
||||
d->lineEdit->setFocusProxy(this);
|
||||
d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
#ifndef QT_NO_COMPLETER
|
||||
|
@ -376,6 +376,7 @@ public:
|
||||
void keyboardSearchString(const QString &text);
|
||||
void modelChanged();
|
||||
void updateViewContainerPaletteAndOpacity();
|
||||
void updateFocusPolicy();
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
bool showNativePopup();
|
||||
|
Loading…
Reference in New Issue
Block a user