diff options
Diffstat (limited to 'src/gui/widgets/qmainwindow.cpp')
-rw-r--r-- | src/gui/widgets/qmainwindow.cpp | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 71c8e6d..8805fb8 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1,7 +1,6 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -21,9 +20,10 @@ ** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. @@ -73,7 +73,7 @@ class QMainWindowPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QMainWindow) public: inline QMainWindowPrivate() - : layout(0), toolButtonStyle(Qt::ToolButtonIconOnly) + : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_WS_MAC , useHIToolBar(false) #endif @@ -107,8 +107,6 @@ void QMainWindowPrivate::init() layout = new QMainWindowLayout(q); const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); - explicitIconSize = false; - q->setAttribute(Qt::WA_Hover); } @@ -148,8 +146,8 @@ void QMainWindowPrivate::init() \class QMainWindow \brief The QMainWindow class provides a main application window. - \ingroup application - \mainclass + \ingroup mainwindow-classes + \tableofcontents @@ -481,6 +479,11 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->deleteLater(); } d->layout->setMenuBar(menuBar); + if (menuBar) { + QAction* menu = new QAction(QString::fromLatin1("Options"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); + setSoftKey(menu); + } } /*! @@ -1029,6 +1032,8 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget Restores the state of \a dockwidget if it is created after the call to restoreState(). Returns true if the state was restored; otherwise returns false. + + \sa restoreState(), saveState() */ bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget) @@ -1160,6 +1165,11 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const To restore the saved state, pass the return value and \a version number to restoreState(). + To save the geometry when the window closes, you can + implement a close event like this: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0 + \sa restoreState(), QWidget::saveGeometry(), QWidget::restoreGeometry() */ QByteArray QMainWindow::saveState(int version) const @@ -1179,7 +1189,13 @@ QByteArray QMainWindow::saveState(int version) const unchanged, and this function returns \c false; otherwise, the state is restored, and this function returns \c true. - \sa saveState(), QWidget::saveGeometry(), QWidget::restoreGeometry() + To restore geometry saved using QSettings, you can use code like + this: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1 + + \sa saveState(), QWidget::saveGeometry(), + QWidget::restoreGeometry(), restoreDockWidget() */ bool QMainWindow::restoreState(const QByteArray &state, int version) { @@ -1369,20 +1385,25 @@ bool QMainWindow::event(QEvent *event) #ifdef Q_WS_MAC case QEvent::Show: if (unifiedTitleAndToolBarOnMac()) - macWindowToolbarShow(this, true); + d->layout->syncUnifiedToolbarVisibility(); + d->layout->blockVisiblityCheck = false; break; -# ifdef QT_MAC_USE_COCOA case QEvent::WindowStateChange: { + if (isHidden()) { + // We are coming out of a minimize, leave things as is. + d->layout->blockVisiblityCheck = true; + } +# ifdef QT_MAC_USE_COCOA // 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(); } +# endif // Cocoa } break; -# endif // Cocoa -#endif +#endif // Q_WS_MAC #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) case QEvent::CursorChange: if (d->cursorAdjusted) { @@ -1391,7 +1412,16 @@ bool QMainWindow::event(QEvent *event) } break; #endif - +#ifndef QT_NO_MENUBAR + case QEvent::WindowActivate: + if (d->layout->menuBar()) { + // ### TODO: This is evil, there is no need to create a new action every time + QAction* menu = new QAction(QString::fromLatin1("Options"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); + setSoftKey(menu); + } + break; +#endif default: break; } |