int ToolBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QToolBar::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: order(); break; case 1: randomize(); break; case 2: addSpinBox(); break; case 3: removeSpinBox(); break; case 4: changeMovable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 5: allowLeft((*reinterpret_cast< bool(*)>(_a[1]))); break; case 6: allowRight((*reinterpret_cast< bool(*)>(_a[1]))); break; case 7: allowTop((*reinterpret_cast< bool(*)>(_a[1]))); break; case 8: allowBottom((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: placeLeft((*reinterpret_cast< bool(*)>(_a[1]))); break; case 10: placeRight((*reinterpret_cast< bool(*)>(_a[1]))); break; case 11: placeTop((*reinterpret_cast< bool(*)>(_a[1]))); break; case 12: placeBottom((*reinterpret_cast< bool(*)>(_a[1]))); break; case 13: updateMenu(); break; case 14: insertToolBarBreak(); break; default: ; } _id -= 15; } return _id; }
ToolBar::ToolBar(const QString &title, QWidget *parent) : QToolBar(parent), spinbox(0), spinboxAction(0) { tip = 0; setWindowTitle(title); setObjectName(title); setIconSize(QSize(32, 32)); QColor bg(palette().background().color()); menu = new QMenu("One", this); menu->setIcon(genIcon(iconSize(), 1, Qt::black)); menu->addAction(genIcon(iconSize(), "A", Qt::blue), "A"); menu->addAction(genIcon(iconSize(), "B", Qt::blue), "B"); menu->addAction(genIcon(iconSize(), "C", Qt::blue), "C"); addAction(menu->menuAction()); QAction *two = addAction(genIcon(iconSize(), 2, Qt::white), "Two"); QFont boldFont; boldFont.setBold(true); two->setFont(boldFont); addAction(genIcon(iconSize(), 3, Qt::red), "Three"); addAction(genIcon(iconSize(), 4, Qt::green), "Four"); addAction(genIcon(iconSize(), 5, Qt::blue), "Five"); addAction(genIcon(iconSize(), 6, Qt::yellow), "Six"); orderAction = new QAction(this); orderAction->setText(tr("Order Items in Tool Bar")); connect(orderAction, SIGNAL(triggered()), SLOT(order())); randomizeAction = new QAction(this); randomizeAction->setText(tr("Randomize Items in Tool Bar")); connect(randomizeAction, SIGNAL(triggered()), SLOT(randomize())); addSpinBoxAction = new QAction(this); addSpinBoxAction->setText(tr("Add Spin Box")); connect(addSpinBoxAction, SIGNAL(triggered()), SLOT(addSpinBox())); removeSpinBoxAction = new QAction(this); removeSpinBoxAction->setText(tr("Remove Spin Box")); removeSpinBoxAction->setEnabled(false); connect(removeSpinBoxAction, SIGNAL(triggered()), SLOT(removeSpinBox())); movableAction = new QAction(tr("Movable"), this); movableAction->setCheckable(true); connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool))); allowedAreasActions = new QActionGroup(this); allowedAreasActions->setExclusive(false); allowLeftAction = new QAction(tr("Allow on Left"), this); allowLeftAction->setCheckable(true); connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool))); allowRightAction = new QAction(tr("Allow on Right"), this); allowRightAction->setCheckable(true); connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool))); allowTopAction = new QAction(tr("Allow on Top"), this); allowTopAction->setCheckable(true); connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool))); allowBottomAction = new QAction(tr("Allow on Bottom"), this); allowBottomAction->setCheckable(true); connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool))); allowedAreasActions->addAction(allowLeftAction); allowedAreasActions->addAction(allowRightAction); allowedAreasActions->addAction(allowTopAction); allowedAreasActions->addAction(allowBottomAction); areaActions = new QActionGroup(this); areaActions->setExclusive(true); leftAction = new QAction(tr("Place on Left") , this); leftAction->setCheckable(true); connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool))); rightAction = new QAction(tr("Place on Right") , this); rightAction->setCheckable(true); connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool))); topAction = new QAction(tr("Place on Top") , this); topAction->setCheckable(true); connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool))); bottomAction = new QAction(tr("Place on Bottom") , this); bottomAction->setCheckable(true); connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool))); areaActions->addAction(leftAction); areaActions->addAction(rightAction); areaActions->addAction(topAction); areaActions->addAction(bottomAction); toolBarBreakAction = new QAction(tr("Insert break"), this); connect(toolBarBreakAction, SIGNAL(triggered(bool)), this, SLOT(insertToolBarBreak())); connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool))); connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool))); menu = new QMenu(title, this); menu->addAction(toggleViewAction()); menu->addSeparator(); menu->addAction(orderAction); menu->addAction(randomizeAction); menu->addSeparator(); menu->addAction(addSpinBoxAction); menu->addAction(removeSpinBoxAction); menu->addSeparator(); menu->addAction(movableAction); menu->addSeparator(); menu->addActions(allowedAreasActions->actions()); menu->addSeparator(); menu->addActions(areaActions->actions()); menu->addSeparator(); menu->addAction(toolBarBreakAction); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); randomize(); }
QWidget* GUIBuilder::buildGUI(model::gui::Element* root, QWidget *parent ) { QWidget* widget = NULL; if( widget == NULL ) { model::gui::TabLayout* tab_layout = dynamic_cast<model::gui::TabLayout*>( root ); if( tab_layout != NULL ) { widget = addTabLayout( tab_layout, parent ); } } if( widget == NULL ) { model::gui::Grid* grid = dynamic_cast<model::gui::Grid*>( root ); if( grid != NULL ) { widget = addGrid( grid, parent ); } } if( widget == NULL ) { model::gui::TextInput* text_input = dynamic_cast<model::gui::TextInput*>( root ); if( text_input != NULL ) { widget = new QLineEdit( parent ); new StringController( widget, m_model, text_input->key(), true ); } } if( widget == NULL ) { model::gui::Canvas* canvas = dynamic_cast<model::gui::Canvas*>( root ); if( canvas != NULL ) { widget = addCanvas( canvas, parent ); } } if( widget == NULL ) { model::gui::Label* label = dynamic_cast<model::gui::Label*>( root ); if( label != NULL ) { widget = new QLabel( parent ); new StringController( widget, m_model, label->key(), label->showValue() ); } } if( widget == NULL ) { model::gui::ComboBox* combobox = dynamic_cast<model::gui::ComboBox*>( root ); if( combobox != NULL ) { widget = addCombobox( combobox, parent); } } if( widget == NULL ) { model::gui::ElementGroup* element_group = dynamic_cast<model::gui::ElementGroup*>( root ); if( element_group != NULL ) { widget = addElementGroup( element_group, parent); } } if( widget == NULL ) { model::gui::RadioButtons* radio_buttons = dynamic_cast<model::gui::RadioButtons*>( root ); if( radio_buttons != NULL ) { widget = addRadiobuttons( radio_buttons, parent); } } if( widget == NULL ) { model::gui::SpinBox* spin_box = dynamic_cast<model::gui::SpinBox*>( root ); if( spin_box != NULL ) { widget = addSpinBox( spin_box, parent); } } if( widget == NULL ) { model::gui::CheckBox* check_box = dynamic_cast<model::gui::CheckBox*>( root ); if( check_box != NULL ) { widget = addCheckBox( check_box, parent); } } if( widget == NULL ) { model::gui::Button* button = dynamic_cast<model::gui::Button*>( root ); if( button != NULL ) { widget = addButton( button, parent); } } if( widget == NULL ) { model::gui::HorizontalSlider* horizontal_slider = dynamic_cast<model::gui::HorizontalSlider*>( root ); if( horizontal_slider != NULL ) { widget = addHorizontalSlider( horizontal_slider, parent); } } if( widget == NULL ) { model::gui::HorizontalLayout* horizontal_layout = dynamic_cast<model::gui::HorizontalLayout*>( root ); if( horizontal_layout != NULL ) { widget = addHorizontalLayout( horizontal_layout, parent); } } if( widget == NULL ) { model::gui::VerticalLayout* vertical_layout = dynamic_cast<model::gui::VerticalLayout*>( root ); if( vertical_layout != NULL ) { widget = addVerticalLayout( vertical_layout, parent); } } if( widget == NULL ) { model::gui::DoubleSpinBox* double_spinbox = dynamic_cast<model::gui::DoubleSpinBox*>( root ); if( double_spinbox != NULL ) { widget = addDoubleSpinBox( double_spinbox, parent); } } if( widget == NULL ) { model::gui::PopupButton* popup_button = dynamic_cast<model::gui::PopupButton*>( root ); if( popup_button != NULL ) { widget = addPopupButton( popup_button, parent ); } } if(widget == NULL ) { model::gui::FileDialogButton* file_dialog_button = dynamic_cast<model::gui::FileDialogButton*>( root ); if(file_dialog_button != NULL) { widget = addFileDialogButton(file_dialog_button, parent); } } if( widget != NULL ) { if( !root->visibilityKey().empty() ) { new VisibilityController( widget, m_model, root->visibilityKey(), root->visibilityInverted() ); } if( !root->enabledKey().empty() ) { new EnabledController( widget, m_model, root->enabledKey(), root->enabledInverted() ); } } return widget; }