void MenuBar::dropEvent(QDropEvent *event) { const MimeDataObject *mimeData = qobject_cast<const MimeDataObject *>(event->mimeData()); QAction *aAction = qobject_cast<QAction *>(mimeData->object()); if (aAction && isEdited()) { if (activeAction()) if (activeAction()->menu()) activeAction()->menu()->close(); if (aAction->menu()) if (aAction->objectName() == "actionNewMenu") { Menu *menu = new Menu(aAction->text()); menu->setEdited(true); aAction = menu->menuAction(); } QAction *eAction = this->actionAt(event->pos()); QRect rect = actionGeometry(eAction); eAction = this->actionAt(QPoint(event->pos().x()+rect.width()/2, event->pos().y())); if (eAction) { if (aAction->isSeparator()) insertSeparator(eAction); else insertAction(eAction,aAction); } else { if (aAction->isSeparator()) addSeparator(); else addAction(aAction); } event->acceptProposedAction(); } }
void AcceleratorManagerPrivate::manageMenuBar(QMenuBar *mbar, Item *item) { QAction *maction; QString s; for (int i=0; i<mbar->actions().count(); ++i) { maction = mbar->actions()[i]; if (!maction) continue; // nothing to do for separators if (maction->isSeparator()) continue; s = maction->text(); if (!s.isEmpty()) { Item *it = new Item; item->addChild(it); it->m_content = AccelString(s, // menu titles are important, so raise the weight AccelManagerAlgorithm::MENU_TITLE_WEIGHT); it->m_widget = mbar; it->m_index = i; } // have a look at the popup as well, if present if (maction->menu()) PopupAccelManager::manage(maction->menu()); } }
void tst_QMenu::indexBasedInsertion() { // test the compat'ed index based insertion QFETCH(int, indexForInsertion); QFETCH(int, expectedIndex); { QMenu menu; menu.addAction("Regular Item"); menu.insertItem("New Item", -1 /*id*/, indexForInsertion); QAction *act = menu.actions().value(expectedIndex); QVERIFY(act); QCOMPARE(act->text(), QString("New Item")); } { QMenu menu; menu.addAction("Regular Item"); menu.insertSeparator(indexForInsertion); QAction *act = menu.actions().value(expectedIndex); QVERIFY(act); QVERIFY(act->isSeparator()); } }
void QDesignerMenuBar::showLineEdit() { QAction *action = 0; if (m_currentIndex >= 0 && m_currentIndex < realActionCount()) action = safeActionAt(m_currentIndex); else action = m_addMenu; if (action->isSeparator()) return; // hideMenu(); m_lastFocusWidget = qApp->focusWidget(); // open edit field for item name const QString text = action != m_addMenu ? action->text() : QString(); m_editor->setText(text); m_editor->selectAll(); m_editor->setGeometry(actionGeometry(action)); m_editor->show(); qApp->setActiveWindow(m_editor); m_editor->setFocus(); m_editor->grabKeyboard(); }
void ToolbarEditor::populateList(QListWidget * w, QList<QAction *> actions_list, bool add_separators) { w->clear(); QAction * action; for (int n = 0; n < actions_list.count(); n++) { action = static_cast<QAction*> (actions_list[n]); if (action) { if (!action->objectName().isEmpty()) { QListWidgetItem * i = new QListWidgetItem; QString text = fixname(action->text(), action->objectName()); i->setText(text + " ("+ action->objectName() +")"); QIcon icon = action->icon(); if (icon.isNull()) { icon = Images::icon("empty_icon"); } i->setIcon(icon); i->setData(Qt::UserRole, action->objectName()); w->addItem(i); } else if ((action->isSeparator()) && (add_separators)) { QListWidgetItem * i = new QListWidgetItem; //i->setText(tr("(separator)")); i->setText("---------"); i->setData(Qt::UserRole, "separator"); i->setIcon(Images::icon("empty_icon")); w->addItem(i); } } } }
QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const { QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y))); if(act && act->isSeparator()) act = 0; return act ? getOrCreateMenu(menu(), act) : 0; }
bool QActionProto::isSeparator() const { QAction *item = qscriptvalue_cast<QAction*>(thisObject()); if (item) return item->isSeparator(); return false; }
void MenuManager::setup(MenuItem* menuItems) const { if (!menuItems) return; // empty menu bar QMenuBar* menuBar = getMainWindow()->menuBar(); //menuBar->setUpdatesEnabled(false); QList<MenuItem*> items = menuItems->getItems(); QList<QAction*> actions = menuBar->actions(); for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it) { // search for the menu action QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str())); if (!action) { // There must be not more than one separator in the menu bar, so // we can safely remove it if available and append it at the end if ((*it)->command() == "Separator") { action = menuBar->addSeparator(); action->setObjectName(QLatin1String("Separator")); } else { // create a new menu std::string menuName = (*it)->command(); QMenu* menu = menuBar->addMenu( QApplication::translate("Workbench", menuName.c_str(), 0, QApplication::UnicodeUTF8)); action = menu->menuAction(); menu->setObjectName(QString::fromAscii(menuName.c_str())); action->setObjectName(QString::fromAscii(menuName.c_str())); } // set the menu user data action->setData(QString::fromAscii((*it)->command().c_str())); } else { // put the menu at the end menuBar->removeAction(action); menuBar->addAction(action); action->setVisible(true); int index = actions.indexOf(action); actions.removeAt(index); } // flll up the menu if (!action->isSeparator()) setup(*it, action->menu()); } // hide all menus which we don't need for the moment for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) { (*it)->setVisible(false); } // enable update again //menuBar->setUpdatesEnabled(true); }
static QStringList objectNameList(QDesignerFormWindowInterface *form) { typedef QList<QAction*> ActionList; typedef QList<QButtonGroup *> ButtonGroupList; QStringList result; QWidget *mainContainer = form->mainContainer(); if (!mainContainer) return result; // Add main container container pages (QStatusBar, QWizardPages) etc. // to the list. Pages of containers on the form are not added, however. if (const QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension *>(form->core()->extensionManager(), mainContainer)) { const int count = c->count(); for (int i = 0 ; i < count; i++) addWidgetToObjectList(c->widget(i), result); } const QDesignerFormWindowCursorInterface *cursor = form->cursor(); const int widgetCount = cursor->widgetCount(); for (int i = 0; i < widgetCount; ++i) addWidgetToObjectList(cursor->widget(i), result); const QDesignerMetaDataBaseInterface *mdb = form->core()->metaDataBase(); // Add managed actions and actions with managed menus const ActionList actions = mainContainer->findChildren<QAction*>(); if (!actions.empty()) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { QAction *a = *it; if (!a->isSeparator()) { if (QMenu *menu = a->menu()) { if (mdb->item(menu)) result.push_back(menu->objectName()); } else { if (mdb->item(a)) result.push_back(a->objectName()); } } } } // Add managed buttons groups const ButtonGroupList buttonGroups = mainContainer->findChildren<QButtonGroup *>(); if (!buttonGroups.empty()) { const ButtonGroupList::const_iterator cend = buttonGroups.constEnd(); for (ButtonGroupList::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) if (mdb->item(*it)) result.append((*it)->objectName()); } result.sort(); return result; }
void MacMenu::updateWindow(MainWindow *win) { QListIterator<QAction*> i(_windows->actions()); i.toBack(); while(i.hasPrevious()) { QAction *a = i.previous(); if(a->isSeparator()) break; if(a->property("mainwin").value<MainWindow*>() == win) { a->setText(menuWinTitle(win->windowTitle())); break; } } }
void PopupMenu::mouseReleaseEvent(QMouseEvent *e) { DEBUG_PRST_ROUTES(stderr, "PopupMenu::mouseReleaseEvent this:%p\n", this); if(_contextMenu && _contextMenu->isVisible()) return; // Removed by Tim. Why not stay-open scrollable menus? // if(MusEGlobal::config.scrollableSubMenus) // { // QMenu::mouseReleaseEvent(e); // return; // } QAction* action = actionAt(e->pos()); if (!(action && action == activeAction() && !action->isSeparator() && action->isEnabled())) action=NULL; #ifdef POPUP_MENU_DISABLE_STAY_OPEN if (action && action->menu() != NULL && action->isCheckable()) action->activate(QAction::Trigger); QMenu::mouseReleaseEvent(e); if (action && action->menu() != NULL && action->isCheckable()) close(); return; #else // Check for Ctrl to stay open. const bool stay_open = _stayOpen && (MusEGlobal::config.popupsDefaultStayOpen || (e->modifiers() & Qt::ControlModifier)); // Stay open? Or does the action have a submenu, but also a checkbox of its own? if(action && (stay_open || (action->isEnabled() && action->menu() && action->isCheckable()))) { DEBUG_PRST_ROUTES(stderr, "PopupMenu::mouseReleaseEvent: stay open\n"); action->trigger(); // Trigger the action. e->accept(); if(!stay_open) closeUp(); return; // We handled it. } // Otherwise let ancestor QMenu handle it... e->ignore(); QMenu::mouseReleaseEvent(e); #endif // POPUP_MENU_DISABLE_STAY_OPEN }
void MacMenu::updateWinMenu() { const MainWindow *top = qobject_cast<MainWindow*>(qApp->activeWindow()); QListIterator<QAction*> i(_windows->actions()); i.toBack(); while(i.hasPrevious()) { QAction *a = i.previous(); if(a->isSeparator()) break; // TODO show bullet if window has unsaved changes and diamond // if minimized. a->setChecked(a->property("mainwin").value<MainWindow*>() == top); } }
bool ToolBarEventFilter::handleContextMenuEvent(QContextMenuEvent * event ) { event->accept(); const QPoint globalPos = event->globalPos(); const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation()); const ActionList actions = m_toolBar->actions(); QAction *action = index != -1 ?actions.at(index) : 0; QVariant itemData; QMenu menu(0); // Insert before if (action && index != 0 && !action->isSeparator()) { QAction *newSeperatorAct = menu.addAction(tr("Insert Separator before '%1'").arg(action->objectName())); qVariantSetValue(itemData, action); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); } // Append separator if (actions.empty() || !actions.back()->isSeparator()) { QAction *newSeperatorAct = menu.addAction(tr("Append Separator")); qVariantSetValue(itemData, static_cast<QAction*>(0)); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); } // Remove if (!menu.actions().empty()) menu.addSeparator(); // Remove if (action) { QAction *a = menu.addAction(tr("Remove action '%1'").arg(action->objectName())); qVariantSetValue(itemData, action); a->setData(itemData); connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction())); } QAction *remove_toolbar = menu.addAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName())); connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar())); menu.exec(globalPos); return true; }
void MacMenu::removeWindow(MainWindow *win) { QListIterator<QAction*> i(_windows->actions()); i.toBack(); QAction *delthis = nullptr; while(i.hasPrevious()) { QAction *a = i.previous(); if(a->isSeparator()) break; if(a->property("mainwin").value<MainWindow*>() == win) { delthis = a; break; } } Q_ASSERT(delthis); delete delthis; }
ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) { ActionList rc; const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation()); const ActionList actions = m_toolBar->actions(); QAction *action = index != -1 ?actions.at(index) : 0; QVariant itemData; // Insert before if (action && index != 0 && !action->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0); itemData.setValue(action); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); } // Append separator if (actions.empty() || !actions.back()->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0); itemData.setValue(static_cast<QAction*>(0)); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); } // Promotion if (!m_promotionTaskMenu) m_promotionTaskMenu = new PromotionTaskMenu(m_toolBar, PromotionTaskMenu::ModeSingleWidget, this); m_promotionTaskMenu->addActions(formWindow(), PromotionTaskMenu::LeadingSeparator|PromotionTaskMenu::TrailingSeparator, rc); // Remove if (action) { QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0); itemData.setValue(action); a->setData(itemData); connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction())); rc.push_back(a); } QAction *remove_toolbar = new QAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName()), 0); connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar())); rc.push_back(remove_toolbar); return rc; }
void TToolbarEditor::populateList(QListWidget* w, const TActionList& actions_list) { w->clear(); for (int n = 0; n < actions_list.count(); n++) { QAction* action = actions_list[n]; if (action && !action->objectName().isEmpty() && !action->isSeparator()) { QListWidgetItem* i = new QListWidgetItem; QString text = TActionsEditor::actionTextToDescription(action->text(), action->objectName()); i->setText(text + " ("+ action->objectName() +")"); QIcon icon = action->icon(); if (icon.isNull()) { icon = Images::icon("empty_icon"); } i->setIcon(icon); i->setData(Qt::UserRole, action->objectName()); w->addItem(i); } } }
QStringList ToolbarEditor::save(QWidget *w) { qDebug("ToolbarEditor::save: '%s'", w->objectName().toUtf8().data()); QList<QAction *> list = w->actions(); QStringList o; QAction *action; for (int n = 0; n < list.count(); n++) { action = static_cast<QAction *>(list[n]); if (action->isSeparator()) { o << "separator"; } else if (!action->objectName().isEmpty()) { o << action->objectName(); } else qWarning("ToolbarEditor::save: unknown action at pos %d", n); } return o; }
void ToolBar::mouseMoveEvent(QMouseEvent *event) { QToolBar::mouseMoveEvent(event); QAction *action = this->actionAt(m_dragPos); if (event->buttons() & Qt::LeftButton && action && isEdited()) { qint32 distance = (event->pos() - m_dragPos).manhattanLength(); if (distance > QApplication::startDragDistance() ) { QDrag *drag = new QDrag(this); MimeDataObject *mimeData = new MimeDataObject(); mimeData->setObject(action); drag->setMimeData(mimeData); if (drag->exec(Qt::MoveAction) == Qt::MoveAction) if (drag->target() != this || action->isSeparator()) this->removeAction(action); return; } } }
void Nexus::updateWindowsArg(QWindow* closedWindow) { QWindowList windowList = QApplication::topLevelWindows(); delete windowActions; windowActions = new QActionGroup(this); windowMenu->addSeparator(); QAction* dockLast; if (dockMenu->actions().count() != 0) dockLast = dockMenu->actions().first(); else dockLast = nullptr; QWindow* activeWindow; if (QApplication::activeWindow()) activeWindow = QApplication::activeWindow()->windowHandle(); else activeWindow = nullptr; for (int i = 0; i < windowList.size(); ++i) { if (closedWindow == windowList[i]) continue; QAction* action = windowActions->addAction(windowList[i]->title()); action->setCheckable(true); action->setChecked(windowList[i] == activeWindow); connect(action, SIGNAL(triggered()), windowMapper, SLOT(map())); windowMapper->setMapping(action, windowList[i]); windowMenu->addAction(action); dockMenu->insertAction(dockLast, action); } if (dockLast && !dockLast->isSeparator()) dockMenu->insertSeparator(dockLast); }
int Action::isSeparator(lua_State * L) // const : bool { QAction* obj = QtObject<QAction>::check( L, 1); Lua::Util::push( L, obj->isSeparator() ); return 1; }
LDViewMainWindow::LDViewMainWindow(QApplication *a) :QMainWindow(),Ui::LDView(), fileSeparatorIndex(-1), toolbarMaxStep(new QLabel), toolbarCurrentStep(new QLabel), toolbarStepLabel(new QLabel("Step :")), toolbarViewAngle(NULL), toolbarWireframeMenu(new QMenu(this)), edgeMenu(new QMenu(this)), bfcMenu(new QMenu(this)), primitiveMenu(new QMenu(this)) { setupUi(this); toolbar->insertWidget(toolbarFirstStep,toolbarStepLabel); toolbar->insertWidget(toolbarFirstStep,toolbarCurrentStep); toolbar->insertWidget(toolbarFirstStep,toolbarMaxStep); if (modelViewer) modelViewer->setMainWindow(this); connect( fileOpenAction, SIGNAL( triggered() ), this, SLOT( fileOpen() ) ); connect( fileSaveSettingsAction, SIGNAL( triggered() ), this, SLOT( fileSaveSettings() ) ); connect( fileExportAction, SIGNAL( triggered() ), this, SLOT( fileExport() ) ); connect( fileExportOptionAction, SIGNAL( triggered() ), this, SLOT( fileExportOption() ) ); connect( file3DSExportOptionAction, SIGNAL( triggered() ), this, SLOT( file3DSExportOption() ) ); connect( fileJPEGOptionsAction, SIGNAL( triggered() ), this, SLOT( fileJPEGOptions() ) ); connect( fileSaveAction, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); connect( filePrintAction, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); connect( fileExitAction, SIGNAL( triggered() ), this, SLOT( fileExit() ) ); connect( helpContentsAction, SIGNAL( triggered() ), this, SLOT( helpContents() ) ); connect( helpAboutAction, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); connect( helpAboutQtAction, SIGNAL( triggered() ), this, SLOT( helpAboutQt() ) ); connect( editPreferencesAction, SIGNAL( triggered() ), this, SLOT( editPreferences() ) ); connect( viewToolBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewToolBar(bool) ) ); connect( toolbarWireframeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframe(bool) ) ); connect( toolbarEdgeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarEdge(bool) ) ); connect( toolbarPrimitiveSubstitutionAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarPrimitiveSubstitution(bool) ) ); connect( toolbarLightingAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarLighting(bool) ) ); connect( toolbarBFCAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarBFC(bool) ) ); connect( toolbarAxesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarAxes(bool) ) ); connect( toolbarSeamsAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarSeams(bool) ) ); connect( viewStatusBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewStatusBar(bool) ) ); connect( viewLatitudeRotationAction, SIGNAL( toggled(bool) ), this, SLOT( latitudeRotation(bool) ) ); connect( viewKeepRightSideUpAction, SIGNAL( toggled(bool) ), this, SLOT( keepRightSideUp(bool) ) ); connect( viewFullScreenAction, SIGNAL( triggered() ), this, SLOT( viewFullScreen() ) ); connect( viewResetViewAction, SIGNAL( triggered() ), this, SLOT( viewResetView() ) ); connect( helpOpenGLDriverInfoAction, SIGNAL( triggered() ), this, SLOT( helpOpenGLDriverInfo() ) ); connect( fileLDrawDirAction, SIGNAL( triggered() ), this, SLOT( fileLDrawDir() ) ); connect( fileExtraDirAction, SIGNAL( triggered() ), this, SLOT( fileExtraDir() ) ); connect( fileCheckForUpdatesAction, SIGNAL( triggered() ), this, SLOT( fileCheckForUpdates() ) ); connect( fileReloadAction, SIGNAL( triggered() ), this, SLOT( fileReload() ) ); connect( viewShowErrorsAction, SIGNAL( triggered() ), this, SLOT( viewShowErrors() ) ); connect( pollActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( pollChanged(QAction*) ) ); connect( viewZoomToFitAction, SIGNAL( triggered() ), this, SLOT( viewZoomToFit() ) ); connect( viewRightSideUpAction, SIGNAL( triggered() ), this, SLOT( viewRightSideUp() ) ); connect( viewModeActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( viewModeChanged(QAction*) ) ); connect( frontViewAngleAction, SIGNAL( triggered() ), this, SLOT( frontViewAngle() ) ); connect( backViewAngleAction, SIGNAL( triggered() ), this, SLOT( backViewAngle() ) ); connect( leftViewAngleAction, SIGNAL( triggered() ), this, SLOT( leftViewAngle() ) ); connect( rightViewAngleAction, SIGNAL( triggered() ), this, SLOT( rightViewAngle() ) ); connect( topViewAngleAction, SIGNAL( triggered() ), this, SLOT( topViewAngle() ) ); connect( bottomViewAngleAction, SIGNAL( triggered() ), this, SLOT( bottomViewAngle() ) ); connect( latLongViewAngleAction, SIGNAL( triggered() ), this, SLOT( latLongViewAngle() ) ); connect( isoViewAngleAction, SIGNAL( triggered() ), this, SLOT( isoViewAngle() ) ); connect( saveDefaultViewAngleAction, SIGNAL( triggered() ), this, SLOT( saveDefaultViewAngle() ) ); connect( fileCancelLoadAction, SIGNAL( triggered() ), this, SLOT( fileCancelLoad() ) ); connect( showViewInfoAction, SIGNAL( triggered() ), this, SLOT( showViewInfo() ) ); connect( showPovCameraAction, SIGNAL( triggered() ), this, SLOT( showPovCamera() ) ); connect( showPovAspectRatioAction, SIGNAL( toggled(bool) ), this, SLOT( showPovAspectRatio(bool) ) ); connect( toolsPartListAction, SIGNAL( triggered() ), this, SLOT( toolsPartList() ) ); connect( toolbarPrevStep, SIGNAL( triggered() ), this, SLOT( prevStep() ) ); connect( toolbarNextStep, SIGNAL( triggered() ), this, SLOT( nextStep() ) ); connect( toolbarFirstStep, SIGNAL( triggered() ), this, SLOT( firstStep() ) ); connect( toolbarLastStep, SIGNAL( triggered() ), this, SLOT( lastStep() ) ); connect( stepGoto, SIGNAL( triggered() ), this, SLOT( gotoStep() ) ); connect( toolsModelTreeAction, SIGNAL( triggered() ), this, SLOT( toolsModelTree() ) ); connect( toolsBoundingBoxAction, SIGNAL( triggered() ), this, SLOT( toolsBoundingBox() ) ); connect( toolsMpdModelSelectionAction, SIGNAL( triggered() ), this, SLOT( toolsMpdModelSelection() ) ); connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(doFileMenuAboutToShow())); connect(editMenu, SIGNAL(aboutToShow()), this, SLOT(doEditMenuAboutToShow())); connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(doViewMenuAboutToShow())); connect(toolsMenu,SIGNAL(aboutToShow()), this, SLOT(doToolsMenuAboutToShow())); connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(doHelpMenuAboutToShow())); int cnt,i; QAction *item; for ( cnt = i = 0; ; i++) { item = fileMenu->actions()[i]; if (item->isSeparator()) { if (++cnt == 2) break; } } fileSeparatorIndex = i; #ifdef __APPLE__ fileMenu->removeItemAt(fileSeparatorIndex); fileSeparatorIndex = -1; openRecentMenu = new QMenu(this, "openRecentMenu"); fileMenu->insertItem("Open Recent", openRecentMenu, -1, 1); #endif // __APPLE__ if (!recentFiles) { recentFiles = new TCStringArray(10); populateRecentFiles(); } populateRecentFileMenuItems(); setupStandardSizes(); #ifdef __APPLE__ // Since Preferences is the only item in the edit menu, we need to // delete the edit menu on the Mac, since the item is going to get // magically moved to the LDView menu. The problem is, if we delete // the edit menu, the magic stops working, since it's apparently all // done on the fly. So, we're going to create a new fully-functional // Preferences menu item at the top of the File menu, and THEN delete // the edit menu. This newly created menu item won't be visible to the // user, but it will make the other one continue to function after the // deletion of the edit menu. fileMenu->insertItem("Preferences", this, SLOT(doPreferences()), 0, -1, 0); // Remove the (empty without Preferences) edit menu. menuBar->removeItem(menuBar->idAt(1)); #endif //__APPLE__ toolbarViewAngle = new QToolButton(toolbar); toolbarViewAngle->setMenu(viewingAnglePopupMenu); toolbarViewAngle->setPopupMode(QToolButton::InstantPopup); toolbarViewAngle->setIcon(QPixmap( ":/images/images/toolbar_view.png")); toolbarViewAngle->setEnabled(false); toolbar->insertWidget(editPreferencesAction,toolbarViewAngle); connect( wireframeFogAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeFog(bool) ) ); connect( wireframeRemoveHiddenLinesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeRemoveHiddenLines(bool) ) ); toolbarWireframeMenu->addAction(wireframeFogAction); toolbarWireframeMenu->addAction(wireframeRemoveHiddenLinesAction); QToolButton *toolbarWireframe = (QToolButton *)toolbar->widgetForAction(toolbarWireframeAction); if (toolbarWireframe != NULL) { toolbarWireframe->setMenu(toolbarWireframeMenu); toolbarWireframe->setPopupMode(QToolButton::MenuButtonPopup); } connect( textureStudAction, SIGNAL( toggled(bool) ), this, SLOT( textureStud(bool) ) ); primitiveMenu->addAction(textureStudAction); QToolButton *toolbarPrimitives = (QToolButton *)toolbar->widgetForAction(toolbarPrimitiveSubstitutionAction); if (toolbarPrimitives) { toolbarPrimitives->setMenu(primitiveMenu); toolbarPrimitives->setPopupMode(QToolButton::MenuButtonPopup); } connect( edgeShowEdgeOnlyAction, SIGNAL( toggled(bool) ), this, SLOT( edgeShowEdgeOnly(bool) ) ); connect( edgeConditionalLineAction, SIGNAL( toggled(bool) ), this, SLOT( edgeConditionalLine(bool) ) ); connect( edgeHighQualityAction, SIGNAL( toggled(bool) ), this, SLOT( edgeHighQuality(bool) ) ); connect( edgeAlwaysBlackAction, SIGNAL( toggled(bool) ), this, SLOT( edgeAlwaysBlack(bool) ) ); edgeMenu->addAction(edgeShowEdgeOnlyAction); edgeMenu->addAction(edgeConditionalLineAction); edgeMenu->addAction(edgeHighQualityAction); edgeMenu->addAction(edgeAlwaysBlackAction); QToolButton *toolbarEdge = (QToolButton *)toolbar->widgetForAction(toolbarEdgeAction); if (toolbarEdge) { toolbarEdge->setMenu(edgeMenu); toolbarEdge->setPopupMode(QToolButton::MenuButtonPopup); } connect( bfcRedBackFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcRedBackFaces(bool) ) ); connect( bfcGreenFrontFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcGreenFrontFaces(bool) ) ); connect( bfcBlueNeutralFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcBlueNeutralFaces(bool) ) ); bfcMenu->addAction(bfcRedBackFacesAction); bfcMenu->addAction(bfcGreenFrontFacesAction); bfcMenu->addAction(bfcBlueNeutralFacesAction); QToolButton *toolbarBfc = (QToolButton *)toolbar->widgetForAction(toolbarBFCAction); if (toolbarBfc) { toolbarBfc->setMenu(bfcMenu); toolbarBfc->setPopupMode(QToolButton::MenuButtonPopup); } modelViewer->setApplication(a); }