mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 04:44:13 +02:00
Mouse gestures: own command list, 4 or 8 directions
The right-drag ring showed the shortcut bar's commands for the selection. A new Preferences page, "Gestes de la souris", lets the user pick the ring's commands per selection context, one per direction, and choose 4 or 8 directions. Commands are dropped from the list onto a slot of a ring editor, or placed with a button; Delete empties a slot. A context the user never edits keeps following the shortcut bar, and 8 directions stays the default, so nothing changes for anyone who does not open the page. A picked list is positional: a direction left empty, or holding a command this build lacks, stays empty instead of shifting the others. Stored like ShortcutBarSettings: diagrameditor/gestures/<context> id lists in QSettings, defaults not stored. tst_gesturesettings covers the defaults, positional lists, the 4/8 setting, the overlay's sectors and empty slots, and the page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+25
-1
@@ -42,6 +42,7 @@
|
||||
#include "diagram.h"
|
||||
#include "diagramcontexttoolbar.h"
|
||||
#include "diagramgestureoverlay.h"
|
||||
#include "gesturesettings.h"
|
||||
#include "shortcutbarsettings.h"
|
||||
#include "shortcutmanager.h"
|
||||
#include "ElementsCollection/xmlelementcollection.h"
|
||||
@@ -794,7 +795,8 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e)
|
||||
m_diagram->clearEventInterface();
|
||||
m_swallow_native_menu = true;
|
||||
}
|
||||
m_gesture_overlay->showAt(m_gesture_origin, selectionCommands());
|
||||
m_gesture_overlay->showAt(m_gesture_origin, gestureCommands(),
|
||||
GestureSettings::directions());
|
||||
}
|
||||
if (m_gesture_overlay->isVisible()) {
|
||||
m_gesture_overlay->setPointer(pos);
|
||||
@@ -981,6 +983,28 @@ QList<QAction *> DiagramView::selectionCommands() const
|
||||
return actions;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief DiagramView::gestureCommands
|
||||
@return the gesture ring's commands for the current selection, as this
|
||||
window's actions. A list the user picked keeps its directions: a
|
||||
command this window lacks leaves its direction empty (nullptr).
|
||||
Otherwise the ring shows the shortcut bar's commands, in order.
|
||||
*/
|
||||
QList<QAction *> DiagramView::gestureCommands() const
|
||||
{
|
||||
QETDiagramEditor *qde = diagramEditor();
|
||||
const auto context = ShortcutBarSettings::contextFor(m_diagram->selectedItems());
|
||||
if (!qde || !GestureSettings::isCustom(context)) {
|
||||
return selectionCommands();
|
||||
}
|
||||
QList<QAction *> actions;
|
||||
for (const QString &id : GestureSettings::ids(context)) {
|
||||
actions << (id.isEmpty() ? nullptr
|
||||
: ShortcutManager::instance().action(id, qde));
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief DiagramView::showContextToolbar
|
||||
After a click that leaves something selected, show the shortcut bar's
|
||||
|
||||
Reference in New Issue
Block a user