X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdialogs%2Fsettings.cpp;h=deeb71f1b87b9296705e1358721df434e8fb6d27;hp=c29d80b68f9ddc7d434041e4ef915f92f14c8470;hb=4e4d72b22a81d1f2d8daee1093ac45264a0a1e2d;hpb=b14db788ee3483eed195c1e73a1ab85ea8c41e47 diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index c29d80b6..deeb71f1 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -17,24 +17,40 @@ * along with this program; if not, see . */ -#include "settings.hpp" -#include "pv/globalsettings.hpp" - +#include #include #include #include #include #include +#include +#include +#include +#include #include +#include "settings.hpp" + +#include "pv/devicemanager.hpp" +#include "pv/globalsettings.hpp" + +#include + +#ifdef ENABLE_DECODE +#include +#endif + namespace pv { namespace dialogs { -Settings::Settings(QWidget *parent) : - QDialog(parent, nullptr) +Settings::Settings(DeviceManager &device_manager, QWidget *parent) : + QDialog(parent, nullptr), + device_manager_(device_manager) { const int icon_size = 64; + resize(600, 400); + page_list = new QListWidget; page_list->setViewMode(QListView::IconMode); page_list->setIconSize(QSize(icon_size, icon_size)); @@ -76,6 +92,15 @@ void Settings::create_pages() viewButton->setText(tr("Views")); viewButton->setTextAlignment(Qt::AlignHCenter); viewButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + // About page + pages->addWidget(get_about_page(pages)); + + QListWidgetItem *aboutButton = new QListWidgetItem(page_list); + aboutButton->setIcon(QIcon(":/icons/information.svg")); + aboutButton->setText(tr("About")); + aboutButton->setTextAlignment(Qt::AlignHCenter); + aboutButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } QWidget *Settings::get_view_settings_form(QWidget *parent) const @@ -105,6 +130,88 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const return form; } +QWidget *Settings::get_about_page(QWidget *parent) const +{ +#ifdef ENABLE_DECODE + struct srd_decoder *dec; +#endif + + QLabel *icon = new QLabel(); + icon->setPixmap(QPixmap(QString::fromUtf8(":/icons/sigrok-logo-notext.svg"))); + + /* Setup the version field */ + QLabel *version_info = new QLabel(); + version_info->setText(tr("%1 %2
%3
%4") + .arg(QApplication::applicationName(), + QApplication::applicationVersion(), + tr("GNU GPL, version 3 or later"), + QApplication::organizationDomain())); + version_info->setOpenExternalLinks(true); + + std::shared_ptr context = device_manager_.context(); + + QString s; + s.append(""); + + /* Set up the supported field */ + s.append(""); + for (auto entry : context->drivers()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->long_name().c_str()))); + } + + s.append(""); + for (auto entry : context->input_formats()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); + } + + s.append(""); + for (auto entry : context->output_formats()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); + } + +#ifdef ENABLE_DECODE + s.append(""); + for (const GSList *l = srd_decoder_list(); l; l = l->next) { + dec = (struct srd_decoder *)l->data; + s.append(QString("") + .arg(QString::fromUtf8(dec->id), + QString::fromUtf8(dec->longname))); + } +#endif + + s.append("
" + + tr("Supported hardware drivers:") + + "
%1%2
" + + tr("Supported input formats:") + + "
%1%2
" + + tr("Supported output formats:") + + "
%1%2
" + + tr("Supported protocol decoders:") + + "
%1%2
"); + + QTextDocument *supported_doc = new QTextDocument(); + supported_doc->setHtml(s); + + QTextBrowser *support_list = new QTextBrowser(); + support_list->setDocument(supported_doc); + + QGridLayout *layout = new QGridLayout(); + layout->addWidget(icon, 0, 0, 1, 1); + layout->addWidget(version_info, 0, 1, 1, 1); + layout->addWidget(support_list, 1, 1, 1, 1); + + QWidget *page = new QWidget(parent); + page->setLayout(layout); + + return page; +} + void Settings::accept() { GlobalSettings settings;