]> sigrok.org Git - sigrok-qt.git/blob - main.cpp
.gitignore: Add missing entries.
[sigrok-qt.git] / main.cpp
1 /*
2  * This file is part of the sigrok project.
3  *
4  * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 extern "C" {
22 #include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
23 #include <stdint.h>
24 #include <libsigrok/libsigrok.h>
25 }
26
27 #include <iostream>
28 #include <QtGui/QApplication>
29 #include <QTranslator>
30 #include <QLocale>
31 #include <QDebug>
32 #include "mainwindow.h"
33
34 uint8_t *sample_buffer;
35 MainWindow *w;
36
37 int main(int argc, char *argv[])
38 {
39         QString locale = QLocale::system().name();
40         QApplication a(argc, argv);
41         QTranslator translator;
42
43         translator.load(QString("locale/sigrok-qt_") + locale);
44         a.installTranslator(&translator);
45
46         /* Set some application metadata. */
47         QApplication::setApplicationVersion(APP_VERSION);
48         QApplication::setApplicationName("sigrok-qt");
49         QApplication::setOrganizationDomain("http://www.sigrok.org");
50
51         /* Disable this to actually allow running the (pre-alpha!) Qt GUI. */
52         qDebug() << "The Qt GUI is not yet usable, aborting.";
53         // return 1;
54
55         if (sr_init() != SR_OK) {
56                 qDebug() << "ERROR: libsigrok init failed.";
57                 return 1;
58         }
59         qDebug() << "libsigrok initialized successfully.";
60
61         if (srd_init(NULL) != SRD_OK) {
62                 qDebug() << "ERROR: libsigrokdecode init failed.";
63                 return 1;
64         }
65         qDebug() << "libsigrokdecode initialized successfully.";
66
67         w = new MainWindow;
68         w->show();
69
70         /* The GUI wants to show a list of all PDs before use, so we
71          * might as well load them now.
72          */
73         srd_decoder_load_all();
74
75         return a.exec();
76 }