2 * This file is part of the PulseView project.
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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/>.
20 #ifndef PULSEVIEW_PV_WIDGETS_DEVICETOOLBUTTON_HPP
21 #define PULSEVIEW_PV_WIDGETS_DEVICETOOLBUTTON_HPP
29 #include <QSignalMapper>
30 #include <QToolButton>
33 using std::shared_ptr;
49 class DeviceToolButton : public QToolButton
56 * @param parent the parent widget.
57 * @param device_manager the device manager.
58 * @param connect_action the connect-to-device action.
60 DeviceToolButton(QWidget *parent, DeviceManager &device_manager,
61 QAction *connect_action);
64 * Returns a reference to the selected device.
66 shared_ptr<devices::Device> selected_device();
69 * Sets the current list of devices.
70 * @param device the list of devices.
71 * @param selected_device the currently active device.
74 const list< shared_ptr<devices::Device> > &devices,
75 shared_ptr<devices::Device> selected);
78 * Sets the current device to "no device". Useful for when a selected
79 * device fails to open.
85 * Repopulates the menu from the device list.
87 void update_device_list();
90 void on_action(QObject *action);
92 void on_menu_hovered(QAction *action);
94 void on_menu_hover_timeout();
97 void device_selected();
100 DeviceManager &device_manager_;
101 QAction *const connect_action_;
104 QSignalMapper mapper_;
106 shared_ptr<devices::Device> selected_device_;
107 vector< weak_ptr<devices::Device> > devices_;
109 QString device_tooltip_;
112 } // namespace widgets
115 #endif // PULSEVIEW_PV_WIDGETS_DEVICETOOLBUTTON_HPP