forked from Ivasoft/DSView
Add tool button of device type
This commit is contained in:
@@ -133,5 +133,9 @@
|
||||
<file>icons/dark/osc.png</file>
|
||||
<file>icons/showDoc25.png</file>
|
||||
<file>icons/showDoc31.png</file>
|
||||
<file>icons/usb2.png</file>
|
||||
<file>icons/usb3.png</file>
|
||||
<file>icons/data.png</file>
|
||||
<file>icons/demo.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
DSView/icons/data.png
Normal file
BIN
DSView/icons/data.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
DSView/icons/demo.png
Normal file
BIN
DSView/icons/demo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
DSView/icons/usb2.png
Normal file
BIN
DSView/icons/usb2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
DSView/icons/usb3.png
Normal file
BIN
DSView/icons/usb3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -58,7 +58,6 @@
|
||||
#include "dialogs/deviceoptions.h"
|
||||
#include "dialogs/storeprogress.h"
|
||||
#include "dialogs/waitingdialog.h"
|
||||
#include "dialogs/dsmessagebox.h"
|
||||
#include "dialogs/regionoptions.h"
|
||||
|
||||
#include "toolbars/samplingbar.h"
|
||||
@@ -86,6 +85,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <glib.h>
|
||||
#include <list>
|
||||
#include <libusb.h>
|
||||
|
||||
using boost::shared_ptr;
|
||||
using boost::dynamic_pointer_cast;
|
||||
@@ -99,7 +99,8 @@ MainWindow::MainWindow(DeviceManager &device_manager,
|
||||
QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
_device_manager(device_manager),
|
||||
_session(device_manager)
|
||||
_session(device_manager),
|
||||
_msg(NULL)
|
||||
{
|
||||
setup_ui();
|
||||
if (open_file_name) {
|
||||
@@ -346,6 +347,9 @@ void MainWindow::update_device_list()
|
||||
{
|
||||
assert(_sampling_bar);
|
||||
|
||||
if (_msg)
|
||||
_msg->close();
|
||||
|
||||
switchLanguage(_language);
|
||||
_session.stop_capture();
|
||||
_view->reload();
|
||||
@@ -434,6 +438,29 @@ void MainWindow::update_device_list()
|
||||
_trigger_widget->init();
|
||||
_dso_trigger_widget->init();
|
||||
_measure_widget->reload();
|
||||
|
||||
// USB device speed check
|
||||
if (!selected_device->name().contains("virtual")) {
|
||||
int usb_speed;
|
||||
GVariant *gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB_SPEED);
|
||||
if (gvar != NULL) {
|
||||
usb_speed = g_variant_get_int32(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
bool usb30_support = false;
|
||||
gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB30_SUPPORT);
|
||||
if (gvar != NULL) {
|
||||
usb30_support = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (usb30_support && usb_speed == LIBUSB_SPEED_HIGH)
|
||||
show_session_error(tr("Speed limited"), tr("This is a super-speed usb device(USB 3.0). "
|
||||
"Plug it into a USB 2.0 port will seriously affect its performance."
|
||||
"Please replug it into a USB 3.0 port."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::reload()
|
||||
@@ -464,11 +491,13 @@ void MainWindow::show_session_error(
|
||||
const QString text, const QString info_text)
|
||||
{
|
||||
dialogs::DSMessageBox msg(this);
|
||||
_msg = &msg;
|
||||
msg.mBox()->setText(text);
|
||||
msg.mBox()->setInformativeText(info_text);
|
||||
msg.mBox()->setStandardButtons(QMessageBox::Ok);
|
||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
||||
msg.exec();
|
||||
_msg = NULL;
|
||||
}
|
||||
|
||||
void MainWindow::device_attach()
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "sigsession.h"
|
||||
#include "dialogs/dsmessagebox.h"
|
||||
|
||||
class QAction;
|
||||
class QMenuBar;
|
||||
@@ -106,7 +107,7 @@ private slots:
|
||||
|
||||
void reload();
|
||||
|
||||
void show_session_error(
|
||||
void show_session_error(
|
||||
const QString text, const QString info_text);
|
||||
|
||||
void run_stop();
|
||||
@@ -161,6 +162,7 @@ private:
|
||||
SigSession _session;
|
||||
|
||||
pv::view::View *_view;
|
||||
dialogs::DSMessageBox *_msg;
|
||||
|
||||
QMenuBar *_menu_bar;
|
||||
QMenu *_menu_file;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <extdef.h>
|
||||
#include <assert.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <libusb.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
@@ -30,7 +31,6 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include "samplingbar.h"
|
||||
|
||||
#include "../devicemanager.h"
|
||||
#include "../device/devinst.h"
|
||||
#include "../dialogs/deviceoptions.h"
|
||||
@@ -57,6 +57,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
|
||||
_session(session),
|
||||
_enable(true),
|
||||
_sampling(false),
|
||||
_device_type(this),
|
||||
_device_selector(this),
|
||||
_updating_device_selector(false),
|
||||
_configure_button(this),
|
||||
@@ -104,6 +105,8 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
|
||||
leftMargin->setFixedWidth(4);
|
||||
addWidget(leftMargin);
|
||||
|
||||
_device_type.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
addWidget(&_device_type);
|
||||
addWidget(&_device_selector);
|
||||
_configure_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
addWidget(&_configure_button);
|
||||
@@ -146,6 +149,27 @@ void SamplingBar::changeEvent(QEvent *event)
|
||||
|
||||
void SamplingBar::retranslateUi()
|
||||
{
|
||||
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->dev_inst()) {
|
||||
if (dev_inst->name().contains("virtual-demo"))
|
||||
_device_type.setText(tr("Demo"));
|
||||
else if (dev_inst->name().contains("virtual"))
|
||||
_device_type.setText(tr("File"));
|
||||
else {
|
||||
int usb_speed;
|
||||
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
|
||||
if (gvar != NULL) {
|
||||
usb_speed = g_variant_get_int32(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
if (usb_speed == LIBUSB_SPEED_HIGH)
|
||||
_device_type.setText(tr("USB 2.0"));
|
||||
else if (usb_speed == LIBUSB_SPEED_SUPER)
|
||||
_device_type.setText(tr("USB 3.0"));
|
||||
else
|
||||
_device_type.setText(tr("USB UNKNOWN"));
|
||||
}
|
||||
}
|
||||
_configure_button.setText(tr("Options"));
|
||||
_mode_button.setText(tr("Mode"));
|
||||
if (_instant) {
|
||||
@@ -172,6 +196,26 @@ void SamplingBar::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
|
||||
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->dev_inst()) {
|
||||
if (dev_inst->name().contains("virtual-demo"))
|
||||
_device_type.setIcon(QIcon(":/icons/demo.png"));
|
||||
else if (dev_inst->name().contains("virtual"))
|
||||
_device_type.setIcon(QIcon(":/icons/data.png"));
|
||||
else {
|
||||
int usb_speed;
|
||||
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
|
||||
if (gvar != NULL) {
|
||||
usb_speed = g_variant_get_int32(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
if (usb_speed == LIBUSB_SPEED_SUPER)
|
||||
_device_type.setIcon(QIcon(":/icons/usb3.png"));
|
||||
else
|
||||
_device_type.setIcon(QIcon(":/icons/usb2.png"));
|
||||
|
||||
}
|
||||
}
|
||||
_configure_button.setIcon(QIcon(iconPath+"/params.png"));
|
||||
_mode_button.setIcon(_session.get_run_mode() == pv::SigSession::Single ? QIcon(iconPath+"/modes.png") :
|
||||
QIcon(iconPath+"/moder.png"));
|
||||
@@ -964,6 +1008,7 @@ void SamplingBar::reload()
|
||||
enable_toggle(true);
|
||||
}
|
||||
retranslateUi();
|
||||
reStyle();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@ private:
|
||||
bool _enable;
|
||||
bool _sampling;
|
||||
|
||||
QToolButton _device_type;
|
||||
|
||||
QComboBox _device_selector;
|
||||
std::map<const void*, boost::weak_ptr<device::DevInst> >
|
||||
_device_selector_map;
|
||||
|
||||
Reference in New Issue
Block a user