From 3a4e7cabf8d1f768ad5e75dbd9207cca2d63f71d Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 13 Jun 2022 09:24:56 +0800 Subject: [PATCH 1/5] fix: the comboBox width is inadequate on mac os --- DSView/pv/ui/dscombobox.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/DSView/pv/ui/dscombobox.cpp b/DSView/pv/ui/dscombobox.cpp index cc3e38c5..b57c66d8 100644 --- a/DSView/pv/ui/dscombobox.cpp +++ b/DSView/pv/ui/dscombobox.cpp @@ -25,6 +25,11 @@ #include #include +#ifdef Q_OS_DARWIN +#include +#include +#endif + #include "../config/appconfig.h" DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent) @@ -62,8 +67,13 @@ DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent) int x = rc.left() + 6; int y = rc.top(); int w = rc.right() - rc.left(); - int h = rc.bottom() - rc.top() + 15; + int h = rc.bottom() - rc.top() + 20; popup->setGeometry(x, y, w, h); + + int sy = QGuiApplication::primaryScreen()->size().height(); + if (sy <= 1080){ + popup->setMaximumHeight(750); + } if (AppConfig::Instance()._frameOptions.style == THEME_STYLE_DARK){ popup->setStyleSheet("background-color:#262626;"); From 65ec20cd6147ef854037b9b43bf6086bc30c89bc Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 13 Jun 2022 11:16:17 +0800 Subject: [PATCH 2/5] fix: on mac, the device options dailog scroll bar is hiden --- DSView/pv/dialogs/deviceoptions.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index a2636573..769484e9 100755 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -352,6 +352,11 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout) line_lay->addWidget(disable_all_probes); _groupHeight2 = contentHeight + (row1 + row2) * 2 + 38; + +#ifdef Q_OS_DARWIN + _groupHeight2 += 5; +#endif + _dynamic_panel->setFixedHeight(_groupHeight2); } @@ -713,6 +718,11 @@ void DeviceOptions::try_resize_scroll() int contentHeight = _groupHeight1 + _groupHeight2 + 10; // +space //dialog height int dlgHeight = contentHeight + 100; // +bottom buttton + +#ifdef Q_OS_DARWIN + dlgHeight += 20; +#endif + float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96; int srcHeight = 600; @@ -735,19 +745,24 @@ void DeviceOptions::try_resize_scroll() } _container_panel->setFixedHeight(contentHeight); + int sclw = w - 23; + +#ifdef Q_OS_DARWIN + sclw -= 20; +#endif if (sk * dlgHeight > srcHeight) { int exth = 120; this->setFixedSize(w + 12, srcHeight); _scroll_panel->setFixedSize(w, srcHeight - exth); - _scroll->setFixedSize(w - 23, srcHeight - exth); + _scroll->setFixedSize(sclw, srcHeight - exth); } else { this->setFixedSize(w + 12, dlgHeight); _scroll_panel->setFixedSize(w, contentHeight); - _scroll->setFixedSize(w - 23, contentHeight); + _scroll->setFixedSize(sclw, contentHeight); } } From 3ae76506022c9f65cff8b4780f158a900c6f3f13 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 13 Jun 2022 19:09:09 +0800 Subject: [PATCH 3/5] fix: on mac, the decoder options dailog scroll bar is hidden --- DSView/pv/dialogs/decoderoptionsdlg.cpp | 77 ++++++++++++------------- DSView/pv/dialogs/decoderoptionsdlg.h | 2 + 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/pv/dialogs/decoderoptionsdlg.cpp index f11a4520..50636bdf 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/pv/dialogs/decoderoptionsdlg.cpp @@ -57,6 +57,7 @@ DecoderOptionsDlg::DecoderOptionsDlg(QWidget *parent) { _cursor1 = 0; _cursor2 = 0; + _contentHeight = 0; } DecoderOptionsDlg::~DecoderOptionsDlg() @@ -73,7 +74,6 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) _trace = trace; DSDialog *dlg = this; - QWidget *line = NULL; QFormLayout *form = new QFormLayout(); form->setContentsMargins(0, 0, 0, 0); @@ -94,25 +94,19 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) form->addRow(scroll_pannel); // decoder options - QWidget *decoder_container = new QWidget(); + QWidget *container_panel = new QWidget(); QVBoxLayout *decoder_lay = new QVBoxLayout(); decoder_lay->setContentsMargins(0, 0, 0, 0); decoder_lay->setDirection(QBoxLayout::TopToBottom); - decoder_container->setLayout(decoder_lay); - // form->addRow(decoder_container); - scroll_lay->addWidget(decoder_container); + container_panel->setLayout(decoder_lay); + // form->addRow(container_panel); + scroll_lay->addWidget(container_panel); - load_decoder_forms(decoder_container); + load_decoder_forms(container_panel); if (_trace->decoder()->stack().size() > 0){ // form->addRow(new QLabel(tr("* Required channels"), dlg)); - } - - //line - line = new QWidget(); - line->setMinimumHeight(3); - line->setMaximumHeight(3); - form->addRow(line); + } //Add region combobox _start_comboBox = new DsComboBox(dlg); @@ -153,46 +147,57 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) _end_comboBox->setCurrentIndex(dex2); update_decode_range(); // set default sample range - + form->addRow(_start_comboBox, new QLabel( tr("The cursor for decode start time"))); form->addRow(_end_comboBox, new QLabel( tr("The cursor for decode end time"))); + //space + QWidget *space = new QWidget(); + space->setFixedHeight(5); + form->addRow(space); + // Add ButtonBox (OK/Cancel) QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dlg); - - //line - line = new QWidget(); - line->setMinimumHeight(20); - form->addRow(line); - QHBoxLayout *confirm_button_box = new QHBoxLayout; confirm_button_box->addWidget(button_box, 0, Qt::AlignRight); form->addRow(confirm_button_box); // scroll QSize tsize = dlg->sizeHint(); - int w = tsize.width(); - int h = tsize.height(); + int w = tsize.width(); + int other_height = 190; + _contentHeight += 5; +#ifdef Q_OS_DARWIN + other_height += 40; +#endif + + int dlgHeight = _contentHeight + other_height; + float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96; - int srcHeight = QGuiApplication::primaryScreen()->availableSize().height(); - if (srcHeight > 600) - srcHeight = 600; + int srcHeight = 600; + container_panel->setFixedHeight(_contentHeight); - if (h * sk > srcHeight) - { - int other_height = 235; + if (dlgHeight * sk > srcHeight) + { QScrollArea *scroll = new QScrollArea(scroll_pannel); - scroll->setWidget(decoder_container); + scroll->setWidget(container_panel); scroll->setStyleSheet("QScrollArea{border:none;}"); scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); dlg->setFixedSize(w + 20, srcHeight); scroll_pannel->setFixedSize(w, srcHeight - other_height); - scroll->setFixedSize(w - 18, srcHeight - other_height); + int sclw = w - 18; +#ifdef Q_OS_DARWIN + sclw -= 20; +#endif + scroll->setFixedSize(sclw, srcHeight - other_height); + } + else{ + dlg->setFixedSize(w + 20,dlgHeight); } connect(_start_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_region_set(int))); @@ -211,21 +216,15 @@ void DecoderOptionsDlg::load_decoder_forms(QWidget *container) for(auto dec : _trace->decoder()->stack()) { ++dex; - - //spacing - if (dex > 1){ - QWidget *l = new QWidget(); - l->setMinimumHeight(1); - l->setMaximumHeight(1); - } - QWidget *panel = new QWidget(container); QFormLayout *form = new QFormLayout(); form->setContentsMargins(0,0,0,0); panel->setLayout(form); container->layout()->addWidget(panel); - create_decoder_form(dec, panel, form); + create_decoder_form(dec, panel, form); + + _contentHeight += panel->sizeHint().height(); } } diff --git a/DSView/pv/dialogs/decoderoptionsdlg.h b/DSView/pv/dialogs/decoderoptionsdlg.h index f96881e6..be4386ce 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.h +++ b/DSView/pv/dialogs/decoderoptionsdlg.h @@ -111,6 +111,8 @@ private: view::DecodeTrace *_trace; uint64_t _cursor1; //cursor key uint64_t _cursor2; + int _contentHeight; + std::vector _probe_selectors; }; From 83ad020bda7b70ad6d57bf0cfa935b7d90e8adcc Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 14 Jun 2022 11:14:09 +0800 Subject: [PATCH 4/5] fix: decoder dialog scroll bar --- DSView/pv/dialogs/decoderoptionsdlg.cpp | 2 +- DSView/pv/prop/binding/binding.cpp | 11 +++++++++-- DSView/pv/prop/binding/binding.h | 8 ++++++++ DSView/pv/prop/binding/decoderoptions.cpp | 5 ++--- DSView/pv/prop/binding/probeoptions.cpp | 4 ++-- DSView/pv/widgets/decodergroupbox.cpp | 6 ++++++ DSView/pv/widgets/decodergroupbox.h | 5 +++++ 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/pv/dialogs/decoderoptionsdlg.cpp index 50636bdf..b4cc9155 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/pv/dialogs/decoderoptionsdlg.cpp @@ -180,7 +180,7 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96; int srcHeight = 600; - container_panel->setFixedHeight(_contentHeight); + container_panel->setFixedHeight(_contentHeight + 10); if (dlgHeight * sk > srcHeight) { diff --git a/DSView/pv/prop/binding/binding.cpp b/DSView/pv/prop/binding/binding.cpp index 4d861370..99708538 100755 --- a/DSView/pv/prop/binding/binding.cpp +++ b/DSView/pv/prop/binding/binding.cpp @@ -36,6 +36,10 @@ const std::vector& Binding::properties() return _properties; } +Binding::Binding(){ + _row_num = 0; +} + void Binding::commit() { for(auto &p : _properties) { @@ -55,15 +59,18 @@ void Binding::add_properties_to_form(QFormLayout *layout, QWidget *const widget = p->get_widget(layout->parentWidget(), auto_commit); - if (p->labeled_widget()) + if (p->labeled_widget()){ layout->addRow(widget); + _row_num++; + } else{ const QString &lbstr = p->label(); //remove data format options if (lbstr == "Data format"){ continue; } - layout->addRow(p->label(), widget); + layout->addRow(p->label(), widget); + _row_num++; } } } diff --git a/DSView/pv/prop/binding/binding.h b/DSView/pv/prop/binding/binding.h index 68bae0d7..a3c7e7b2 100755 --- a/DSView/pv/prop/binding/binding.h +++ b/DSView/pv/prop/binding/binding.h @@ -44,6 +44,8 @@ namespace binding { class Binding { public: + Binding(); + const std::vector& properties(); void commit(); @@ -58,10 +60,16 @@ public: static QString print_gvariant(GVariant *const gvar); + inline int get_row_count(){ + return _row_num; + } + protected: std::vector _properties; QWidget *_form; + + int _row_num; }; } // binding diff --git a/DSView/pv/prop/binding/decoderoptions.cpp b/DSView/pv/prop/binding/decoderoptions.cpp index e7162ff0..1ca3d80a 100755 --- a/DSView/pv/prop/binding/decoderoptions.cpp +++ b/DSView/pv/prop/binding/decoderoptions.cpp @@ -39,9 +39,8 @@ namespace pv { namespace prop { namespace binding { -DecoderOptions::DecoderOptions( - pv::data::DecoderStack* decoder_stack, - data::decode::Decoder *decoder) : +DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::decode::Decoder *decoder) : + Binding(), _decoder_stack(decoder_stack), _decoder(decoder) { diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index ea665886..76fdb81a 100755 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -40,8 +40,8 @@ namespace pv { namespace prop { namespace binding { -ProbeOptions::ProbeOptions(struct sr_dev_inst *sdi, - struct sr_channel *probe) : +ProbeOptions::ProbeOptions(struct sr_dev_inst *sdi, struct sr_channel *probe) : + Binding(), _sdi(sdi), _probe(probe) { diff --git a/DSView/pv/widgets/decodergroupbox.cpp b/DSView/pv/widgets/decodergroupbox.cpp index 20fa6f22..b25af709 100755 --- a/DSView/pv/widgets/decodergroupbox.cpp +++ b/DSView/pv/widgets/decodergroupbox.cpp @@ -48,6 +48,8 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, QWidget *parent) : QWidget(parent) { + _row_num = 0; + _dec = dec; _decoder_stack = decoder_stack; _widget = new QWidget(this); @@ -88,6 +90,8 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, _layout->addWidget(_show_button, 0, 2); + _row_num++; + // add row show/hide int index = 0; @@ -107,6 +111,8 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, _layout->addWidget(show_button, _row_show_button.size(), 2); } index++; + + _row_num++; } _layout->addLayout(dec_layout, _row_show_button.size()+1, 0, 1, 3); diff --git a/DSView/pv/widgets/decodergroupbox.h b/DSView/pv/widgets/decodergroupbox.h index 05bab08b..414b852f 100755 --- a/DSView/pv/widgets/decodergroupbox.h +++ b/DSView/pv/widgets/decodergroupbox.h @@ -52,6 +52,10 @@ public: ~DecoderGroupBox(); bool eventFilter(QObject *o, QEvent *e); + inline int get_row_count(){ + return _row_num; + } + signals: void show_hide_decoder(); void show_hide_row(); @@ -72,6 +76,7 @@ private: QPushButton *_del_button; QPushButton *_show_button; std::list _row_show_button; + int _row_num; }; } // widgets From 32de41813f02d262d96f99f74af198910b8236b2 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 14 Jun 2022 11:49:24 +0800 Subject: [PATCH 5/5] fix: decoder options height --- DSView/pv/dialogs/decoderoptionsdlg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/pv/dialogs/decoderoptionsdlg.cpp index b4cc9155..58f60d62 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/pv/dialogs/decoderoptionsdlg.cpp @@ -170,7 +170,7 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) QSize tsize = dlg->sizeHint(); int w = tsize.width(); int other_height = 190; - _contentHeight += 5; + _contentHeight += 10; #ifdef Q_OS_DARWIN other_height += 40; @@ -180,7 +180,7 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace, bool isNew) float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96; int srcHeight = 600; - container_panel->setFixedHeight(_contentHeight + 10); + container_panel->setFixedHeight(_contentHeight); if (dlgHeight * sk > srcHeight) {