#include <boost/bind.hpp>
#include <boost/foreach.hpp>
+#include <algorithm>
+#include <iterator>
+
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include "mainwindow.h"
#include "devicemanager.h"
+#include "device/device.h"
#include "dialogs/about.h"
#include "dialogs/connect.h"
#include "dialogs/storeprogress.h"
#include <glib.h>
#include <libsigrok/libsigrok.h>
+using boost::shared_ptr;
using std::list;
namespace pv {
"MainWindow", "Zoom &In", 0, QApplication::UnicodeUTF8));
action_view_zoom_in->setIcon(QIcon::fromTheme("zoom-in",
QIcon(":/icons/zoom-in.png")));
+ // simply using Qt::Key_Plus shows no + in the menu
+ action_view_zoom_in->setShortcut(QKeySequence::ZoomIn);
action_view_zoom_in->setObjectName(
QString::fromUtf8("actionViewZoomIn"));
menu_view->addAction(action_view_zoom_in);
"MainWindow", "Zoom &Out", 0, QApplication::UnicodeUTF8));
action_view_zoom_out->setIcon(QIcon::fromTheme("zoom-out",
QIcon(":/icons/zoom-out.png")));
+ action_view_zoom_out->setShortcut(QKeySequence::ZoomOut);
action_view_zoom_out->setObjectName(
QString::fromUtf8("actionViewZoomOut"));
menu_view->addAction(action_view_zoom_out);
Q_ARG(QString, info_text));
}
-void MainWindow::update_device_list(struct sr_dev_inst *selected_device)
+void MainWindow::update_device_list(
+ shared_ptr<pv::device::DevInst> selected_device)
{
assert(_sampling_bar);
- const list<sr_dev_inst*> &devices = _device_manager.devices();
+ list< shared_ptr<device::DevInst> > devices;
+ std::copy(_device_manager.devices().begin(),
+ _device_manager.devices().end(), std::back_inserter(devices));
+
_sampling_bar->set_device_list(devices);
if (!selected_device && !devices.empty()) {
selected_device = devices.front();
// Try and find the demo device and select that by default
- BOOST_FOREACH (struct sr_dev_inst *sdi, devices)
- if (strcmp(sdi->driver->name, "demo") == 0) {
- selected_device = sdi;
+ BOOST_FOREACH (shared_ptr<pv::device::DevInst> dev_inst, devices)
+ if (strcmp(dev_inst->dev_inst()->driver->name,
+ "demo") == 0) {
+ selected_device = dev_inst;
}
}
void MainWindow::on_actionOpen_triggered()
{
- // Enumerate the file formats
- QString filters(tr("Sigrok Sessions (*.sr)"));
- filters.append(tr(";;All Files (*.*)"));
-
// Show the dialog
const QString file_name = QFileDialog::getOpenFileName(
- this, tr("Open File"), "", filters);
+ this, tr("Open File"), "", tr(
+ "Sigrok Sessions (*.sr);;"
+ "All Files (*.*)"));
if (!file_name.isEmpty())
load_file(file_name);
}
// If the user selected a device, select it in the device list. Select the
// current device otherwise.
- struct sr_dev_inst *const sdi = dlg.exec() ?
+ shared_ptr<device::DevInst> dev_inst = dlg.exec() ?
dlg.get_selected_device() : _session.get_device();
- update_device_list(sdi);
+ update_device_list(dev_inst);
}
void MainWindow::on_actionQuit_triggered()
{
switch(_session.get_capture_state()) {
case SigSession::Stopped:
- _session.start_capture(_sampling_bar->get_record_length(),
- boost::bind(&MainWindow::session_error, this,
+ _session.start_capture(
+ boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
break;