CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include <QApplication>
2#include <QQuickWindow>
3#include <QQmlApplicationEngine>
4
6
9
13
14#include "core_initialization.h"
15
16#include <spdlog/spdlog.h>
17
18int main(int argc, char *argv[])
19{
20 QApplication app(argc, argv);
22
24 splash.show();
25 app.processEvents();
26
27 spdlog::info("Initialization");
28 splash.showMessage("Initializing core...");
29 app.processEvents();
31
32 splash.showMessage("Registering components...");
33 app.processEvents();
34 QQmlApplicationEngine engine;
35
36 // Register QML types Rendering
37 qmlRegisterType<CaptureMoment::UI::QMLPaintedImageItem>(
38 "CaptureMoment.UI.Rendering.Painted", 1, 0, "QMLPaintedImageItem"
39 );
40 qmlRegisterType<CaptureMoment::UI::QMLSGSImageItem>(
41 "CaptureMoment.UI.Rendering.SGS", 1, 0, "QMLSGSImageItem"
42 );
43 qmlRegisterType<CaptureMoment::UI::QMLRHIImageItem>(
44 "CaptureMoment.UI.Rendering.RHI", 1, 0, "QMLRHIImageItem"
45 );
46
47 splash.showMessage("Setting up context...");
48 app.processEvents();
49
50 // Setup QML context once
51 auto context = engine.rootContext();
53 spdlog::error("Failed to setup QML context");
54 return -1;
55 }
56
57 // Handle QML engine errors
58 QObject::connect(
59 &engine,
60 &QQmlApplicationEngine::objectCreationFailed,
61 &app,
62 []() { QCoreApplication::exit(-1); },
63 Qt::QueuedConnection
64 );
65
66 // Load the main QML module
67 splash.showMessage("Loading UI...");
68 app.processEvents();
69 engine.loadFromModule("CaptureMoment.desktop", "DesktopMain");
70
71 if (engine.rootObjects().isEmpty()) {
72 spdlog::error("Failed to load QML module");
73 return -1;
74 }
75
76 QObject* rootObject { engine.rootObjects().first() };
77 if (auto* window { qobject_cast<QQuickWindow*>(rootObject) })
78 {
79 QObject::connect(window, &QQuickWindow::frameSwapped, window, [window, &splash]() {
80 splash.close();
81 window->raise();
82 }, Qt::SingleShotConnection);
83 } else {
84 splash.close();
85 }
86
87 return app.exec();
88}
static bool setupContext(QQmlContext *context)
Setup complete QML context with all objects.
Custom splash screen displaying the application logo and loading status.
void showMessage(const QString &message, int alignment=Qt::AlignBottom|Qt::AlignHCenter, const QColor &color=Qt::darkGray)
Updates the loading status message displayed on the splash screen.
Core library initialization entry point.
Platform-specific application settings (Linux / macOS / Windows)
int main(int argc, char *argv[])
Definition main.cpp:18
void initialize()
Initializes the CaptureMoment Core library.
void applyApplicationSettings()
Applies Qt settings specific to the host platform.
Manages creation and setup of all C++ objects for QML.
QML-compatible wrapper for PaintedImageItem.
QML object of RHIImageItem.
QML object wrapper for SGSImageItem using modern C++20/23 features.
Splash screen class for application startup.
CaptureMoment — footer