Hydrogens::Hydrogens(QObject *parent_) : Avogadro::QtGui::ExtensionPlugin(parent_), m_molecule(NULL) { QAction *action = new QAction(tr("Adjust &Hydrogens (Add and Remove)"), this); action->setShortcut(QKeySequence("Ctrl+Alt+H")); connect(action, SIGNAL(triggered()), SLOT(adjustHydrogens())); m_actions.append(action); action = new QAction(tr("Adjust Hydrogens (&Add Only)"), this); connect(action, SIGNAL(triggered()), SLOT(addHydrogens())); m_actions.append(action); action = new QAction(tr("Adjust Hydrogens (&Remove Only)"), this); connect(action, SIGNAL(triggered()), SLOT(removeHydrogens())); m_actions.append(action); action = new QAction(tr("&Remove All Hydrogens"), this); connect(action, SIGNAL(triggered()), SLOT(removeAllHydrogens())); m_actions.append(action); }
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())); }
void MainWindow::createConnections() { connect(&m_toolBar, SIGNAL(newMolecule()), &m_viewerModel, SLOT(newMoleculeMenu())); connect(&m_toolBar, SIGNAL(open()), this, SLOT(openFile())); connect(&m_toolBar, SIGNAL(save()), &m_viewerModel, SLOT(saveAll())); connect(&m_toolBar, SIGNAL(addHydrogens()), &m_viewerModel, SLOT(addHydrogens())); connect(&m_toolBar, SIGNAL(minimizeEnergy()), &m_viewerModel, SLOT(minimizeEnergy())); connect(&m_toolBar, SIGNAL(deleteSelection()), &m_viewerModel, SLOT(deleteSelection())); connect(&m_toolBar, SIGNAL(takeSnapshot()), &m_viewer, SLOT(saveSnapshot())); connect(&m_toolBar, SIGNAL(record(bool)), this, SLOT(setRecordingActive(bool))); connect(this, SIGNAL(recordingActive(bool)), &m_toolBar, SLOT(setRecordAnimationButtonChecked(bool))); connect(this, SIGNAL(recordingActive(bool)), &m_viewer, SLOT(setRecordingActive(bool))); connect(&m_viewer, SIGNAL(recordingCancelled()), this, SLOT(recordingCancelled())); connect(&m_toolBar, SIGNAL(fullScreen()), this, SLOT(fullScreen())); connect(&m_toolBar, SIGNAL(showHelp()), this, SLOT(showHelp())); connect(&m_toolBar, SIGNAL(viewerModeChanged(Viewer::Mode const)), &m_viewer, SLOT(setActiveViewerMode(Viewer::Mode const))); connect(&m_toolBar, SIGNAL(buildElementSelected(unsigned int)), &m_viewer, SLOT(setDefaultBuildElement(unsigned int))); connect(&m_toolBar, SIGNAL(buildFragmentSelected(QString const&, Viewer::Mode const)), &m_viewer, SLOT(setDefaultBuildFragment(QString const&, Viewer::Mode const))); // ViewerModel connect(&m_viewerModel, SIGNAL(updated()), &m_viewer, SLOT(updateGL())); connect(&m_viewerView, SIGNAL(doubleClicked(QModelIndex const&)), &m_viewerModel, SLOT(itemDoubleClicked(QModelIndex const&))); connect(&m_viewerView, SIGNAL(expanded(QModelIndex const&)), &m_viewerModel, SLOT(itemExpanded(QModelIndex const&))); connect(&m_viewerModel, SIGNAL(sceneRadiusChanged(double const)), &m_viewer, SLOT(setSceneRadius(double const))); connect(&m_viewerModel, SIGNAL(changeActiveViewerMode(Viewer::Mode const)), &m_viewer, SLOT(setActiveViewerMode(Viewer::Mode const))); connect(&m_viewerModel, SIGNAL(displayMessage(QString const&)), &m_viewer, SLOT(displayMessage(QString const&))); connect(&m_viewerModel, SIGNAL(postCommand(QUndoCommand*)), this, SLOT(addCommand(QUndoCommand*))); connect(&m_viewerModel, SIGNAL(foregroundColorChanged(QColor const&)), &m_viewer, SLOT(setForegroundColor(QColor const&))); connect(&(ProcessMonitor::instance()), SIGNAL(resultsAvailable(JobInfo*)), &m_viewerModel, SLOT(openCalculationResults(JobInfo*))); // Viewer connect(&m_viewer, SIGNAL(enableUpdate(bool const)), &m_viewerModel, SLOT(enableUpdate(bool const))); connect(&m_viewerModel, SIGNAL(pushAnimators(AnimatorList const&)), &m_viewer, SLOT(pushAnimators(AnimatorList const&))); connect(&m_viewerModel, SIGNAL(popAnimators(AnimatorList const&)), &m_viewer, SLOT(popAnimators(AnimatorList const&))); connect(&m_viewer, SIGNAL(postCommand(QUndoCommand*)), this, SLOT(addCommand(QUndoCommand*))); connect(&m_viewer, SIGNAL(openFileFromDrop(QString const&)), this, SLOT(openFile(QString const&))); connect(&m_viewer, SIGNAL(activeViewerModeChanged(Viewer::Mode const)), &m_toolBar, SLOT(setToolBarMode(Viewer::Mode const))); connect(&m_viewer, SIGNAL(escapeFullScreen()), this, SLOT(fullScreen())); connect(&m_viewer, SIGNAL(animationStep()), &m_viewerModel, SLOT(reperceiveBondsForAnimation())); // Selection connect(&m_viewerSelectionModel, SIGNAL(selectionChanged(QItemSelection const&, QItemSelection const&)), &m_viewerModel, SLOT(selectionChanged(QItemSelection const&, QItemSelection const&)) ); connect(&m_viewerModel, SIGNAL(selectionChanged(QItemSelection const&, QItemSelectionModel::SelectionFlags)), &m_viewerSelectionModel, SLOT(select(QItemSelection const&, QItemSelectionModel::SelectionFlags)) ); connect(&m_viewerModel, SIGNAL(clearSelection()), &m_viewerSelectionModel, SLOT(clearSelection())); connect(&m_viewer, SIGNAL(clearSelection()), &m_viewerSelectionModel, SLOT(clearSelection())); connect(&m_viewer, SIGNAL(select(QModelIndex const&, QItemSelectionModel::SelectionFlags)), &m_viewerSelectionModel, SLOT(select(QModelIndex const&, QItemSelectionModel::SelectionFlags))); connect(&m_viewerModel, SIGNAL(select(QModelIndex const&, QItemSelectionModel::SelectionFlags)), &m_viewerSelectionModel, SLOT(select(QModelIndex const&, QItemSelectionModel::SelectionFlags))); }