src/gui/widgets/qmainwindow.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    63 #include <private/qt_cocoa_helpers_mac_p.h>
    63 #include <private/qt_cocoa_helpers_mac_p.h>
    64 QT_BEGIN_NAMESPACE
    64 QT_BEGIN_NAMESPACE
    65 extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
    65 extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
    66 QT_END_NAMESPACE
    66 QT_END_NAMESPACE
    67 #endif
    67 #endif
    68 #ifdef QT_SOFTKEYS_ENABLED
       
    69 #include <private/qsoftkeymanager_p.h>
       
    70 #endif
       
    71 
    68 
    72 QT_BEGIN_NAMESPACE
    69 QT_BEGIN_NAMESPACE
    73 
    70 
    74 class QMainWindowPrivate : public QWidgetPrivate
    71 class QMainWindowPrivate : public QWidgetPrivate
    75 {
    72 {
    77 public:
    74 public:
    78     inline QMainWindowPrivate()
    75     inline QMainWindowPrivate()
    79         : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
    76         : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
    80 #ifdef Q_WS_MAC
    77 #ifdef Q_WS_MAC
    81             , useHIToolBar(false)
    78             , useHIToolBar(false)
    82 #endif
       
    83 #ifdef QT_SOFTKEYS_ENABLED
       
    84             , menuBarAction(0)
       
    85 #endif
    79 #endif
    86 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
    80 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
    87             , hasOldCursor(false) , cursorAdjusted(false)
    81             , hasOldCursor(false) , cursorAdjusted(false)
    88 #endif
    82 #endif
    89     { }
    83     { }
    92     bool explicitIconSize;
    86     bool explicitIconSize;
    93     Qt::ToolButtonStyle toolButtonStyle;
    87     Qt::ToolButtonStyle toolButtonStyle;
    94 #ifdef Q_WS_MAC
    88 #ifdef Q_WS_MAC
    95     bool useHIToolBar;
    89     bool useHIToolBar;
    96 #endif
    90 #endif
    97 #ifdef QT_SOFTKEYS_ENABLED
       
    98     QAction *menuBarAction;
       
    99 #endif
       
   100     void init();
    91     void init();
   101     QList<int> hoverSeparator;
    92     QList<int> hoverSeparator;
   102     QPoint hoverPos;
    93     QPoint hoverPos;
   103 
    94 
   104 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
    95 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
   115     Q_Q(QMainWindow);
   106     Q_Q(QMainWindow);
   116     layout = new QMainWindowLayout(q);
   107     layout = new QMainWindowLayout(q);
   117     const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
   108     const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
   118     iconSize = QSize(metric, metric);
   109     iconSize = QSize(metric, metric);
   119     q->setAttribute(Qt::WA_Hover);
   110     q->setAttribute(Qt::WA_Hover);
   120 #ifdef QT_SOFTKEYS_ENABLED
       
   121     menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q);
       
   122 #endif
       
   123 }
   111 }
   124 
   112 
   125 /*
   113 /*
   126     The Main Window:
   114     The Main Window:
   127 
   115 
   489         }
   477         }
   490         oldMenuBar->hide();
   478         oldMenuBar->hide();
   491         oldMenuBar->deleteLater();
   479         oldMenuBar->deleteLater();
   492     }
   480     }
   493     d->layout->setMenuBar(menuBar);
   481     d->layout->setMenuBar(menuBar);
   494 
       
   495 #ifdef QT_SOFTKEYS_ENABLED
       
   496     if (menuBar)
       
   497         addAction(d->menuBarAction);
       
   498     else
       
   499         removeAction(d->menuBarAction);
       
   500 #endif
       
   501 }
   482 }
   502 
   483 
   503 /*!
   484 /*!
   504     \since 4.2
   485     \since 4.2
   505 
   486 
  1424                d->oldCursor = cursor();
  1405                d->oldCursor = cursor();
  1425                d->hasOldCursor = testAttribute(Qt::WA_SetCursor);
  1406                d->hasOldCursor = testAttribute(Qt::WA_SetCursor);
  1426            }
  1407            }
  1427            break;
  1408            break;
  1428 #endif
  1409 #endif
  1429 #ifdef QT_SOFTKEYS_ENABLED
       
  1430     case QEvent::LanguageChange:
       
  1431         d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
       
  1432         break;
       
  1433 #endif
       
  1434         default:
  1410         default:
  1435             break;
  1411             break;
  1436     }
  1412     }
  1437 
  1413 
  1438     return QWidget::event(event);
  1414     return QWidget::event(event);