8#include <QDragEnterEvent>
9#include <QDragMoveEvent>
12#include <QResizeEvent>
21std::optional<DragDropPayload> extractDragPayload(
const QMimeData *mimeData)
32 QDataStream stream(&itemData, QIODevice::ReadOnly);
46 setAccessibleName(m_section ==
Section::Embedded ? tr(
"Embedded IC drop zone") : tr(
"File-based IC drop zone"));
48 ? tr(
"Drop a file-based IC here to embed it directly in the circuit.")
49 : tr(
"Drop an embedded IC here to extract it to its own file."));
53 m_hintOverlay =
new QLabel(
this);
54 m_hintOverlay->setObjectName(
"icDropHint");
55 m_hintOverlay->setAlignment(Qt::AlignCenter);
56 m_hintOverlay->setWordWrap(
true);
58 ? tr(
"Drop here to embed this IC in the circuit")
59 : tr(
"Drop here to extract this IC to a file"));
61 m_hintOverlay->setStyleSheet(QStringLiteral(
62 "QLabel { background: rgba(51, 129, 204, 215); color: white;"
63 " border: 2px dashed white; border-radius: 6px; padding: 8px; font-weight: bold; }"));
64 m_hintOverlay->hide();
67void ICDropZone::setHintVisible(
bool visible)
70 m_hintOverlay->resize(size());
71 m_hintOverlay->raise();
73 m_hintOverlay->setVisible(visible);
78 QWidget::resizeEvent(event);
79 m_hintOverlay->resize(event->size());
84 auto payload = extractDragPayload(event->mimeData());
89 event->acceptProposedAction();
92 event->acceptProposedAction();
99 event->acceptProposedAction();
105 setHintVisible(
false);
110 setHintVisible(
false);
112 auto payload = extractDragPayload(event->mimeData());
113 if (!payload)
return;
117 event->acceptProposedAction();
120 event->acceptProposedAction();
DragDropPayload readDragDropPayload(QDataStream &stream)
Reads a drag-and-drop payload from stream.
Shared reader for wiRedPanda's drag-and-drop MIME payload format.
Central enumeration types for element types, groups, and signal status.
ICDropZone: drop target widget for cross-section IC palette drops.
MIME type string constants for drag-and-drop operations.
Circuit and waveform file serialization/deserialization utilities.
void dragMoveEvent(QDragMoveEvent *event) override
void extractByBlobNameRequested(const QString &blobName)
Emitted when an embedded IC is dropped onto the file-based section.
Section
Identifies which IC palette section this zone belongs to.
@ Embedded
The embedded IC section (accepts file-backed drops for embedding).
@ FileBased
The file-backed IC section (accepts embedded drops for extraction).
void embedByFileRequested(const QString &fileName)
Emitted when a file-based IC is dropped onto the embedded section.
void dragEnterEvent(QDragEnterEvent *event) override
ICDropZone(Section section, QWidget *parent=nullptr)
Constructs a drop zone for the given palette section.
void dropEvent(QDropEvent *event) override
void dragLeaveEvent(QDragLeaveEvent *event) override
void resizeEvent(QResizeEvent *event) override
static QVersionNumber readPandaHeader(QDataStream &stream)
Reads and validates the .panda circuit file header; returns the stored version number.
constexpr const char * DragDropLegacy
Legacy drag-and-drop MIME type retained for backward compatibility.
constexpr const char * DragDrop
Current drag-and-drop MIME type for element palette → scene drops.