]> sigrok.org Git - pulseview.git/blob - pv/dialogs/about.cpp
c4827962c59afda9891b62a99cd2268ae8c44234
[pulseview.git] / pv / dialogs / about.cpp
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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 #ifdef ENABLE_DECODE
22 #include <libsigrokdecode/libsigrokdecode.h>
23 #endif
24
25 #include <QTextDocument>
26
27 #include "about.h"
28 #include <ui_about.h>
29
30 /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
31 #define __STDC_FORMAT_MACROS
32 #include <glib.h>
33 #include <libsigrok/libsigrok.h>
34
35
36 namespace pv {
37 namespace dialogs {
38
39 About::About(QWidget *parent) :
40         QDialog(parent),
41         ui(new Ui::About)
42 {
43         struct sr_dev_driver **drivers;
44         struct sr_input_format **inputs;
45
46 #ifdef ENABLE_DECODE
47         struct srd_decoder *dec;
48 #endif
49
50         QString s;
51
52         ui->setupUi(this);
53
54         /* Setup the version field */
55         ui->versionInfo->setText(tr("%1 %2<br />%3<br /><a href=\"%4\">%4</a>")
56                                  .arg(QApplication::applicationName())
57                                  .arg(QApplication::applicationVersion())
58                                  .arg(tr("GNU GPL, version 3 or later"))
59                                  .arg(QApplication::organizationDomain()));
60         ui->versionInfo->setOpenExternalLinks(true);
61
62         s.append("<table>");
63
64         /* Set up the supported field */
65         s.append("<tr><td colspan=\"2\"><b>" +
66                 tr("Supported hardware drivers:") +
67                 "</b></td></tr>");
68         drivers = sr_driver_list();
69         for (int i = 0; drivers[i]; ++i) {
70                 s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
71                          .arg(QString::fromUtf8(drivers[i]->name))
72                          .arg(QString::fromUtf8(drivers[i]->longname)));
73         }
74
75         s.append("<tr><td colspan=\"2\"><b>" +
76                 tr("Supported input formats:") +
77                 "</b></td></tr>");
78         inputs = sr_input_list();
79         for (int i = 0; inputs[i]; ++i) {
80                 s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
81                          .arg(QString::fromUtf8(inputs[i]->id))
82                          .arg(QString::fromUtf8(inputs[i]->description)));
83         }
84
85 #ifdef ENABLE_DECODE
86         s.append("<tr><td colspan=\"2\"><b>" +
87                 tr("Supported protocol decoders:") +
88                 "</b></td></tr>");
89         for (const GSList *l = srd_decoder_list(); l; l = l->next) {
90                 dec = (struct srd_decoder *)l->data;
91                 s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
92                          .arg(QString::fromUtf8(dec->id))
93                          .arg(QString::fromUtf8(dec->longname)));
94         }
95 #endif
96
97         s.append("</table>");
98
99         supportedDoc.reset(new QTextDocument(this));
100         supportedDoc->setHtml(s);
101         ui->supportList->setDocument(supportedDoc.get());
102 }
103
104 About::~About()
105 {
106         delete ui;
107 }
108
109 } // namespace dialogs
110 } // namespace pv