MenuBarWidget::MenuBarWidget(MainWindow *parent) : QMenuBar(parent),
    m_mainWindow(parent),
    m_leftToolBar(NULL),
    m_rightToolBar(NULL)
{
    QFile file(SessionsManager::getReadableDataPath(QLatin1String("menu/menuBar.json")));
    file.open(QFile::ReadOnly);

    const QJsonArray definition = QJsonDocument::fromJson(file.readAll()).array();

    file.close();

    for (int i = 0; i < definition.count(); ++i)
    {
        const QJsonObject object = definition.at(i).toObject();
        Menu *menu = new Menu(Menu::getRole(object.value(QLatin1String("identifier")).toString()), this);
        menu->load(object);

        addMenu(menu);
    }

    if (!isNativeMenuBar())
    {
        setup();

        connect(ToolBarsManager::getInstance(), SIGNAL(toolBarModified(int)), this, SLOT(toolBarModified(int)));
    }
示例#2
0
int QMenuBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: triggered((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 1: hovered((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 2: setVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: d_func()->_q_actionTriggered(); break;
        case 4: d_func()->_q_actionHovered(); break;
        case 5: d_func()->_q_internalShortcutActivated((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 6: d_func()->_q_updateLayout(); break;
        default: ;
        }
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isDefaultUp(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isNativeMenuBar(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDefaultUp(*reinterpret_cast< bool*>(_v)); break;
        case 1: setNativeMenuBar(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#3
0
int QMenuBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 9)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 9;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isDefaultUp(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isNativeMenuBar(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDefaultUp(*reinterpret_cast< bool*>(_v)); break;
        case 1: setNativeMenuBar(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}