MCPcopy Create free account
hub / github.com/QNapi/qnapi / main

Function main

gui/src/main.cpp:32–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30void sigHandler(int);
31
32int main(int argc, char **argv) {
33 LibQNapi::init(argv[0]);
34
35 const QNapiConfig config = LibQNapi::loadConfig();
36
37 QString uiLanguage = LibQNapi::uiLanguage(config.generalConfig());
38
39 bool isCliCall = QNapiCli::isCliCall(argc, argv);
40
41 QStringList parsedFilePaths = parseArgs(argc, argv);
42
43 regSignal();
44
45 bool quietBatch = config.generalConfig().quietBatch();
46#ifdef Q_OS_MAC
47 quietBatch = false;
48#endif
49
50 bool useGui = !isCliCall && !(quietBatch && !parsedFilePaths.isEmpty());
51
52 if (useGui) {
53 QNapiApp app(argc, argv, true, "QNapi");
54
55 QString resourceDir =
56 QLibraryInfo::location(QLibraryInfo::TranslationsPath);
57
58 QTranslator qtTranslator, qnapiTranslator;
59 qtTranslator.load("qt_" + uiLanguage, resourceDir);
60 app.installTranslator(&qtTranslator);
61
62 qnapiTranslator.load("qnapi_" + uiLanguage, ":/translations");
63 app.installTranslator(&qnapiTranslator);
64
65 app.setQuitOnLastWindowClosed(false);
66
67 if (app.arguments().contains("-o") ||
68 app.arguments().contains("--options")) {
69 app.setQuitOnLastWindowClosed(true);
70 app.showSettings();
71 return 0;
72 }
73
74 if (!app.isInstanceAllowed()) {
75 for (int i = 0; i < parsedFilePaths.size(); i++) {
76 QString &fileName = parsedFilePaths[i];
77 QFileInfo fi(fileName);
78 app.sendRequest(fi.absoluteFilePath());
79 }
80 return 0;
81 }
82
83 if (config.firstrun()) {
84 if (QMessageBox::question(0, QObject::tr("First Run"),
85 QObject::tr("This is the first launch of the "
86 "program QNapi. Do you want to "
87 "configure it now?"),
88 QMessageBox::Yes | QMessageBox::No) ==
89 QMessageBox::Yes) {

Callers

nothing calls this directly

Calls 15

parseArgsFunction · 0.85
regSignalFunction · 0.85
SubtitleLanguageClass · 0.85
generalConfigMethod · 0.80
quietBatchMethod · 0.80
showSettingsMethod · 0.80
isInstanceAllowedMethod · 0.80
sendRequestMethod · 0.80
firstrunMethod · 0.80
setBatchModeMethod · 0.80
progressMethod · 0.80
toTwoLetterMethod · 0.80

Tested by

no test coverage detected