diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2014-10-01 16:21:12 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-10-01 16:21:12 +0200 |
commit | 8ee9774e67edf57d891528749a360a0af8f0c6f7 (patch) | |
tree | e0b7d4b19c26c48fe41e930532f2037f8dc43204 /src/widgets | |
parent | d78fb442d750b33afe2e41f31588ec94cf4023ad (diff) | |
parent | 8ab25620d3df25c43011ae982f4614639578afb3 (diff) |
Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 16 | ||||
-rw-r--r-- | src/widgets/styles/qgtkstyle.cpp | 1 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 86 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac_p_p.h | 2 |
6 files changed, 87 insertions, 23 deletions
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 9dba8ef894..0a4e57812a 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1002,6 +1002,9 @@ void QTreeModel::timerEvent(QTimerEvent *ev) \since 4.2 Hides the item if \a hide is true, otherwise shows the item. + \note A call to this function has no effect if the item is not currently in a view. In particular, + calling \c setHidden(true) on an item and only then adding it to a view will result in + a visible item. \sa isHidden() */ diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index a98b2db0fc..3349b45467 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -271,7 +271,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge // (and reaches this point), then the menu item itself has been disabled. // This occurs at the QPA level on Mac, were we disable all the Cocoa menus // when showing a modal window. - if (a->shortcut().count() <= 1) + if (a->shortcut().count() < 1 || (a->shortcut().count() == 1 && (a->shortcut()[0] & Qt::MODIFIER_MASK) != 0)) continue; #endif QAction *a = menu->menuAction(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 423bb33cc2..de64755e4f 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -10528,6 +10528,22 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { if (extra && extra->hasWindowContainer) QWindowContainer::toplevelAboutToBeDestroyed(q); + + QWindow *newParentWindow = newparent->windowHandle(); + if (!newParentWindow) + if (QWidget *npw = newparent->nativeParentWidget()) + newParentWindow = npw->windowHandle(); + + Q_FOREACH (QObject *child, q->windowHandle()->children()) { + QWindow *childWindow = qobject_cast<QWindow *>(child); + if (!childWindow) + continue; + + QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow); + QWidget *childWidget = childWW ? childWW->widget() : 0; + if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow))) + childWindow->setParent(newParentWindow); + } q->destroy(); } diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index ad6e4dc10d..6f2a2046b7 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -289,6 +289,7 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto static GdkColor fromQColor(const QColor &color) { GdkColor retval; + retval.pixel = 0; retval.red = color.red() * 255; retval.green = color.green() * 255; retval.blue = color.blue() * 255; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f0a45548f6..01a2f2b3bd 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1749,11 +1749,13 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags) return tds; } -NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const +NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind, QPoint *offset) const { NSView *bv = buttons[kind]; if (!bv) { - if (kind == kThemePopupButton) + if (kind == kThemePopupButton + || kind == kThemePopupButtonSmall + || kind == kThemePopupButtonMini) bv = [[NSPopUpButton alloc] init]; else if (kind == kThemeComboBox) bv = [[NSComboBox alloc] init]; @@ -1793,25 +1795,61 @@ NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const break; } -// if (kind == kThemePushButtonSmall -// || kind == kThemePopupButtonSmall -// || kind == kThemeCheckBoxSmall -// || kind == kThemeRadioButtonSmall) -// bc.controlSize = NSSmallControlSize; -// else if (kind == kThemePushButtonMini -// || kind == kThemePopupButtonMini -// || kind == kThemeCheckBoxMini -// || kind == kThemeRadioButtonMini) -// bc.controlSize = NSMiniControlSize; - if ([bv isKindOfClass:[NSButton class]]) { NSButton *bc = (NSButton *)bv; bc.title = nil; + + NSCell *bcell = bc.cell; + switch (kind) { + case kThemePushButtonSmall: + case kThemePopupButtonSmall: + case kThemeCheckBoxSmall: + case kThemeRadioButtonSmall: + bcell.controlSize = NSSmallControlSize; + break; + case kThemePushButtonMini: + case kThemePopupButtonMini: + case kThemeCheckBoxMini: + case kThemeRadioButtonMini: + bcell.controlSize = NSMiniControlSize; + break; + default: + break; + } } const_cast<QMacStylePrivate *>(this)->buttons.insert(kind, bv); } + if (offset) { + switch (kind) { + case kThemeRadioButton: + offset->setY(2); + break; + case kThemeRadioButtonSmall: + *offset = QPoint(-1, 2); + break; + case kThemeRadioButtonMini: + offset->setY(2); + break; + case kThemePopupButtonSmall: + case kThemeCheckBox: + offset->setY(1); + break; + case kThemeCheckBoxSmall: + offset->setX(-1); + break; + case kThemeCheckBoxMini: + *offset = QPoint(7, 5); + break; + case kThemePopupButtonMini: + *offset = QPoint(2, -1); + break; + default: + break; + } + } + return bv; } @@ -1827,8 +1865,8 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height()); [backingStoreNSView addSubview:view]; - view.frame = rect; - [view drawRect:rect]; + view.frame = NSRectFromCGRect(rect); + [view drawRect:NSRectFromCGRect(rect)]; [view removeFromSuperviewWithoutNeedingDisplay]; [NSGraphicsContext restoreGraphicsState]; @@ -1928,14 +1966,20 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD } pm = QPixmap::fromImage(image); } else if ((usingYosemiteOrLater && combo && !editableCombo) || button) { - NSButton *bc = (NSButton *)buttonOfKind(bdi->kind); + QPoint offset; + NSButton *bc = (NSButton *)buttonOfKind(bdi->kind, &offset); [bc highlight:pressed]; bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive; + bc.allowsMixedState = YES; bc.state = bdi->value == kThemeButtonOn ? NSOnState : bdi->value == kThemeButtonMixed ? NSMixedState : NSOffState; - p->translate(0, 1); - drawNSViewInRect(bc, opt->rect, p); - p->translate(0, -1); + // The view frame may differ from what we pass to HITheme + QRect rect = opt->rect; + if (bdi->kind == kThemePopupButtonMini) + rect.adjust(0, 0, -5, 0); + p->translate(offset); + drawNSViewInRect(bc, rect, p); + p->translate(-offset); return; } else if (usingYosemiteOrLater && editableCombo) { QImage image = activePixmap.toImage(); @@ -3821,9 +3865,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter NSBezierPath *pushButtonFocusRingPath; if (bdi.kind == kThemeBevelButton) - pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:focusRect]; + pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRect)]; else - pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4]; + pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(focusRect) xRadius:4 yRadius:4]; qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath); } diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index f5b67cd549..d145ff620b 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -187,7 +187,7 @@ public: void setAutoDefaultButton(QObject *button) const; - NSView *buttonOfKind(ThemeButtonKind kind) const; + NSView *buttonOfKind(ThemeButtonKind kind, QPoint *offset) const; void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const; void resolveCurrentNSView(QWindow *window); |