- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
77 lines
1.6 KiB
C++
77 lines
1.6 KiB
C++
#include "track_entry_previewer.h"
|
|
|
|
#include "track_content_widget.h"
|
|
#include "track_entry.h"
|
|
#include "track_entry_painters.h"
|
|
|
|
#include <QDrag>
|
|
#include <QMimeData>
|
|
#include <QMouseEvent>
|
|
#include <QPainter>
|
|
|
|
namespace LtsScriptTimeline
|
|
{
|
|
|
|
QDataStream& operator<<(QDataStream& ds, const TrackEntry& te);
|
|
QDataStream& operator>>(QDataStream& ds, TrackEntry& te);
|
|
|
|
TrackEntryPreviewer::TrackEntryPreviewer(QWidget* parent) : QWidget(parent), m_te(nullptr)
|
|
{
|
|
|
|
setVisible(false);
|
|
}
|
|
|
|
TrackEntryPreviewer::~TrackEntryPreviewer() {}
|
|
|
|
void TrackEntryPreviewer::setTrackEntry(TrackEntry* te)
|
|
{
|
|
m_te = te;
|
|
|
|
if (m_te->isSet)
|
|
return;
|
|
|
|
connect(m_te, &TrackEntry::destroyed, this, [this]() {
|
|
m_te = nullptr;
|
|
emit signalDelete();
|
|
});
|
|
}
|
|
|
|
void TrackEntryPreviewer::mousePressEvent(QMouseEvent* event)
|
|
{
|
|
|
|
if (!m_te || event->buttons() != Qt::LeftButton)
|
|
return;
|
|
|
|
m_te->isSet = true;
|
|
QByteArray itemData(TrackContentWidget::itemsToData({m_te}, 0));
|
|
m_te->isSet = false;
|
|
|
|
QMimeData* mimeData = new QMimeData;
|
|
mimeData->setData(TrackContentWidget::mime, itemData);
|
|
|
|
QDrag* drag = new QDrag(this);
|
|
drag->setDragCursor(QPixmap(), Qt::CopyAction);
|
|
drag->setMimeData(mimeData);
|
|
|
|
emit signalStartDrag();
|
|
|
|
if (drag->exec(Qt::CopyAction) == Qt::CopyAction)
|
|
emit signalDelete();
|
|
|
|
emit signalStopDrag();
|
|
}
|
|
|
|
void TrackEntryPreviewer::paintEvent(QPaintEvent* event)
|
|
{
|
|
QWidget::paintEvent(event);
|
|
|
|
QPainter painter(this);
|
|
|
|
if (!m_te)
|
|
return;
|
|
|
|
drawTrackEntry(m_te, painter, rect().adjusted(0, 0, -1, -1), false, isEnabled());
|
|
}
|
|
|
|
} // namespace LtsScriptTimeline
|