Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsScriptTimeline/track_entry_preview_widget.cpp
T
torstenandCopilot d6b6ffce7c Apply clang-format to Lts/Common and DTC/enum headers
- 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>
2026-08-19 14:46:29 +02:00

90 lines
2.8 KiB
C++

#include "track_entry_preview_widget.h"
#include "track_entry.h"
#include "ui_track_entry_preview_widget.h"
#include <LtsSession/lts_session_data.h>
#include <LtsWidgets/lts_message_dialog.h>
#include <QContextMenuEvent>
#include <QJsonDocument>
#include <QMenu>
#include <QTextEdit>
namespace LtsScriptTimeline
{
TrackEntryPreviewWidget::TrackEntryPreviewWidget(QWidget* parent)
: QWidget(parent), m_ui(new Ui::TrackEntryPreviewWidget)
{
m_ui->setupUi(this);
#ifndef LTS_DEBUG
m_ui->lbTopicId->hide();
m_ui->lblTopicId->hide();
m_ui->lbLen->hide();
m_ui->lblLen->hide();
#endif
connect(m_ui->widget, &TrackEntryPreviewer::signalDelete, this, &TrackEntryPreviewWidget::signalDelete);
connect(m_ui->widget, &TrackEntryPreviewer::signalStartDrag, this, &TrackEntryPreviewWidget::signalStartDrag);
connect(m_ui->widget, &TrackEntryPreviewer::signalStopDrag, this, &TrackEntryPreviewWidget::signalStopDrag);
}
TrackEntryPreviewWidget::~TrackEntryPreviewWidget()
{
delete m_ui;
}
void TrackEntryPreviewWidget::contextMenuEvent(QContextMenuEvent* event)
{
#ifndef LTS_DEBUG
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(
QStringLiteral("TrackEntryPreviewWidget.DebugMenu")) == QVariant(true))
#endif
{
QMenu* m = new QMenu(this);
m->setAttribute(Qt::WA_DeleteOnClose);
QPoint p = mapToGlobal(m->pos());
m->setGeometry(QRect(p, QPoint(event->x(), event->y())));
m->addAction(QStringLiteral("enable"), this, [this]() { setTopicEnabled(true); });
m->addAction(QStringLiteral("disable"), this, [this]() { setTopicEnabled(false); });
m->addAction(QStringLiteral("show detail data"), this, [this]() {
TrackEntry* te = m_ui->widget->trackEntry();
if (te == nullptr)
{
LtsWidgets::LtsMessageDialog::showMessage(this, QStringLiteral("no te was set"));
return;
}
QTextEdit* ted = new QTextEdit(nullptr);
ted->setAttribute(Qt::WA_DeleteOnClose);
ted->setWindowTitle(QStringLiteral("Track Entry #%1 - Detail Data string").arg(te->m_topicId));
ted->setText(QString::fromUtf8(QJsonDocument(te->m_detailData).toJson()));
ted->setReadOnly(true);
ted->show();
});
m->show();
}
}
void TrackEntryPreviewWidget::setTopicEnabled(bool enabled)
{
m_ui->widget->setEnabled(enabled);
}
void TrackEntryPreviewWidget::setTrackEntry(TrackEntry* te)
{
m_ui->lblDnD->setVisible(!te->isSet);
m_ui->widget->setVisible(!te->isSet);
m_ui->lbTopicId->setText(QString::number(te->m_topicId));
m_ui->lbLen->setText(QString::number(te->m_length));
m_ui->widget->setTrackEntry(te);
}
} // namespace LtsScriptTimeline