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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets/widgets/qtoolbar.cpp') 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(); -- 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/widgets/qtoolbar.cpp | 68 +--------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'src/widgets/widgets/qtoolbar.cpp') 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: { -- cgit v1.2.3