From 9fc9b1d7bd4a55ba04b6412d4625f496ae6ba5e6 Mon Sep 17 00:00:00 2001 From: DreamSourceLab Date: Sat, 23 Apr 2022 16:40:00 +0800 Subject: [PATCH] code clean --- DSView/pv/dialogs/applicationpardlg.cpp | 2 +- DSView/pv/mainframe.cpp | 30 +++++++++- DSView/pv/mainframe.h | 12 ++++ DSView/pv/sigsession.cpp | 17 +++--- DSView/pv/storesession.cpp | 2 +- DSView/pv/toolbars/trigbar.cpp | 12 ++-- DSView/pv/toolbars/trigbar.h | 2 +- libsigrok4DSL/hardware/DSL/dslogic.c | 5 -- libsigrok4DSL/hardware/demo/demo.h | 5 +- libsigrok4DSL/hwdriver.c | 80 ------------------------- libsigrok4DSL/session_file.c | 1 - 11 files changed, 60 insertions(+), 108 deletions(-) diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index bed3df36..282127ec 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -43,7 +43,7 @@ ApplicationParamDlg::~ApplicationParamDlg() bool ApplicationParamDlg::ShowDlg(QWidget *parent) { DSDialog dlg(parent, true, true); - dlg.setTitle("Application options"); + dlg.setTitle("Display options"); dlg.setMinimumSize(300, 200); QFormLayout &lay = *(new QFormLayout()); lay.setContentsMargins(0,20,0,30); diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index adab48f6..6b2732f4 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -134,7 +134,12 @@ MainFrame::MainFrame() _layout->addWidget(_bottom, 2, 1); _layout->addWidget(_bottom_right, 2, 2); - connect(&_timer, SIGNAL(timeout()), this, SLOT(unfreezing())); +#ifdef _WIN32 + _taskBtn = new QWinTaskbarButton(this); + connect(_mainWindow, SIGNAL(prgRate(int)), this, SLOT(setTaskbarProgress(int))); +#endif + + connect(&_timer, SIGNAL(timeout()), this, SLOT(unfreezing())); } void MainFrame::resizeEvent(QResizeEvent *event) @@ -436,9 +441,30 @@ void MainFrame::readSettings() _titleBar->setRestoreButton(app._frameOptions.isMax); } +#ifdef _WIN32 +void MainFrame::showEvent(QShowEvent *event) +{ + // Taskbar Progress Effert for Win7 and Above + if (_taskBtn->window() == NULL) { + _taskBtn->setWindow(windowHandle()); + _taskPrg = _taskBtn->progress(); + } + event->accept(); +} +#endif + void MainFrame::setTaskbarProgress(int progress) { - (void)progress; +#ifdef _WIN32 + if (progress > 0) { + _taskPrg->setVisible(true); + _taskPrg->setValue(progress); + } else { + _taskPrg->setVisible(false); + } +#else + (void)progress; +#endif } void MainFrame::show_doc() diff --git a/DSView/pv/mainframe.h b/DSView/pv/mainframe.h index 25b8df4b..fe699185 100755 --- a/DSView/pv/mainframe.h +++ b/DSView/pv/mainframe.h @@ -28,6 +28,10 @@ #include #include #include +#ifdef _WIN32 +#include +#include +#endif namespace pv { @@ -73,6 +77,9 @@ protected: void resizeEvent(QResizeEvent *event); void closeEvent(QCloseEvent *event); bool eventFilter(QObject *object, QEvent *event); + #ifdef _WIN32 + void showEvent(QShowEvent *event); + #endif public slots: void unfreezing(); @@ -107,6 +114,11 @@ private: int _hit_border; QTimer _timer; bool _freezing; + // Taskbar Progress Effert for Win7 and Above +#ifdef _WIN32 + QWinTaskbarButton *_taskBtn; + QWinTaskbarProgress *_taskPrg; +#endif }; } // namespace pv diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index ad369cfd..ab279ddd 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1206,7 +1206,8 @@ void SigSession::data_feed_in_proc(const struct sr_dev_inst *sdi, /* * hotplug function */ -void SigSession::hotplug_callback(void *ctx, void *dev, int event, void *user_data) { +void SigSession::hotplug_callback(void *ctx, void *dev, int event, void *user_data) +{ (void)ctx; (void)dev; @@ -1214,32 +1215,32 @@ void SigSession::hotplug_callback(void *ctx, void *dev, int event, void *user_da if (USB_EV_HOTPLUG_ATTACH == event) { _session->_hot_attach = true; - qDebug("receive event:DreamSourceLab Hardware attached!"); }else if (USB_EV_HOTPLUG_DETTACH == event) { _session->_hot_detach = true; - qDebug("receive event:DreamSourceLab Hardware detached!"); }else{ qDebug("Unhandled event %d\n", event); } } void SigSession::hotplug_proc() -{ +{ if (!_dev_inst) return; - + + qDebug("Hotplug thread start!"); + try { while(_session && !_bHotplugStop) { sr_hotplug_wait_timout(_sr_ctx); if (_hot_attach) { - qDebug("process event:DreamSourceLab hardware attached!"); + qDebug("process event: DreamSourceLab hardware attached!"); _callback->device_attach(); _hot_attach = false; } if (_hot_detach) { - qDebug("process event:DreamSourceLab hardware detached!"); + qDebug("process event: DreamSourceLab hardware detached!"); _callback->device_detach(); _hot_detach = false; } @@ -1248,7 +1249,7 @@ void SigSession::hotplug_proc() } catch(...) { qDebug("Interrupt exception for hotplug thread was thrown."); } - // qDebug("Hotplug thread exit!"); + qDebug("Hotplug thread exit!"); } void SigSession::register_hotplug_callback() diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index effdd01a..77090213 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -145,7 +145,7 @@ bool StoreSession::save_start() } if (_file_name == ""){ - _error = tr("No set file name."); + _error = tr("No file name."); return false; } diff --git a/DSView/pv/toolbars/trigbar.cpp b/DSView/pv/toolbars/trigbar.cpp index 211892ac..579d28a7 100755 --- a/DSView/pv/toolbars/trigbar.cpp +++ b/DSView/pv/toolbars/trigbar.cpp @@ -87,14 +87,14 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) : _themes->addAction(_light_style); _themes->addAction(_dark_style); - _appParam_action = new QAction(this); + _action_dispalyOptions = new QAction(this); _display_menu = new QMenu(this); _display_menu->setContentsMargins(0,0,0,0); - _display_menu->addAction(_appParam_action); _display_menu->addAction(_action_lissajous); _display_menu->addMenu(_themes); + _display_menu->addAction(_action_dispalyOptions); _setting_button.setPopupMode(QToolButton::InstantPopup); _setting_button.setMenu(_display_menu); @@ -127,7 +127,7 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) : connect(_action_lissajous, SIGNAL(triggered()), this, SLOT(on_actionLissajous_triggered())); connect(_dark_style, SIGNAL(triggered()), this, SLOT(on_actionDark_triggered())); connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered())); - connect(_appParam_action, SIGNAL(triggered()), this, SLOT(on_application_param())); + connect(_action_dispalyOptions, SIGNAL(triggered()), this, SLOT(on_application_param())); } void TrigBar::changeEvent(QEvent *event) @@ -146,7 +146,7 @@ void TrigBar::retranslateUi() _measure_button.setText(tr("Measure")); _search_button.setText(tr("Search")); _function_button.setText(tr("Function")); - _setting_button.setText(tr("Setting")); + _setting_button.setText(tr("Display")); _action_lissajous->setText(tr("&Lissajous")); @@ -157,7 +157,7 @@ void TrigBar::retranslateUi() _action_fft->setText(tr("FFT")); _action_math->setText(tr("Math")); - _appParam_action->setText(tr("Application")); + _action_dispalyOptions->setText(tr("Options")); } void TrigBar::reStyle() @@ -177,7 +177,7 @@ void TrigBar::reStyle() _dark_style->setIcon(QIcon(iconPath+"/dark.svg")); _light_style->setIcon(QIcon(iconPath+"/light.svg")); - _appParam_action->setIcon(QIcon(iconPath+"/params.svg")); + _action_dispalyOptions->setIcon(QIcon(iconPath+"/params.svg")); AppConfig &app = AppConfig::Instance(); diff --git a/DSView/pv/toolbars/trigbar.h b/DSView/pv/toolbars/trigbar.h index 06add2a8..e10132b2 100755 --- a/DSView/pv/toolbars/trigbar.h +++ b/DSView/pv/toolbars/trigbar.h @@ -109,7 +109,7 @@ private: QMenu *_display_menu; QMenu *_themes; - QAction *_appParam_action; + QAction *_action_dispalyOptions; QAction *_dark_style; QAction *_light_style; QAction *_action_lissajous; diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 66d8ff28..76419965 100755 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -288,9 +288,6 @@ static GSList *scan(GSList *options) /* Find all DSLogic compatible devices and upload firmware to them. */ devices = NULL; libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); - int stdnum = 0; - - for (i = 0; devlist[i]; i++) { if (conn) { usb = NULL; @@ -317,8 +314,6 @@ static GSList *scan(GSList *options) (usb_speed != LIBUSB_SPEED_SUPER)) continue; - stdnum++; - prof = NULL; for (j = 0; supported_DSLogic[j].vid; j++) { if (des.idVendor == supported_DSLogic[j].vid && diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index e347401f..8a2d1630 100755 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -168,9 +168,8 @@ static const struct DEMO_profile supported_Demo[] = { (1 << DEMO_LOGIC100x16) | (1 << DEMO_ANALOG10x2) | (1 << DEMO_DSO200x2), - //SR_Mn(100), - SR_Gn(16), - SR_Kn(20), + SR_Mn(100), + SR_Kn(20), 0, vdivs10to2000, 0, diff --git a/libsigrok4DSL/hwdriver.c b/libsigrok4DSL/hwdriver.c index 7ce483ac..6af67d91 100755 --- a/libsigrok4DSL/hwdriver.c +++ b/libsigrok4DSL/hwdriver.c @@ -27,8 +27,6 @@ #include #include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ -#include "hardware/DSL/dsl.h" - /* Message logging helpers with subsystem-specific prefix string. */ #define LOG_PREFIX "hwdriver: " #define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) @@ -477,81 +475,3 @@ SR_PRIV int sr_source_add(int fd, int events, int timeout, } /** @} */ - -/* -test usb device api -*/ -/* -SR_API void sr_test_usb_api() -{ - libusb_context *ctx; - struct libusb_device_descriptor des; - int usb_speed; - int ret; - int i; - int num_devs; - libusb_device **devlist; - int stdnum = 0; - int j; - int bfind = 0; - int dlsnum = 0; - struct libusb_device_handle *devhandle; - - printf("\n"); - - ret = libusb_init(&ctx); - if (ret) { - printf("unable to initialize libusb: %i\n", ret); - return; - } - - num_devs = libusb_get_device_list(ctx, &devlist); - printf("usb dev num:%d\n", num_devs); - - for (i=0; i