]>
Commit | Line | Data |
---|---|---|
d7bed479 | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
d7bed479 JH |
3 | * |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
943edd76 MC |
21 | #include <cassert> |
22 | ||
269528f5 | 23 | #ifdef ENABLE_DECODE |
aaabd61b | 24 | #include <libsigrokdecode/libsigrokdecode.h> |
269528f5 | 25 | #endif |
30236a54 | 26 | |
85843b14 JH |
27 | #include <algorithm> |
28 | #include <iterator> | |
29 | ||
7d5425ef JH |
30 | #include <QAction> |
31 | #include <QApplication> | |
32 | #include <QButtonGroup> | |
93f683ad | 33 | #include <QCloseEvent> |
2953961c | 34 | #include <QFileDialog> |
f2edb557 | 35 | #include <QMessageBox> |
7d5425ef JH |
36 | #include <QMenu> |
37 | #include <QMenuBar> | |
643f65f9 | 38 | #include <QSettings> |
7d5425ef JH |
39 | #include <QStatusBar> |
40 | #include <QVBoxLayout> | |
41 | #include <QWidget> | |
2953961c | 42 | |
d7bed479 | 43 | #include "mainwindow.h" |
107ca6d3 JH |
44 | |
45 | #include "devicemanager.h" | |
85843b14 | 46 | #include "device/device.h" |
acda14b8 | 47 | #include "dialogs/about.h" |
9663c82b | 48 | #include "dialogs/connect.h" |
0fbda3c2 | 49 | #include "dialogs/storeprogress.h" |
f4c92e1c | 50 | #include "toolbars/samplingbar.h" |
3045c869 | 51 | #include "view/logicsignal.h" |
4104d7f3 | 52 | #include "view/view.h" |
269528f5 | 53 | #ifdef ENABLE_DECODE |
f0d37dab | 54 | #include "widgets/decodermenu.h" |
269528f5 | 55 | #endif |
d7bed479 | 56 | |
30236a54 JH |
57 | /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */ |
58 | #define __STDC_FORMAT_MACROS | |
59 | #include <inttypes.h> | |
60 | #include <stdint.h> | |
61 | #include <stdarg.h> | |
62 | #include <glib.h> | |
63 | #include <libsigrok/libsigrok.h> | |
e82fd481 | 64 | |
819f4c25 | 65 | using std::list; |
f9abf97e | 66 | using std::shared_ptr; |
30236a54 | 67 | |
51e77110 JH |
68 | namespace pv { |
69 | ||
b1264f56 JH |
70 | namespace view { |
71 | class SelectableItem; | |
72 | } | |
73 | ||
643f65f9 JS |
74 | const char *MainWindow::SettingOpenDirectory = "MainWindow/OpenDirectory"; |
75 | const char *MainWindow::SettingSaveDirectory = "MainWindow/SaveDirectory"; | |
76 | ||
107ca6d3 JH |
77 | MainWindow::MainWindow(DeviceManager &device_manager, |
78 | const char *open_file_name, | |
1d478458 | 79 | QWidget *parent) : |
107ca6d3 | 80 | QMainWindow(parent), |
dc0867ff | 81 | _device_manager(device_manager), |
f0d37dab | 82 | _session(device_manager) |
d7bed479 | 83 | { |
7d5425ef | 84 | setup_ui(); |
93f683ad | 85 | restore_ui_settings(); |
1d478458 JH |
86 | if (open_file_name) { |
87 | const QString s(QString::fromUtf8(open_file_name)); | |
88 | QMetaObject::invokeMethod(this, "load_file", | |
89 | Qt::QueuedConnection, | |
90 | Q_ARG(QString, s)); | |
91 | } | |
7d5425ef JH |
92 | } |
93 | ||
94 | void MainWindow::setup_ui() | |
95 | { | |
96 | setObjectName(QString::fromUtf8("MainWindow")); | |
97 | ||
7d5425ef JH |
98 | // Set the window icon |
99 | QIcon icon; | |
100 | icon.addFile(QString::fromUtf8(":/icons/sigrok-logo-notext.png"), | |
101 | QSize(), QIcon::Normal, QIcon::Off); | |
102 | setWindowIcon(icon); | |
103 | ||
e072efc8 JH |
104 | // Setup the central widget |
105 | _central_widget = new QWidget(this); | |
106 | _vertical_layout = new QVBoxLayout(_central_widget); | |
107 | _vertical_layout->setSpacing(6); | |
108 | _vertical_layout->setContentsMargins(0, 0, 0, 0); | |
109 | setCentralWidget(_central_widget); | |
110 | ||
111 | _view = new pv::view::View(_session, this); | |
b1264f56 | 112 | |
e072efc8 JH |
113 | _vertical_layout->addWidget(_view); |
114 | ||
ab1d13ee | 115 | // Setup the menu bar |
ced1cc13 JH |
116 | QMenuBar *const menu_bar = new QMenuBar(this); |
117 | menu_bar->setGeometry(QRect(0, 0, 400, 25)); | |
a429590b | 118 | |
ab1d13ee | 119 | // File Menu |
ced1cc13 | 120 | QMenu *const menu_file = new QMenu; |
0a9fdca5 | 121 | menu_file->setTitle(tr("&File")); |
e072efc8 | 122 | |
ced1cc13 | 123 | QAction *const action_open = new QAction(this); |
0a9fdca5 | 124 | action_open->setText(tr("&Open...")); |
ced1cc13 | 125 | action_open->setIcon(QIcon::fromTheme("document-open", |
362eea96 | 126 | QIcon(":/icons/document-open.png"))); |
5117748b | 127 | action_open->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); |
ced1cc13 JH |
128 | action_open->setObjectName(QString::fromUtf8("actionOpen")); |
129 | menu_file->addAction(action_open); | |
009e1503 | 130 | |
0fbda3c2 | 131 | QAction *const action_save_as = new QAction(this); |
0a9fdca5 | 132 | action_save_as->setText(tr("&Save As...")); |
0fbda3c2 JH |
133 | action_save_as->setIcon(QIcon::fromTheme("document-save-as", |
134 | QIcon(":/icons/document-save-as.png"))); | |
5117748b | 135 | action_save_as->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); |
0fbda3c2 JH |
136 | action_save_as->setObjectName(QString::fromUtf8("actionSaveAs")); |
137 | menu_file->addAction(action_save_as); | |
138 | ||
ced1cc13 | 139 | menu_file->addSeparator(); |
2a032dcb | 140 | |
ced1cc13 | 141 | QAction *const action_connect = new QAction(this); |
0a9fdca5 | 142 | action_connect->setText(tr("&Connect to Device...")); |
ced1cc13 JH |
143 | action_connect->setObjectName(QString::fromUtf8("actionConnect")); |
144 | menu_file->addAction(action_connect); | |
9663c82b | 145 | |
ced1cc13 | 146 | menu_file->addSeparator(); |
9663c82b | 147 | |
ced1cc13 | 148 | QAction *action_quit = new QAction(this); |
0a9fdca5 | 149 | action_quit->setText(tr("&Quit")); |
ced1cc13 | 150 | action_quit->setIcon(QIcon::fromTheme("application-exit", |
2a032dcb | 151 | QIcon(":/icons/application-exit.png"))); |
ced1cc13 JH |
152 | action_quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); |
153 | action_quit->setObjectName(QString::fromUtf8("actionQuit")); | |
154 | menu_file->addAction(action_quit); | |
2a032dcb | 155 | |
ab1d13ee | 156 | // View Menu |
ced1cc13 | 157 | QMenu *menu_view = new QMenu; |
0a9fdca5 | 158 | menu_view->setTitle(tr("&View")); |
ab1d13ee | 159 | |
ced1cc13 | 160 | QAction *const action_view_zoom_in = new QAction(this); |
0a9fdca5 | 161 | action_view_zoom_in->setText(tr("Zoom &In")); |
ced1cc13 | 162 | action_view_zoom_in->setIcon(QIcon::fromTheme("zoom-in", |
ab1d13ee | 163 | QIcon(":/icons/zoom-in.png"))); |
d2899ad5 | 164 | // simply using Qt::Key_Plus shows no + in the menu |
165 | action_view_zoom_in->setShortcut(QKeySequence::ZoomIn); | |
ced1cc13 | 166 | action_view_zoom_in->setObjectName( |
ab1d13ee | 167 | QString::fromUtf8("actionViewZoomIn")); |
ced1cc13 | 168 | menu_view->addAction(action_view_zoom_in); |
ab1d13ee | 169 | |
ced1cc13 | 170 | QAction *const action_view_zoom_out = new QAction(this); |
0a9fdca5 | 171 | action_view_zoom_out->setText(tr("Zoom &Out")); |
ced1cc13 | 172 | action_view_zoom_out->setIcon(QIcon::fromTheme("zoom-out", |
ab1d13ee | 173 | QIcon(":/icons/zoom-out.png"))); |
d2899ad5 | 174 | action_view_zoom_out->setShortcut(QKeySequence::ZoomOut); |
ced1cc13 | 175 | action_view_zoom_out->setObjectName( |
ab1d13ee | 176 | QString::fromUtf8("actionViewZoomOut")); |
ced1cc13 | 177 | menu_view->addAction(action_view_zoom_out); |
ab1d13ee | 178 | |
ca46b534 | 179 | QAction *const action_view_zoom_fit = new QAction(this); |
0a9fdca5 | 180 | action_view_zoom_fit->setText(tr("Zoom to &Fit")); |
ca46b534 JH |
181 | action_view_zoom_fit->setIcon(QIcon::fromTheme("zoom-fit", |
182 | QIcon(":/icons/zoom-fit.png"))); | |
183 | action_view_zoom_fit->setShortcut(QKeySequence(Qt::Key_F)); | |
184 | action_view_zoom_fit->setObjectName( | |
185 | QString::fromUtf8("actionViewZoomFit")); | |
186 | menu_view->addAction(action_view_zoom_fit); | |
187 | ||
d1e7d82c | 188 | QAction *const action_view_zoom_one_to_one = new QAction(this); |
0a9fdca5 | 189 | action_view_zoom_one_to_one->setText(tr("Zoom to &One-to-One")); |
d1e7d82c JH |
190 | action_view_zoom_one_to_one->setIcon(QIcon::fromTheme("zoom-original", |
191 | QIcon(":/icons/zoom-original.png"))); | |
192 | action_view_zoom_one_to_one->setShortcut(QKeySequence(Qt::Key_O)); | |
193 | action_view_zoom_one_to_one->setObjectName( | |
194 | QString::fromUtf8("actionViewZoomOneToOne")); | |
195 | menu_view->addAction(action_view_zoom_one_to_one); | |
196 | ||
ced1cc13 | 197 | menu_view->addSeparator(); |
ab1d13ee | 198 | |
ced1cc13 JH |
199 | QAction *action_view_show_cursors = new QAction(this); |
200 | action_view_show_cursors->setCheckable(true); | |
201 | action_view_show_cursors->setChecked(_view->cursors_shown()); | |
202 | action_view_show_cursors->setShortcut(QKeySequence(Qt::Key_C)); | |
203 | action_view_show_cursors->setObjectName( | |
ab1d13ee | 204 | QString::fromUtf8("actionViewShowCursors")); |
0a9fdca5 | 205 | action_view_show_cursors->setText(tr("Show &Cursors")); |
ced1cc13 | 206 | menu_view->addAction(action_view_show_cursors); |
a429590b | 207 | |
7dd093df | 208 | // Decoders Menu |
269528f5 | 209 | #ifdef ENABLE_DECODE |
ced1cc13 | 210 | QMenu *const menu_decoders = new QMenu; |
0a9fdca5 | 211 | menu_decoders->setTitle(tr("&Decoders")); |
7dd093df | 212 | |
ced1cc13 | 213 | pv::widgets::DecoderMenu *const menu_decoders_add = |
f69ec72d | 214 | new pv::widgets::DecoderMenu(menu_decoders, true); |
0a9fdca5 | 215 | menu_decoders_add->setTitle(tr("&Add")); |
ced1cc13 | 216 | connect(menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)), |
f0d37dab | 217 | this, SLOT(add_decoder(srd_decoder*))); |
7dd093df | 218 | |
ced1cc13 | 219 | menu_decoders->addMenu(menu_decoders_add); |
269528f5 | 220 | #endif |
7dd093df | 221 | |
ab1d13ee | 222 | // Help Menu |
ced1cc13 | 223 | QMenu *const menu_help = new QMenu; |
0a9fdca5 | 224 | menu_help->setTitle(tr("&Help")); |
ab1d13ee | 225 | |
ced1cc13 JH |
226 | QAction *const action_about = new QAction(this); |
227 | action_about->setObjectName(QString::fromUtf8("actionAbout")); | |
0a9fdca5 | 228 | action_about->setText(tr("&About...")); |
ced1cc13 | 229 | menu_help->addAction(action_about); |
7d5425ef | 230 | |
ced1cc13 JH |
231 | menu_bar->addAction(menu_file->menuAction()); |
232 | menu_bar->addAction(menu_view->menuAction()); | |
269528f5 | 233 | #ifdef ENABLE_DECODE |
ced1cc13 | 234 | menu_bar->addAction(menu_decoders->menuAction()); |
269528f5 | 235 | #endif |
ced1cc13 | 236 | menu_bar->addAction(menu_help->menuAction()); |
7d5425ef | 237 | |
ced1cc13 | 238 | setMenuBar(menu_bar); |
7d5425ef JH |
239 | QMetaObject::connectSlotsByName(this); |
240 | ||
5ac961e3 | 241 | // Setup the toolbar |
ced1cc13 | 242 | QToolBar *const toolbar = new QToolBar(tr("Main Toolbar"), this); |
0c7cdea2 | 243 | toolbar->setObjectName(QString::fromUtf8("MainToolbar")); |
ced1cc13 | 244 | toolbar->addAction(action_open); |
f45512cb | 245 | toolbar->addAction(action_save_as); |
ced1cc13 JH |
246 | toolbar->addSeparator(); |
247 | toolbar->addAction(action_view_zoom_in); | |
248 | toolbar->addAction(action_view_zoom_out); | |
ca46b534 | 249 | toolbar->addAction(action_view_zoom_fit); |
f45512cb | 250 | toolbar->addAction(action_view_zoom_one_to_one); |
ced1cc13 | 251 | addToolBar(toolbar); |
0a4db787 | 252 | |
5ac961e3 | 253 | // Setup the sampling bar |
aca00b1e | 254 | _sampling_bar = new toolbars::SamplingBar(_session, this); |
5ac961e3 JH |
255 | |
256 | // Populate the device list and select the initially selected device | |
107ca6d3 | 257 | update_device_list(); |
5ac961e3 | 258 | |
274d4f13 JH |
259 | connect(_sampling_bar, SIGNAL(run_stop()), this, |
260 | SLOT(run_stop())); | |
d4984fe7 JH |
261 | addToolBar(_sampling_bar); |
262 | ||
5ac961e3 | 263 | // Set the title |
0a9fdca5 | 264 | setWindowTitle(tr("PulseView")); |
a8d3fb2d | 265 | |
6ac96c2e JH |
266 | // Setup _session events |
267 | connect(&_session, SIGNAL(capture_state_changed(int)), this, | |
268 | SLOT(capture_state_changed(int))); | |
269 | ||
d7bed479 | 270 | } |
30236a54 | 271 | |
93f683ad SA |
272 | void MainWindow::save_ui_settings() |
273 | { | |
274 | QSettings settings("sigrok", "PulseView"); | |
275 | ||
276 | settings.beginGroup("MainWindow"); | |
277 | settings.setValue("state", saveState()); | |
278 | settings.setValue("geometry", saveGeometry()); | |
279 | settings.endGroup(); | |
280 | } | |
281 | ||
282 | void MainWindow::restore_ui_settings() | |
283 | { | |
284 | QSettings settings("sigrok", "PulseView"); | |
285 | ||
286 | settings.beginGroup("MainWindow"); | |
287 | ||
288 | if (settings.contains("geometry")) { | |
289 | restoreGeometry(settings.value("geometry").toByteArray()); | |
290 | restoreState(settings.value("state").toByteArray()); | |
291 | } else | |
292 | resize(1000, 720); | |
293 | ||
294 | settings.endGroup(); | |
295 | } | |
296 | ||
f2edb557 JH |
297 | void MainWindow::session_error( |
298 | const QString text, const QString info_text) | |
299 | { | |
300 | QMetaObject::invokeMethod(this, "show_session_error", | |
301 | Qt::QueuedConnection, Q_ARG(QString, text), | |
302 | Q_ARG(QString, info_text)); | |
303 | } | |
304 | ||
d873f4d6 | 305 | void MainWindow::update_device_list() |
107ca6d3 JH |
306 | { |
307 | assert(_sampling_bar); | |
308 | ||
d873f4d6 | 309 | shared_ptr<pv::device::DevInst> selected_device = _session.get_device(); |
85843b14 | 310 | list< shared_ptr<device::DevInst> > devices; |
52a80eb3 SA |
311 | |
312 | if (_device_manager.devices().size() == 0) | |
313 | return; | |
314 | ||
85843b14 JH |
315 | std::copy(_device_manager.devices().begin(), |
316 | _device_manager.devices().end(), std::back_inserter(devices)); | |
317 | ||
a5ea63c2 JH |
318 | if (std::find(devices.begin(), devices.end(), selected_device) == |
319 | devices.end()) | |
320 | devices.push_back(selected_device); | |
e95e8563 | 321 | assert(selected_device); |
a5ea63c2 | 322 | |
e95e8563 | 323 | _sampling_bar->set_device_list(devices, selected_device); |
107ca6d3 JH |
324 | } |
325 | ||
93f683ad SA |
326 | void MainWindow::closeEvent(QCloseEvent *event) |
327 | { | |
328 | save_ui_settings(); | |
329 | event->accept(); | |
330 | } | |
331 | ||
1d478458 JH |
332 | void MainWindow::load_file(QString file_name) |
333 | { | |
f2edb557 JH |
334 | const QString errorMessage( |
335 | QString("Failed to load file %1").arg(file_name)); | |
336 | const QString infoMessage; | |
ae2d1bc5 JH |
337 | |
338 | try { | |
339 | _session.set_file(file_name.toStdString()); | |
340 | } catch(QString e) { | |
341 | show_session_error(tr("Failed to load ") + file_name, e); | |
6fd0b639 JH |
342 | _session.set_default_device(); |
343 | update_device_list(); | |
344 | return; | |
ae2d1bc5 JH |
345 | } |
346 | ||
a5ea63c2 JH |
347 | update_device_list(); |
348 | ||
6db73158 JH |
349 | _session.start_capture([&, errorMessage, infoMessage](QString) { |
350 | session_error(errorMessage, infoMessage); }); | |
f2edb557 JH |
351 | } |
352 | ||
353 | void MainWindow::show_session_error( | |
354 | const QString text, const QString info_text) | |
355 | { | |
356 | QMessageBox msg(this); | |
357 | msg.setText(text); | |
358 | msg.setInformativeText(info_text); | |
359 | msg.setStandardButtons(QMessageBox::Ok); | |
360 | msg.setIcon(QMessageBox::Warning); | |
361 | msg.exec(); | |
1d478458 JH |
362 | } |
363 | ||
2953961c JH |
364 | void MainWindow::on_actionOpen_triggered() |
365 | { | |
643f65f9 JS |
366 | QSettings settings; |
367 | const QString dir = settings.value(SettingOpenDirectory).toString(); | |
368 | ||
1d43d767 | 369 | // Show the dialog |
1d478458 | 370 | const QString file_name = QFileDialog::getOpenFileName( |
643f65f9 | 371 | this, tr("Open File"), dir, tr( |
6866d5de JH |
372 | "Sigrok Sessions (*.sr);;" |
373 | "All Files (*.*)")); | |
643f65f9 JS |
374 | |
375 | if (!file_name.isEmpty()) { | |
92b139d0 | 376 | load_file(file_name); |
643f65f9 JS |
377 | |
378 | const QString abs_path = QFileInfo(file_name).absolutePath(); | |
379 | settings.setValue(SettingOpenDirectory, abs_path); | |
380 | } | |
2953961c JH |
381 | } |
382 | ||
0fbda3c2 JH |
383 | void MainWindow::on_actionSaveAs_triggered() |
384 | { | |
385 | using pv::dialogs::StoreProgress; | |
386 | ||
387 | // Stop any currently running capture session | |
388 | _session.stop_capture(); | |
389 | ||
643f65f9 JS |
390 | QSettings settings; |
391 | const QString dir = settings.value(SettingSaveDirectory).toString(); | |
392 | ||
0fbda3c2 JH |
393 | // Show the dialog |
394 | const QString file_name = QFileDialog::getSaveFileName( | |
643f65f9 | 395 | this, tr("Save File"), dir, tr("Sigrok Sessions (*.sr)")); |
0fbda3c2 JH |
396 | |
397 | if (file_name.isEmpty()) | |
398 | return; | |
399 | ||
643f65f9 JS |
400 | const QString abs_path = QFileInfo(file_name).absolutePath(); |
401 | settings.setValue(SettingSaveDirectory, abs_path); | |
402 | ||
0fbda3c2 JH |
403 | StoreProgress *dlg = new StoreProgress(file_name, _session, this); |
404 | dlg->run(); | |
405 | } | |
406 | ||
9663c82b JH |
407 | void MainWindow::on_actionConnect_triggered() |
408 | { | |
b99cfc42 JH |
409 | // Stop any currently running capture session |
410 | _session.stop_capture(); | |
411 | ||
107ca6d3 | 412 | dialogs::Connect dlg(this, _device_manager); |
5eb0fa13 | 413 | |
dc0867ff JH |
414 | // If the user selected a device, select it in the device list. Select the |
415 | // current device otherwise. | |
d873f4d6 JH |
416 | if (dlg.exec()) |
417 | _session.set_device(dlg.get_selected_device()); | |
dc0867ff | 418 | |
d873f4d6 | 419 | update_device_list(); |
9663c82b JH |
420 | } |
421 | ||
2a032dcb JH |
422 | void MainWindow::on_actionQuit_triggered() |
423 | { | |
424 | close(); | |
425 | } | |
426 | ||
a429590b JH |
427 | void MainWindow::on_actionViewZoomIn_triggered() |
428 | { | |
429 | _view->zoom(1); | |
430 | } | |
431 | ||
432 | void MainWindow::on_actionViewZoomOut_triggered() | |
433 | { | |
434 | _view->zoom(-1); | |
435 | } | |
436 | ||
ca46b534 JH |
437 | void MainWindow::on_actionViewZoomFit_triggered() |
438 | { | |
439 | _view->zoom_fit(); | |
440 | } | |
441 | ||
d1e7d82c JH |
442 | void MainWindow::on_actionViewZoomOneToOne_triggered() |
443 | { | |
444 | _view->zoom_one_to_one(); | |
445 | } | |
446 | ||
e072efc8 JH |
447 | void MainWindow::on_actionViewShowCursors_triggered() |
448 | { | |
449 | assert(_view); | |
b4d91e56 JH |
450 | |
451 | const bool show = !_view->cursors_shown(); | |
452 | if(show) | |
453 | _view->centre_cursors(); | |
454 | ||
455 | _view->show_cursors(show); | |
e072efc8 JH |
456 | } |
457 | ||
30236a54 JH |
458 | void MainWindow::on_actionAbout_triggered() |
459 | { | |
acda14b8 | 460 | dialogs::About dlg(this); |
40eb2ff4 | 461 | dlg.exec(); |
30236a54 | 462 | } |
274d4f13 | 463 | |
f0d37dab | 464 | void MainWindow::add_decoder(srd_decoder *decoder) |
7dd093df | 465 | { |
269528f5 | 466 | #ifdef ENABLE_DECODE |
f0d37dab JH |
467 | assert(decoder); |
468 | _session.add_decoder(decoder); | |
269528f5 JH |
469 | #else |
470 | (void)decoder; | |
471 | #endif | |
7dd093df JH |
472 | } |
473 | ||
274d4f13 JH |
474 | void MainWindow::run_stop() |
475 | { | |
5b7cf66c JH |
476 | switch(_session.get_capture_state()) { |
477 | case SigSession::Stopped: | |
6db73158 JH |
478 | _session.start_capture([&](QString message) { |
479 | session_error("Capture failed", message); }); | |
5b7cf66c JH |
480 | break; |
481 | ||
2b49eeb0 | 482 | case SigSession::AwaitingTrigger: |
5b7cf66c JH |
483 | case SigSession::Running: |
484 | _session.stop_capture(); | |
485 | break; | |
486 | } | |
274d4f13 | 487 | } |
51e77110 | 488 | |
6ac96c2e JH |
489 | void MainWindow::capture_state_changed(int state) |
490 | { | |
2b49eeb0 | 491 | _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); |
6ac96c2e JH |
492 | } |
493 | ||
51e77110 | 494 | } // namespace pv |