26 #include <libsigrokcxx/libsigrokcxx.hpp>
34 using std::shared_ptr;
46 QAction *connect_action) :
48 device_manager_(device_manager),
49 connect_action_(connect_action),
54 setPopupMode(QToolButton::MenuButtonPopup);
57 setMinimumWidth(QFontMetrics(font()).averageCharWidth() * 24);
62 connect(&
menu_, SIGNAL(hovered(QAction*)),
72 const list< shared_ptr<Device> > &devices, shared_ptr<Device> selected)
75 setText(selected ? QString::fromStdString(
77 devices_ = vector< weak_ptr<Device> >(devices.begin(), devices.end());
88 for (weak_ptr<Device> dev_weak_ptr :
devices_) {
89 shared_ptr<Device> dev(dev_weak_ptr.lock());
93 QAction *
const a =
new QAction(QString::fromStdString(
95 a->setCheckable(
true);
97 a->setData(qVariantFromValue((
void*)dev.get()));
98 a->setToolTip(QString::fromStdString(dev->full_name()));
101 connect(a, SIGNAL(triggered()), &
mapper_, SLOT(map()));
111 Device *
const dev = (
Device*)((QAction*)action)->data().value<
void*>();
112 for (weak_ptr<Device> dev_weak_ptr :
devices_) {
113 shared_ptr<Device> dev_ptr(dev_weak_ptr);
114 if (dev_ptr.get() == dev) {
121 setText(QString::fromStdString(
133 if (!action->data().isValid())
138 if (QToolTip::isVisible())