QMainWindow: remove dead code about mac unified toolbar
Qt5 implementation of the unified toolbar is different and we can cleanup the old Qt4 code. Change-Id: I17805217e3fba43dad8fd4a5a13468e22fc746de Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
parent
e4b3e47935
commit
dc41aaa294
@ -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
|
||||
@ -94,10 +83,6 @@ public:
|
||||
Qt::ToolButtonStyle toolButtonStyle;
|
||||
#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;
|
||||
@ -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
|
||||
@ -1625,9 +1544,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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -2253,9 +2158,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);
|
||||
@ -2280,10 +2182,6 @@ QMainWindowLayout::~QMainWindowLayout()
|
||||
layoutState.deleteAllLayoutItems();
|
||||
layoutState.deleteCentralWidgetItem();
|
||||
|
||||
#if 0 // Used to be included in Qt4 for Q_WS_MAC
|
||||
cleanUpMacToolbarItems();
|
||||
#endif
|
||||
|
||||
delete statusbar;
|
||||
}
|
||||
|
||||
@ -2654,22 +2552,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
|
||||
|
@ -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;
|
||||
|
||||
@ -313,10 +312,8 @@ public:
|
||||
QLayoutItem *unplug(QWidget *widget, bool group = false);
|
||||
void revert(QLayoutItem *widgetItem);
|
||||
void updateGapIndicator();
|
||||
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:
|
||||
@ -330,40 +327,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)
|
||||
|
Loading…
Reference in New Issue
Block a user