X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdialogs%2Fsettings.cpp;h=b8f9bf9fa5910ec906f4b4a84e1487a5cb3374a0;hp=eb9e88b6755ddc2813d08d66f3fd208be7f6cd21;hb=c063290ac7189bdd15221450f598504f43286b43;hpb=13e475e412663ee904b94a6510b5628bdb8b84fa diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index eb9e88b6..b8f9bf9f 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -17,40 +17,95 @@ * 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 +#include "settings.hpp" + +#include "pv/devicemanager.hpp" +#include "pv/globalsettings.hpp" + +#include + +#ifdef ENABLE_DECODE +#include +#endif + +using std::shared_ptr; + 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) { - QTabWidget *tab_stack = new QTabWidget(this); - tab_stack->addTab(get_view_settings_form(tab_stack), tr("&Views")); + 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)); + page_list->setMovement(QListView::Static); + page_list->setMaximumWidth(icon_size + (icon_size / 2)); + page_list->setSpacing(12); + + pages = new QStackedWidget; + create_pages(); + page_list->setCurrentIndex(page_list->model()->index(0, 0)); + + QHBoxLayout *tab_layout = new QHBoxLayout; + tab_layout->addWidget(page_list); + tab_layout->addWidget(pages, Qt::AlignLeft); QDialogButtonBox *button_box = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); QVBoxLayout* root_layout = new QVBoxLayout(this); - root_layout->addWidget(tab_stack); + root_layout->addLayout(tab_layout); root_layout->addWidget(button_box); connect(button_box, SIGNAL(accepted()), this, SLOT(accept())); connect(button_box, SIGNAL(rejected()), this, SLOT(reject())); + connect(page_list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(on_page_changed(QListWidgetItem*, QListWidgetItem*))); // Start to record changes GlobalSettings settings; settings.start_tracking(); } +void Settings::create_pages() +{ + // View page + pages->addWidget(get_view_settings_form(pages)); + + QListWidgetItem *viewButton = new QListWidgetItem(page_list); + viewButton->setIcon(QIcon(":/icons/settings-views.svg")); + 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 { GlobalSettings settings; @@ -68,16 +123,110 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const QCheckBox *coloured_bg_cb = new QCheckBox(); coloured_bg_cb->setChecked(settings.value(GlobalSettings::Key_View_ColouredBG).toBool()); connect(coloured_bg_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_colouredBG_changed(int))); - trace_view_layout->addRow(tr("Use &coloured trace background"), coloured_bg_cb); + trace_view_layout->addRow(tr("Use coloured trace &background"), coloured_bg_cb); QCheckBox *always_zoom_to_fit_cb = new QCheckBox(); always_zoom_to_fit_cb->setChecked(settings.value(GlobalSettings::Key_View_AlwaysZoomToFit).toBool()); connect(always_zoom_to_fit_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_alwaysZoomToFit_changed(int))); - trace_view_layout->addRow(tr("Always zoom-to-&fit during capture"), always_zoom_to_fit_cb); + trace_view_layout->addRow(tr("Constantly perform &zoom-to-fit during capture"), always_zoom_to_fit_cb); + + QCheckBox *sticky_scrolling_cb = new QCheckBox(); + sticky_scrolling_cb->setChecked(settings.value(GlobalSettings::Key_View_StickyScrolling).toBool()); + connect(sticky_scrolling_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_stickyScrolling_changed(int))); + trace_view_layout->addRow(tr("Always keep &newest samples at the right edge during capture"), sticky_scrolling_cb); + + QCheckBox *show_sampling_points_cb = new QCheckBox(); + show_sampling_points_cb->setChecked(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool()); + connect(show_sampling_points_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showSamplingPoints_changed(int))); + trace_view_layout->addRow(tr("Show data &sampling points"), show_sampling_points_cb); 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); + + shared_ptr context = device_manager_.context(); + + QString s; + s.append(""); + + /* Library info */ + s.append(""); + s.append(QString("") + .arg(QString("Qt"), qVersion())); + + /* 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("Used libraries:") + "
%1%2
" + + 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; @@ -94,6 +243,14 @@ void Settings::reject() QDialog::reject(); } +void Settings::on_page_changed(QListWidgetItem *current, QListWidgetItem *previous) +{ + if (!current) + current = previous; + + pages->setCurrentIndex(page_list->row(current)); +} + void Settings::on_view_alwaysZoomToFit_changed(int state) { GlobalSettings settings; @@ -106,5 +263,17 @@ void Settings::on_view_colouredBG_changed(int state) settings.setValue(GlobalSettings::Key_View_ColouredBG, state ? true : false); } +void Settings::on_view_stickyScrolling_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_StickyScrolling, state ? true : false); +} + +void Settings::on_view_showSamplingPoints_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, state ? true : false); +} + } // namespace dialogs } // namespace pv