- LtsWidgets: Fixed Qt6 API compatibility issues - QWheelEvent::delta() → angleDelta().y() - QStyleOption::init() → initFrom() - QComboBox activated signal signature change - QTextCodec removal (UTF-8 default in Qt6) - Missing widget includes added - LtsWebSocket: Fixed m_logger reference initialization - Added NGLLoggerBootstrap includes - Proper initialization in constructor initializer lists - CMake: Added BUILD_LTSWEBSOCKET option for temporary exclusion - Docker: RTI Connext permanent installation script added - ci/install-rti-in-docker.sh for persistent RTI setup - Removes need for volume mounting RTI into container - BUILD options: FilterManagement, RTI, Codification, Grantlee, LtsWebSocket can be disabled for partial builds during migration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
143 lines
4.3 KiB
C++
143 lines
4.3 KiB
C++
#include "lts_message_dialog_helper.h"
|
|
|
|
#include <QEventLoop>
|
|
#include <QHBoxLayout>
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
|
|
LtsMessageDialogHelper::LtsMessageDialogHelper(QObject* parent)
|
|
: QObject(parent), m_result(Button::Cancel), m_dialog(nullptr)
|
|
{
|
|
}
|
|
|
|
Button LtsMessageDialogHelper::showMessage(QWidget* parent, const QString& message, const QString& title,
|
|
Behaviour behaviour, Buttons buttons,
|
|
const QHash<Button, QString>& buttonTexts)
|
|
{
|
|
m_dialog = new LtsFramelessDialog(parent, behaviour);
|
|
|
|
m_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
QVBoxLayout* mainLayout = new QVBoxLayout(m_dialog);
|
|
|
|
QString text;
|
|
if (!title.isEmpty())
|
|
{
|
|
text = QStringLiteral("<b>%1</b><br><br>").arg(title);
|
|
}
|
|
|
|
text += message;
|
|
|
|
QLabel* messageLabel = new QLabel(text, m_dialog);
|
|
messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
mainLayout->addWidget(messageLabel);
|
|
|
|
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
|
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
connect(m_dialog, &LtsFramelessDialog::rejected, this, &LtsMessageDialogHelper::slotCancel);
|
|
|
|
if (buttons.testFlag(Button::Ok))
|
|
connect(addButton(buttonTexts.value(Button::Ok, tr("Ok")), buttonLayout, m_dialog, Button::Ok, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotOkay);
|
|
|
|
if (buttons.testFlag(Button::Yes))
|
|
connect(addButton(buttonTexts.value(Button::Yes, tr("Yes")), buttonLayout, m_dialog, Button::Yes, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotYes);
|
|
|
|
if (buttons.testFlag(Button::No))
|
|
connect(addButton(buttonTexts.value(Button::No, tr("No")), buttonLayout, m_dialog, Button::No, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotNo);
|
|
|
|
if (buttons.testFlag(Button::Apply))
|
|
connect(addButton(buttonTexts.value(Button::Apply, tr("Apply")), buttonLayout, m_dialog, Button::Apply, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotApply);
|
|
|
|
if (buttons.testFlag(Button::Discard))
|
|
connect(addButton(buttonTexts.value(Button::Discard, tr("Discard")), buttonLayout, m_dialog, Button::Discard,
|
|
parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotDiscard);
|
|
|
|
if (buttons.testFlag(Button::Cancel))
|
|
connect(
|
|
addButton(buttonTexts.value(Button::Cancel, tr("Cancel")), buttonLayout, m_dialog, Button::Cancel, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogHelper::slotCancel);
|
|
|
|
QWidget* buttonLayoutWidget = new QWidget;
|
|
buttonLayoutWidget->setLayout(buttonLayout);
|
|
|
|
mainLayout->addWidget(buttonLayoutWidget);
|
|
|
|
m_dialog->show();
|
|
m_dialog->raise();
|
|
|
|
QEventLoop loop;
|
|
connect(this, &LtsMessageDialogHelper::signalQuitEventLoop, &loop, &QEventLoop::quit, Qt::QueuedConnection);
|
|
loop.exec();
|
|
|
|
return m_result;
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotOkay()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::Ok;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotYes()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::Yes;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotNo()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::No;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotApply()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::Apply;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotDiscard()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::Discard;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
void LtsMessageDialogHelper::slotCancel()
|
|
{
|
|
m_dialog->hide();
|
|
m_result = Button::Cancel;
|
|
emit signalQuitEventLoop();
|
|
}
|
|
|
|
QPushButton* LtsMessageDialogHelper::addButton(const QString& text, QHBoxLayout* thatLayout, LtsFramelessDialog* dialog,
|
|
const Button& button, QWidget* parent)
|
|
{
|
|
QPushButton* btn = new QPushButton(text, parent);
|
|
connect(btn, &QPushButton::clicked, dialog, &LtsFramelessDialog::accept);
|
|
thatLayout->addWidget(btn);
|
|
|
|
if (button == Button::Ok || button == Button::Cancel)
|
|
{
|
|
btn->setDefault(true);
|
|
}
|
|
|
|
return btn;
|
|
}
|
|
|
|
} // namespace LtsWidgets
|