From db14e88f734b29880d4019d27031110427c5a9f4 Mon Sep 17 00:00:00 2001 From: fox Date: Thu, 21 Nov 2024 12:38:47 +0100 Subject: [PATCH 1/2] Add Shortcut Keys to navigate/modify molecules --- avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp | 2 +- avogadro/qtplugins/editor/editor.cpp | 2 +- avogadro/qtplugins/label/labeleditor.cpp | 2 +- avogadro/qtplugins/manipulator/manipulator.cpp | 2 +- avogadro/qtplugins/measuretool/measuretool.cpp | 2 +- avogadro/qtplugins/navigator/navigator.cpp | 2 +- avogadro/qtplugins/playertool/playertool.cpp | 2 +- avogadro/qtplugins/selectiontool/selectiontool.cpp | 2 +- avogadro/qtplugins/templatetool/templatetool.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp b/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp index 7a37475361..1f47eb49c9 100644 --- a/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp +++ b/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp @@ -116,7 +116,7 @@ BondCentricTool::BondCentricTool(QObject* parent_) { m_activateAction->setText(tr("Bond-Centric Manipulation")); m_activateAction->setToolTip( - tr("Bond Centric Manipulation Tool\n\n" + tr("Bond Centric Manipulation Tool \tCtrl+7\n\n" "Left Mouse: \tClick and drag to rotate the view.\n" "Middle Mouse: \tClick and drag to zoom in or out.\n" "Right Mouse: \tClick and drag to move the view.\n" diff --git a/avogadro/qtplugins/editor/editor.cpp b/avogadro/qtplugins/editor/editor.cpp index 073a12d172..0b05507bbc 100644 --- a/avogadro/qtplugins/editor/editor.cpp +++ b/avogadro/qtplugins/editor/editor.cpp @@ -70,7 +70,7 @@ Editor::Editor(QObject* parent_) { m_activateAction->setText(tr("Draw")); m_activateAction->setToolTip( - tr("Draw Tool\n\n" + tr("Draw Tool \tCtrl+2\n\n" "Left Mouse: \tClick and Drag to create Atoms and Bond\n" "Right Mouse: \tDelete Atom")); setIcon(); diff --git a/avogadro/qtplugins/label/labeleditor.cpp b/avogadro/qtplugins/label/labeleditor.cpp index 97b30b3de4..87be036475 100644 --- a/avogadro/qtplugins/label/labeleditor.cpp +++ b/avogadro/qtplugins/label/labeleditor.cpp @@ -30,7 +30,7 @@ LabelEditor::LabelEditor(QObject* parent_) { m_activateAction->setText(tr("Edit Labels")); m_activateAction->setToolTip( - tr("Atom Label Tool\n\n" + tr("Atom Label Tool \tCtrl+4\n\n" "Left Mouse: \tClick on Atoms to add Custom Labels")); setIcon(); } diff --git a/avogadro/qtplugins/manipulator/manipulator.cpp b/avogadro/qtplugins/manipulator/manipulator.cpp index 69af565abe..2593eb1ab7 100644 --- a/avogadro/qtplugins/manipulator/manipulator.cpp +++ b/avogadro/qtplugins/manipulator/manipulator.cpp @@ -48,7 +48,7 @@ Manipulator::Manipulator(QObject* parent_) { m_activateAction->setText(tr("Manipulate")); m_activateAction->setToolTip( - tr("Manipulation Tool\n\n" + tr("Manipulation Tool \tCtrl+6\n\n" "Left Mouse: \tClick and drag to move atoms\n" "Right Mouse: \tClick and drag to rotate atoms.\n")); setIcon(); diff --git a/avogadro/qtplugins/measuretool/measuretool.cpp b/avogadro/qtplugins/measuretool/measuretool.cpp index 9bb9e57b82..1580370392 100644 --- a/avogadro/qtplugins/measuretool/measuretool.cpp +++ b/avogadro/qtplugins/measuretool/measuretool.cpp @@ -53,7 +53,7 @@ MeasureTool::MeasureTool(QObject* parent_) { m_activateAction->setText(tr("Measure")); m_activateAction->setToolTip( - tr("Measure Tool\n\n" + tr("Measure Tool \tCtrl+8\n\n" "Left Mouse: \tSelect up to four Atoms.\n" "\tDistances are measured between 1-2 and 2-3\n" "\tAngle is measured between 1-3 using 2 as the common point\n" diff --git a/avogadro/qtplugins/navigator/navigator.cpp b/avogadro/qtplugins/navigator/navigator.cpp index 03cd4386c4..f690f1c415 100644 --- a/avogadro/qtplugins/navigator/navigator.cpp +++ b/avogadro/qtplugins/navigator/navigator.cpp @@ -38,7 +38,7 @@ Navigator::Navigator(QObject* parent_) { m_activateAction->setText(tr("Navigate")); m_activateAction->setToolTip( - tr("Navigation Tool\n\n" + tr("Navigation Tool \tCtrl+1\n\n" "Left Mouse: \tClick and drag to rotate the view.\n" "Middle Mouse: \tClick and drag to zoom in or out.\n" "Right Mouse: \tClick and drag to move the view.\n")); diff --git a/avogadro/qtplugins/playertool/playertool.cpp b/avogadro/qtplugins/playertool/playertool.cpp index fd26583732..b770163a9e 100644 --- a/avogadro/qtplugins/playertool/playertool.cpp +++ b/avogadro/qtplugins/playertool/playertool.cpp @@ -45,7 +45,7 @@ PlayerTool::PlayerTool(QObject* parent_) m_toolWidget(nullptr), m_frameIdx(nullptr), m_slider(nullptr) { m_activateAction->setText(tr("Player")); - m_activateAction->setToolTip(tr("Animation Tool")); + m_activateAction->setToolTip(tr("Animation Tool \tCtrl+9")); setIcon(); } diff --git a/avogadro/qtplugins/selectiontool/selectiontool.cpp b/avogadro/qtplugins/selectiontool/selectiontool.cpp index 7382c4a94b..efc60289a0 100644 --- a/avogadro/qtplugins/selectiontool/selectiontool.cpp +++ b/avogadro/qtplugins/selectiontool/selectiontool.cpp @@ -49,7 +49,7 @@ SelectionTool::SelectionTool(QObject* parent_) { m_activateAction->setText(tr("Selection")); m_activateAction->setToolTip( - tr("Selection Tool\n\n" + tr("Selection Tool \tCtrl+5\n\n" "Left Mouse: \tClick to pick individual atoms, residues, or fragments\n" "\tDrag to select a range of atoms\n" "Right Mouse: \tClick outside the molecule to clear selection\n" diff --git a/avogadro/qtplugins/templatetool/templatetool.cpp b/avogadro/qtplugins/templatetool/templatetool.cpp index c745f2ad57..d82c485c8f 100644 --- a/avogadro/qtplugins/templatetool/templatetool.cpp +++ b/avogadro/qtplugins/templatetool/templatetool.cpp @@ -80,7 +80,7 @@ TemplateTool::TemplateTool(QObject* parent_) { m_activateAction->setText(tr("Template")); m_activateAction->setToolTip( - tr("Template Tool\n\n" + tr("Template Tool \tCtrl+3\n\n" "Insert fragments, including metal centers.\n" "Select an element and coordination geometry," "then click to insert a fragment.\n\n" From 99ec8410604b4ed1a106d11de2d99e8a6a7170d4 Mon Sep 17 00:00:00 2001 From: Pietro Natale <62770418+Milziade@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:17:58 +0100 Subject: [PATCH 2/2] Make the shortcut assignment easier and OS agnostic Signed-off-by: Pietro Natale <62770418+Milziade@users.noreply.github.com> --- avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp | 5 +++-- avogadro/qtplugins/editor/editor.cpp | 5 +++-- avogadro/qtplugins/label/labeleditor.cpp | 5 +++-- avogadro/qtplugins/manipulator/manipulator.cpp | 5 +++-- avogadro/qtplugins/measuretool/measuretool.cpp | 5 +++-- avogadro/qtplugins/navigator/navigator.cpp | 5 +++-- avogadro/qtplugins/playertool/playertool.cpp | 3 ++- avogadro/qtplugins/selectiontool/selectiontool.cpp | 5 +++-- avogadro/qtplugins/templatetool/templatetool.cpp | 5 +++-- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp b/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp index 1f47eb49c9..ae5fdb2ff8 100644 --- a/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp +++ b/avogadro/qtplugins/bondcentrictool/bondcentrictool.cpp @@ -114,16 +114,17 @@ BondCentricTool::BondCentricTool(QObject* parent_) m_molecule(nullptr), m_renderer(nullptr), m_moveState(IgnoreMove), m_planeSnapIncr(10.f), m_snapPlaneToBonds(true) { + QString shortcut = tr("Ctrl+7", "control-key 7"); m_activateAction->setText(tr("Bond-Centric Manipulation")); m_activateAction->setToolTip( - tr("Bond Centric Manipulation Tool \tCtrl+7\n\n" + tr("Bond Centric Manipulation Tool \t(%1)\n\n" "Left Mouse: \tClick and drag to rotate the view.\n" "Middle Mouse: \tClick and drag to zoom in or out.\n" "Right Mouse: \tClick and drag to move the view.\n" "Double-Click: \tReset the view.\n\n" "Left Click & Drag on a Bond to set the Manipulation Plane:\n" "Left Click & Drag one of the Atoms in the Bond to change the angle\n" - "Right Click & Drag one of the Atoms in the Bond to change the length")); + "Right Click & Drag one of the Atoms in the Bond to change the length").arg(shortcut)); setIcon(); } diff --git a/avogadro/qtplugins/editor/editor.cpp b/avogadro/qtplugins/editor/editor.cpp index 0b05507bbc..f133dd746c 100644 --- a/avogadro/qtplugins/editor/editor.cpp +++ b/avogadro/qtplugins/editor/editor.cpp @@ -68,11 +68,12 @@ Editor::Editor(QObject* parent_) m_clickedAtomicNumber(INVALID_ATOMIC_NUMBER), m_bondAdded(false), m_fixValenceLater(false), m_layerManager("Editor") { + QString shortcut = tr("Ctrl+2", "control-key 2"); m_activateAction->setText(tr("Draw")); m_activateAction->setToolTip( - tr("Draw Tool \tCtrl+2\n\n" + tr("Draw Tool \t(%1)\n\n" "Left Mouse: \tClick and Drag to create Atoms and Bond\n" - "Right Mouse: \tDelete Atom")); + "Right Mouse: \tDelete Atom").arg(shortcut)); setIcon(); reset(); } diff --git a/avogadro/qtplugins/label/labeleditor.cpp b/avogadro/qtplugins/label/labeleditor.cpp index 87be036475..b26107eb24 100644 --- a/avogadro/qtplugins/label/labeleditor.cpp +++ b/avogadro/qtplugins/label/labeleditor.cpp @@ -28,10 +28,11 @@ LabelEditor::LabelEditor(QObject* parent_) m_molecule(nullptr), m_glWidget(nullptr), m_renderer(nullptr), m_selected(false), m_text("") { + QString shortcut = tr("Ctrl+4", "control-key 4"); m_activateAction->setText(tr("Edit Labels")); m_activateAction->setToolTip( - tr("Atom Label Tool \tCtrl+4\n\n" - "Left Mouse: \tClick on Atoms to add Custom Labels")); + tr("Atom Label Tool \t(%1)\n\n" + "Left Mouse: \tClick on Atoms to add Custom Labels").arg(shortcut)); setIcon(); } diff --git a/avogadro/qtplugins/manipulator/manipulator.cpp b/avogadro/qtplugins/manipulator/manipulator.cpp index 2593eb1ab7..07eb04e84a 100644 --- a/avogadro/qtplugins/manipulator/manipulator.cpp +++ b/avogadro/qtplugins/manipulator/manipulator.cpp @@ -46,11 +46,12 @@ Manipulator::Manipulator(QObject* parent_) m_toolWidget(new ManipulateWidget(dynamic_cast(parent_))), m_currentAction(Nothing) { + QString shortcut = tr("Ctrl+6", "control-key 6"); m_activateAction->setText(tr("Manipulate")); m_activateAction->setToolTip( - tr("Manipulation Tool \tCtrl+6\n\n" + tr("Manipulation Tool \t(%1)\n\n" "Left Mouse: \tClick and drag to move atoms\n" - "Right Mouse: \tClick and drag to rotate atoms.\n")); + "Right Mouse: \tClick and drag to rotate atoms.\n").arg(shortcut)); setIcon(); connect(m_toolWidget->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); diff --git a/avogadro/qtplugins/measuretool/measuretool.cpp b/avogadro/qtplugins/measuretool/measuretool.cpp index 1580370392..491859fd36 100644 --- a/avogadro/qtplugins/measuretool/measuretool.cpp +++ b/avogadro/qtplugins/measuretool/measuretool.cpp @@ -51,14 +51,15 @@ MeasureTool::MeasureTool(QObject* parent_) : QtGui::ToolPlugin(parent_), m_activateAction(new QAction(this)), m_molecule(nullptr), m_rwMolecule(nullptr), m_renderer(nullptr) { + QString shortcut = tr("Ctrl+8", "control-key 8"); m_activateAction->setText(tr("Measure")); m_activateAction->setToolTip( - tr("Measure Tool \tCtrl+8\n\n" + tr("Measure Tool \t(%1)\n\n" "Left Mouse: \tSelect up to four Atoms.\n" "\tDistances are measured between 1-2 and 2-3\n" "\tAngle is measured between 1-3 using 2 as the common point\n" "\tDihedral is measured between 1-2-3-4\n" - "Right Mouse: \tReset the measurements.")); + "Right Mouse: \tReset the measurements.").arg(shortcut)); setIcon(); } diff --git a/avogadro/qtplugins/navigator/navigator.cpp b/avogadro/qtplugins/navigator/navigator.cpp index f690f1c415..4672081f7a 100644 --- a/avogadro/qtplugins/navigator/navigator.cpp +++ b/avogadro/qtplugins/navigator/navigator.cpp @@ -36,12 +36,13 @@ Navigator::Navigator(QObject* parent_) m_renderer(nullptr), m_pressedButtons(Qt::NoButton), m_currentAction(Nothing) { + QString shortcut = tr("Ctrl+1", "control-key 1"); m_activateAction->setText(tr("Navigate")); m_activateAction->setToolTip( - tr("Navigation Tool \tCtrl+1\n\n" + tr("Navigation Tool \t(%1)\n\n" "Left Mouse: \tClick and drag to rotate the view.\n" "Middle Mouse: \tClick and drag to zoom in or out.\n" - "Right Mouse: \tClick and drag to move the view.\n")); + "Right Mouse: \tClick and drag to move the view.\n").arg(shortcut)); setIcon(); QSettings settings; m_zoomDirection = settings.value("navigator/zoom", 1).toInt(); diff --git a/avogadro/qtplugins/playertool/playertool.cpp b/avogadro/qtplugins/playertool/playertool.cpp index b770163a9e..9345bf06e4 100644 --- a/avogadro/qtplugins/playertool/playertool.cpp +++ b/avogadro/qtplugins/playertool/playertool.cpp @@ -44,8 +44,9 @@ PlayerTool::PlayerTool(QObject* parent_) m_molecule(nullptr), m_renderer(nullptr), m_currentFrame(0), m_toolWidget(nullptr), m_frameIdx(nullptr), m_slider(nullptr) { + QString shortcut = tr("Ctrl+9", "control-key 9"); m_activateAction->setText(tr("Player")); - m_activateAction->setToolTip(tr("Animation Tool \tCtrl+9")); + m_activateAction->setToolTip(tr("Animation Tool \t(%1)").arg(shortcut)); setIcon(); } diff --git a/avogadro/qtplugins/selectiontool/selectiontool.cpp b/avogadro/qtplugins/selectiontool/selectiontool.cpp index efc60289a0..6e1219d34b 100644 --- a/avogadro/qtplugins/selectiontool/selectiontool.cpp +++ b/avogadro/qtplugins/selectiontool/selectiontool.cpp @@ -47,14 +47,15 @@ SelectionTool::SelectionTool(QObject* parent_) m_drawSelectionBox(false), m_doubleClick(false), m_initSelectionBox(false), m_layerManager("Selection Tool") { + QString shortcut = tr("Ctrl+5", "control-key 5"); m_activateAction->setText(tr("Selection")); m_activateAction->setToolTip( - tr("Selection Tool \tCtrl+5\n\n" + tr("Selection Tool \t(%1)\n\n" "Left Mouse: \tClick to pick individual atoms, residues, or fragments\n" "\tDrag to select a range of atoms\n" "Right Mouse: \tClick outside the molecule to clear selection\n" "Use Ctrl to toggle the selection and shift to add to the selection.\n" - "Double-Click: \tSelect an entire fragment.")); + "Double-Click: \tSelect an entire fragment.").arg(shortcut)); setIcon(); } diff --git a/avogadro/qtplugins/templatetool/templatetool.cpp b/avogadro/qtplugins/templatetool/templatetool.cpp index d82c485c8f..c7ac628791 100644 --- a/avogadro/qtplugins/templatetool/templatetool.cpp +++ b/avogadro/qtplugins/templatetool/templatetool.cpp @@ -78,14 +78,15 @@ TemplateTool::TemplateTool(QObject* parent_) m_clickedAtomicNumber(INVALID_ATOMIC_NUMBER), m_bondAdded(false), m_fixValenceLater(false) { + QString shortcut = tr("Ctrl+3", "control-key 3"); m_activateAction->setText(tr("Template")); m_activateAction->setToolTip( - tr("Template Tool \tCtrl+3\n\n" + tr("Template Tool \t(%1)\n\n" "Insert fragments, including metal centers.\n" "Select an element and coordination geometry," "then click to insert a fragment.\n\n" "Select a ligand or functional group and click" - "on a hydrogen atom to attach it.")); + "on a hydrogen atom to attach it.").arg(shortcut)); setIcon(); reset(); }