add view quick scroll check flag

This commit is contained in:
dreamsourcelabTAI 2021-10-25 15:16:30 +08:00
parent dd2630c4fb
commit 1afaf9d53c
19 changed files with 175 additions and 74 deletions

View File

@ -72,7 +72,7 @@ void StringToFormatArray(const QString &str, vector<StringPair> &protocolFormats
AppConfig::AppConfig()
{
_appOptions.quickScroll = true;
}
AppConfig::~AppConfig()
@ -135,6 +135,12 @@ bool AppConfig::Save()
QString profomats = FormatArrayToString(m_protocolFormats);
jobj["ProtocolFormats"] = QJsonValue::fromVariant(profomats);
//application options
QJsonObject app;
app["QuickScroll"] = QJsonValue::fromVariant(_appOptions.quickScroll);
jobj["Application"] = QJsonValue::fromVariant(app);
QJsonDocument jdoc(jobj);
QByteArray bytes = jdoc.toJson();
string json;
@ -155,6 +161,12 @@ bool AppConfig::Save()
m_protocolFormats.clear();
StringToFormatArray(jobj["ProtocolFormats"].toString(), m_protocolFormats);
}
//application node
if (jobj.contains("Application")){
QJsonObject app = jobj["Application"].toObject();
_appOptions.quickScroll = app["QuickScroll"].toBool();
}
}
void AppConfig::SetProtocolFormat(const string &protocolName, const string &value)

View File

@ -26,13 +26,7 @@
#include <vector>
using namespace std;
struct app_status{
};
class StringPair
{
public:
@ -41,13 +35,12 @@ public:
string m_value;
};
class config_data
{
public:
struct AppOptions
{
bool quickScroll;
};
class AppConfig
{
private:
@ -63,11 +56,10 @@ public:
void FromJson(string &json);
void SetProtocolFormat(const string &protocolName, const string &value);
string GetProtocolFormat(const string &protocolName);
string GetProtocolFormat(const string &protocolName);
public:
config_data m_data;
app_status m_status;
AppOptions _appOptions;
private:
string m_fileName;

View File

@ -21,6 +21,10 @@
#include "applicationpardlg.h"
#include "dsdialog.h"
#include <QFormLayout>
#include <QCheckBox>
#include <QString>
#include "../config/appconfig.h"
namespace pv
{
@ -29,7 +33,7 @@ namespace dialogs
ApplicationParamDlg::ApplicationParamDlg()
{
m_ret = false;
}
ApplicationParamDlg::~ApplicationParamDlg()
@ -39,14 +43,32 @@ ApplicationParamDlg::~ApplicationParamDlg()
bool ApplicationParamDlg::ShowDlg(QWidget *parent)
{
DSDialog dlg(parent, true, true);
dlg.exec();
return m_ret;
}
dlg.setMinimumSize(300, 200);
QFormLayout &lay = *(new QFormLayout());
lay.setContentsMargins(0,20,0,30);
//------------IDlgCallback
void ApplicationParamDlg::OnDlgResult(bool bYes){
m_ret = bYes;
}
//show config
AppOptions &_app = AppConfig::Instance()._appOptions;
QCheckBox *ck_quickScroll = new QCheckBox();
ck_quickScroll->setChecked(_app.quickScroll);
lay.addRow("Quick scroll", ck_quickScroll);
dlg.layout()->addLayout(&lay);
dlg.exec();
bool ret = dlg.IsClickYes();
//save config
if (ret){
_app.quickScroll = ck_quickScroll->isChecked();
AppConfig::Instance().Save();
}
return ret;
}
} //
}//

View File

@ -23,14 +23,13 @@
#include <QObject>
#include <QWidget>
#include "../interface/uicallback.h"
namespace pv
{
namespace dialogs
{
class ApplicationParamDlg : private IDlgCallback
class ApplicationParamDlg
{
// Q_OBJECT
@ -44,8 +43,7 @@ namespace pv
private:
void OnDlgResult(bool bYes);
private:
bool m_ret;
};
}//

View File

@ -31,6 +31,7 @@
#include "../view/trace.h"
#include "../dialogs/dsmessagebox.h"
#include "../dsvdef.h"
using namespace boost;
using namespace std;
@ -44,7 +45,13 @@ const QString Calibration::VCOMB = QT_TR_NOOP(" VCOMB");
Calibration::Calibration(QWidget *parent) :
DSDialog(parent)
{
{
_save_btn = NULL;
_abort_btn = NULL;
_reset_btn = NULL;
_exit_btn = NULL;
_flayout = NULL;
#ifdef Q_OS_DARWIN
Qt::WindowFlags flags = windowFlags();
this->setWindowFlags(flags | Qt::Tool);
@ -89,6 +96,14 @@ Calibration::Calibration(QWidget *parent) :
retranslateUi();
}
Calibration::~Calibration(){
DESTROY_QT_OBJECT(_save_btn);
DESTROY_QT_OBJECT(_abort_btn);
DESTROY_QT_OBJECT(_reset_btn);
DESTROY_QT_OBJECT(_exit_btn);
DESTROY_QT_OBJECT(_flayout);
}
void Calibration::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)

View File

@ -50,6 +50,7 @@ private:
public:
Calibration(QWidget *parent);
~Calibration();
void set_device(boost::shared_ptr<pv::device::DevInst> dev_inst);
protected:
@ -69,8 +70,7 @@ private slots:
private:
boost::shared_ptr<pv::device::DevInst> _dev_inst;
toolbars::TitleBar *_titlebar;
QPushButton *_save_btn;
QPushButton *_abort_btn;
QPushButton *_reset_btn;

View File

@ -30,10 +30,11 @@
#include "dsmessagebox.h"
#include <pv/prop/property.h>
#include "../dsvdef.h"
using namespace boost;
using namespace std;
namespace pv {
namespace dialogs {
@ -43,6 +44,11 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
_button_box(QDialogButtonBox::Ok, Qt::Horizontal, this),
_device_options_binding(_dev_inst->dev_inst())
{
_dynamic_box = NULL;
_props_box = NULL;
_config_button = NULL;
_cali_button = NULL;
_props_box = new QGroupBox(tr("Mode"), this);
_props_box->setLayout(get_property_form(_props_box));
_layout.addWidget(_props_box);
@ -73,6 +79,13 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
_mode_check.start();
}
DeviceOptions::~DeviceOptions(){
DESTROY_QT_OBJECT(_dynamic_box);
DESTROY_QT_OBJECT(_props_box);
DESTROY_QT_OBJECT(_config_button);
DESTROY_QT_OBJECT(_cali_button);
}
void DeviceOptions::accept()
{
using namespace Qt;

View File

@ -57,6 +57,8 @@ class DeviceOptions : public DSDialog
public:
DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevInst> dev_inst);
~DeviceOptions();
protected:
void accept();
void reject();
@ -84,8 +86,7 @@ private slots:
private:
boost::shared_ptr<pv::device::DevInst> _dev_inst;
QVBoxLayout _layout;
toolbars::TitleBar *_titlebar;
QVBoxLayout _layout;
QGroupBox *_dynamic_box;
QGridLayout _dynamic_layout;

View File

@ -59,6 +59,7 @@ DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) :
_base_button = NULL;
m_callback = NULL;
_clickYes = false;
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
setAttribute(Qt::WA_TranslucentBackground);
@ -80,19 +81,23 @@ void DSDialog::accept()
{
using namespace Qt;
_clickYes = true;
if (m_callback){
m_callback->OnDlgResult(true);
}
QDialog::accept();
}
void DSDialog::reject()
{
using namespace Qt;
_clickYes = false;
if (m_callback){
m_callback->OnDlgResult(false);
}
}
QDialog::reject();
}
@ -114,7 +119,8 @@ int DSDialog::exec()
//ok,cancel
if (m_bBaseButton){
_base_button = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal, this);
_main_layout->addWidget(_base_button);//, 5, 1, 1, 1, Qt::AlignHCenter | Qt::AlignBottom);
_main_layout->addWidget(_base_button);//, 5, 1, 1, 1, Qt::AlignHCenter | Qt::AlignBottom);
//_main_layout->addWidget(_base_button,0, Qt::AlignHCenter | Qt::AlignBottom);
connect(_base_button, SIGNAL(rejected()), this, SLOT(reject()));
connect(_base_button, SIGNAL(accepted()), this, SLOT(accept()));
}
@ -142,6 +148,9 @@ void DSDialog::build_base(bool hasClose)
_main_layout->addWidget(_titlebar);
_base_layout->addWidget(_main_widget);
setLayout(_base_layout);
_main_layout->setAlignment(Qt::AlignCenter | Qt::AlignTop);
}
} // namespace dialogs

View File

@ -56,6 +56,7 @@ public:
void setTitle(QString title);
void reload();
int exec();
inline bool IsClickYes(){return _clickYes;}
protected:
void accept();
@ -74,6 +75,7 @@ private:
QPoint _startPos;
bool m_bBaseButton;
bool _clickYes;
IDlgCallback *m_callback;
};

View File

@ -31,6 +31,7 @@
#include <QBitmap>
#include <boost/foreach.hpp>
#include "../dsvdef.h"
using namespace boost;
using namespace std;
@ -48,6 +49,8 @@ DsoMeasure::DsoMeasure(SigSession &session, View &parent,
_button_box(QDialogButtonBox::Reset | QDialogButtonBox::Cancel,
Qt::Horizontal, this)
{
_measure_tab = NULL;
setMinimumSize(500, 400);
_measure_tab = new QTabWidget(this);
@ -79,6 +82,10 @@ DsoMeasure::DsoMeasure(SigSession &session, View &parent,
connect(_session.get_device().get(), SIGNAL(device_updated()), this, SLOT(reject()));
}
DsoMeasure::~DsoMeasure(){
DESTROY_QT_OBJECT(_measure_tab);
}
void DsoMeasure::add_measure(QWidget *widget, const boost::shared_ptr<view::DsoSignal> dsoSig)
{
const int Column = 5;
@ -86,6 +93,7 @@ void DsoMeasure::add_measure(QWidget *widget, const boost::shared_ptr<view::DsoS
QGridLayout *layout = new QGridLayout(widget);
layout->setMargin(0);
layout->setSpacing(0);
for (int i=DSO_MS_BEGIN+1; i<DSO_MS_END; i++) {
QToolButton *button = new QToolButton(this);
button->setProperty("id", QVariant(i));

View File

@ -49,8 +49,9 @@ class DsoMeasure : public DSDialog
Q_OBJECT
public:
DsoMeasure(SigSession &session, view::View &parent,
unsigned int position, int last_sig_index);
DsoMeasure(SigSession &session, view::View &parent, unsigned int position, int last_sig_index);
~DsoMeasure();
static QString get_ms_icon(int ms_type);
static QString get_ms_text(int ms_type);
@ -70,12 +71,10 @@ private:
SigSession &_session;
view::View &_view;
unsigned int _position;
toolbars::TitleBar *_titlebar;
QDialogButtonBox _button_box;
QTabWidget *_measure_tab;
QVBoxLayout _layout;
std::vector<QToolButton *> _mbtn_vec;
QVBoxLayout _layout;
};
} // namespace dialogs

View File

@ -34,7 +34,7 @@
using namespace boost;
using namespace std;
namespace pv {
namespace dialogs {
@ -44,6 +44,18 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
_button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this)
{
_len_combobox = NULL;
_interval_combobox = NULL;
_en_checkbox = NULL;
_ch_combobox = NULL;
_window_combobox = NULL;
_dc_checkbox = NULL;
_view_combobox = NULL;
_dbv_combobox = NULL;
_hint_label = NULL;
_glayout = NULL;
_layout = NULL;
_en_checkbox = new QCheckBox(this);
_len_combobox = new QComboBox(this);
_interval_combobox = new QComboBox(this);
@ -173,7 +185,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
QPixmap pixmap(hint_pic);
_hint_label->setPixmap(pixmap);
_glayout = new QGridLayout();
_glayout = new QGridLayout(); //QGridLayout
_glayout->setVerticalSpacing(5);
_glayout->addWidget(new QLabel(tr("FFT Enable: "), this), 0, 0);
_glayout->addWidget(_en_checkbox, 0, 1);
@ -208,6 +220,10 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
connect(_session.get_device().get(), SIGNAL(device_updated()), this, SLOT(reject()));
}
FftOptions::~FftOptions(){
}
void FftOptions::accept()
{
using namespace Qt;

View File

@ -52,6 +52,8 @@ private:
public:
FftOptions(QWidget *parent, SigSession &session);
~FftOptions();
protected:
void accept();
void reject();
@ -63,8 +65,7 @@ private slots:
private:
SigSession &_session;
uint64_t _sample_limit;
toolbars::TitleBar *_titlebar;
QComboBox *_len_combobox;
QComboBox *_interval_combobox;
QCheckBox *_en_checkbox;

View File

@ -32,6 +32,11 @@ Interval::Interval(SigSession &session, QWidget *parent) :
_button_box(QDialogButtonBox::Ok,
Qt::Horizontal, this)
{
_interval_label = NULL;
_interval_spinBox = NULL;
_interval_slider = NULL;
setMinimumWidth(300);
_interval_label = new QLabel(tr("Interval(s): "), this);
_interval_spinBox = new QSpinBox(this);

View File

@ -33,6 +33,7 @@
#include <boost/foreach.hpp>
using namespace boost;
using namespace std;
using namespace pv::view;
@ -46,6 +47,12 @@ LissajousOptions::LissajousOptions(SigSession &session, QWidget *parent) :
_button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this)
{
_enable = NULL;
_x_group = NULL;
_y_group = NULL;
_percent = NULL;
_layout = NULL;
setMinimumSize(300, 300);
_enable = new QCheckBox(this);

View File

@ -73,10 +73,11 @@ private:
QGroupBox *_x_group;
QGroupBox *_y_group;
QSlider *_percent;
QGridLayout *_layout;
QVector<QRadioButton *> _x_radio;
QVector<QRadioButton *> _y_radio;
QDialogButtonBox _button_box;
QGridLayout *_layout;
QDialogButtonBox _button_box;
};
} // namespace dialogs

View File

@ -316,9 +316,8 @@ void TrigBar::on_actionLissajous_triggered()
}
void TrigBar::on_application_param(){
pv::dialogs::MathOptions math_dlg(_session, this);
math_dlg.exec();
return;
// pv::dialogs::MathOptions math_dlg(_session, this); math_dlg.exec(); return;
pv::dialogs::ApplicationParamDlg dlg;
dlg.ShowDlg(this);
}

View File

@ -37,12 +37,12 @@
#include <QMouseEvent>
#include <QStyleOption>
#include <QPainterPath>
#include <math.h>
#include <QPainterPath>
#include <math.h>
#include <boost/foreach.hpp>
#include "../config/appconfig.h"
using namespace boost;
using namespace std;
@ -91,24 +91,20 @@ Viewport::Viewport(View &parent, View_type type) :
// drag inertial
_drag_strength = 0;
_drag_timer.setSingleShot(true);
connect(&trigger_timer, SIGNAL(timeout()),
this, SLOT(on_trigger_timer()));
connect(&_drag_timer, SIGNAL(timeout()),
this, SLOT(on_drag_timer()));
connect(&_view.session(), &SigSession::receive_data,
this, &Viewport::set_receive_len);
_cmenu = new QMenu(this);
QAction *yAction = _cmenu->addAction(tr("Add Y-cursor"));
QAction *xAction = _cmenu->addAction(tr("Add X-cursor"));
setContextMenuPolicy(Qt::CustomContextMenu);
connect(&trigger_timer, SIGNAL(timeout()),this, SLOT(on_trigger_timer()));
connect(&_drag_timer, SIGNAL(timeout()),this, SLOT(on_drag_timer()));
connect(&_view.session(), &SigSession::receive_data, this, &Viewport::set_receive_len);
connect(yAction, SIGNAL(triggered(bool)), this, SLOT(add_cursor_y()));
connect(xAction, SIGNAL(triggered(bool)), this, SLOT(add_cursor_x()));
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(show_contextmenu(const QPoint&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(show_contextmenu(const QPoint&)));
}
int Viewport::get_total_height() const
@ -757,14 +753,19 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
void Viewport::mouseReleaseEvent(QMouseEvent *event)
{
assert(event);
if (_type == TIME_VIEW) {
if (_type != TIME_VIEW){
update();
return;
}
if ((_action_type == NO_ACTION) &&
(event->button() == Qt::LeftButton)) {
if (_view.session().get_device()->dev_inst()->mode == LOGIC &&
_view.session().get_capture_state() == SigSession::Stopped) {
// priority 1
if (_action_type == NO_ACTION) {
//priority 1
//try to quick scroll view
if (_action_type == NO_ACTION && AppConfig::Instance()._appOptions.quickScroll) {
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
if (_elapsed_time.elapsed() < 200 &&
abs(_drag_strength) < MinorDragOffsetUp &&
@ -936,7 +937,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
}
_action_type = NO_ACTION;
}
}
update();
}
@ -1621,7 +1622,7 @@ void Viewport::on_trigger_timer()
}
void Viewport::on_drag_timer()
{
{
const int64_t offset = _view.offset();
const double scale = _view.scale();
if (_view.session().get_capture_state() == SigSession::Stopped &&