diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 45 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox_p.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qfontcombobox.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 9 | ||||
-rw-r--r-- | src/widgets/widgets/qstackedwidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbar.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 7 |
7 files changed, 43 insertions, 27 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index f857f4eac0..eae0cbbd06 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -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 @@ -2055,7 +2063,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) if (indexChanged) currentIndex = QPersistentModelIndex(normalized); if (lineEdit) { - QString newText = q->itemText(normalized.row()); + const QString newText = itemText(normalized); if (lineEdit->text() != newText) lineEdit->setText(newText); updateLineEditGeometry(); @@ -2377,6 +2385,16 @@ QSize QComboBox::sizeHint() const } #ifdef Q_OS_OSX + +namespace { +struct IndexSetter { + int index; + QComboBox *cb; + + void operator()(void) { cb->setCurrentIndex(index); } +}; +} + /*! * \internal * @@ -2391,13 +2409,6 @@ bool QComboBoxPrivate::showNativePopup() if (QPlatformMenu *menu = theme->createPlatformMenu()) { int itemsCount = q->count(); - struct IndexSetter { - int index; - QComboBox *cb; - - void operator()(void) { cb->setCurrentIndex(index); } - }; - QList<QPlatformMenuItem *> items; items.reserve(itemsCount); QPlatformMenuItem *currentItem = 0; diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index dceffe8d35..fb1ed71ee6 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -376,6 +376,7 @@ public: void keyboardSearchString(const QString &text); void modelChanged(); void updateViewContainerPaletteAndOpacity(); + void updateFocusPolicy(); #ifdef Q_OS_OSX bool showNativePopup(); diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 40ca73904c..db01543629 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -548,7 +548,7 @@ bool QFontComboBox::event(QEvent *e) if (e->type() == QEvent::Resize) { QListView *lview = qobject_cast<QListView*>(view()); if (lview) { - setFixedWidth(qMin(width() * 5 / 3, + lview->window()->setFixedWidth(qMin(width() * 5 / 3, QApplication::desktop()->availableGeometry(lview).width())); } } diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 358569a5e4..36ca90ba00 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1226,7 +1226,9 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const /*! Saves the current state of this mainwindow's toolbars and - dockwidgets. The \a version number is stored as part of the data. + dockwidgets. This includes the corner settings which can + be set with setCorner(). The \a version number is stored + as part of the data. The \l{QObject::objectName}{objectName} property is used to identify each QToolBar and QDockWidget. You should make sure @@ -1255,8 +1257,9 @@ QByteArray QMainWindow::saveState(int version) const /*! Restores the \a state of this mainwindow's toolbars and - dockwidgets. The \a version number is compared with that stored - in \a state. If they do not match, the mainwindow's state is left + dockwidgets. Also restores the corner settings too. The + \a version number is compared with that stored in \a state. + If they do not match, the mainwindow's state is left unchanged, and this function returns \c false; otherwise, the state is restored, and this function returns \c true. diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 4b7170a596..6dbc7c8fad 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -91,7 +91,7 @@ public: the list using the addWidget() function, or inserted at a given index using the insertWidget() function. The removeWidget() function removes a widget from the stacked widget. The number of - widgets contained in the stacked widget, can + widgets contained in the stacked widget can be obtained using the count() function. The widget() function returns the widget at a given index diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 3fd615c3c7..1c05529cd6 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -59,6 +59,10 @@ #include <private/qwidgetaction_p.h> #include <private/qmainwindowlayout_p.h> +#ifdef Q_OS_OSX +#include <qpa/qplatformnativeinterface.h> +#endif + #include "qtoolbar_p.h" #include "qtoolbarseparator_p.h" #include "qtoolbarlayout_p.h" diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index da348e4edc..a6b1aceb66 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1694,9 +1694,6 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button return; } - if (!mousePressed) - return; - const qreal mouseX = qreal(mousePos.x()); int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); @@ -1717,7 +1714,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button if (newCursorPos == -1) return; - if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) { + if (mousePressed && wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) { selectedWordOnDoubleClick = cursor; selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); } @@ -1726,7 +1723,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button extendBlockwiseSelection(newCursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(newCursorPos, mouseX); - else if (!isPreediting()) + else if (mousePressed && !isPreediting()) setCursorPosition(newCursorPos, QTextCursor::KeepAnchor); if (interactionFlags & Qt::TextEditable) { |