14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #include <QApplication> |
17 #include <QApplication> |
18 #include <QCommandLineParser> |
18 #include <QCommandLineParser> |
|
19 #include <QDebug> |
|
20 #include <QDate> |
|
21 #include <QMessageBox> |
|
22 |
19 //#include <QLocale> |
23 //#include <QLocale> |
20 //#include <QTranslator> |
24 //#include <QTranslator> |
21 |
25 |
|
26 #include "bmsapp.h" |
22 #include "config.h" |
27 #include "config.h" |
23 |
28 |
24 |
29 |
25 int main(int argc, char *argv[]) |
30 int main(int argc, char *argv[]) |
26 { |
31 { |
31 #else |
36 #else |
32 "bmsapp" |
37 "bmsapp" |
33 #endif |
38 #endif |
34 ); |
39 ); |
35 app.setApplicationVersion(VERSIONSTRING); |
40 app.setApplicationVersion(VERSIONSTRING); |
|
41 app.setOrganizationName("mbse"); |
36 |
42 |
37 return app.exec(); |
43 /* Setup user ini format */ |
|
44 QSettings::setDefaultFormat(QSettings::IniFormat); |
|
45 |
|
46 /* Setup commandline parser */ |
|
47 QCommandLineParser parser; |
|
48 parser.setApplicationDescription("Brewery Management System Application."); |
|
49 parser.addOptions({ |
|
50 // A boolean option with multiple names (-f, --force) |
|
51 {{"c", "config"}, |
|
52 QCoreApplication::translate("main", "Start the configuration editor.")}, |
|
53 {{"d", "develop"}, |
|
54 QCoreApplication::translate("main", "Use the development database.")}, |
|
55 }); |
|
56 parser.addHelpOption(); |
|
57 parser.addVersionOption(); |
|
58 parser.process(app); |
|
59 |
|
60 qDebug().noquote() << "Starting" << app.applicationName() << app.applicationVersion() << QDateTime::currentDateTime().toString(); |
|
61 |
|
62 try { |
|
63 auto mainAppReturnValue = Bmsapp::run(); |
|
64 qDebug().noquote() << "Finished" << app.applicationName() << app.applicationVersion() << QDateTime::currentDateTime().toString(); |
|
65 return mainAppReturnValue; |
|
66 } |
|
67 catch (const QString &error) { |
|
68 QMessageBox::critical(0, |
|
69 QApplication::tr("Application terminates"), |
|
70 QApplication::tr("The application encountered a fatal error.\nError message:\n%1").arg(error)); |
|
71 } |
|
72 return EXIT_FAILURE; |
38 } |
73 } |