"Fossies" - the Fresh Open Source Software Archive 
Member "cb2bib-2.0.1/src/main.cpp" (12 Feb 2021, 3577 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "main.cpp" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
2.0.0_vs_2.0.1.
1 /***************************************************************************
2 * Copyright (C) 2004-2021 by Pere Constans
3 * constans@molspaces.com
4 * cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
5 * See the LICENSE file that comes with this distribution.
6 ***************************************************************************/
7 #include "qtsingleapplication/src/qtsingleapplication.h"
8 #include "qtsingleapplication/src/qtsinglecoreapplication.h"
9
10 #include "c2bConfigure.h"
11 #include "c2bConsole.h"
12 #include "c2bSettings.h"
13 #include "cb2Bib.h"
14
15 #ifdef C2B_USE_QWEB
16 #include "c2bAnnote.h"
17 #endif
18
19
20 int main(int argc, char* argv[])
21 {
22 Q_INIT_RESOURCE(cb2bib);
23 Q_INIT_RESOURCE(c2blib);
24
25 c2bSettings* c2b_settings; // Delete before app, this avoids QVariant::save: unable to save type 67/64
26 int code(0);
27
28 if (c2bSettings::isConsoleMode(argc, argv))
29 {
30 // Cannot use QCoreApplication, QTextDocument is required by c2bUtils::fromHtmlString
31 // Needs also workaround c2bSettings::decodeFilename()
32 QApplication app(argc, argv);
33 app.setOrganizationName(C2B_ORGANIZATION);
34 app.setApplicationName(C2B_APPLICATION);
35 c2b_settings = c2bSettings::initSettings();
36 if (c2b_settings->loaded())
37 {
38 c2bConsole c2B;
39 c2B.load();
40 code = app.exec();
41 }
42 delete c2b_settings;
43 }
44 else if (c2bSettings::isSingleApplicationMode(argc, argv))
45 {
46 // Avoid connecting to the graphic server. On Windows it would create a void window.
47 {
48 QtSingleCoreApplication* capp = new QtSingleCoreApplication(argc, argv);
49 const bool is_running = capp->sendMessage(QString());
50 delete capp;
51 if (is_running)
52 return code;
53 }
54 QtSingleApplication app(argc, argv);
55 if (app.isRunning()) // Activate local peer
56 return code;
57 app.setQuitOnLastWindowClosed(false);
58 app.setOrganizationName(C2B_ORGANIZATION);
59 app.setApplicationName(C2B_APPLICATION);
60 app.setWindowIcon(QIcon(":/icons/icons/cb2bib.ico"));
61 c2b_settings = c2bSettings::initSettings();
62 if (c2b_settings->loaded())
63 {
64 cb2Bib c2B;
65 c2B.show();
66 QObject::connect(&app, SIGNAL(messageReceived(QString)), &c2B, SLOT(show()));
67 code = app.exec();
68 }
69 delete c2b_settings;
70 }
71 else
72 {
73 QApplication app(argc, argv);
74 app.setOrganizationName(C2B_ORGANIZATION);
75 app.setApplicationName(C2B_APPLICATION);
76 app.setWindowIcon(QIcon(":/icons/icons/cb2bib.ico"));
77 c2b_settings = c2bSettings::initSettings();
78 if (c2b_settings->loaded())
79 {
80 if (c2b_settings->cl_cb2bib_import_mode)
81 code = app.exec();
82 else if (c2b_settings->cl_configure)
83 {
84 c2bConfigure c2B;
85 c2B.show();
86 code = app.exec();
87 }
88 else if (c2b_settings->cl_view_annote)
89 {
90 #ifdef C2B_USE_QWEB
91 c2bAnnote c2B;
92 if (c2B.show())
93 code = app.exec();
94 #else
95 fprintf(stdout, "cb2Bib Annote is disabled. Recompile using QtWebKit or QtWebEngine library.\n");
96 #endif
97 }
98 else
99 {
100 cb2Bib c2B;
101 c2B.show();
102 code = app.exec();
103 }
104 }
105 delete c2b_settings;
106 }
107
108 return code;
109 }