// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "JFJochMouseShortcutsWindow.h" #include #include namespace { struct Shortcut { QString action; QString effect; }; struct Section { QString title; QVector rows; }; QString BuildHtml() { // Qt reads the Command key as Ctrl on macOS, and a Mac keyboard often has no Home/End/Page keys #ifdef Q_OS_MACOS const QString ctrl = "Cmd (\u2318)"; const QString home_end = "Home / End (Fn + \u2190 / \u2192)"; const QString page_up_down = "Page Up / Page Down (Fn + \u2191 / \u2193)"; const QString right_click = "Right click (Ctrl + click)"; #else const QString ctrl = "Ctrl"; const QString home_end = "Home / End"; const QString page_up_down = "Page Up / Page Down"; const QString right_click = "Right click"; #endif const QVector
sections = { // JFJochImage / JFJochDiffractionImage mouse handling {"Diffraction image", { {"Wheel", "Zoom in / out, centred on the cursor"}, {"Shift + wheel", "Move the foreground (upper contrast limit) in linear steps"}, {ctrl + " + wheel", "Move the foreground in multiplicative steps (×1.15 per notch)"}, {"F held + wheel", "Same as Shift + wheel, for as long as F is held"}, {"B held + wheel", "Move the background (lower contrast limit) in linear steps, for as long as B is held"}, {"A", "Apply auto-contrast once; press again to switch on continuous Auto"}, {home_end, "Jump to the first / last image in the dataset"}, {page_up_down, "Step one image forward / back"}, {"Hover", "Status bar shows the pixel position, its value and the resolution"}, {"Drag", "Pan the image"}, {"Shift + move", "Move the magnifier panel to the cursor; a frame shows the area it covers"}, {"Shift + drag", "Draw a rectangular ROI"}, {"Shift + " + ctrl + " + drag", "Draw a circular ROI"}, {"Drag an ROI or its handle", "Move or resize the selected ROI"}, {right_click, "Copy / save the image, fit to view, clear the ROI"}, }}, // JFJochGridScanImage {"Grid scan", { {"Hover", "Status bar shows the image number, the grid position and its value"}, {"Shift + hover", "Load the image under the cursor while moving over the grid"}, {"Double click", "Load the image under the cursor"}, }}, {"Other views", { {"2D azimuthal image: double click", "Zoom the diffraction image on the corresponding detector position"}, {"Dataset-info plot: hover", "Status bar shows the image number and the plotted value"}, {"Dataset-info plot: Shift + hover", "Load the hovered image"}, {"Spot / reflection list: double click", "Zoom the diffraction image on that spot or prediction"}, {"Image list: double click", "Load that image"}, }}, }; QString html = ""; for (const auto §ion : sections) { html += "

" + section.title + "

"; html += ""; for (const auto &row : section.rows) html += ""; html += "
" + row.action + "" + row.effect + "
"; } html += ""; return html; } } JFJochMouseShortcutsWindow::JFJochMouseShortcutsWindow(QWidget *parent) : QDialog(parent) { setWindowTitle("Mouse Shortcuts"); resize(620, 620); auto *browser = new QTextBrowser(this); browser->setHtml(BuildHtml()); auto *layout = new QVBoxLayout(this); layout->addWidget(browser); }