Files
Jungfraujoch/viewer/jfjoch_viewer.cpp
2025-07-16 20:19:48 +02:00

60 lines
2.0 KiB
C++

#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include "JFJochViewerWindow.h"
#include "../writer/HDF5Objects.h"
#include "../common/GitInfo.h"
int main(int argc, char *argv[]) {
qRegisterMetaType<std::shared_ptr<const JFJochReaderDataset>>("std::shared_ptr<const JFJochReaderDataset>");
qRegisterMetaType<std::shared_ptr<const JFJochReaderImage>>("std::shared_ptr<const JFJochReaderImage>");
RegisterHDF5Filter();
QApplication app(argc, argv);
app.setApplicationName("JFJoch Viewer");
app.setApplicationVersion(QString::fromStdString(jfjoch_version()));
// Parse command line arguments
QCommandLineParser parser;
parser.setApplicationDescription("JFJoch Image Viewer");
parser.addHelpOption();
parser.addVersionOption();
// Add --dbus option with a value option that defaults to true
QCommandLineOption dbusOption(QStringList() << "d" << "dbus",
"Enable or disable D-Bus interface (default: enabled)",
"enable", "true");
parser.addOption(dbusOption);
// Process the actual command line arguments
parser.process(app);
// Get any positional arguments (files to open)
QString fileToOpen;
QStringList positionalArgs = parser.positionalArguments();
if (!positionalArgs.isEmpty()) {
// Use the last argument as the file to open
fileToOpen = positionalArgs.last();
}
// Check if D-Bus should be enabled or disabled
bool enableDBus = true; // Default is enabled
QString dbusValue = parser.value(dbusOption).toLower();
if (dbusValue == "false" || dbusValue == "0" || dbusValue == "no" || dbusValue == "off") {
enableDBus = false;
qDebug() << "D-Bus interface disabled";
} else {
qDebug() << "D-Bus interface enabled";
}
// Create and show the main window with the appropriate settings
JFJochViewerWindow mainWindow(nullptr, enableDBus, fileToOpen);
mainWindow.show();
return QApplication::exec();
}