diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index ac5d1c28..44c62989 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -72,7 +72,7 @@ void StringToFormatArray(const QString &str, vector &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) diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index ec2b2ee1..a5c93aea 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -26,13 +26,7 @@ #include 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; diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index 26e07484..b27da3a5 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -21,6 +21,10 @@ #include "applicationpardlg.h" #include "dsdialog.h" +#include +#include +#include +#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; +} + } // }// diff --git a/DSView/pv/dialogs/applicationpardlg.h b/DSView/pv/dialogs/applicationpardlg.h index 71e35d51..e890c985 100644 --- a/DSView/pv/dialogs/applicationpardlg.h +++ b/DSView/pv/dialogs/applicationpardlg.h @@ -23,14 +23,13 @@ #include #include -#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; + }; }// diff --git a/DSView/pv/dialogs/calibration.cpp b/DSView/pv/dialogs/calibration.cpp index 36298622..e91d1722 100755 --- a/DSView/pv/dialogs/calibration.cpp +++ b/DSView/pv/dialogs/calibration.cpp @@ -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) diff --git a/DSView/pv/dialogs/calibration.h b/DSView/pv/dialogs/calibration.h index 97bf7ce2..8418606e 100755 --- a/DSView/pv/dialogs/calibration.h +++ b/DSView/pv/dialogs/calibration.h @@ -50,6 +50,7 @@ private: public: Calibration(QWidget *parent); + ~Calibration(); void set_device(boost::shared_ptr dev_inst); protected: @@ -69,8 +70,7 @@ private slots: private: boost::shared_ptr _dev_inst; - - toolbars::TitleBar *_titlebar; + QPushButton *_save_btn; QPushButton *_abort_btn; QPushButton *_reset_btn; diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index 3ac73ad2..fe8513ed 100755 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -30,10 +30,11 @@ #include "dsmessagebox.h" #include +#include "../dsvdef.h" using namespace boost; using namespace std; - + namespace pv { namespace dialogs { @@ -43,6 +44,11 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptrdev_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 dev_inst); + ~DeviceOptions(); + protected: void accept(); void reject(); @@ -84,8 +86,7 @@ private slots: private: boost::shared_ptr _dev_inst; - QVBoxLayout _layout; - toolbars::TitleBar *_titlebar; + QVBoxLayout _layout; QGroupBox *_dynamic_box; QGridLayout _dynamic_layout; diff --git a/DSView/pv/dialogs/dsdialog.cpp b/DSView/pv/dialogs/dsdialog.cpp index 81165b3f..1d8f15ff 100755 --- a/DSView/pv/dialogs/dsdialog.cpp +++ b/DSView/pv/dialogs/dsdialog.cpp @@ -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 diff --git a/DSView/pv/dialogs/dsdialog.h b/DSView/pv/dialogs/dsdialog.h index 22799aa2..00f83ef7 100755 --- a/DSView/pv/dialogs/dsdialog.h +++ b/DSView/pv/dialogs/dsdialog.h @@ -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; }; diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/pv/dialogs/dsomeasure.cpp index d1acaa19..a454d86c 100755 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/pv/dialogs/dsomeasure.cpp @@ -31,6 +31,7 @@ #include #include +#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 dsoSig) { const int Column = 5; @@ -86,6 +93,7 @@ void DsoMeasure::add_measure(QWidget *widget, const boost::shared_ptrsetMargin(0); layout->setSpacing(0); + for (int i=DSO_MS_BEGIN+1; isetProperty("id", QVariant(i)); diff --git a/DSView/pv/dialogs/dsomeasure.h b/DSView/pv/dialogs/dsomeasure.h index ab9c25ea..5016fda7 100755 --- a/DSView/pv/dialogs/dsomeasure.h +++ b/DSView/pv/dialogs/dsomeasure.h @@ -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 _mbtn_vec; + QVBoxLayout _layout; }; } // namespace dialogs diff --git a/DSView/pv/dialogs/fftoptions.cpp b/DSView/pv/dialogs/fftoptions.cpp index 3436ff7f..9202500d 100755 --- a/DSView/pv/dialogs/fftoptions.cpp +++ b/DSView/pv/dialogs/fftoptions.cpp @@ -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; diff --git a/DSView/pv/dialogs/fftoptions.h b/DSView/pv/dialogs/fftoptions.h index b16dfe60..2486c871 100755 --- a/DSView/pv/dialogs/fftoptions.h +++ b/DSView/pv/dialogs/fftoptions.h @@ -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; diff --git a/DSView/pv/dialogs/interval.cpp b/DSView/pv/dialogs/interval.cpp index e2ff752b..7ab456b7 100755 --- a/DSView/pv/dialogs/interval.cpp +++ b/DSView/pv/dialogs/interval.cpp @@ -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); diff --git a/DSView/pv/dialogs/lissajousoptions.cpp b/DSView/pv/dialogs/lissajousoptions.cpp index 5f502f81..02c98167 100755 --- a/DSView/pv/dialogs/lissajousoptions.cpp +++ b/DSView/pv/dialogs/lissajousoptions.cpp @@ -33,6 +33,7 @@ #include + 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); diff --git a/DSView/pv/dialogs/lissajousoptions.h b/DSView/pv/dialogs/lissajousoptions.h index b3fd13f1..b0653548 100755 --- a/DSView/pv/dialogs/lissajousoptions.h +++ b/DSView/pv/dialogs/lissajousoptions.h @@ -73,10 +73,11 @@ private: QGroupBox *_x_group; QGroupBox *_y_group; QSlider *_percent; + QGridLayout *_layout; + QVector _x_radio; QVector _y_radio; - QDialogButtonBox _button_box; - QGridLayout *_layout; + QDialogButtonBox _button_box; }; } // namespace dialogs diff --git a/DSView/pv/toolbars/trigbar.cpp b/DSView/pv/toolbars/trigbar.cpp index d63d857b..95f336f4 100755 --- a/DSView/pv/toolbars/trigbar.cpp +++ b/DSView/pv/toolbars/trigbar.cpp @@ -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); } diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 141884c8..1bf6720f 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -37,12 +37,12 @@ #include #include -#include - -#include - +#include +#include #include +#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 &&