QAbstractMenuBarImpl::allowSetVisible => setVisible

This makes it possible to alter the behavior of QMenuBar::setVisible().
It seems to be needed for the Mac menubar.

Merge-request: 916
Reviewed-by: Thierry Bastian <thierry.bastian@nokia.com>
(cherry picked from commit bafeffd7b8b2c40761369ba496ee655dff6cf2a5)
This commit is contained in:
Aurélien Gâteau 2011-04-14 10:00:30 +02:00 committed by Olivier Goffart
parent 03b0eb416f
commit 9317fee1d9
4 changed files with 6 additions and 14 deletions

View File

@ -77,8 +77,7 @@ public:
// QMenuBarPrivate::init()
virtual void init(QMenuBar *) = 0;
// QMenuBar::setVisible()
virtual bool allowSetVisible() const = 0;
virtual void setVisible(bool visible) = 0;
virtual void actionEvent(QActionEvent *) = 0;

View File

@ -1055,10 +1055,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
void QMenuBar::setVisible(bool visible)
{
Q_D(QMenuBar);
if (!d->impl->allowSetVisible()) {
return;
}
QWidget::setVisible(visible);
d->impl->setVisible(visible);
}
/*!

View File

@ -90,20 +90,16 @@ void QMenuBarImpl::init(QMenuBar *_menuBar)
#endif
}
bool QMenuBarImpl::allowSetVisible() const
void QMenuBarImpl::setVisible(bool visible)
{
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
// FIXME: Port this to a setVisible() method
/*
if (isNativeMenuBar()) {
if (!visible)
QWidget::setVisible(false);
menuBar->QWidget::setVisible(false);
return;
}
*/
return !isNativeMenuBar();
#endif
return true;
menuBar->QWidget::setVisible(visible);
}
void QMenuBarImpl::actionEvent(QActionEvent *e)

View File

@ -56,7 +56,7 @@ public:
virtual void init(QMenuBar *);
virtual bool allowSetVisible() const;
virtual void setVisible(bool visible);
virtual void actionEvent(QActionEvent *e);