961836837f
- Fusion fills QGroupBox interiors with a flat light colour, so the settings window
lost its salmon look. A tiny app stylesheet (QGroupBox { background: transparent })
makes them show the salmon window background again; entry widgets stay white via
the palette.
- The dataset-info chart now fixes the x-axis to the whole dataset [0, n) (the
largest run = the original file), so a subset run is drawn at its real image
positions instead of being stretched to fill the plot. Subsets with binning bin
by ordinal and place each point at its mapped image number (correct for the
common contiguous sub-range).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
101 lines
3.8 KiB
C++
101 lines
3.8 KiB
C++
#include <QApplication>
|
|
#include <QCommandLineParser>
|
|
#include <QCommandLineOption>
|
|
#include <QSplashScreen>
|
|
#include <QTimer>
|
|
#include <QPalette>
|
|
|
|
#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);
|
|
|
|
// Theme via the palette (robust across widgets): salmon panels, white entry fields that fall back
|
|
// to salmon when disabled, and a teal accent for selections and progress-bar chunks.
|
|
app.setStyle("Fusion");
|
|
QPalette pal = app.palette();
|
|
pal.setColor(QPalette::Window, QColor(255, 235, 230));
|
|
pal.setColor(QPalette::Base, Qt::white);
|
|
pal.setColor(QPalette::AlternateBase, QColor(255, 245, 242));
|
|
pal.setColor(QPalette::Button, QColor(255, 235, 230));
|
|
pal.setColor(QPalette::Disabled, QPalette::Base, QColor(255, 235, 230));
|
|
pal.setColor(QPalette::Highlight, QColor(0x2a, 0x9d, 0x8f));
|
|
pal.setColor(QPalette::HighlightedText, Qt::white);
|
|
app.setPalette(pal);
|
|
// Fusion fills QGroupBox interiors with a flat light colour; make them transparent so they show
|
|
// the salmon window background like the rest of the UI (entry widgets stay white via the palette).
|
|
app.setStyleSheet("QGroupBox { background-color: transparent; }");
|
|
|
|
QIcon appIcon(":/jfjoch.png");
|
|
app.setWindowIcon(appIcon);
|
|
|
|
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();
|
|
|
|
QPixmap pixmap(":/jfjoch.png");
|
|
QPixmap splash_pixmap(256+2*50, 256+50+50+30);
|
|
splash_pixmap.fill(Qt::white);
|
|
QPainter painter(&splash_pixmap);
|
|
painter.drawPixmap(50, 50, pixmap);
|
|
|
|
QSplashScreen *splash = new QSplashScreen(splash_pixmap);
|
|
splash->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::SplashScreen);
|
|
QString version(QString::fromStdString(jfjoch_version()));
|
|
splash->showMessage(
|
|
"<b>Jungfrujoch image viewer</b><br/> Version " + version + "<br/>Paul Scherrer Institut",
|
|
Qt::AlignBottom | Qt::AlignHCenter,
|
|
Qt::black
|
|
);
|
|
|
|
splash->show();
|
|
|
|
QTimer::singleShot(5000, splash, &QSplashScreen::close);
|
|
return QApplication::exec();
|
|
}
|