PulseView  0.3.0
A Qt-based sigrok GUI
about.cpp
Go to the documentation of this file.
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.hpp"
28 #include <ui_about.h>
29 
30 #include <libsigrokcxx/libsigrokcxx.hpp>
31 
32 using std::shared_ptr;
33 using sigrok::Context;
34 
35 namespace pv {
36 namespace dialogs {
37 
38 About::About(shared_ptr<Context> context, QWidget *parent) :
39  QDialog(parent),
40  ui(new Ui::About)
41 {
42 #ifdef ENABLE_DECODE
43  struct srd_decoder *dec;
44 #endif
45 
46  QString s;
47 
48  ui->setupUi(this);
49 
50  /* Setup the version field */
51  ui->versionInfo->setText(tr("%1 %2<br />%3<br /><a href=\"%4\">%4</a>")
52  .arg(QApplication::applicationName())
53  .arg(QApplication::applicationVersion())
54  .arg(tr("GNU GPL, version 3 or later"))
55  .arg(QApplication::organizationDomain()));
56  ui->versionInfo->setOpenExternalLinks(true);
57 
58  s.append("<table>");
59 
60  /* Set up the supported field */
61  s.append("<tr><td colspan=\"2\"><b>" +
62  tr("Supported hardware drivers:") +
63  "</b></td></tr>");
64  for (auto entry : context->drivers()) {
65  s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
66  .arg(QString::fromUtf8(entry.first.c_str()))
67  .arg(QString::fromUtf8(entry.second->long_name().c_str())));
68  }
69 
70  s.append("<tr><td colspan=\"2\"><b>" +
71  tr("Supported input formats:") +
72  "</b></td></tr>");
73  for (auto entry : context->input_formats()) {
74  s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
75  .arg(QString::fromUtf8(entry.first.c_str()))
76  .arg(QString::fromUtf8(entry.second->description().c_str())));
77  }
78 
79  s.append("<tr><td colspan=\"2\"><b>" +
80  tr("Supported output formats:") +
81  "</b></td></tr>");
82  for (auto entry : context->output_formats()) {
83  s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
84  .arg(QString::fromUtf8(entry.first.c_str()))
85  .arg(QString::fromUtf8(entry.second->description().c_str())));
86  }
87 
88 #ifdef ENABLE_DECODE
89  s.append("<tr><td colspan=\"2\"><b>" +
90  tr("Supported protocol decoders:") +
91  "</b></td></tr>");
92  for (const GSList *l = srd_decoder_list(); l; l = l->next) {
93  dec = (struct srd_decoder *)l->data;
94  s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
95  .arg(QString::fromUtf8(dec->id))
96  .arg(QString::fromUtf8(dec->longname)));
97  }
98 #endif
99 
100  s.append("</table>");
101 
102  supportedDoc = new QTextDocument(this);
103  supportedDoc->setHtml(s);
104  ui->supportList->setDocument(supportedDoc);
105 }
106 
108 {
109  delete ui;
110 }
111 
112 } // namespace dialogs
113 } // namespace pv
void setupUi(QDialog *About)
Definition: ui_about.h:36
QLabel * versionInfo
Definition: ui_about.h:32
Definition: about.hpp:34
QTextBrowser * supportList
Definition: ui_about.h:33
Ui::About * ui
Definition: about.hpp:50
QTextDocument * supportedDoc
Definition: about.hpp:51
About(std::shared_ptr< sigrok::Context > context, QWidget *parent=0)
Definition: about.cpp:38