|
wiRedPanda
Logic Circuit Simulator
|
Manages clipboard operations (copy/cut/paste) and clone-drag for the circuit scene. More...
#include <ClipboardManager.h>
Public Member Functions | |
| ClipboardManager (Scene *scene) | |
| void | cloneDrag (const QPointF &mousePos) |
| Initiates a clone-drag (Ctrl+drag) of the current selection. | |
| void | copy () |
| Copies the currently selected items to the system clipboard. | |
| void | cut () |
| Cuts the currently selected items (copy + delete). | |
| void | duplicate () |
| void | paste () |
| Pastes items from the system clipboard into the scene. | |
Static Public Member Functions | |
| static QImage | buildDragImage (Scene *scene, const QTransform &viewTransform, const QRectF &sourceRect) |
| Renders sourceRect of scene, mapped through viewTransform, into a transparent-filled QImage bounded by kMaxDragImageDimension. | |
| static bool | canPaste (const QMimeData *mimeData) |
| Returns whether mimeData carries circuit data paste() accepts. | |
Static Public Attributes | |
| static constexpr int | kMaxDragImageDimension = 1024 |
Manages clipboard operations (copy/cut/paste) and clone-drag for the circuit scene.
Extracted from Scene to decouple clipboard serialization and blob-registry handling from the main circuit scene. Delegates item creation and undo commands back to the owning Scene.
Definition at line 33 of file ClipboardManager.h.
|
explicit |
Definition at line 29 of file ClipboardManager.cpp.
|
static |
Renders sourceRect of scene, mapped through viewTransform, into a transparent-filled QImage bounded by kMaxDragImageDimension.
sourceRect is a union of selected elements' scene bounding rects — unbounded magnitude, since position validation on load only rejects non-finite coordinates, never bounds them. Scaled down to fit rather than allocated proportionally. Exposed for testing.
Definition at line 191 of file ClipboardManager.cpp.
References kMaxDragImageDimension.
Referenced by cloneDrag().
|
static |
Returns whether mimeData carries circuit data paste() accepts.
Single source of truth for paste gating (context menu, future action enabling): paste() reads both the current and the legacy mime format, so any gate that checks only one of them silently drifts.
Definition at line 183 of file ClipboardManager.cpp.
References MimeType::Clipboard, and MimeType::ClipboardLegacy.
Referenced by Scene::contextMenu().
| void ClipboardManager::cloneDrag | ( | const QPointF & | mousePos | ) |
Initiates a clone-drag (Ctrl+drag) of the current selection.
Definition at line 216 of file ClipboardManager.cpp.
References buildDragImage(), MimeType::CloneDrag, qCDebug, sentryBreadcrumb(), Connection::Type, GraphicElement::Type, Scene::view(), and Serialization::writePandaHeader().
| void ClipboardManager::copy | ( | ) |
Copies the currently selected items to the system clipboard.
Definition at line 34 of file ClipboardManager.cpp.
References MimeType::BlobRegistry, MimeType::BlobRegistryV2, MimeType::Clipboard, and Serialization::writePandaHeader().
| void ClipboardManager::cut | ( | ) |
Cuts the currently selected items (copy + delete).
Definition at line 78 of file ClipboardManager.cpp.
References MimeType::BlobRegistry, MimeType::BlobRegistryV2, MimeType::Clipboard, and Serialization::writePandaHeader().
| void ClipboardManager::duplicate | ( | ) |
Duplicates the current selection in place (a grid step down-right), without touching the system clipboard, as a single undoable step; the copies become the new selection.
Definition at line 331 of file ClipboardManager.cpp.
References Constants::gridSize, Serialization::readPandaHeader(), and Serialization::writePandaHeader().
| void ClipboardManager::paste | ( | ) |
Pastes items from the system clipboard into the scene.
Definition at line 123 of file ClipboardManager.cpp.
References MimeType::BlobRegistry, MimeType::BlobRegistryV2, MimeType::Clipboard, MimeType::ClipboardLegacy, Serialization::readBoundedBlobMap(), and Serialization::readPandaHeader().
|
staticconstexpr |
Maximum width/height (in device pixels) buildDragImage() will allocate. A drag ghost is a transient visual aid, not saved output, so a modest cap is enough — selection extent beyond this is scaled down to fit rather than sized proportionally.
Definition at line 67 of file ClipboardManager.h.
Referenced by buildDragImage().