24#include <QApplication>
35 : QObject(parent), container_(nullptr) {
53 if (aboutTextTemplate) {
56 QApplication::applicationVersion());
59 tr(
"Could not load the About page. The resource "
60 "file might be missing or corrupted.");
74 QWidget* QmlBridge::displayContainer()
const {
return container_; }
76 QString QmlBridge::aboutText()
const {
return aboutText_; }
91 QWidget* container_for_deferred_delete) {
98 if (container_for_deferred_delete) {
99 container_for_deferred_delete->deleteLater();
107 if (container_for_deferred_delete) {
108 QObject::connect(displayRaw, &QObject::destroyed,
109 container_for_deferred_delete,
110 &QObject::deleteLater, Qt::QueuedConnection);
112 displayRaw->deleteLater();
130 QMessageBox::about(
nullptr,
131 tr(
"About Pure C++",
"About message box title"),
143 const QStringList pathsToTry = {QStringLiteral(
":/locales/about_%1.htm")
144 .arg(QLocale::system().name()),
145 QStringLiteral(
":/locales/about.htm")};
147 for (
const auto& path : pathsToTry) {
149 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
150 QTextStream in(&file);
Manages the Qt3D window, scene setup, and the main simulation loop.
void simulationFinished()
Emitted when the simulation has run for n_iter iterations.
void releaseDisplayStrict(QWidget *container)
Synchronously destroys the display container and its window.
QmlBridge(const Configuration::SimulationConfig &config, QObject *parent=nullptr)
Constructs the QML bridge.
Q_INVOKABLE void startSimulation()
Starts the simulation after the window is shown.
std::optional< QString > loadAboutText()
Loads the "About" page content from resources.
QString aboutText_
The cached about text.
void aboutTextChanged()
Emitted when the about text changes.
QPointer< Display > display_
The 3D display view for the simulation.
void displayContainerChanged()
Emitted when the display container is created.
bool uiReleased_
True after UI resources have been released.
Q_INVOKABLE void shutdownSimulation()
Stops the physics thread and prints profiling reports.
void showAboutQt()
Slot to display the "About Qt" dialogue.
void releaseDisplayDeferred(QWidget *container_for_deferred_delete)
Schedules deferred destruction of Display and its container.
~QmlBridge() override
Destructor.
QPointer< QWidget > container_
The widget container for the 3D display.
void quit()
Slot to quit the application.
void simulationFinished()
Emitted when the simulation finishes.
void showAbout()
Slot to display the "About" dialogue.
Bridge class to expose C++ functionality to QML.