]> sigrok.org Git - pulseview.git/blob - pv/popups/deviceoptions.cpp
Fix #1035 by checking for exceptions when accessing config
[pulseview.git] / pv / popups / deviceoptions.cpp
1 /*
2  * This file is part of the PulseView project.
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, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "deviceoptions.hpp"
21
22 #include <QFormLayout>
23 #include <QListWidget>
24
25 #include <pv/prop/property.hpp>
26
27 #include <libsigrokcxx/libsigrokcxx.hpp>
28
29 using std::shared_ptr;
30
31 using sigrok::Device;
32
33 namespace pv {
34 namespace popups {
35
36 DeviceOptions::DeviceOptions(shared_ptr<Device> device, QWidget *parent) :
37         Popup(parent),
38         device_(device),
39         layout_(this),
40         binding_(device)
41 {
42         setLayout(&layout_);
43
44         layout_.addWidget(binding_.get_property_form(this, true));
45 }
46
47 pv::binding::Device& DeviceOptions::binding()
48 {
49         return binding_;
50 }
51
52 void DeviceOptions::show()
53 {
54         // Update device config widgets with the current values supplied by the
55         // driver before actually showing the popup dialog
56         binding_.update_property_widgets();
57
58         Popup::show();
59 }
60
61 } // namespace popups
62 } // namespace pv