void MainWindow::createMenus() { QAction* action; QString name; QMenu* menu; QMenu* subMenu; // ----- File Menu ----- menu = menuBar()->addMenu("File"); name = "About"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showAbout())); name = "New Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu())); action->setShortcut(QKeySequence::New); name = "New Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(newViewer())); name = "Open"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openFile())); action->setShortcut(QKeySequence::Open); name = "Open Recent"; m_recentFilesMenu = menu->addMenu(name); updateRecentFilesMenu(); menu->addSeparator(); /* name = "Parse Test File"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(parseFile())); menu->addSeparator(); */ name = "Close Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(close())); action->setShortcut(QKeySequence::Close); name = "Save"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll())); action->setShortcut(QKeySequence::Save); name = "Save As"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S); menu->addSeparator(); name = "Save Picture"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot())); action->setShortcut(Qt::CTRL + Qt::Key_P); name = "Record Animation"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P); m_recordAnimationAction = action; name = "Show Message Log"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages())); action->setShortcut(Qt::CTRL + Qt::Key_L); name = "Quit"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(quit())); action->setShortcut(Qt::CTRL + Qt::Key_Q); // ----- Edit Menu ----- menu = menuBar()->addMenu("Edit"); name = "Undo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo())); action->setShortcut(QKeySequence::Undo); connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool))); name = "Redo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo())); action->setShortcut(QKeySequence::Redo); connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool))); menu->addSeparator(); name = "Cut"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection())); action->setShortcut(Qt::CTRL + Qt::Key_X); name = "Copy"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_C); name = "Paste"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_V); menu->addSeparator(); name = "Select All"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll())); action->setShortcut(Qt::CTRL + Qt::Key_A); name = "Select None"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A); name = "Invert Selection"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection())); action->setShortcut(Qt::CTRL + Qt::Key_I); menu->addSeparator(); name = "Reindex Atoms"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms())); menu->addSeparator(); name = "Preferences"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showPreferences())); // ----- Display Menu ----- menu = menuBar()->addMenu("Display"); name = "Full Screen"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(fullScreen())); action->setShortcut(Qt::CTRL + Qt::Key_0); m_fullScreenAction = action; name = "Reset View"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView())); action->setShortcut(Qt::CTRL + Qt::Key_R); name = "Show Axes"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes())); connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool))); action->setShortcut(Qt::Key_A); menu->addSeparator(); name = "Atom Labels"; subMenu = menu->addMenu(name); name = "Element"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Element); action->setShortcut(Qt::Key_E); action->setCheckable(true); m_labelActions << action; name = "Index"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Index); action->setShortcut(Qt::Key_I); action->setCheckable(true); m_labelActions << action; name = "Mass"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Mass); action->setShortcut(Qt::Key_M); action->setCheckable(true); m_labelActions << action; /* name = "NMR Shifts"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::NmrShifts); action->setShortcut(Qt::Key_N); action->setCheckable(true); m_labelActions << action; */ name = "Partial Charge"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Charge); action->setShortcut(Qt::Key_Q); action->setCheckable(true); m_labelActions << action; name = "Spin Densities"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Spin); action->setShortcut(Qt::Key_S); action->setCheckable(true); m_labelActions << action; menu->addSeparator(); name = "Configure Appearance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance())); // These are not working correctly at the moment. /* name = "Partial Charge Type"; QActionGroup* partialChargeGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString pc("Gasteiger"); action = subMenu->addAction(pc); action->setCheckable(true); action->setChecked(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Sanderson"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Mulliken"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); */ // ----- Build Menu ----- menu = menuBar()->addMenu("Build"); name = "Fill Valencies With Hydrogens"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens())); action->setShortcut(Qt::CTRL + Qt::Key_F); name = "Reperceive Bonds"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds())); menu->addSeparator(); name = "Set Constraint"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint())); action->setShortcut(Qt::CTRL + Qt::Key_K); name = "Minimize Structure"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy())); action->setShortcut(Qt::CTRL + Qt::Key_M); name = "Select Force Field"; QActionGroup* forceFieldGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString ff("MMFF94"); action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "MMFF94s"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "UFF"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Ghemical"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Gaff"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); menu->addSeparator(); name = "Translate To Center"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter())); action->setShortcut(Qt::CTRL + Qt::Key_T ); name = "Symmetrize Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize())); action->setShortcut(Qt::CTRL + Qt::Key_Y ); name = "Set Symmetry Tolerance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance())); name = "Auto-detect Symmetry"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry())); // ----- Calculation Menu ----- menu = menuBar()->addMenu("Calculation"); name = "Q-Chem Setup"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI())); action->setShortcut(Qt::CTRL + Qt::Key_U ); m_qchemSetupAction = action; name = "Job Monitor"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor())); action->setShortcut(Qt::CTRL + Qt::Key_J ); menu->addSeparator(); name = "Edit Servers"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(editServers())); name = "Remove All Processes"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &(ProcessMonitor::instance()), SLOT(clearProcessList())); name = "Reset Password Vault Key"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword())); // ----- Help Menu ----- menu = menuBar()->addMenu("Help"); name = "Show Help"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showHelp())); }
/** Post construction initialization, done after event loop displays the gui */ void PackageView::init() { //setup context menu for installed packages QWidget * installedPage = tabWidget->widget( 0 ); QMenu *installedContext = QSoftMenuBar::menuFor( installedPage ); detailsAction = new QAction( tr("Details"), this); detailsAction->setVisible( false ); connect( detailsAction, SIGNAL(triggered()), this, SLOT(displayDetails()) ); uninstallAction = new QAction( tr("Uninstall"), installedPage ); uninstallAction->setVisible( false ); connect( uninstallAction, SIGNAL(triggered()), this, SLOT(startUninstall()) ); reenableAction = new QAction( tr("Re-enable"), installedPage ); reenableAction->setVisible( false ); connect( reenableAction, SIGNAL(triggered()), this, SLOT(confirmReenable()) ); installedContext->addAction( detailsAction ); installedContext->addAction( uninstallAction ); installedContext->addAction( reenableAction ); connect( installedContext, SIGNAL(aboutToShow()), this, SLOT(contextMenuShow()) ); //setup context menu for downloadable packages QWidget * downloadPage = tabWidget->widget( 1 ); QMenu *downloadContext = QSoftMenuBar::menuFor( tabWidget->widget(1) ); installAction = new QAction( tr("Install"), downloadPage ); installAction->setVisible( false ); connect( installAction, SIGNAL(triggered()), this, SLOT(startInstall()) ); menuServers = new QMenu( tr( "Connect" ), this ); QAction* editServersAction = new QAction( tr( "Edit servers" ), this ); connect( editServersAction, SIGNAL(triggered()), this, SLOT(editServers()) ); downloadContext->addMenu( menuServers ); downloadContext->addAction( detailsAction ); downloadContext->addAction( installAction ); downloadContext->addAction( editServersAction ); connect( downloadContext, SIGNAL(aboutToShow()), this, SLOT(contextMenuShow()) ); model->populateServers(); QStringList servers = model->getServers(); qSort( servers ); QAction *sa; serversActionGroup = new QActionGroup( this ); serversActionGroup->setExclusive( true ); connect( serversActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(serverChoice(QAction*)) ); for ( int i = 0; i < servers.count(); i++ ) { sa = new QAction( servers[i], serversActionGroup ); serversActionGroup->addAction( sa ); } menuServers->addActions( serversActionGroup->actions() ); targetActionGroup = new QActionGroup( this ); targetActionGroup->setExclusive( true ); connect( targetActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(targetChoice(QAction*)) ); waitWidget = new QWaitWidget( this ); }