* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "settings.hpp"
-#include "pv/globalsettings.hpp"
-
+#include <QApplication>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
+#include <QLabel>
+#include <QString>
+#include <QTextBrowser>
+#include <QTextDocument>
#include <QVBoxLayout>
+#include "settings.hpp"
+
+#include "pv/devicemanager.hpp"
+#include "pv/globalsettings.hpp"
+
+#include <libsigrokcxx/libsigrokcxx.hpp>
+
+#ifdef ENABLE_DECODE
+#include <libsigrokdecode/libsigrokdecode.h>
+#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)
{
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->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);
pages->addWidget(get_view_settings_form(pages));
QListWidgetItem *viewButton = new QListWidgetItem(page_list);
- viewButton->setIcon(QIcon(":/icons/sigrok-logo-notext.svg"));
+ 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
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<br />%3<br /><a href=\"http://%4\">%4</a>")
+ .arg(QApplication::applicationName(),
+ QApplication::applicationVersion(),
+ tr("GNU GPL, version 3 or later"),
+ QApplication::organizationDomain()));
+ version_info->setOpenExternalLinks(true);
+
+ shared_ptr<sigrok::Context> context = device_manager_.context();
+
+ QString s;
+ s.append("<table>");
+
+ /* Library info */
+ s.append("<tr><td colspan=\"2\"><b>" +
+ tr("Used libraries:") + "</b></td></tr>");
+ s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+ .arg(QString("Qt"), qVersion()));
+
+ /* Set up the supported field */
+ s.append("<tr><td colspan=\"2\"><b>" +
+ tr("Supported hardware drivers:") + "</b></td></tr>");
+ for (auto entry : context->drivers()) {
+ s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+ .arg(QString::fromUtf8(entry.first.c_str()),
+ QString::fromUtf8(entry.second->long_name().c_str())));
+ }
+
+ s.append("<tr><td colspan=\"2\"><b>" +
+ tr("Supported input formats:") + "</b></td></tr>");
+ for (auto entry : context->input_formats()) {
+ s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+ .arg(QString::fromUtf8(entry.first.c_str()),
+ QString::fromUtf8(entry.second->description().c_str())));
+ }
+
+ s.append("<tr><td colspan=\"2\"><b>" +
+ tr("Supported output formats:") + "</b></td></tr>");
+ for (auto entry : context->output_formats()) {
+ s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+ .arg(QString::fromUtf8(entry.first.c_str()),
+ QString::fromUtf8(entry.second->description().c_str())));
+ }
+
+#ifdef ENABLE_DECODE
+ s.append("<tr><td colspan=\"2\"><b>" +
+ tr("Supported protocol decoders:") + "</b></td></tr>");
+ for (const GSList *l = srd_decoder_list(); l; l = l->next) {
+ dec = (struct srd_decoder *)l->data;
+ s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+ .arg(QString::fromUtf8(dec->id),
+ QString::fromUtf8(dec->longname)));
+ }
+#endif
+
+ s.append("</table>");
+
+ 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;
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