MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / set_device

Method set_device

DSView/pv/view/devmode.cpp:103–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void DevMode::set_device()
104{
105 if (_device_agent->have_instance() == false){
106 dsv_detail("DevMode::set_device, Have no device.");
107 return;
108 }
109
110 _bFile = false;
111
112 //remove all action object
113 for(std::map<QAction *, const sr_dev_mode *>::const_iterator i = _mode_list.begin();
114 i != _mode_list.end(); i++) {
115 (*i).first->setParent(NULL);
116 _pop_menu->removeAction((*i).first);
117 delete (*i).first;
118 }
119 _mode_list.clear();
120
121 _close_button->setIcon(QIcon());
122 _close_button->setDisabled(true);
123
124 QString iconPath = GetIconPath() + "/";
125 auto dev_mode_list = _device_agent->get_device_mode_list();
126
127 for (const GSList *l = dev_mode_list; l; l = l->next)
128 {
129 const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
130 auto *mode_name = get_mode_name(mode->mode);
131 QString icon_name = QString::fromLocal8Bit(mode_name->_logo);
132
133 QAction *action = new QAction(this);
134 action->setIcon(QIcon(iconPath + "square-" + icon_name));
135
136 int md = mode->mode;
137
138 if (md == LOGIC)
139 action->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_LOGIC), "Logic Analyzer"));
140 else if (md == ANALOG)
141 action->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_ANALOG), "Data Acquisition"));
142 else if (md == DSO)
143 action->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_DSO), "Oscilloscope"));
144
145 connect(action, SIGNAL(triggered()), this, SLOT(on_mode_change()));
146
147 _mode_list[action] = mode;
148 int cur_mode = _device_agent->get_work_mode();
149
150 if (cur_mode == _mode_list[action]->mode)
151 {
152 QString icon_fname = iconPath + icon_name;
153 _mode_btn->setIcon(QIcon(icon_fname));
154
155 if (cur_mode == LOGIC)
156 _mode_btn->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_LOGIC), "Logic Analyzer"));
157 else if (cur_mode == ANALOG)
158 _mode_btn->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_ANALOG), "Data Acquisition"));
159 else if (cur_mode == DSO)
160 _mode_btn->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_DEVICE_MODE_DSO), "Oscilloscope"));

Callers

nothing calls this directly

Calls 7

GetIconPathFunction · 0.85
have_instanceMethod · 0.80
get_device_mode_listMethod · 0.80
get_work_modeMethod · 0.80
endMethod · 0.45
clearMethod · 0.45
is_fileMethod · 0.45

Tested by

no test coverage detected