diff options
Diffstat (limited to 'src/widgets')
27 files changed, 167 insertions, 79 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 8866a3e97e..3889a589c7 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.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. @@ -1442,7 +1442,7 @@ void QColorDialogPrivate::_q_newHsv(int h, int s, int v) } //sets all widgets to display rgb -void QColorDialogPrivate::setCurrentColor(QRgb rgb) +void QColorDialogPrivate::setCurrentRgbColor(QRgb rgb) { if (!nativeDialogInUse) { cs->setRgb(rgb); @@ -1525,14 +1525,14 @@ void QColorDialogPrivate::_q_nextCustom(int r, int c) void QColorDialogPrivate::_q_newCustom(int r, int c) { const int i = r + 2 * c; - setCurrentColor(QColorDialogOptions::customColor(i)); + setCurrentRgbColor(QColorDialogOptions::customColor(i)); if (standard) standard->setSelected(-1,-1); } void QColorDialogPrivate::_q_newStandard(int r, int c) { - setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); + setCurrentRgbColor(QColorDialogOptions::standardColor(r + c * 6)); if (custom) custom->setSelected(-1,-1); } @@ -1873,6 +1873,21 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) d->init(initial); } +void QColorDialogPrivate::setCurrentColor(const QColor &color, SetColorMode setColorMode) +{ + if (nativeDialogInUse) { + platformColorDialogHelper()->setCurrentColor(color); + return; + } + + if (setColorMode & ShowColor) { + setCurrentRgbColor(color.rgb()); + setCurrentAlpha(color.alpha()); + } + if (setColorMode & SelectColor) + selectColor(color); +} + /*! \property QColorDialog::currentColor \brief the currently selected color in the dialog @@ -1881,13 +1896,7 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) void QColorDialog::setCurrentColor(const QColor &color) { Q_D(QColorDialog); - if (d->nativeDialogInUse) - d->platformColorDialogHelper()->setCurrentColor(color); - else { - d->setCurrentColor(color.rgb()); - d->selectColor(color); - d->setCurrentAlpha(color.alpha()); - } + d->setCurrentColor(color); } QColor QColorDialog::currentColor() const @@ -2162,10 +2171,11 @@ void QColorDialog::changeEvent(QEvent *e) bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) { - Q_Q(QColorDialog); const QPoint globalPos = e->globalPos(); const QColor color = grabScreenColor(globalPos); - q->setCurrentColor(color); + // QTBUG-39792, do not change standard, custom color selectors while moving as + // otherwise it is not possible to pre-select a custom cell for assignment. + setCurrentColor(color, ShowColor); lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel") .arg(globalPos.x()).arg(globalPos.y()).arg(color.name())); return true; @@ -2173,8 +2183,7 @@ bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e) { - Q_Q(QColorDialog); - q->setCurrentColor(grabScreenColor(e->globalPos())); + setCurrentColor(grabScreenColor(e->globalPos()), SetColorAll); releaseColorPicking(); return true; } diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 72c3b0e3cd..feabce4bbf 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -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. @@ -77,6 +77,12 @@ class QColorDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QColorDialog) public: + enum SetColorMode { + ShowColor = 0x1, + SelectColor = 0x2, + SetColorAll = ShowColor | SelectColor + }; + QColorDialogPrivate() : options(new QColorDialogOptions) {} QPlatformColorDialogHelper *platformColorDialogHelper() const @@ -86,7 +92,8 @@ public: void initWidgets(); QRgb currentColor() const; QColor currentQColor() const; - void setCurrentColor(QRgb rgb); + void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll); + void setCurrentRgbColor(QRgb rgb); void setCurrentQColor(const QColor &color); bool selectColor(const QColor &color); QColor grabScreenColor(const QPoint &p); diff --git a/src/widgets/doc/snippets/qstyleplugin/main.cpp b/src/widgets/doc/snippets/qstyleplugin/main.cpp index 4cf20ab960..e1a0d1b626 100644 --- a/src/widgets/doc/snippets/qstyleplugin/main.cpp +++ b/src/widgets/doc/snippets/qstyleplugin/main.cpp @@ -45,7 +45,7 @@ class MyStylePlugin : public QStylePlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE mystyleplugin.json) + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "mystyleplugin.json") public: MyStylePlugin(QObject *parent = 0); diff --git a/src/widgets/doc/src/graphicsview.qdoc b/src/widgets/doc/src/graphicsview.qdoc index 148b4ea47d..d1d8630935 100644 --- a/src/widgets/doc/src/graphicsview.qdoc +++ b/src/widgets/doc/src/graphicsview.qdoc @@ -301,7 +301,7 @@ pass a QPainterPath to mapToScene(), and then pass the mapped path to QGraphicsScene::items(). - You can map coordinates and shapes to and from and item's scene by + You can map coordinates and shapes to and from an item's scene by calling QGraphicsItem::mapToScene() and QGraphicsItem::mapFromScene(). You can also map to an item's parent item by calling QGraphicsItem::mapToParent() and diff --git a/src/widgets/doc/src/qtwidgets-index.qdoc b/src/widgets/doc/src/qtwidgets-index.qdoc index 859a0ef933..bc74f43b35 100644 --- a/src/widgets/doc/src/qtwidgets-index.qdoc +++ b/src/widgets/doc/src/qtwidgets-index.qdoc @@ -139,6 +139,7 @@ interfaces \section2 Examples \list \li \l{Qt Widgets Examples} + \li \l{Layout Examples} \endlist \section1 API Reference diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc index 99d512b507..f581df4cb3 100644 --- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc @@ -386,5 +386,13 @@ then set it. (This does not only apply to layouts, you should do the same if you implement your own resizeEvent(), for example.) \endlist -*/ + \section1 Layout Examples + + Many Qt Widgets \l{Qt Widgets Examples}{examples} already use layouts, + however, several examples exist to showcase various layouts. + + \list + \li \l{Layout Examples} + \endlist +*/ diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index d4edc63403..e327a8737a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -9911,7 +9911,7 @@ void QGraphicsTextItem::setDefaultTextColor(const QColor &col) } /*! - Returns the default text color that is used to for unformatted text. + Returns the default text color that is used for unformatted text. */ QColor QGraphicsTextItem::defaultTextColor() const { diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 1f954d67dd..f376583f55 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1325,6 +1325,11 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, \fn void QListWidget::removeItemWidget(QListWidgetItem *item) Removes the widget set on the given \a item. + + To remove an item (row) from the list entirely, either delete the item or + use takeItem(). + + \sa itemWidget(), setItemWidget() */ /*! @@ -1620,6 +1625,8 @@ void QListWidget::closePersistentEditor(QListWidgetItem *item) \since 4.1 Returns the widget displayed in the given \a item. + + \sa setItemWidget(), removeItemWidget() */ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const { @@ -1638,7 +1645,7 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const implement a custom editor widget, use QListView and subclass QItemDelegate instead. - \sa {Delegate Classes} + \sa itemWidget(), removeItemWidget(), {Delegate Classes} */ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4bd306ed32..04d398206b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3625,6 +3625,9 @@ bool QApplication::keypadNavigationEnabled() We recommend that widgets do not cache this value as it may change at any time if the user changes the global desktop settings. + + \note This property may hold a negative value, for instance if cursor + blinking is disabled. */ void QApplication::setCursorFlashTime(int msecs) { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 65e435fbdc..7396808442 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2912,7 +2912,13 @@ void QWidget::showNormal() This is the case if neither the widget itself nor every parent up to but excluding \a ancestor has been explicitly disabled. - isEnabledTo(0) is equivalent to isEnabled(). + isEnabledTo(0) returns false if this widget or any if its ancestors + was explicitly disabled. + + The word ancestor here means a parent widget within the same window. + + Therefore isEnabledTo(0) stops at this widget's window, unlike + isEnabled() which also takes parent windows into considerations. \sa setEnabled(), enabled */ diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index e5f552679c..5a4bd33672 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -115,6 +115,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->setProperty(propertyName, q->property(propertyName)); } +#ifdef Q_OS_OSX + if (q->testAttribute(Qt::WA_ShowWithoutActivating)) + win->setProperty("_q_showWithoutActivating", QVariant(true)); +#endif win->setFlags(data.window_flags); fixPosIncludesFrame(); if (q->testAttribute(Qt::WA_Moved) @@ -134,7 +138,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO if (QWidget *nativeParent = q->nativeParentWidget()) { if (nativeParent->windowHandle()) { if (flags & Qt::Window) { - win->setTransientParent(nativeParent->windowHandle()); + win->setTransientParent(nativeParent->window()->windowHandle()); win->setParent(0); } else { win->setTransientParent(0); @@ -779,7 +783,10 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } } - if (isMove) { + // generate a move event for QWidgets without window handles. QWidgets with native + // window handles already receive a move event from + // QGuiApplicationPrivate::processGeometryChangeEvent. + if (isMove && (!q->windowHandle() || q->testAttribute(Qt::WA_DontShowOnScreen))) { QMoveEvent e(q->pos(), oldPos); QApplication::sendEvent(q, &e); } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 35a526e77d..fc328e7af0 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -591,24 +591,16 @@ void QWidgetWindow::updateNormalGeometry() void QWidgetWindow::handleMoveEvent(QMoveEvent *event) { - // If the widget's position already matches that of the event, this is a - // result of call to QWidget::move(), which already sends an event. - const bool spontaneous = m_widget->geometry().topLeft() != event->pos(); updateGeometry(); - if (spontaneous) - QGuiApplication::sendSpontaneousEvent(m_widget, event); + QGuiApplication::sendSpontaneousEvent(m_widget, event); } void QWidgetWindow::handleResizeEvent(QResizeEvent *event) { QSize oldSize = m_widget->data->crect.size(); - // If the widget's size already matches that of the event, this is a - // result of call to QWidget::resize(), which already sends an event. - const bool spontaneous = oldSize != event->size(); updateGeometry(); - if (spontaneous) - QGuiApplication::sendSpontaneousEvent(m_widget, event); + QGuiApplication::sendSpontaneousEvent(m_widget, event); if (m_widget->d_func()->paintOnScreen()) { QRegion updateRegion(geometry()); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 2172c9082f..82c53def7d 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2493,7 +2493,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption QColor arrowColor = option->palette.foreground().color(); arrowColor.setAlpha(220); - const QColor bgColor = option->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(option->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (transient) { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8bc454a795..b3c0463bca 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -100,13 +100,14 @@ QT_USE_NAMESPACE -@interface NotificationReceiver : NSObject { +@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject { QMacStylePrivate *mPrivate; } - (id)initWithPrivate:(QMacStylePrivate *)priv; - (void)scrollBarStyleDidChange:(NSNotification *)notification; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver); @implementation NotificationReceiver - (id)initWithPrivate:(QMacStylePrivate *)priv @@ -3186,17 +3187,15 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai fdi.version = qt_mac_hitheme_version; fdi.state = tds; SInt32 frame_size; - if (pe == PE_FrameLineEdit) { - fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound : - kHIThemeFrameTextFieldSquare; - GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); - if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled)) - fdi.state = kThemeStateInactive; - } else { - baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam - fdi.kind = kHIThemeFrameListBox; - GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size); - } + fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound : + kHIThemeFrameTextFieldSquare; + GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); + if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled)) + fdi.state = kThemeStateInactive; + else if (fdi.state == kThemeStatePressed) + // This pressed state doesn't make sense for a line edit frame. + // And Yosemite agrees with us. Otherwise it starts showing yellow pixels. + fdi.state = kThemeStateActive; fdi.isFocused = (frame->state & State_HasFocus); int lw = frame->lineWidth; if (lw <= 0) @@ -4046,11 +4045,20 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_FocusFrame: { - int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1; - int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1; - HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff, - opt->rect.height() - 2 * yOff); - HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal); + int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w); + int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w); + NSRect rect = NSMakeRect(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff, + opt->rect.height() - 2 * yOff); + CGContextSaveGState(cg); + [NSGraphicsContext setCurrentContext:[NSGraphicsContext + graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]]; + [NSGraphicsContext saveGraphicsState]; + NSSetFocusRingStyle(NSFocusRingOnly); + NSBezierPath *focusFramePath = [NSBezierPath bezierPathWithRect:rect]; + [focusFramePath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos + [focusFramePath fill]; + [NSGraphicsContext restoreGraphicsState]; + CGContextRestoreGState(cg); break; } case CE_MenuItem: case CE_MenuEmptyArea: @@ -5133,7 +5141,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())]; // mac os behaviour: as soon as one color channel is >= 128, // the bg is considered bright, scroller is dark - const QColor bgColor = opt->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (isDarkBg) diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index fc73488154..6be07a3f45 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -45,6 +45,8 @@ #include <private/qmath_p.h> #include <private/qstyle_p.h> #include <qmath.h> +#include <qscrollbar.h> +#include <qabstractscrollarea.h> #include "qstylehelper_p.h" #include <qstringbuilder.h> @@ -387,5 +389,13 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec } } + +QColor backgroundColor(const QPalette &pal, const QWidget* widget) +{ + if (qobject_cast<const QScrollBar *>(widget) && widget->parent() && + qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent())) + return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); + return pal.color(QPalette::Base); +} } QT_END_NAMESPACE diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index 6355cbc985..73e5c94dcd 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -86,6 +86,7 @@ namespace QStyleHelper bool isInstanceOf(QObject *obj, QAccessible::Role role); bool hasAncestor(QObject *obj, QAccessible::Role role); #endif + QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 94f8e36235..60bfc8e075 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2697,6 +2697,7 @@ void QStyleSheetStyle::polish(QWidget *w) styleSheetCaches->styleRulesCache.remove(w); styleSheetCaches->hasStyleRuleCache.remove(w); styleSheetCaches->renderRulesCache.remove(w); + styleSheetCaches->styleSheetCache.remove(w); } setGeometry(w); setProperties(w); diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 347e5701c0..21ce23437f 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -83,6 +83,7 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *ev); virtual bool event(QEvent *); virtual void paintEvent(QPaintEvent *); + virtual void resizeEvent(QResizeEvent *); private slots: void systemTrayWindowChanged(QScreen *screen); @@ -205,6 +206,11 @@ void QSystemTrayIconSys::paintEvent(QPaintEvent *) q->icon().paint(&painter, rect); } +void QSystemTrayIconSys::resizeEvent(QResizeEvent *) +{ + update(); +} + //////////////////////////////////////////////////////////////////////////// QSystemTrayIconPrivate::QSystemTrayIconPrivate() diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index 0b289c75ae..b12e2836d4 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -9,6 +9,7 @@ win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused MODULE_PLUGIN_TYPES += \ + styles \ accessible/libqtaccessiblewidgets.so QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf 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/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index f58881af0d..1f29af319a 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.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. @@ -1224,7 +1224,9 @@ void QSplitter::childEvent(QChildEvent *c) return; } QWidget *w = static_cast<QWidget*>(c->child()); - if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) { + if (w->isWindow()) + return; + if (c->added() && !d->blockChildAdd && !d->findWidget(w)) { d->insertWidget_helper(d->list.count(), w, false); } else if (c->polished() && !d->blockChildAdd) { if (isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide))) 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/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index b16477246f..75f30599be 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1472,7 +1472,7 @@ void QWidgetLineControl::setCursorBlinkPeriod(int msec) if (m_blinkTimer) { killTimer(m_blinkTimer); } - if (msec && !m_readOnly) { + if (msec > 0 && !m_readOnly) { m_blinkTimer = startTimer(msec / 2); m_blinkStatus = 1; } else { |