main.cpp
pv/application.cpp
pv/devicemanager.cpp
+ pv/globalsettings.cpp
pv/mainwindow.cpp
pv/session.cpp
pv/storesession.cpp
pv/dialogs/about.cpp
pv/dialogs/connect.cpp
pv/dialogs/inputoutputoptions.cpp
+ pv/dialogs/settings.cpp
pv/dialogs/storeprogress.cpp
pv/popups/deviceoptions.cpp
pv/popups/channels.cpp
# This list includes only QObject derived class headers.
set(pulseview_HEADERS
+ pv/globalsettings.hpp
pv/mainwindow.hpp
pv/session.hpp
pv/storesession.hpp
pv/dialogs/about.hpp
pv/dialogs/connect.hpp
pv/dialogs/inputoutputoptions.hpp
+ pv/dialogs/settings.hpp
pv/dialogs/storeprogress.hpp
pv/popups/channels.hpp
pv/popups/deviceoptions.hpp
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "settings.hpp"
+#include "pv/globalsettings.hpp"
+
+#include <QCheckBox>
+#include <QDialogButtonBox>
+#include <QFormLayout>
+#include <QGroupBox>
+#include <QTabWidget>
+#include <QVBoxLayout>
+
+namespace pv {
+namespace dialogs {
+
+Settings::Settings(QWidget *parent) :
+ QDialog(parent, 0)
+{
+ QTabWidget *tab_stack = new QTabWidget(this);
+ tab_stack->addTab(get_view_settings_form(tab_stack), tr("&Views"));
+
+ QDialogButtonBox *button_box = new QDialogButtonBox(
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+
+ QVBoxLayout* root_layout = new QVBoxLayout(this);
+ root_layout->addWidget(tab_stack);
+ root_layout->addWidget(button_box);
+
+ connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(button_box, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+QWidget *Settings::get_view_settings_form(QWidget *parent) const
+{
+ GlobalSettings settings;
+
+ QWidget *form = new QWidget(parent);
+ QVBoxLayout *form_layout = new QVBoxLayout(form);
+
+ // Trace view settings
+ QGroupBox *trace_view_group = new QGroupBox(tr("Trace View"));
+ form_layout->addWidget(trace_view_group);
+
+ QFormLayout *trace_view_layout = new QFormLayout();
+ trace_view_group->setLayout(trace_view_layout);
+
+ 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);
+
+ 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);
+
+ return form;
+}
+
+void Settings::accept()
+{
+ QDialog::accept();
+}
+
+void Settings::reject()
+{
+ QDialog::reject();
+}
+
+void Settings::on_view_alwaysZoomToFit_changed(int state)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_AlwaysZoomToFit, state ? true : false);
+}
+
+void Settings::on_view_colouredBG_changed(int state)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_ColouredBG, state ? true : false);
+}
+
+} // namespace dialogs
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_PV_SETTINGS_HPP
+#define PULSEVIEW_PV_SETTINGS_HPP
+
+#include <QDialog>
+
+namespace pv {
+namespace dialogs {
+
+class Settings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ Settings(QWidget *parent = 0);
+
+ QWidget *get_view_settings_form(QWidget *parent) const;
+
+ void accept();
+ void reject();
+
+private Q_SLOTS:
+ void on_view_alwaysZoomToFit_changed(int state);
+ void on_view_colouredBG_changed(int state);
+};
+
+} // namespace dialogs
+} // namespace pv
+
+#endif // PULSEVIEW_PV_SETTINGS_HPP
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "globalsettings.hpp"
+
+namespace pv {
+
+const QString GlobalSettings::Key_View_AlwaysZoomToFit = "View_AlwaysZoomToFit";
+const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG";
+
+std::multimap< QString, std::function<void(QVariant)> > GlobalSettings::callbacks_;
+
+GlobalSettings::GlobalSettings() :
+ QSettings()
+{
+ beginGroup("Settings");
+}
+
+void GlobalSettings::register_change_handler(const QString key,
+ std::function<void(QVariant)> cb)
+{
+ callbacks_.emplace(key, cb);
+}
+
+void GlobalSettings::setValue(const QString &key, const QVariant &value)
+{
+ QSettings::setValue(key, value);
+
+ // Call all registered callbacks for this key
+ auto range = callbacks_.equal_range(key);
+
+ for (auto it = range.first; it != range.second; it++)
+ it->second(value);
+}
+
+
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_GLOBALSETTINGS_HPP
+#define PULSEVIEW_GLOBALSETTINGS_HPP
+
+#include <functional>
+#include <map>
+
+#include <QSettings>
+#include <QString>
+#include <QVariant>
+
+namespace pv {
+
+class GlobalSettings : public QSettings
+{
+ Q_OBJECT
+
+public:
+ static const QString Key_View_AlwaysZoomToFit;
+ static const QString Key_View_ColouredBG;
+
+public:
+ GlobalSettings();
+
+ static void register_change_handler(const QString key,
+ std::function<void(QVariant)> cb);
+
+ void setValue(const QString& key, const QVariant& value);
+
+private:
+ static std::multimap< QString, std::function<void(QVariant)> > callbacks_;
+};
+
+} // namespace pv
+
+#endif // PULSEVIEW_GLOBALSETTINGS_HPP
#include "mainwindow.hpp"
#include "devicemanager.hpp"
+#include "globalsettings.hpp"
#include "util.hpp"
#include "devices/hardwaredevice.hpp"
#include "dialogs/about.hpp"
+#include "dialogs/settings.hpp"
#include "toolbars/mainbar.hpp"
#include "view/view.hpp"
#include "views/trace/standardbar.hpp"
using toolbars::MainBar;
+using std::bind;
+using std::placeholders::_1;
+
const QString MainWindow::WindowTitle = tr("PulseView");
MainWindow::MainWindow(DeviceManager &device_manager,
this, SLOT(on_run_stop_clicked()));
connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
this, SLOT(on_capture_state_changed(QObject*)));
+ connect(settings_button_, SIGNAL(clicked(bool)),
+ this, SLOT(on_settings_clicked()));
connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
this, SLOT(on_tab_close_requested(int)));
}
}
+void MainWindow::on_settings_clicked()
+{
+ dialogs::Settings dlg;
+ dlg.exec();
+}
+
void MainWindow::on_session_name_changed()
{
// Update the corresponding dock widget's name(s)
void on_new_session_clicked();
void on_run_stop_clicked();
+ void on_settings_clicked();
void on_session_name_changed();
void on_capture_state_changed(QObject *obj);
set(pulseview_TEST_SOURCES
${PROJECT_SOURCE_DIR}/pv/devicemanager.cpp
+ ${PROJECT_SOURCE_DIR}/pv/globalsettings.cpp
${PROJECT_SOURCE_DIR}/pv/session.cpp
${PROJECT_SOURCE_DIR}/pv/storesession.cpp
${PROJECT_SOURCE_DIR}/pv/util.cpp
# This list includes only QObject derived class headers.
set(pulseview_TEST_HEADERS
+ ${PROJECT_SOURCE_DIR}/pv/globalsettings.hpp
${PROJECT_SOURCE_DIR}/pv/session.hpp
${PROJECT_SOURCE_DIR}/pv/storesession.hpp
${PROJECT_SOURCE_DIR}/pv/binding/device.hpp