From 91dd746f2d2aef3f950a594bc127ba67f951c429 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 25 Oct 2021 16:51:34 +0800 Subject: [PATCH] disable toolbar context menu --- DSView/pv/dialogs/applicationpardlg.cpp | 1 + DSView/pv/mainwindow.cpp | 136 ++++++++++-------------- DSView/pv/storesession.cpp | 23 +++- DSView/pv/toolbars/filebar.cpp | 30 +++--- 4 files changed, 90 insertions(+), 100 deletions(-) diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index b27da3a5..469e0657 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -43,6 +43,7 @@ ApplicationParamDlg::~ApplicationParamDlg() bool ApplicationParamDlg::ShowDlg(QWidget *parent) { DSDialog dlg(parent, true, true); + dlg.setTitle("Application options"); dlg.setMinimumSize(300, 200); QFormLayout &lay = *(new QFormLayout()); lay.setContentsMargins(0,20,0,30); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 06c30bc9..70828a2a 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -109,6 +109,9 @@ MainWindow::MainWindow(DeviceManager &device_manager, _msg(NULL) { setup_ui(); + + setContextMenuPolicy(Qt::NoContextMenu); + if (open_file_name) { qDebug("Open file: %s", open_file_name); const QString s(QString::fromUtf8(open_file_name)); @@ -119,7 +122,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, } void MainWindow::setup_ui() -{ +{ setObjectName(QString::fromUtf8("MainWindow")); setContentsMargins(0,0,0,0); layout()->setMargin(0); @@ -141,34 +144,7 @@ void MainWindow::setup_ui() _file_bar->setObjectName("file_bar"); _logo_bar = new toolbars::LogoBar(_session, this); _logo_bar->setObjectName("logo_bar"); - - connect(_trig_bar, SIGNAL(on_protocol(bool)), this, - SLOT(on_protocol(bool))); - connect(_trig_bar, SIGNAL(on_trigger(bool)), this, - SLOT(on_trigger(bool))); - connect(_trig_bar, SIGNAL(on_measure(bool)), this, - SLOT(on_measure(bool))); - connect(_trig_bar, SIGNAL(on_search(bool)), this, - SLOT(on_search(bool))); - connect(_trig_bar, SIGNAL(setTheme(QString)), this, - SLOT(switchTheme(QString))); - connect(_file_bar, SIGNAL(load_file(QString)), this, - SLOT(load_file(QString))); - connect(_file_bar, SIGNAL(on_save()), this, - SLOT(on_save())); - connect(_file_bar, SIGNAL(on_export()), this, - SLOT(on_export())); - connect(_file_bar, SIGNAL(on_screenShot()), this, - SLOT(on_screenShot()), Qt::QueuedConnection); - connect(_file_bar, SIGNAL(load_session(QString)), this, - SLOT(load_session(QString))); - connect(_file_bar, SIGNAL(store_session(QString)), this, - SLOT(store_session(QString))); - connect(_logo_bar, SIGNAL(setLanguage(int)), this, - SLOT(switchLanguage(int))); - connect(_logo_bar, SIGNAL(openDoc()), this, - SLOT(openDoc())); - + // trigger dock _trigger_dock=new QDockWidget(tr("Trigger Setting..."),this); _trigger_dock->setObjectName("trigger_dock"); @@ -190,28 +166,7 @@ void MainWindow::setup_ui() // Setup _view widget _view = new pv::view::View(_session, _sampling_bar, this); _vertical_layout->addWidget(_view); - - connect(_sampling_bar, SIGNAL(device_selected()), this, - SLOT(update_device_list())); - connect(_sampling_bar, SIGNAL(device_updated()), this, - SLOT(reload())); - connect(_sampling_bar, SIGNAL(run_stop()), this, - SLOT(run_stop())); - connect(_sampling_bar, SIGNAL(instant_stop()), this, - SLOT(instant_stop())); - connect(_sampling_bar, SIGNAL(duration_changed()), _trigger_widget, - SLOT(device_updated())); - connect(_sampling_bar, SIGNAL(duration_changed()), _view, - SLOT(timebase_changed())); - connect(_sampling_bar, SIGNAL(show_calibration()), _view, - SLOT(show_calibration())); - connect(_trig_bar, SIGNAL(show_lissajous(bool)), _view, - SLOT(show_lissajous(bool))); - connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view, - SLOT(set_trig_pos(int))); - connect(_view, SIGNAL(auto_trig(int)), _dso_trigger_widget, - SLOT(auto_trig(int))); - + setIconSize(QSize(40,40)); addToolBar(_sampling_bar); addToolBar(_trig_bar); @@ -230,8 +185,7 @@ void MainWindow::setup_ui() _protocol_widget = new dock::ProtocolDock(_protocol_dock, *_view, _session); _protocol_dock->setWidget(_protocol_widget); qDebug() << "Protocol decoder enabled!\n"; - - connect(_protocol_widget, SIGNAL(protocol_updated()), _view, SLOT(signals_changed())); + #endif // measure dock _measure_dock=new QDockWidget(tr("Measurement"),this); @@ -265,35 +219,6 @@ void MainWindow::setup_ui() std::string std_title = title.toStdString(); setWindowTitle(QApplication::translate("MainWindow", std_title.c_str(), 0)); - // Setup _session events - connect(&_session, SIGNAL(capture_state_changed(int)), this, - SLOT(capture_state_changed(int))); - connect(&_session, SIGNAL(device_attach()), this, - SLOT(device_attach()), Qt::QueuedConnection); - connect(&_session, SIGNAL(device_detach()), this, - SLOT(device_detach()), Qt::QueuedConnection); - connect(&_session, SIGNAL(session_error()), this, - SLOT(show_error()), Qt::QueuedConnection); - connect(&_session, SIGNAL(session_save()), this, - SLOT(session_save())); - connect(&_session, SIGNAL(data_updated()), _measure_widget, - SLOT(reCalc())); - connect(&_session, SIGNAL(repeat_resume()), this, - SLOT(repeat_resume())); - connect(&_session, SIGNAL(update_capture()), _view, - SLOT(update_hori_res()), Qt::DirectConnection); - - connect(&_session, SIGNAL(cur_snap_samplerate_changed()), _measure_widget, - SLOT(cursor_update())); - connect(_view, SIGNAL(cursor_update()), _measure_widget, - SLOT(cursor_update())); - connect(_view, SIGNAL(cursor_moving()), _measure_widget, - SLOT(cursor_moving())); - connect(_view, SIGNAL(cursor_moved()), _measure_widget, - SLOT(reCalc())); - connect(_view, SIGNAL(prgRate(int)), this, SIGNAL(prgRate(int))); - connect(_view, SIGNAL(device_changed(bool)), - this, SLOT(device_changed(bool)), Qt::DirectConnection); // event filter _view->installEventFilter(this); @@ -330,6 +255,53 @@ void MainWindow::setup_ui() QString(tr("Hotplug failed")), _1)); retranslateUi(); + + + // Setup _session events + connect(&_session, SIGNAL(capture_state_changed(int)), this, SLOT(capture_state_changed(int))); + connect(&_session, SIGNAL(device_attach()), this, SLOT(device_attach()), Qt::QueuedConnection); + connect(&_session, SIGNAL(device_detach()), this, SLOT(device_detach()), Qt::QueuedConnection); + connect(&_session, SIGNAL(session_error()), this, SLOT(show_error()), Qt::QueuedConnection); + connect(&_session, SIGNAL(session_save()), this, SLOT(session_save())); + connect(&_session, SIGNAL(data_updated()), _measure_widget, SLOT(reCalc())); + connect(&_session, SIGNAL(repeat_resume()), this, SLOT(repeat_resume())); + connect(&_session, SIGNAL(update_capture()), _view, SLOT(update_hori_res()), Qt::DirectConnection); + connect(&_session, SIGNAL(cur_snap_samplerate_changed()), _measure_widget, SLOT(cursor_update())); + connect(_view, SIGNAL(cursor_update()), _measure_widget, SLOT(cursor_update())); + connect(_view, SIGNAL(cursor_moving()), _measure_widget, SLOT(cursor_moving())); + connect(_view, SIGNAL(cursor_moved()), _measure_widget, SLOT(reCalc())); + connect(_view, SIGNAL(prgRate(int)), this, SIGNAL(prgRate(int))); + connect(_view, SIGNAL(device_changed(bool)), this, SLOT(device_changed(bool)), Qt::DirectConnection); + + //tool bar event + connect(_trig_bar, SIGNAL(on_protocol(bool)), this, SLOT(on_protocol(bool))); + connect(_trig_bar, SIGNAL(on_trigger(bool)), this, SLOT(on_trigger(bool))); + connect(_trig_bar, SIGNAL(on_measure(bool)), this, SLOT(on_measure(bool))); + connect(_trig_bar, SIGNAL(on_search(bool)), this, SLOT(on_search(bool))); + connect(_trig_bar, SIGNAL(setTheme(QString)), this, SLOT(switchTheme(QString))); + connect(_file_bar, SIGNAL(load_file(QString)), this, SLOT(load_file(QString))); + connect(_file_bar, SIGNAL(on_save()), this, SLOT(on_save())); + connect(_file_bar, SIGNAL(on_export()), this, SLOT(on_export())); + connect(_file_bar, SIGNAL(on_screenShot()), this, SLOT(on_screenShot()), Qt::QueuedConnection); + connect(_file_bar, SIGNAL(load_session(QString)), this, SLOT(load_session(QString))); + connect(_file_bar, SIGNAL(store_session(QString)), this, SLOT(store_session(QString))); + connect(_logo_bar, SIGNAL(setLanguage(int)), this, SLOT(switchLanguage(int))); + connect(_logo_bar, SIGNAL(openDoc()), this, SLOT(openDoc())); + +#ifdef ENABLE_DECODE + connect(_protocol_widget, SIGNAL(protocol_updated()), _view, SLOT(signals_changed())); +#endif + + connect(_sampling_bar, SIGNAL(device_selected()), this, SLOT(update_device_list())); + connect(_sampling_bar, SIGNAL(device_updated()), this, SLOT(reload())); + connect(_sampling_bar, SIGNAL(run_stop()), this, SLOT(run_stop())); + connect(_sampling_bar, SIGNAL(instant_stop()), this, SLOT(instant_stop())); + connect(_sampling_bar, SIGNAL(duration_changed()), _trigger_widget, SLOT(device_updated())); + connect(_sampling_bar, SIGNAL(duration_changed()), _view, SLOT(timebase_changed())); + connect(_sampling_bar, SIGNAL(show_calibration()), _view, SLOT(show_calibration())); + connect(_trig_bar, SIGNAL(show_lissajous(bool)), _view, SLOT(show_lissajous(bool))); + connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view, SLOT(set_trig_pos(int))); + connect(_view, SIGNAL(auto_trig(int)), _dso_trigger_widget, SLOT(auto_trig(int))); } diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index 0d37207a..ca8c51d2 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -568,6 +568,7 @@ QString StoreSession::meta_gen(boost::shared_ptr snapshot) return metafile; } +//export as csv file bool StoreSession::export_start() { std::set type_set; @@ -596,6 +597,7 @@ bool StoreSession::export_start() const QString DIR_KEY("ExportPath"); QSettings settings(QApplication::organizationName(), QApplication::applicationName()); QString default_name = settings.value(DIR_KEY).toString() + "/" + _session.get_device()->name() + "-"; + for (const GSList *l = _session.get_device()->get_dev_mode_list(); l; l = l->next) { const sr_dev_mode *mode = (const sr_dev_mode *)l->data; @@ -616,6 +618,7 @@ bool StoreSession::export_start() } _file_name = QFileDialog::getSaveFileName( NULL, tr("Export Data"), default_name,filter,&filter); + if (!_file_name.isEmpty()) { QFileInfo f(_file_name); QStringList list = filter.split('.').last().split(')'); @@ -681,6 +684,7 @@ void StoreSession::export_proc(shared_ptr snapshot) output.param = NULL; if(_outModule->init) _outModule->init(&output, params); + QFile file(_file_name); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); @@ -692,9 +696,11 @@ void StoreSession::export_proc(shared_ptr snapshot) struct sr_datafeed_packet p; struct sr_datafeed_meta meta; struct sr_config *src; + src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(_session.cur_snap_samplerate())); meta.config = g_slist_append(NULL, src); + src = sr_config_new(SR_CONF_LIMIT_SAMPLES, g_variant_new_uint64(snapshot->get_sample_count())); meta.config = g_slist_append(meta.config, src); @@ -743,6 +749,7 @@ void StoreSession::export_proc(shared_ptr snapshot) bool sample; std::vector buf_vec; std::vector buf_sample; + for (int blk = 0; !boost::this_thread::interruption_requested() && blk < blk_num; blk++) { uint64_t buf_sample_num = logic_snapshot->get_block_size(blk) * 8; @@ -764,6 +771,7 @@ void StoreSession::export_proc(shared_ptr snapshot) unsigned int usize = 8192; unsigned int size = usize; struct sr_datafeed_logic lp; + for(uint64_t i = 0; !boost::this_thread::interruption_requested() && i < buf_sample_num; i+=usize){ if(buf_sample_num - i < usize) @@ -773,8 +781,9 @@ void StoreSession::export_proc(shared_ptr snapshot) _has_error = true; _error = tr("xbuffer malloc failed."); return; - } + } memset(xbuf, 0, size * unitsize); + for (uint64_t j = 0; j < size; j++) { for (unsigned int k = 0; k < buf_vec.size(); k++) { if (buf_vec[k] == NULL && buf_sample[k]) @@ -783,6 +792,7 @@ void StoreSession::export_proc(shared_ptr snapshot) xbuf[j*unitsize+k/8] += 1 << k%8; } } + lp.data = xbuf; lp.length = size * unitsize; lp.unitsize = unitsize; @@ -790,6 +800,7 @@ void StoreSession::export_proc(shared_ptr snapshot) p.status = SR_PKT_OK; p.payload = &lp; _outModule->receive(&output, &p, &data_out); + if(data_out){ out << QString::fromUtf8((char*) data_out->str); g_string_free(data_out,TRUE); @@ -801,35 +812,41 @@ void StoreSession::export_proc(shared_ptr snapshot) progress_updated(); } } + } else if (channel_type == SR_CHANNEL_DSO) { _unit_count = snapshot->get_sample_count(); unsigned char* datat = (unsigned char*)snapshot->get_data(); unsigned int usize = 8192; unsigned int size = usize; - struct sr_datafeed_dso dp; + struct sr_datafeed_dso dp; + for(uint64_t i = 0; !boost::this_thread::interruption_requested() && i < _unit_count; i+=usize){ if(_unit_count - i < usize) size = _unit_count - i; + dp.data = &datat[i*snapshot->get_channel_num()]; dp.num_samples = size; p.type = SR_DF_DSO; p.status = SR_PKT_OK; p.payload = &dp; _outModule->receive(&output, &p, &data_out); + if(data_out){ out << (char*) data_out->str; g_string_free(data_out,TRUE); } - + _units_stored += size; progress_updated(); } + } else if (channel_type == SR_CHANNEL_ANALOG) { _unit_count = snapshot->get_sample_count(); unsigned char* datat = (unsigned char*)snapshot->get_data(); unsigned int usize = 8192; unsigned int size = usize; struct sr_datafeed_analog ap; + for(uint64_t i = 0; !boost::this_thread::interruption_requested() && i < _unit_count; i+=usize){ if(_unit_count - i < usize) size = _unit_count - i; diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/pv/toolbars/filebar.cpp index 5efbca7f..ea0b47ac 100755 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/pv/toolbars/filebar.cpp @@ -47,16 +47,13 @@ FileBar::FileBar(SigSession &session, QWidget *parent) : _action_load = new QAction(this); _action_load->setObjectName(QString::fromUtf8("actionLoad")); - connect(_action_load, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered())); - + _action_store = new QAction(this); _action_store->setObjectName(QString::fromUtf8("actionStore")); - connect(_action_store, SIGNAL(triggered()), this, SLOT(on_actionStore_triggered())); - + _action_default = new QAction(this); _action_default->setObjectName(QString::fromUtf8("actionDefault")); - connect(_action_default, SIGNAL(triggered()), this, SLOT(on_actionDefault_triggered())); - + _menu_session = new QMenu(this); _menu_session->setObjectName(QString::fromUtf8("menuSession")); _menu_session->addAction(_action_load); @@ -65,21 +62,16 @@ FileBar::FileBar(SigSession &session, QWidget *parent) : _action_open = new QAction(this); _action_open->setObjectName(QString::fromUtf8("actionOpen")); - connect(_action_open, SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered())); - + _action_save = new QAction(this); _action_save->setObjectName(QString::fromUtf8("actionSave")); - connect(_action_save, SIGNAL(triggered()), this, SIGNAL(on_save())); - + _action_export = new QAction(this); _action_export->setObjectName(QString::fromUtf8("actionExport")); - connect(_action_export, SIGNAL(triggered()), this, SIGNAL(on_export())); - - + _action_capture = new QAction(this); _action_capture->setObjectName(QString::fromUtf8("actionCapture")); - connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered())); - + _file_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); _file_button.setPopupMode(QToolButton::InstantPopup); @@ -93,6 +85,14 @@ FileBar::FileBar(SigSession &session, QWidget *parent) : addWidget(&_file_button); retranslateUi(); + + connect(_action_load, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered())); + connect(_action_store, SIGNAL(triggered()), this, SLOT(on_actionStore_triggered())); + connect(_action_default, SIGNAL(triggered()), this, SLOT(on_actionDefault_triggered())); + connect(_action_open, SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered())); + connect(_action_save, SIGNAL(triggered()), this, SIGNAL(on_save())); + connect(_action_export, SIGNAL(triggered()), this, SIGNAL(on_export())); + connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered())); } void FileBar::changeEvent(QEvent *event)