diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 99 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout_p.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 86 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 182 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout_p.h | 36 | ||||
-rw-r--r-- | src/widgets/widgets/qmdiarea.cpp | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qmdisubwindow.cpp | 58 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qpushbutton.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 5 |
13 files changed, 92 insertions, 403 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b18066c174..272032d76f 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -67,11 +67,6 @@ #include <private/qabstractscrollarea_p.h> #include <private/qlineedit_p.h> #include <qdebug.h> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && QT_CONFIG(style_mac) -#include <private/qcore_mac_p.h> -#include <private/qmacstyle_mac_p.h> -#include <private/qt_cocoa_helpers_mac_p.h> -#endif #ifndef QT_NO_EFFECTS # include <private/qeffects_p.h> #endif diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 8140fa6def..27ecc33dba 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1044,33 +1044,6 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) Q_ASSERT(item.widgetItem != 0); Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem); item.flags &= ~QDockAreaLayoutItem::GapItem; - - QRect result; - -#ifndef QT_NO_TABBAR - if (tabbed) { - } else -#endif - { - int prev = this->prev(index); - int next = this->next(index); - - if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { - item.pos += *sep; - item.size -= *sep; - } - if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) - item.size -= *sep; - - QPoint pos; - rpick(o, pos) = item.pos; - rperp(o, pos) = perp(o, rect.topLeft()); - QSize s; - rpick(o, s) = item.size; - rperp(o, s) = perp(o, rect.size()); - result = QRect(pos, s); - } - return item.widgetItem; } @@ -1323,29 +1296,46 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) return item_list[index].subinfo->info(path.mid(1)); } -QRect QDockAreaLayoutInfo::itemRect(int index) const +QRect QDockAreaLayoutInfo::itemRect(int index, bool isGap) const { const QDockAreaLayoutItem &item = item_list.at(index); if (item.skip()) return QRect(); + if (isGap && !(item.flags & QDockAreaLayoutItem::GapItem)) + return QRect(); + QRect result; #ifndef QT_NO_TABBAR if (tabbed) { - if (tabId(item) == currentTabId()) + if (isGap || tabId(item) == currentTabId()) result = tabContentRect(); } else #endif { - QPoint pos; - rpick(o, pos) = item.pos; - rperp(o, pos) = perp(o, rect.topLeft()); + int pos = item.pos; + int size = item.size; + + if (isGap) { + int prev = this->prev(index); + int next = this->next(index); + if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { + pos += *sep; + size -= *sep; + } + if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) + size -= *sep; + } + + QPoint p; + rpick(o, p) = pos; + rperp(o, p) = perp(o, rect.topLeft()); QSize s; - rpick(o, s) = item.size; + rpick(o, s) = size; rperp(o, s) = perp(o, rect.size()); - result = QRect(pos, s); + result = QRect(p, s); } return result; @@ -3422,47 +3412,10 @@ QRect QDockAreaLayout::gapRect(const QList<int> &path) const const QDockAreaLayoutInfo *info = this->info(path); if (info == 0) return QRect(); - const QList<QDockAreaLayoutItem> &item_list = info->item_list; - Qt::Orientation o = info->o; int index = path.last(); - if (index < 0 || index >= item_list.count()) - return QRect(); - const QDockAreaLayoutItem &item = item_list.at(index); - if (!(item.flags & QDockAreaLayoutItem::GapItem)) + if (index < 0 || index >= info->item_list.count()) return QRect(); - - QRect result; - -#ifndef QT_NO_TABBAR - if (info->tabbed) { - result = info->tabContentRect(); - } else -#endif - { - int pos = item.pos; - int size = item.size; - - int prev = info->prev(index); - int next = info->next(index); - - if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { - pos += sep; - size -= sep; - } - if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) - size -= sep; - - QPoint p; - rpick(o, p) = pos; - rperp(o, p) = perp(o, info->rect.topLeft()); - QSize s; - rpick(o, s) = size; - rperp(o, s) = perp(o, info->rect.size()); - - result = QRect(p, s); - } - - return result; + return info->itemRect(index, true); } void QDockAreaLayout::keepSize(QDockWidget *w) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 21787283f4..e9bd661cbd 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -160,7 +160,7 @@ public: void fitItems(); bool expansive(Qt::Orientation o) const; int changeSize(int index, int size, bool below); - QRect itemRect(int index) const; + QRect itemRect(int index, bool isGap = false) const; QRect itemRect(const QList<int> &path) const; QRect separatorRect(int index) const; QRect separatorRect(const QList<int> &path) const; diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 307a261a43..2928d51d20 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -58,11 +58,6 @@ #include "qdockwidget_p.h" #include "qmainwindowlayout_p.h" -#if 0 // Used to be included in Qt4 for Q_WS_MAC -#include <private/qapplication_p.h> -#include <private/qt_mac_p.h> -#include <private/qmacstyle_mac_p.h> -#endif QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 27dd186f04..29c8a42cad 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -76,7 +76,10 @@ #include "private/qapplication_p.h" #include "private/qshortcutmap_p.h" #include "qkeysequence.h" -#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ +#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \ + ? false \ + : qApp->styleHints()->showShortcutsInContextMenus()) \ + && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else #define ACCEL_KEY(k) QString() diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index c9349ac72d..8eb5669f1c 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -61,13 +61,6 @@ #ifdef Q_OS_OSX #include <qpa/qplatformnativeinterface.h> #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC -#include <private/qt_mac_p.h> -#include <private/qt_cocoa_helpers_mac_p.h> -QT_BEGIN_NAMESPACE -extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp -QT_END_NAMESPACE -#endif QT_BEGIN_NAMESPACE @@ -80,10 +73,6 @@ public: #ifdef Q_OS_OSX , useUnifiedToolBar(false) #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC - , useHIToolBar(false) - , activateUnifiedToolbarAfterFullScreen(false) -#endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) #endif @@ -95,10 +84,6 @@ public: #ifdef Q_OS_OSX bool useUnifiedToolBar; #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC - bool useHIToolBar; - bool activateUnifiedToolbarAfterFullScreen; -#endif void init(); QList<int> hoverSeparator; QPoint hoverPos; @@ -805,11 +790,7 @@ void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar) #endif } - if (!d->layout->usesHIToolBar(toolbar)) { - d->layout->removeWidget(toolbar); - } else { - d->layout->removeToolBar(toolbar); - } + d->layout->removeToolBar(toolbar); toolbar->d_func()->_q_updateIconSize(d->iconSize); toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); @@ -1111,21 +1092,6 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget } d_func()->layout->removeWidget(dockwidget); // in case it was already in here addDockWidget(area, dockwidget, orientation); - -#if 0 // Used to be included in Qt4 for Q_WS_MAC //drawer support - QMacAutoReleasePool pool; - extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp - if (qt_mac_is_macdrawer(dockwidget)) { - extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp - window()->createWinId(); - dockwidget->window()->createWinId(); - qt_mac_set_drawer_preferred_edge(dockwidget, area); - if (dockwidget->isVisible()) { - dockwidget->hide(); - dockwidget->show(); - } - } -#endif } /*! @@ -1516,26 +1482,6 @@ bool QMainWindow::event(QEvent *event) if (!d->explicitIconSize) setIconSize(QSize()); break; -#if 0 // Used to be included in Qt4 for Q_WS_MAC - case QEvent::Show: - if (unifiedTitleAndToolBarOnMac()) - d->layout->syncUnifiedToolbarVisibility(); - d->layout->blockVisiblityCheck = false; - break; - case QEvent::WindowStateChange: - { - if (isHidden()) { - // We are coming out of a minimize, leave things as is. - d->layout->blockVisiblityCheck = true; - } - // We need to update the HIToolbar status when we go out of or into fullscreen. - QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event); - if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) { - d->layout->updateHIToolBarStatus(); - } - } - break; -#endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) case QEvent::CursorChange: // CursorChange events are triggered as mouse moves to new widgets even @@ -1589,33 +1535,6 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) (reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set); update(); } -#endif - -#if 0 // Used to be included in Qt4 for Q_WS_MAC - Q_D(QMainWindow); - if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) - return; - - d->useHIToolBar = set; - createWinId(); // We need the hiview for down below. - - // Activate the unified toolbar with the raster engine. - if (windowSurface() && set) { - d->layout->unifiedSurface = new QUnifiedToolbarSurface(this); - } - - d->layout->updateHIToolBarStatus(); - - // Deactivate the unified toolbar with the raster engine. - if (windowSurface() && !set) { - if (d->layout->unifiedSurface) { - delete d->layout->unifiedSurface; - d->layout->unifiedSurface = 0; - } - } - - // Enabling the unified toolbar clears the opaque size grip setting, update it. - d->macUpdateOpaqueSizeGrip(); #else Q_UNUSED(set) #endif @@ -1626,9 +1545,6 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const #ifdef Q_OS_OSX return d_func()->useUnifiedToolBar; #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC - return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); -#endif return false; } diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index d31fa3ddfa..98421588a7 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -70,10 +70,6 @@ #include <private/qapplication_p.h> #include <private/qlayoutengine_p.h> #include <private/qwidgetresizehandler_p.h> -#if 0 // Used to be included in Qt4 for Q_WS_MAC -# include <private/qcore_mac_p.h> -# include <private/qt_cocoa_helpers_mac_p.h> -#endif QT_BEGIN_NAMESPACE @@ -1183,14 +1179,7 @@ void QMainWindowLayout::removeToolBar(QToolBar *toolbar) QObject::disconnect(parentWidget(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); -#if 0 // Used to be included in Qt4 for Q_WS_MAC - if (usesHIToolBar(toolbar)) { - removeFromMacToolbar(toolbar); - } else -#endif - { - removeWidget(toolbar); - } + removeWidget(toolbar); } } @@ -1202,25 +1191,17 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, bool) { validateToolBarArea(area); -#if 0 // Used to be included in Qt4 for Q_WS_MAC - if ((area == Qt::TopToolBarArea) - && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { - insertIntoMacToolbar(0, toolbar); - } else -#endif - { - //let's add the toolbar to the layout - addChildWidget(toolbar); - QLayoutItem * item = layoutState.toolBarAreaLayout.addToolBar(toDockPos(area), toolbar); - if (savedState.isValid() && item) { - // copy the toolbar also in the saved state - savedState.toolBarAreaLayout.insertItem(toDockPos(area), item); - } - invalidate(); - - //this ensures that the toolbar has the right window flags (not floating any more) - toolbar->d_func()->updateWindowFlags(false /*floating*/); + // let's add the toolbar to the layout + addChildWidget(toolbar); + QLayoutItem *item = layoutState.toolBarAreaLayout.addToolBar(toDockPos(area), toolbar); + if (savedState.isValid() && item) { + // copy the toolbar also in the saved state + savedState.toolBarAreaLayout.insertItem(toDockPos(area), item); } + invalidate(); + + // this ensures that the toolbar has the right window flags (not floating any more) + toolbar->d_func()->updateWindowFlags(false /*floating*/); } /*! @@ -1228,27 +1209,20 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, */ void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar) { -#if 0 // Used to be included in Qt4 for Q_WS_MAC - if (usesHIToolBar(before)) { - insertIntoMacToolbar(before, toolbar); - } else -#endif - { - addChildWidget(toolbar); - QLayoutItem * item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar); - if (savedState.isValid() && item) { - // copy the toolbar also in the saved state - savedState.toolBarAreaLayout.insertItem(before, item); - } - if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) { - currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex(); - if (!currentGapPos.isEmpty()) { - currentGapPos.prepend(0); - currentGapRect = layoutState.itemRect(currentGapPos); - } + addChildWidget(toolbar); + QLayoutItem *item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar); + if (savedState.isValid() && item) { + // copy the toolbar also in the saved state + savedState.toolBarAreaLayout.insertItem(before, item); + } + if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) { + currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex(); + if (!currentGapPos.isEmpty()) { + currentGapPos.prepend(0); + currentGapRect = layoutState.itemRect(currentGapPos); } - invalidate(); } + invalidate(); } Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const @@ -1261,12 +1235,6 @@ Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const case QInternal::BottomDock: return Qt::BottomToolBarArea; default: break; } -#if 0 // Used to be included in Qt4 for Q_WS_MAC - if (pos == QInternal::DockCount) { - if (qtoolbarsInUnifiedToolbarList.contains(toolbar)) - return Qt::TopToolBarArea; - } -#endif return Qt::NoToolBarArea; } @@ -1283,70 +1251,15 @@ void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar void QMainWindowLayout::toggleToolBarsVisible() { - bool updateNonUnifiedParts = true; -#if 0 // Used to be included in Qt4 for Q_WS_MAC - if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { - // If we hit this case, someone has pressed the "toolbar button" which will - // toggle the unified toolbar visibility, because that's what the user wants. - // We might be in a situation where someone has hidden all the toolbars - // beforehand (maybe in construction), but now they've hit this button and - // and are expecting the items to show. What do we do? - // 1) Check the visibility of all the toolbars, if one is visible, do nothing, this - // preserves what people would expect (these toolbars were visible when I clicked last time). - // 2) If NONE are visible, then show them all. Again, this preserves the user expectation - // of, "I want to see the toolbars." The user may get more toolbars than expected, but this - // is better seeing nothing. - // Don't worry about any of this if we are going invisible. This does mean we may get - // into issues when switching into and out of fullscreen mode, but this is probably minor. - // If we ever need to do hiding, that would have to be taken care of after the unified toolbar - // has finished hiding. - // People can of course handle the QEvent::ToolBarChange event themselves and do - // WHATEVER they want if they don't like what we are doing (though the unified toolbar - // will fire regardless). - - // Check if we REALLY need to update the geometry below. If we only have items in the - // unified toolbar, all the docks will be empty, so there's very little point - // in doing the geometry as Apple will do it (we also avoid flicker in Cocoa as well). - // FWIW, layoutState.toolBarAreaLayout.visible and the state of the unified toolbar - // visibility can get out of sync. I really don't think it's a big issue. It is kept - // to a minimum because we only change the visibility if we absolutely must. - // update the "non unified parts." - updateNonUnifiedParts = !layoutState.toolBarAreaLayout.isEmpty(); - - // We get this function before the unified toolbar does its thing. - // So, the value will be opposite of what we expect. - bool goingVisible = !macWindowToolbarIsVisible(qt_mac_window_for(layoutState.mainWindow)); - if (goingVisible) { - const int ToolBarCount = qtoolbarsInUnifiedToolbarList.size(); - bool needAllVisible = true; - for (int i = 0; i < ToolBarCount; ++i) { - if (!qtoolbarsInUnifiedToolbarList.at(i)->isHidden()) { - needAllVisible = false; - break; - } - } - if (needAllVisible) { - QBoolBlocker blocker(blockVisiblityCheck); // Disable the visibilty check because - // the toggle has already happened. - for (int i = 0; i < ToolBarCount; ++i) - qtoolbarsInUnifiedToolbarList.at(i)->setVisible(true); - } - } - if (!updateNonUnifiedParts) - layoutState.toolBarAreaLayout.visible = goingVisible; - } -#endif - if (updateNonUnifiedParts) { - layoutState.toolBarAreaLayout.visible = !layoutState.toolBarAreaLayout.visible; - if (!layoutState.mainWindow->isMaximized()) { - QPoint topLeft = parentWidget()->geometry().topLeft(); - QRect r = parentWidget()->geometry(); - r = layoutState.toolBarAreaLayout.rectHint(r); - r.moveTo(topLeft); - parentWidget()->setGeometry(r); - } else { - update(); - } + layoutState.toolBarAreaLayout.visible = !layoutState.toolBarAreaLayout.visible; + if (!layoutState.mainWindow->isMaximized()) { + QPoint topLeft = parentWidget()->geometry().topLeft(); + QRect r = parentWidget()->geometry(); + r = layoutState.toolBarAreaLayout.rectHint(r); + r.moveTo(topLeft); + parentWidget()->setGeometry(r); + } else { + update(); } } @@ -1933,14 +1846,6 @@ QSize QMainWindowLayout::minimumSize() const const QSize sbMin = statusbar ? statusbar->minimumSize() : QSize(0, 0); minSize = QSize(qMax(sbMin.width(), minSize.width()), sbMin.height() + minSize.height()); -#if 0 // Used to be included in Qt4 for Q_WS_MAC - const QSize storedSize = minSize; - int minWidth = 0; - foreach (QToolBar *toolbar, qtoolbarsInUnifiedToolbarList) { - minWidth += toolbar->sizeHint().width() + 20; - } - minSize = QSize(qMax(minWidth, storedSize.width()), storedSize.height()); -#endif } return minSize; } @@ -2272,9 +2177,6 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay #endif // QT_NO_DOCKWIDGET , widgetAnimator(this) , pluggingWidget(0) -#if 0 // Used to be included in Qt4 for Q_WS_MAC - , blockVisiblityCheck(false) -#endif { if (parentLayout) setParent(parentLayout); @@ -2299,10 +2201,6 @@ QMainWindowLayout::~QMainWindowLayout() layoutState.deleteAllLayoutItems(); layoutState.deleteCentralWidgetItem(); -#if 0 // Used to be included in Qt4 for Q_WS_MAC - cleanUpMacToolbarItems(); -#endif - delete statusbar; } @@ -2677,22 +2575,6 @@ bool QMainWindowLayout::restoreState(QDataStream &stream) return true; } - -// Returns if this toolbar *should* be using HIToolbar. Won't work for all in between cases -// for example, you have a toolbar in the top area and then you suddenly turn on -// HIToolbar. -bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const -{ -#if 1 // Used to be excluded in Qt4 for Q_WS_MAC - Q_UNUSED(toolbar); - return false; -#else - return qtoolbarsInUnifiedToolbarList.contains(toolbar) - || ((toolBarArea(toolbar) == Qt::TopToolBarArea) - && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()); -#endif -} - void QMainWindowLayout::timerEvent(QTimerEvent *e) { #ifndef QT_NO_DOCKWIDGET diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index ed8da61bc3..507759fe96 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -180,7 +180,6 @@ public: QMainWindow::DockOptions dockOptions; void setDockOptions(QMainWindow::DockOptions opts); - bool usesHIToolBar(QToolBar *toolbar) const; void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; @@ -316,7 +315,6 @@ public: void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip); void applyState(QMainWindowLayoutState &newState, bool animate = true); void restore(bool keepSavedState = false); - void updateHIToolBarStatus(); void animationFinished(QWidget *widget); private Q_SLOTS: @@ -331,40 +329,6 @@ private: #ifndef QT_NO_TABBAR void updateTabBarShapes(); #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC - static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *); - static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event, - void *data); - static void qtMacHIToolbarRegisterQToolBarInHIToolborItemClass(); - static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data); - static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar, - QMainWindowLayout *layout); -public: - struct ToolBarSaveState { - ToolBarSaveState() : movable(false) { } - ToolBarSaveState(bool newMovable, const QSize &newMax) - : movable(newMovable), maximumSize(newMax) { } - bool movable; - QSize maximumSize; - }; - QList<QToolBar *> qtoolbarsInUnifiedToolbarList; - QList<void *> toolbarItemsCopy; - QHash<void *, QToolBar *> unifiedToolbarHash; - QHash<QToolBar *, ToolBarSaveState> toolbarSaveState; - QHash<QString, QToolBar *> cocoaItemIDToToolbarHash; - void insertIntoMacToolbar(QToolBar *before, QToolBar *after); - void removeFromMacToolbar(QToolBar *toolbar); - void cleanUpMacToolbarItems(); - void fixSizeInUnifiedToolbar(QToolBar *tb) const; - bool useHIToolBar; - bool activateUnifiedToolbarAfterFullScreen; - void syncUnifiedToolbarVisibility(); - bool blockVisiblityCheck; - - QUnifiedToolbarSurface *unifiedSurface; - void updateUnifiedToolbarOffset(); - -#endif }; #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG_STREAM) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 18cb823702..0dc45ddbc3 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -160,9 +160,6 @@ #include <QApplication> #include <QStyle> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac) -#include <private/qmacstyle_mac_p.h> -#endif #include <QChildEvent> #include <QResizeEvent> #include <QScrollBar> diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index a8cdca1719..c2dcacc6ba 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -158,9 +158,6 @@ #include <QMainWindow> #include <QScrollBar> #include <QDebug> -#if QT_CONFIG(style_mac) -#include <private/qmacstyle_mac_p.h> -#endif #include <QMdiArea> #include <QScopedValueRollback> @@ -194,6 +191,11 @@ static const Qt::WindowFlags CustomizeWindowFlags = static const int BoundaryMargin = 5; +static inline bool isMacStyle(QStyle *style) +{ + return style->inherits("QMacStyle"); +} + static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag, int delta, int maxDelta, int minDelta) { @@ -295,11 +297,8 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti Q_ASSERT(helpEvent->type() == QEvent::ToolTip); Q_ASSERT(widget); -#if QT_CONFIG(style_mac) - // Native Mac windows don't show tool tip. - if (qobject_cast<QMacStyle *>(widget->style())) + if (widget->style()->styleHint(QStyle::SH_TitleBar_ShowToolTipsOnButtons, &opt, widget)) return; -#endif // Convert CC_MdiControls to CC_TitleBar. Sub controls of different complex // controls cannot be in the same switch as they might have the same value. @@ -1076,10 +1075,8 @@ void QMdiSubWindowPrivate::updateCursor() { #ifndef QT_NO_CURSOR Q_Q(QMdiSubWindow); -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(q->style())) + if (isMacStyle(q->style())) return; -#endif if (currentOperation == None) { q->unsetCursor(); @@ -1504,15 +1501,14 @@ void QMdiSubWindowPrivate::processClickedSubControl() q->showNormal(); break; case QStyle::SC_TitleBarMinButton: -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(q->style())) { + if (isMacStyle(q->style())) { if (q->isMinimized()) q->showNormal(); else q->showMinimized(); break; } -#endif + q->showMinimized(); break; case QStyle::SC_TitleBarNormalButton: @@ -1521,15 +1517,14 @@ void QMdiSubWindowPrivate::processClickedSubControl() q->showNormal(); break; case QStyle::SC_TitleBarMaxButton: -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(q->style())) { + if (isMacStyle(q->style())) { if (q->isMaximized()) q->showNormal(); else q->showMaximized(); break; } -#endif + q->showMaximized(); break; case QStyle::SC_TitleBarCloseButton: @@ -1568,10 +1563,8 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const } QRegion region; -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(q->style())) + if (isMacStyle(q->style())) return region; -#endif switch (operation) { case TopResize: @@ -1775,10 +1768,6 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const if (isChildOfTabbedQMdiArea(q)) return false; -#if QT_CONFIG(style_mac) - Q_UNUSED(isChildOfQMdiSubWindow); - return true; -#else if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) return true; #if defined(QT_NO_MENUBAR) || defined(QT_NO_MAINWINDOW) @@ -1792,7 +1781,6 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const return isChildOfQMdiSubWindow(q); #endif -#endif } #ifndef QT_NO_MENUBAR @@ -2191,10 +2179,8 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) return; newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); bool putSizeGripInLayout = layout ? true : false; -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(q->style())) + if (isMacStyle(q->style())) putSizeGripInLayout = false; -#endif if (putSizeGripInLayout) { layout->addWidget(newSizeGrip); layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); @@ -2843,8 +2829,8 @@ bool QMdiSubWindow::event(QEvent *event) d->isMaximizeMode = false; d->isWidgetHiddenByUs = false; if (!parent()) { -#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(style())) +#if !defined(QT_NO_SIZEGRIP) + if (isMacStyle(style())) delete d->sizeGrip; #endif setOption(RubberBandResize, false); @@ -2938,8 +2924,8 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) return; } -#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(style()) && !d->sizeGrip +#if !defined(QT_NO_SIZEGRIP) + if (isMacStyle(style()) && !d->sizeGrip && !(windowFlags() & Qt::FramelessWindowHint)) { d->setSizeGrip(new QSizeGrip(this)); Q_ASSERT(d->sizeGrip); @@ -3333,10 +3319,10 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, d->hoveredSubControl, this); } -#if QT_CONFIG(style_mac) - if (qobject_cast<QMacStyle *>(style()) && !hoverRegion.isEmpty()) + + if (isMacStyle(style()) && !hoverRegion.isEmpty()) hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options)); -#endif + if (!hoverRegion.isEmpty()) update(hoverRegion); } @@ -3543,10 +3529,8 @@ QSize QMdiSubWindow::minimumSizeHint() const int sizeGripHeight = 0; if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this))) sizeGripHeight = d->sizeGrip->height(); -#if QT_CONFIG(style_mac) - else if (parent() && qobject_cast<QMacStyle *>(style()) && !d->sizeGrip) + else if (parent() && isMacStyle(style()) && !d->sizeGrip) sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); -#endif minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); #endif diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 1925b58326..4e55f0b132 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -332,7 +332,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1))); s = s.left(t); #ifndef QT_NO_SHORTCUT - } else { + } else if (action->isShortcutVisibleInContextMenu()) { QKeySequence seq = action->shortcut(); if (!seq.isEmpty()) tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText))); @@ -1436,7 +1436,8 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) option->icon = action->icon(); QString textAndAccel = action->text(); #ifndef QT_NO_SHORTCUT - if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) { + if (action->isShortcutVisibleInContextMenu() + && textAndAccel.indexOf(QLatin1Char('\t')) == -1) { QKeySequence seq = action->shortcut(); if (!seq.isEmpty()) textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText); diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index 5b1e10eb32..a4318681c9 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -59,10 +59,6 @@ #if QT_CONFIG(dialogbuttonbox) #include "qdialogbuttonbox.h" #endif -#if 0 // Used to be included in Qt4 for Q_WS_MAC -#include "private/qmacstyle_mac_p.h" -#include "private/qmacstyle_mac_p_p.h" -#endif #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 714f8bfda8..0d34fae78f 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -85,7 +85,10 @@ #include "private/qapplication_p.h" #include "private/qshortcutmap_p.h" #include <qkeysequence.h> -#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ +#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \ + ? false \ + : qApp->styleHints()->showShortcutsInContextMenus()) \ + && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else |