mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-09 13:34:14 +02:00
46e041fe01
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>
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef DIAGRAMGESTUREOVERLAY_H
|
|
#define DIAGRAMGESTUREOVERLAY_H
|
|
|
|
#include <QList>
|
|
#include <QWidget>
|
|
|
|
class QAction;
|
|
|
|
/**
|
|
@brief The ring shown while right-dragging on a folio: up to eight
|
|
commands around the point where the button went down, the one in the
|
|
mouse's direction highlighted. Releasing runs it, releasing near the
|
|
centre cancels -- SolidWorks' mouse gestures.
|
|
|
|
Commands are placed clockwise from the top, one per direction (4 or 8).
|
|
A null entry is an empty direction. The ring only draws; the view
|
|
tracks the mouse and asks sectorAt() on release.
|
|
*/
|
|
class DiagramGestureOverlay : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DiagramGestureOverlay(QWidget *viewport);
|
|
|
|
void showAt(const QPoint ¢er, const QList<QAction *> &actions,
|
|
int sectors = 8);
|
|
void setPointer(const QPoint &viewport_pos);
|
|
int sectorAt(const QPoint &viewport_pos) const;
|
|
QAction *actionAt(const QPoint &viewport_pos) const;
|
|
|
|
int sectors() const { return m_sectors; }
|
|
|
|
static bool isEnabled();
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
private:
|
|
QPoint m_center;
|
|
QList<QAction *> m_actions;
|
|
int m_active = -1;
|
|
int m_sectors = 8;
|
|
};
|
|
|
|
#endif // DIAGRAMGESTUREOVERLAY_H
|