- 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>
127 lines
4.7 KiB
C++
127 lines
4.7 KiB
C++
#include "lts_message_dialog.h"
|
|
|
|
#include "lts_message_dialog_helper.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QDebug>
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
namespace LtsMessageDialog
|
|
{
|
|
Button showMessage(QWidget* parent, const QString& message, const QString& title, const Behaviour behaviour,
|
|
const Buttons buttons, const QHash<Button, QString>& buttonTexts)
|
|
{
|
|
static QAtomicInt s_used = 0;
|
|
|
|
if (s_used)
|
|
qDebug() << "LtsMessageDialog: showMessage called while showMessage is in its Event Loop - do not open more "
|
|
"than one Dialog at once !!";
|
|
|
|
s_used = 1;
|
|
|
|
LtsMessageDialogHelper* dialog = new LtsMessageDialogHelper();
|
|
Button result = dialog->showMessage(parent, message, title, behaviour, buttons, buttonTexts);
|
|
dialog->deleteLater();
|
|
|
|
s_used = 0;
|
|
|
|
return result;
|
|
}
|
|
|
|
Button askApplyDiscardCancel(QWidget* parent)
|
|
{
|
|
const QString question = QCoreApplication::translate("LtsDialog", "<br>"
|
|
"Apply - apply changes and close.<br>"
|
|
"Discard - discard changes and close.<br>"
|
|
"Cancel - do not close.");
|
|
const QString title = QCoreApplication::translate("LtsDialog", "Unapplied changes made. Apply the changes?");
|
|
return LtsMessageDialog::showMessage(parent, question, title, Behaviour::Modal,
|
|
Button::Apply | Button::Discard | Button::Cancel);
|
|
}
|
|
|
|
} // namespace LtsMessageDialog
|
|
|
|
LtsMessageDialogNew::LtsMessageDialogNew(QWidget* parent, const QString& message, const QString& title,
|
|
const Behaviour behaviour, const Buttons buttons,
|
|
const QHash<Button, QString>& buttonTexts, bool deleteOnClose)
|
|
{
|
|
m_dialog = new LtsFramelessDialog(parent, behaviour);
|
|
|
|
if (deleteOnClose)
|
|
m_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
connect(m_dialog, &LtsFramelessDialog::destroyed, this, &LtsMessageDialogNew::deleteLater);
|
|
|
|
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);
|
|
|
|
if (buttons.testFlag(Button::Ok))
|
|
connect(addButton(buttonTexts.value(Button::Ok, tr("Ok")), buttonLayout, m_dialog, Button::Ok, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::ok);
|
|
|
|
if (buttons.testFlag(Button::Yes))
|
|
connect(addButton(buttonTexts.value(Button::Yes, tr("Yes")), buttonLayout, m_dialog, Button::Yes, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::yes);
|
|
|
|
if (buttons.testFlag(Button::No))
|
|
connect(addButton(buttonTexts.value(Button::No, tr("No")), buttonLayout, m_dialog, Button::No, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::no);
|
|
|
|
if (buttons.testFlag(Button::Apply))
|
|
connect(addButton(buttonTexts.value(Button::Apply, tr("Apply")), buttonLayout, m_dialog, Button::Apply, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::apply);
|
|
|
|
if (buttons.testFlag(Button::Discard))
|
|
connect(addButton(buttonTexts.value(Button::Discard, tr("Discard")), buttonLayout, m_dialog, Button::Discard,
|
|
parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::discard);
|
|
|
|
if (buttons.testFlag(Button::Cancel))
|
|
connect(
|
|
addButton(buttonTexts.value(Button::Cancel, tr("Cancel")), buttonLayout, m_dialog, Button::Cancel, parent),
|
|
&QPushButton::clicked, this, &LtsMessageDialogNew::cancel);
|
|
|
|
QWidget* buttonLayoutWidget = new QWidget;
|
|
buttonLayoutWidget->setLayout(buttonLayout);
|
|
|
|
mainLayout->addWidget(buttonLayoutWidget);
|
|
|
|
m_dialog->show();
|
|
m_dialog->raise();
|
|
}
|
|
|
|
QPushButton* LtsMessageDialogNew::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
|