From cd5ae8fb21c2e44083f0b8ba85ef8d620803c934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 22:43:05 +0100 Subject: Enable window dragging code in QToolBar on Mac Allows moving the window by dragging the unified title and toolbar area. Task-number: QTBUG-34411 Change-Id: Idd85c0031895b5afd7dfdc8616e4452c47935af2 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtoolbar.cpp | 6 +++--- src/widgets/widgets/qtoolbar_p.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 5f80bbb1ca..096f53de40 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -272,7 +272,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) QStyleOptionToolBar opt; q->initStyleOption(&opt); if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX // When using the unified toolbar on Mac OS X, the user can click and // drag between toolbar contents to move the window. Make this work by // implementing the standard mouse-dragging code and then call @@ -306,7 +306,7 @@ bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) endDrag(); return true; } else { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX if (!macWindowDragging) return false; macWindowDragging = false; @@ -322,7 +322,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) Q_Q(QToolBar); if (!state) { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX if (!macWindowDragging) return false; QWidget *w = q->window(); diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 9ff0b9d61c..c9dd0490cd 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -75,7 +75,7 @@ public: allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal), toolButtonStyle(Qt::ToolButtonIconOnly), layout(0), state(0) -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX , macWindowDragging(false) #endif { } @@ -107,7 +107,7 @@ public: }; DragState *state; -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX bool macWindowDragging; QPoint macWindowDragPressPosition; #endif -- cgit v1.2.3 From 459ad9e018071cdf613d3deb70ea4d96178ca683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 22:49:41 +0100 Subject: Mac: Update PE_IndicatorToolBarHandle drawing. Smaller, rounder, darker toolbar handles. Works especially well in unified toolbar mode. Task-number: QTBUG-34411 Change-Id: I41eafdf0bb1dbbb4ed96d7bd799eb6f53bccbf7d Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 5db4801c37..93a72980c9 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3008,23 +3008,19 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai if (opt->state & State_Horizontal) { while (y < opt->rect.height() - RectHeight - 5) { path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); + path.addEllipse(x, y, RectHeight, RectHeight); y += 6; } } else { while (x < opt->rect.width() - RectHeight - 5) { path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); + path.addEllipse(x, y, RectHeight, RectHeight); x += 6; } } p->setPen(Qt::NoPen); - QColor dark = opt->palette.dark().color(); - dark.setAlphaF(0.75); - QColor light = opt->palette.light().color(); - light.setAlphaF(0.6); - p->fillPath(path, light); - p->translate(1, 1); + QColor dark = opt->palette.dark().color().darker(); + dark.setAlphaF(0.50); p->fillPath(path, dark); p->restore(); -- cgit v1.2.3 From b3d642e71e1b1083e5f17872614da2cbf38e8fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:03:30 +0100 Subject: Mac: Update unified toolbar drawing code. Fill the toolbar background with transparent pixels to allow the view background to shine through. Draw a separator line using HITheme. Task-number: QTBUG-34411 Change-Id: I57732564a67a5a9d1eb7fd9038382b2b65be50a4 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 40 ++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 93a72980c9..8c00f06a4f 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -679,6 +679,18 @@ bool qt_macWindowIsTextured(const QWidget *window) return false; } +static bool qt_macWindowMainWindow(const QWidget *window) +{ + if (QWindow *w = window->windowHandle()) { + if (w->handle()) { + if (NSWindow *nswindow = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("nswindow"), w))) { + return [nswindow isMainWindow]; + } + } + } + return false; +} + /***************************************************************************** QMacCGStyle globals *****************************************************************************/ @@ -4438,12 +4450,34 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_ToolBar: { - // For unified tool bars, draw nothing. - if (w) { + const QStyleOptionToolBar *toolBar = qstyleoption_cast(opt); + + // Unified title and toolbar drawing. In this mode the cocoa platform plugin will + // fill the top toolbar area part with a background gradient that "unifies" with + // the title bar. The following code fills the toolBar area with transparent pixels + // to make that gradient visible. + if (w) { if (QMainWindow * mainWindow = qobject_cast(w->window())) { - if (mainWindow->unifiedTitleAndToolBarOnMac()) + if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) { + + // fill with transparent pixels. + p->save(); + p->setCompositionMode(QPainter::CompositionMode_Source); + p->fillRect(opt->rect, Qt::transparent); + p->restore(); + + // drow horizontal sepearator line at toolBar bottom. + SInt32 margin; + GetThemeMetric(kThemeMetricSeparatorSize, &margin); + CGRect separatorRect = CGRectMake(opt->rect.left(), opt->rect.bottom(), opt->rect.width(), margin); + HIThemeSeparatorDrawInfo separatorDrawInfo; + separatorDrawInfo.version = 0; + separatorDrawInfo.state = qt_macWindowMainWindow(mainWindow) ? kThemeStateActive : kThemeStateInactive; + QMacCGContext cg(p); + HIThemeDrawSeparator(&separatorRect, &separatorDrawInfo, cg, kHIThemeOrientationNormal); break; } + } } // draw background gradient -- cgit v1.2.3 From 4a7f27ea536c2010edae05f39c1a9cb6c56205f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:06:35 +0100 Subject: Mac: remove unified toolbar workarounds. QMainWindow::unifiedTitleAndToolBarOnMac() will again return true, but the new implementation is much more similar to the cross platform one so these workarounds are not needed. Task-number: QTBUG-34411 Change-Id: Ic95f491af94354776385dc984f1a00c64429a3f0 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8c00f06a4f..d13339b555 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2437,11 +2437,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW break; case PM_ToolBarFrameWidth: ret = 1; - if (widget) { - if (QMainWindow * mainWindow = qobject_cast(widget->parent())) - if (mainWindow->unifiedTitleAndToolBarOnMac()) - ret = 0; - } break; case PM_ScrollView_ScrollBarOverlap: #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 @@ -3445,14 +3440,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { needText = true; if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { - QMainWindow *mw = w ? qobject_cast(w->window()) : 0; - if (mw && mw->unifiedTitleAndToolBarOnMac()) { - pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio()); - cr.adjust(0, pr.bottom() + 1, 0, 1); - } else { - pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); - cr.adjust(0, pr.bottom(), 0, -3); - } + pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); + cr.adjust(0, pr.bottom(), 0, -3); alignment |= Qt::AlignCenter; } else { pr.setWidth(pixmap.width() / pixmap.devicePixelRatio() + 8); @@ -6271,18 +6260,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } break; case CT_ToolButton: - if (widget && qobject_cast(widget->parentWidget())) { - if (QMainWindow * mainWindow = qobject_cast(widget->parent())) { - if (mainWindow->unifiedTitleAndToolBarOnMac()) { - sz.rwidth() += 4; - if (sz.height() <= 32) { - // Workaround strange HIToolBar bug when getting constraints. - sz.rheight() += 1; - } - return sz; - } - } - } sz.rwidth() += 10; sz.rheight() += 10; return sz; -- cgit v1.2.3 From e1330ecfdccf75c3c3f93734e7950199918e6ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:36:14 +0100 Subject: Mac: Remove old unified toolbar implementation. This has been dead code in Qt 5 since WS_MAC isn't defined any more. The new implementation is far less intrusive and does not require a separate layout. Task-number: QTBUG-34411 Change-Id: I91bf2294086cb7334a0f56eb1bb97464d8d7b2e3 Reviewed-by: Gabriel de Dietrich --- src/widgets/kernel/qwidget.cpp | 95 +------ src/widgets/kernel/qwidget_p.h | 3 +- src/widgets/widgets/qcocoatoolbardelegate_mac.mm | 151 ----------- src/widgets/widgets/qcocoatoolbardelegate_mac_p.h | 69 ----- src/widgets/widgets/qmainwindowlayout_mac.mm | 292 ---------------------- src/widgets/widgets/qtoolbar.cpp | 68 +---- src/widgets/widgets/qtoolbarlayout.cpp | 23 -- src/widgets/widgets/widgets.pri | 9 - 8 files changed, 5 insertions(+), 705 deletions(-) delete mode 100644 src/widgets/widgets/qcocoatoolbardelegate_mac.mm delete mode 100644 src/widgets/widgets/qcocoatoolbardelegate_mac_p.h delete mode 100644 src/widgets/widgets/qmainwindowlayout_mac.mm (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 08e8975f9d..df523e7e21 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5026,16 +5026,6 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (rgn.isEmpty()) return; -#ifdef Q_WS_MAC - if (qt_mac_clearDirtyOnWidgetInsideDrawWidget) - dirtyOnWidget = QRegion(); - - // We disable the rendering of QToolBar in the backingStore if - // it's supposed to be in the unified toolbar on Mac OS X. - if (backingStore && isInUnifiedToolbar) - return; -#endif // Q_WS_MAC - const bool asRoot = flags & DrawAsRoot; bool onScreen = paintOnScreen(); @@ -9403,26 +9393,13 @@ QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDe if (children.isEmpty()) return 0; -#ifdef Q_WS_MAC - Q_Q(const QWidget); - // Unified tool bars on the Mac require special handling since they live outside - // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8 - bool includeFrame = q->isWindow() && qobject_cast(q) - && static_cast(q)->unifiedTitleAndToolBarOnMac(); - if (includeFrame) - return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame); -#endif - if (!pointInsideRectAndMask(p)) return 0; return childAtRecursiveHelper(p, ignoreChildrenInDestructor); } -QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const +QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor) const { -#ifndef Q_WS_MAC - Q_UNUSED(includeFrame); -#endif for (int i = children.size() - 1; i >= 0; --i) { QWidget *child = qobject_cast(children.at(i)); if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents) @@ -9432,14 +9409,6 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil // Map the point 'p' from parent coordinates to child coordinates. QPoint childPoint = p; -#ifdef Q_WS_MAC - // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar. - // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal - // QWidget::mapFromParent won't do the trick. - if (includeFrame && qobject_cast(child)) - childPoint = qt_mac_nativeMapFromParent(child, p); - else -#endif childPoint -= child->data->crect.topLeft(); // Check if the point hits the child. @@ -9614,13 +9583,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; if (newParent && parent && !desktopWidget) { - if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) -#ifdef Q_WS_MAC - // On Mac, toolbars inside the unified title bar will never overlap with - // siblings in the content view. So we skip enforce native siblings in that case - && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow() -#endif // Q_WS_MAC - ) + if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) setAttribute(Qt::WA_NativeWindow); @@ -9879,12 +9842,6 @@ void QWidget::repaint(const QRect &rect) return; if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -9914,12 +9871,6 @@ void QWidget::repaint(const QRegion &rgn) return; if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -9982,12 +9933,6 @@ void QWidget::update(const QRect &rect) } if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStoreTracker->markDirty(r, this); @@ -10017,12 +9962,6 @@ void QWidget::update(const QRegion &rgn) } if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStoreTracker->markDirty(r, this); @@ -10218,13 +10157,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } - if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget() -#ifdef Q_WS_MAC - // On Mac, toolbars inside the unified title bar will never overlap with - // siblings in the content view. So we skip enforce native siblings in that case - && !d->isInUnifiedToolbar && parentWidget()->isWindow() -#endif // Q_WS_MAC - ) + if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); @@ -11544,28 +11477,6 @@ void QWidget::clearMask() setMask(QRegion()); } -#ifdef Q_WS_MAC -void QWidgetPrivate::syncUnifiedMode() { - // The whole purpose of this method is to keep the unifiedToolbar in sync. - // That means making sure we either exchange the drawing methods or we let - // the toolbar know that it does not require to draw the baseline. - Q_Q(QWidget); - // This function makes sense only if this is a top level - if(!q->isWindow()) - return; - OSWindowRef window = qt_mac_window_for(q); - if(changeMethods) { - // Ok, we are in documentMode. - if(originalDrawMethod) - qt_mac_replaceDrawRect(window, this); - } else { - if(!originalDrawMethod) - qt_mac_replaceDrawRectOriginal(window, this); - } -} - -#endif // Q_WS_MAC - QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index df40908c00..943b7057b5 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -495,7 +495,7 @@ public: void setConstraints_sys(); bool pointInsideRectAndMask(const QPoint &) const; QWidget *childAt_helper(const QPoint &, bool) const; - QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const; + QWidget *childAtRecursiveHelper(const QPoint &p, bool) const; void updateGeometry_helper(bool forceUpdate); void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const; @@ -780,7 +780,6 @@ public: void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef); void syncCocoaMask(); void finishCocoaMaskSetup(); - void syncUnifiedMode(); // Did we add the drawRectOriginal method? bool drawRectOriginalAdded; // Is the original drawRect method available? diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm deleted file mode 100644 index 2ea66b0d40..0000000000 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#import -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -extern QWidgetPrivate *qt_widget_private(QWidget *widget); -QT_END_NAMESPACE - -QT_FORWARD_DECLARE_CLASS(QMainWindowLayout); -QT_FORWARD_DECLARE_CLASS(QToolBar); -QT_FORWARD_DECLARE_CLASS(QCFString); - -@implementation QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) - -- (id)initWithMainWindowLayout:(QMainWindowLayout *)layout -{ - self = [super init]; - if (self) { - mainWindowLayout = layout; - } - return self; -} - -- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar -{ - Q_UNUSED(toolbar); - return [NSArray arrayWithObject:@"org.qt-project.qt.nstoolbar-qtoolbar"]; -} - -- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar -{ - return [self toolbarAllowedItemIdentifiers:toolbar]; -} - -- (void)toolbarDidRemoveItem:(NSNotification *)notification -{ - NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"]; - mainWindowLayout->unifiedToolbarHash.remove(item); - for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) { - if (mainWindowLayout->toolbarItemsCopy.at(i) == item) { - // I know about it, so release it. - mainWindowLayout->toolbarItemsCopy.removeAt(i); - mainWindowLayout->qtoolbarsInUnifiedToolbarList.removeAt(i); - [item release]; - break; - } - } -} - -- (NSToolbarItem *)toolbar:(NSToolbar *)nstoolbar itemForItemIdentifier:(NSString *)itemIdentifier - willBeInsertedIntoToolbar:(BOOL)flag -{ - Q_UNUSED(flag); - Q_UNUSED(nstoolbar); - QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value( - QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(itemIdentifier)); - NSToolbarItem *item = nil; - if (tb) { - item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; - mainWindowLayout->unifiedToolbarHash.insert(item, tb); - } - return item; -} - -- (void)toolbarWillAddItem:(NSNotification *)notification -{ - NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"]; - QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value( - QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([item itemIdentifier])); - if (!tb) - return; // I can't really do anything about this. - [item retain]; - [item setView:QT_PREPEND_NAMESPACE(qt_mac_nativeview_for)(tb)]; - - NSArray *items = [[qt_mac_window_for(mainWindowLayout->layoutState.mainWindow->window()) toolbar] items]; - int someIndex = 0; - for (NSToolbarItem *i in items) { - if (i == item) - break; - ++someIndex; - } - mainWindowLayout->toolbarItemsCopy.insert(someIndex, item); - - // This is synchronization code that was needed in Carbon, but may not be needed anymore here. - QToolBar *toolbar = mainWindowLayout->unifiedToolbarHash.value(item); - if (toolbar) { - int toolbarIndex = mainWindowLayout->qtoolbarsInUnifiedToolbarList.indexOf(toolbar); - if (someIndex != toolbarIndex) { - // Dang, we must be out of sync, rebuild it from the "toolbarItemsCopy" - mainWindowLayout->qtoolbarsInUnifiedToolbarList.clear(); - for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) { - // This will either append the correct toolbar or an - // null toolbar. This is fine because this list - // is really only kept to make sure that things are but in the right order. - mainWindowLayout->qtoolbarsInUnifiedToolbarList.append( - mainWindowLayout->unifiedToolbarHash.value(mainWindowLayout-> - toolbarItemsCopy.at(i))); - } - } - toolbar->update(); - } -} - -@end diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h deleted file mode 100644 index f74f608660..0000000000 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qmacdefines_mac.h" -#import - -QT_BEGIN_NAMESPACE -class QMainWindowLayout; -class QToolBar; -QT_END_NAMESPACE - -@class NSToolbarItem; - -@interface QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) : NSObject { - QT_PREPEND_NAMESPACE(QMainWindowLayout) *mainWindowLayout; - NSToolbarItem *toolbarItem; -} - -- (id)initWithMainWindowLayout:(QT_PREPEND_NAMESPACE(QMainWindowLayout) *)layout; -@end diff --git a/src/widgets/widgets/qmainwindowlayout_mac.mm b/src/widgets/widgets/qmainwindowlayout_mac.mm deleted file mode 100644 index 38605c2e09..0000000000 --- a/src/widgets/widgets/qmainwindowlayout_mac.mm +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#import - -QT_BEGIN_NAMESPACE -#ifdef QT_NAMESPACE - -// namespace up the stuff -#define SS(x) #x -#define S0(x) SS(x) -#define S "org.qt-project.qt-" S0(QT_NAMESPACE) ".qmainwindow.qtoolbarInHIToolbar" -#define SToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".hitoolbar-qtoolbar" -#define SNSToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".qtoolbarInNSToolbar" -#define MacToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".qmainwindow.mactoolbar" - -static NSString *kQToolBarNSToolbarIdentifier = @SNSToolbar; -static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar); -#undef SS -#undef S0 -#undef S -#undef SToolbar -#undef SNSToolbar -#undef MacToolbar - -#else -static NSString *kQToolBarNSToolbarIdentifier = @"org.qt-project.qt.qmainwindow.qtoolbarInNSToolbar"; -static CFStringRef kQMainWindowMacToolbarID = CFSTR("org.qt-project.qt.qmainwindow.mactoolbar"); -#endif // QT_NAMESPACE - - -#ifndef kWindowUnifiedTitleAndToolbarAttribute -#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7) -#endif - -void QMainWindowLayout::updateHIToolBarStatus() -{ - bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac(); - - layoutState.mainWindow->setUpdatesEnabled(false); // reduces a little bit of flicker, not all though - QMacCocoaAutoReleasePool pool; - NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView]; - if (useMacToolbar) { - [cView setPostsFrameChangedNotifications:YES]; - [[NSNotificationCenter defaultCenter] addObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] - selector: @selector(syncContentViewFrame:) - name: NSViewFrameDidChangeNotification - object: cView]; - } - if (!useMacToolbar) { - macWindowToolbarShow(layoutState.mainWindow, false); - // Move everything out of the HIToolbar into the main toolbar. - while (!qtoolbarsInUnifiedToolbarList.isEmpty()) { - // Should shrink the list by one every time. - QToolBar *toolbar = qtoolbarsInUnifiedToolbarList.first(); - unifiedSurface->removeToolbar(toolbar); - layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar); - } - macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0); - } else { - QList toolbars = layoutState.mainWindow->findChildren(); - for (int i = 0; i < toolbars.size(); ++i) { - QToolBar *toolbar = toolbars.at(i); - if (toolBarArea(toolbar) == Qt::TopToolBarArea) { - // Do this here, because we are in an in-between state. - removeWidget(toolbar); - layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar); - } - } - syncUnifiedToolbarVisibility(); - } - if (!useMacToolbar) { - [cView setPostsFrameChangedNotifications:NO]; - [[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] - name: NSViewFrameDidChangeNotification - object: cView]; - } - layoutState.mainWindow->setUpdatesEnabled(true); -} - -void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar) -{ - // This layering could go on to one more level, but I decided to stop here. - // The HIToolbar and NSToolbar APIs are fairly similar as you will see. - if (toolbar == 0) - return; - - // toolbar will now become native (if not already) since we need - // an nsview for it inside the corresponding NSToolbarItem. - // Setting isInUnifiedToolbar will (among other things) stop alien - // siblings from becoming native when this happends since the toolbar - // will not overlap with other children of the QMainWindow. NB: Switching - // unified toolbar off after this stage is not supported, as this means - // that either the menubar must be alien again, or the sibling must - // be backed by an nsview to protect from overlapping issues: - toolbar->d_func()->isInUnifiedToolbar = true; - - QToolBarLayout *toolbarLayout = static_cast(toolbar->layout()); - toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(), toolbar->maximumSize())); - - if (toolbarLayout->hasExpandFlag() == false) - toolbar->setMaximumSize(toolbar->sizeHint()); - - toolbar->setMovable(false); - toolbarLayout->setUsePopupMenu(true); - // Make the toolbar a child of the mainwindow to avoid creating a window. - toolbar->setParent(layoutState.mainWindow); - - toolbar->winId(); // Now create the OSViewRef. - layoutState.mainWindow->createWinId(); - - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); - int beforeIndex = qtoolbarsInUnifiedToolbarList.indexOf(before); - if (beforeIndex == -1) - beforeIndex = qtoolbarsInUnifiedToolbarList.size(); - - int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar); - - QMacCocoaAutoReleasePool pool; - NSToolbar *macToolbar = [window toolbar]; - if (macToolbar == nil) { - macToolbar = [[NSToolbar alloc] initWithIdentifier:(NSString *)kQMainWindowMacToolbarID]; - [macToolbar setDisplayMode:NSToolbarDisplayModeIconOnly]; - [macToolbar setSizeMode:NSToolbarSizeModeRegular]; - [macToolbar setDelegate:[[QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) alloc] initWithMainWindowLayout:this]]; - [window setToolbar:macToolbar]; - [macToolbar release]; - } - if (toolbarIndex != -1) { - qtoolbarsInUnifiedToolbarList.removeAt(toolbarIndex); - [macToolbar removeItemAtIndex:toolbarIndex]; - } - qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar); - - // Adding to the unified toolbar surface for the raster engine. - if (layoutState.mainWindow->windowSurface()) { - QPoint offset(0, 0); - for (int i = 0; i < beforeIndex; ++i) { - offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width()); - } - unifiedSurface->insertToolbar(toolbar, offset); - } - - NSString *toolbarID = kQToolBarNSToolbarIdentifier; - toolbarID = [toolbarID stringByAppendingFormat:@"%p", toolbar]; - cocoaItemIDToToolbarHash.insert(qt_mac_NSStringToQString(toolbarID), toolbar); - [macToolbar insertItemWithItemIdentifier:toolbarID atIndex:beforeIndex]; -} - -void QMainWindowLayout::updateUnifiedToolbarOffset() -{ - QPoint offset(0, 0); - - for (int i = 1; i < qtoolbarsInUnifiedToolbarList.length(); ++i) { - offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i - 1)->size().width()); - qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset; - } -} - - -void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) -{ - QHash::iterator it = unifiedToolbarHash.begin(); - while (it != unifiedToolbarHash.end()) { - if (it.value() == toolbar) { - // Rescue our HIView and set it on the mainWindow again. - bool saveVisible = !toolbar->isHidden(); - toolbar->setParent(0); - toolbar->setParent(parentWidget()); - toolbar->setVisible(saveVisible); - ToolBarSaveState saveState = toolbarSaveState.value(toolbar); - static_cast(toolbar->layout())->setUsePopupMenu(false); - toolbar->setMovable(saveState.movable); - toolbar->setMaximumSize(saveState.maximumSize); - toolbarSaveState.remove(toolbar); - NSToolbarItem *item = static_cast(it.key()); - [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar] - removeItemAtIndex:toolbarItemsCopy.indexOf(item)]; - unifiedToolbarHash.remove(item); - qtoolbarsInUnifiedToolbarList.removeAll(toolbar); - break; - } - ++it; - } -} - -void QMainWindowLayout::cleanUpMacToolbarItems() -{ - QMacCocoaAutoReleasePool pool; - for (int i = 0; i < toolbarItemsCopy.size(); ++i) { - NSToolbarItem *item = static_cast(toolbarItemsCopy.at(i)); - [item setView:0]; - CFRelease(toolbarItemsCopy.at(i)); - } - toolbarItemsCopy.clear(); - unifiedToolbarHash.clear(); - - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); - NSToolbar *macToolbar = [window toolbar]; - if (macToolbar) { - [[macToolbar delegate] release]; - [macToolbar setDelegate:nil]; - } -} - -void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const -{ - QHash::const_iterator it = unifiedToolbarHash.constBegin(); - NSToolbarItem *item = nil; - while (it != unifiedToolbarHash.constEnd()) { - if (tb == it.value()) { - item = static_cast(it.key()); - break; - } - ++it; - } - if (item) { - QMacCocoaAutoReleasePool pool; - QWidgetItem layoutItem(tb); - QSize size = layoutItem.maximumSize(); - NSSize nssize = NSMakeSize(size.width(), size.height()); - [item setMaxSize:nssize]; - size = layoutItem.minimumSize(); - nssize.width = size.width(); - nssize.height = size.height(); - [item setMinSize:nssize]; - } -} - -void QMainWindowLayout::syncUnifiedToolbarVisibility() -{ - if (blockVisiblityCheck) - return; - - Q_ASSERT(layoutState.mainWindow->unifiedTitleAndToolBarOnMac()); - bool show = false; - const int ToolBarCount = qtoolbarsInUnifiedToolbarList.count(); - for (int i = 0; i < ToolBarCount; ++i) { - if (qtoolbarsInUnifiedToolbarList.at(i)->isVisible()) { - show = true; - break; - } - } - macWindowToolbarShow(layoutState.mainWindow, show); -} - -QT_END_NAMESPACE diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 096f53de40..5e7eb943ab 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -57,11 +57,6 @@ #include #include #include -#ifdef Q_WS_MAC -#include -#include -#endif - #include #include "qtoolbar_p.h" @@ -74,14 +69,6 @@ QT_BEGIN_NAMESPACE -#ifdef Q_WS_MAC -static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget) -{ - if (!(parentWidget->windowFlags() & Qt::CustomizeWindowHint)) - parentWidget->setWindowFlags(parentWidget->windowFlags() | Qt::MacWindowToolBarButtonHint); -} -#endif - // qmainwindow.cpp extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); @@ -104,17 +91,6 @@ void QToolBarPrivate::init() layout = new QToolBarLayout(q); layout->updateMarginAndSpacing(); -#ifdef Q_WS_MAC - if (q->parentWidget() && q->parentWidget()->isWindow()) { - // Make sure that the window has the "toolbar" button. - QWidget *parentWidget = q->parentWidget(); - qt_mac_updateToolBarButtonHint(parentWidget); - reinterpret_cast(parentWidget)->d_func()->createWinId(); // Please let me create your winId... - extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp - macWindowToolbarShow(q->parentWidget(), true); - } -#endif - toggleViewAction = new QAction(q); toggleViewAction->setCheckable(true); q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q )); @@ -158,12 +134,8 @@ void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug) flags |= Qt::FramelessWindowHint; - if (unplug) { + if (unplug) flags |= Qt::X11BypassWindowManagerHint; -#ifdef Q_WS_MAC - flags |= Qt::WindowStaysOnTopHint; -#endif - } q->setWindowFlags(flags); } @@ -569,16 +541,6 @@ QToolBar::QToolBar(const QString &title, QWidget *parent) */ QToolBar::~QToolBar() { - // Remove the toolbar button if there is nothing left. - QMainWindow *mainwindow = qobject_cast(parentWidget()); - if (mainwindow) { -#ifdef Q_WS_MAC - QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); - if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() - && mainwindow->testAttribute(Qt::WA_WState_Created)) - macWindowToolbarShow(mainwindow, false); -#endif - } } /*! \property QToolBar::movable @@ -665,12 +627,6 @@ void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas) Qt::ToolBarAreas QToolBar::allowedAreas() const { Q_D(const QToolBar); -#ifdef Q_WS_MAC - if (QMainWindow *window = qobject_cast(parentWidget())) { - if (window->unifiedTitleAndToolBarOnMac()) // Don't allow drags to the top (for now). - return (d->allowedAreas & ~Qt::TopToolBarArea); - } -#endif return d->allowedAreas; } @@ -1083,15 +1039,6 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) return false; } -#if defined(Q_WS_MAC) -static bool toolbarInUnifiedToolBar(QToolBar *toolbar) -{ - const QMainWindow *mainWindow = qobject_cast(toolbar->parentWidget()); - return mainWindow && mainWindow->unifiedTitleAndToolBarOnMac() - && mainWindow->toolBarArea(toolbar) == Qt::TopToolBarArea; -} -#endif - /*! \reimp */ bool QToolBar::event(QEvent *event) { @@ -1115,22 +1062,9 @@ bool QToolBar::event(QEvent *event) case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); emit visibilityChanged(event->type() == QEvent::Show); -#if defined(Q_WS_MAC) - if (toolbarInUnifiedToolBar(this)) { - // I can static_cast because I did the qobject_cast in the if above, therefore - // we must have a QMainWindowLayout here. - QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast(parentWidget())); - mwLayout->fixSizeInUnifiedToolbar(this); - mwLayout->syncUnifiedToolbarVisibility(); - } -#endif // Q_WS_MAC break; case QEvent::ParentChange: d->layout->checkUsePopupMenu(); -#if defined(Q_WS_MAC) - if (parentWidget() && parentWidget()->isWindow()) - qt_mac_updateToolBarButtonHint(parentWidget()); -#endif break; case QEvent::MouseButtonPress: { diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 3c0c84ee2f..fe919feba9 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -332,20 +332,6 @@ void QToolBarLayout::updateGeomArray() const rpick(o, that->hint) += handleExtent; that->hint += QSize(2*margin, 2*margin); - that->dirty = false; -#ifdef Q_WS_MAC - if (QMainWindow *mw = qobject_cast(parentWidget()->parentWidget())) { - if (mw->unifiedTitleAndToolBarOnMac() - && mw->toolBarArea(static_cast(parentWidget())) == Qt::TopToolBarArea) { - if (expandFlag) { - tb->setMaximumSize(0xFFFFFF, 0xFFFFFF); - } else { - tb->setMaximumSize(hint); - } - } - } -#endif - that->dirty = false; } @@ -401,15 +387,6 @@ void QToolBarLayout::setGeometry(const QRect &rect) if (!extension->isHidden()) extension->hide(); } -#ifdef Q_WS_MAC - if (QMainWindow *win = qobject_cast(tb->parentWidget())) { - Qt::ToolBarArea area = win->toolBarArea(tb); - if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { - qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb); - } - } -#endif - } bool QToolBarLayout::layoutActions(const QSize &size) diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index efe1dd3616..1bae87ebcc 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -155,15 +155,6 @@ macx { widgets/qmaccocoaviewcontainer_mac.mm } -# TODO -false:mac { - OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \ - widgets/qcocoamenu_mac_p.h - OBJECTIVE_SOURCES += widgets/qcocoatoolbardelegate_mac.mm \ - widgets/qmainwindowlayout_mac.mm - -} - wince*: { SOURCES += widgets/qmenu_wince.cpp HEADERS += widgets/qmenu_wince_resource_p.h -- cgit v1.2.3 From a761be2fb2191215426f904cb03df0e966214531 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 23 Nov 2013 00:15:30 +0100 Subject: Correct wordwrapped text handling in QListView icon mode Currently a QListView with wordwrapping activated will wrap the text only to the width of the icon even if the grid size is bigger. With this patch the option rect is now updated to match the grid size if valid and the style uses it to determine the correct size when wrapping [ChangeLog][QtWidgets][QTBUG-4714] Use the grid size for wordwrapping when available in icon mode Task-number: QTBUG-4714 Change-Id: I2cb63809d3ee8bd262f38bc11de91df9ff5cf237 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qlistview.cpp | 5 +++++ src/widgets/styles/qcommonstyle.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0cca52daa2..8238e5f6d4 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -915,6 +915,11 @@ QStyleOptionViewItem QListView::viewOptions() const } else { option.decorationPosition = QStyleOptionViewItem::Left; } + + if (d->gridSize().isValid()) { + option.rect.setSize(d->gridSize()); + } + return option; } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index a9f1c3bbbc..2d7107598f 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -838,7 +838,10 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int break; case QStyleOptionViewItem::Top: case QStyleOptionViewItem::Bottom: - bounds.setWidth(wrapText ? option->decorationSize.width() : QFIXED_MAX); + if (wrapText) + bounds.setWidth(bounds.isValid() ? bounds.width() - 2 * textMargin : option->decorationSize.width()); + else + bounds.setWidth(QFIXED_MAX); break; default: break; -- cgit v1.2.3 From a6c79344f74a1cb2c2831bc9ebec4f927d49df9b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 14 Jan 2014 09:33:50 +0100 Subject: Fix typo in QTextEdit documentation Task-number: QTBUG-36077 Change-Id: I5cd9ad3fe309e5dd2e5e5d67d6c7561182e65c25 Reviewed-by: Mitch Curtis Reviewed-by: Giuseppe D'Angelo Reviewed-by: Jerome Pasion --- src/widgets/widgets/qtextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 49e05e8e14..e47abace4d 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2042,7 +2042,7 @@ QList QTextEdit::extraSelections() const This function returns a new MIME data object to represent the contents of the text edit's current selection. It is called when the selection needs to be encapsulated into a new QMimeData object; for example, when a drag - and drop operation is started, or when data is copyied to the clipboard. + and drop operation is started, or when data is copied to the clipboard. If you reimplement this function, note that the ownership of the returned QMimeData object is passed to the caller. The selection can be retrieved -- cgit v1.2.3 From 65defa516d35697df5c3babe5b110c24327a1df9 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Tue, 17 Dec 2013 11:43:12 +1100 Subject: Doc: Fix suggest parentheses GCC warning Change-Id: I96cb76da7d260d08133830de72b0ff6e6a5099be Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp index 338817ea74..70e3090cde 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp @@ -44,7 +44,7 @@ w->setWindowState(w->windowState() ^ Qt::WindowFullScreen); //! [1] -w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive); +w->setWindowState((w->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); //! [1] -- cgit v1.2.3 From 03b6a2f0f98b70b24c0cce645d6d58c084111f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Jan 2014 12:21:21 +0100 Subject: Mac: Improve transformed QGraphicsProxyWidgets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore Mac code paths from Qt 4. Task-number: QTBUG-29139 Change-Id: I2893ddf6015e2bda92d4a16980dbe2c9021eeef7 Reviewed-by: Morten Johan Sørvig --- src/widgets/graphicsview/qgraphicswidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index ccc51120a9..40d32ea1d5 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -2274,7 +2274,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap const QPointF styleOrigin = this->windowFrameRect().topLeft(); painter->translate(styleOrigin); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC const QSize pixmapSize = windowFrameRect.size(); if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0) return; @@ -2342,7 +2342,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap frameOptions.midLineWidth = 1; style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC realPainter->drawPixmap(QPoint(), pm); delete painter; #endif -- cgit v1.2.3