forked from Ivasoft/DSView
Merge branch 'master' of https://github.com/DreamSourceLab/DSView
This commit is contained in:
@@ -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("<i>* Required channels</i>"), 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 += 10;
|
||||
|
||||
#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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,8 @@ private:
|
||||
view::DecodeTrace *_trace;
|
||||
uint64_t _cursor1; //cursor key
|
||||
uint64_t _cursor2;
|
||||
int _contentHeight;
|
||||
|
||||
std::vector<ProbeSelector> _probe_selectors;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ const std::vector<Property*>& 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace binding {
|
||||
class Binding
|
||||
{
|
||||
public:
|
||||
Binding();
|
||||
|
||||
const std::vector<Property*>& 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<Property*> _properties;
|
||||
|
||||
QWidget *_form;
|
||||
|
||||
int _row_num;
|
||||
};
|
||||
|
||||
} // binding
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#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;");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <QPushButton *> _row_show_button;
|
||||
int _row_num;
|
||||
};
|
||||
|
||||
} // widgets
|
||||
|
||||
Reference in New Issue
Block a user