The release moved every source into its own layer (core/, app/, pages/,
providers/, preferences/, logging/, archive/, update/, translations/) and
replaced the plugin shop with .fwspacm packages. main added the headless update
check run at login. Both sides are kept, the feature moved onto the new layout:
- core/startup-check.{h,cpp} and its test, wired into the CMake targets the
release renamed (core/startup-check.cpp, startup-check-test);
- app/main.cpp carries the --check-updates branch, ahead of the command line so
the login unit never opens a window;
- the settings menu keeps the "check at startup" toggle, now through tr(), and
translations/en.json gains the new strings;
- doc/mise-a-jour.md keeps the release's version and gains the startup-check
section; the documented test count follows the new target.
118 lines
4.7 KiB
C++
118 lines
4.7 KiB
C++
#include <QApplication>
|
|
#include <QCoreApplication>
|
|
#include <QLoggingCategory>
|
|
#include <QStringList>
|
|
#include <QTimer>
|
|
|
|
#include "app-settings.h"
|
|
#include "cli-application.h"
|
|
#include "cli-command.h"
|
|
#include "language-manager.h"
|
|
#include "log-manager.h"
|
|
#include "main-window.h"
|
|
#include "startup-check.h"
|
|
#include "update-manager.h"
|
|
|
|
namespace {
|
|
|
|
// The arguments as the command-line grammar wants them: program name excluded.
|
|
QStringList commandLineArguments(int argc, char* argv[]) {
|
|
QStringList arguments;
|
|
if (argc > 1) arguments.reserve(argc - 1);
|
|
for (int i = 1; i < argc; ++i) {
|
|
arguments << QString::fromLocal8Bit(argv[i]);
|
|
}
|
|
return arguments;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char* argv[]) {
|
|
const QStringList arguments = commandLineArguments(argc, argv);
|
|
|
|
// The login check runs headless, from the systemd user unit the app installs
|
|
// itself (Paramètres → « Vérifier les mises à jour au démarrage »). It is
|
|
// detected before any QApplication: that unit has no display, and building a
|
|
// GUI application there would abort on the platform plugin. It also comes
|
|
// before the command line, which would otherwise read the option as an
|
|
// unknown command.
|
|
if (arguments.contains(QStringLiteral("--check-updates"))) {
|
|
QCoreApplication app(argc, argv);
|
|
app.setApplicationName("PacManager");
|
|
app.setApplicationVersion(UpdateManager::currentVersion());
|
|
app.setOrganizationName("Freebuff");
|
|
QLoggingCategory::setFilterRules(QStringLiteral("pacmgr.*=true"));
|
|
LogManager::installQtMessageHandler();
|
|
return StartupCheck().run();
|
|
}
|
|
|
|
// The command line is decided before any widget exists: `pacmanager install
|
|
// vlc` has to work on a machine with no display, so it runs on a
|
|
// QCoreApplication and never builds the window.
|
|
if (cli::isCliInvocation(arguments)) {
|
|
QCoreApplication app(argc, argv);
|
|
app.setApplicationName("PacManager");
|
|
app.setApplicationVersion(UpdateManager::currentVersion());
|
|
app.setOrganizationName("Freebuff");
|
|
|
|
LogManager::installQtMessageHandler();
|
|
LogManager::instance().logEvent(
|
|
QStringLiteral("app"),
|
|
QCoreApplication::translate("main", "session démarrée (v%1)")
|
|
.arg(UpdateManager::currentVersion()));
|
|
|
|
const int code = cli::run(arguments);
|
|
|
|
LogManager::instance().logEvent(
|
|
QStringLiteral("app"),
|
|
QCoreApplication::translate("main", "session terminée (code %1)").arg(code));
|
|
return code;
|
|
}
|
|
|
|
QApplication app(argc, argv);
|
|
app.setApplicationName("PacManager");
|
|
app.setApplicationVersion(UpdateManager::currentVersion());
|
|
app.setOrganizationName("Freebuff");
|
|
// Before any widget exists: the palette is what the platform draws the
|
|
// parts the stylesheet cannot reach, such as the margin around a menu.
|
|
app.setPalette(MainWindow::appPalette());
|
|
|
|
// Every log category the app uses is enabled (qCDebug included) and funnelled
|
|
// into the journal, so the Logs screen shows the same detail as a debug run
|
|
// without the user having to set QT_LOGGING_RULES.
|
|
QLoggingCategory::setFilterRules(QStringLiteral("pacmgr.*=true"));
|
|
// The chosen catalogue goes in before anything is built, widget or journal
|
|
// line: the whole session, interface included, is then in one language
|
|
// rather than starting in French and switching halfway.
|
|
LanguageManager::apply(AppSettings::instance().language());
|
|
|
|
// The journal opens where the user asked it to, not where the previous
|
|
// release wrote it: AppSettings is read before the first line is written.
|
|
LogManager::installQtMessageHandler();
|
|
LogManager::instance().logEvent(
|
|
QStringLiteral("app"),
|
|
QCoreApplication::translate("main", "session démarrée (v%1)")
|
|
.arg(UpdateManager::currentVersion()));
|
|
|
|
MainWindow window;
|
|
window.setWindowTitle(QCoreApplication::translate("main", "PacManager - Gestionnaire de Paquets"));
|
|
window.resize(1200, 760);
|
|
window.setMinimumSize(960, 600);
|
|
window.show();
|
|
|
|
// Files the desktop handed over ("Ouvrir avec PacManager", the desktop
|
|
// entry declares %U): installed once the event loop runs, so the window is
|
|
// visible and any dialog has a parent.
|
|
if (!arguments.isEmpty()) {
|
|
QTimer::singleShot(0, &window, [&window, arguments] {
|
|
window.installLocalFiles(arguments);
|
|
});
|
|
}
|
|
|
|
const int code = app.exec();
|
|
|
|
LogManager::instance().logEvent(QStringLiteral("app"),
|
|
QCoreApplication::translate("main", "session terminée (code %1)").arg(code));
|
|
return code;
|
|
}
|