feat: extend MainWindow with QThread worker, settings panel, and batch dialog

- ConversionWorker runs pipeline on background QThread so the GUI stays
  responsive during conversion; emits file_done, preview_ready, finished
- MainWindow adds: output-format QComboBox, film-type QComboBox, Batch button
  that opens an AppConfig INI file and discovers files from batch.input_dir
- main.cpp: --batch and --config flags trigger CLI mode without Qt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christoph K.
2026-03-14 09:41:23 +01:00
parent fd2d97ddeb
commit 71d535fc50
3 changed files with 421 additions and 107 deletions

View File

@@ -1,35 +1,49 @@
#include "cli/CliRunner.h"
#include "gui/MainWindow.h"
#include <QApplication>
#include <algorithm>
#include <iostream>
#include <string>
#ifndef NO_GUI
#include "gui/MainWindow.h"
#include <QApplication>
#endif
/**
* @brief Application entry point.
*
* Supports two modes:
* - GUI mode (default): launches the Qt MainWindow
* - CLI mode (--cli flag): batch processes files without GUI
* Supports two operating modes:
*
* **GUI mode** (default when compiled with Qt):
* Launches the Qt MainWindow.
*
* **CLI / batch mode** (activated by `--cli` or `--batch`):
* Processes files from the command line or a config file without any GUI.
* Progress is written to stderr; errors are logged but do not abort the batch.
*
* @note The `--batch` flag (or `--config <file>`) implies CLI mode.
*/
int main(int argc, char* argv[]) {
// Check if CLI mode is requested
// Determine whether CLI/batch mode was requested.
bool cli_mode = false;
for (int i = 1; i < argc; ++i) {
if (std::string{argv[i]} == "--cli") {
const std::string arg{argv[i]};
if (arg == "--cli" || arg == "--batch" || arg == "--config") {
cli_mode = true;
break;
}
}
if (cli_mode) {
// CLI batch mode (no Qt dependency)
// ── CLI / Batch mode (no Qt dependency) ─────────────────────────────
auto config_result = photoconv::CliRunner::parse_args(argc, argv);
if (!config_result.has_value()) {
std::cerr << config_result.error().format() << std::endl;
return 1;
// "Help requested" is not an error exit 0.
const bool is_help = config_result.error().message == "Help requested";
if (!is_help) {
std::cerr << config_result.error().format() << std::endl;
}
return is_help ? 0 : 1;
}
photoconv::CliRunner runner;
@@ -39,16 +53,24 @@ int main(int argc, char* argv[]) {
return 1;
}
// Exit code 0 if at least one file was converted, 1 otherwise.
return result.value() > 0 ? 0 : 1;
}
// GUI mode
QApplication app(argc, argv);
#ifndef NO_GUI
// ── GUI mode ─────────────────────────────────────────────────────────────
QApplication app{argc, argv};
app.setApplicationName("Photo Converter");
app.setApplicationVersion("0.1.0");
app.setOrganizationName("photo-converter");
photoconv::MainWindow window;
window.show();
return app.exec();
#else
std::cerr << "This build was compiled without GUI support.\n"
"Use --cli or --batch mode.\n";
return 1;
#endif
}