forked from Ivasoft/DSView
Adjust decoder options dialog
This commit is contained in:
@@ -61,6 +61,7 @@ DecoderOptionsDlg::DecoderOptionsDlg(QWidget *parent)
|
||||
_cursor2 = 0;
|
||||
_contentHeight = 0;
|
||||
_is_reload_form = false;
|
||||
_content_width = 0;
|
||||
}
|
||||
|
||||
DecoderOptionsDlg::~DecoderOptionsDlg()
|
||||
@@ -90,15 +91,14 @@ void DecoderOptionsDlg::load_options_view()
|
||||
{
|
||||
DSDialog *dlg = this;
|
||||
|
||||
dlg->setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODER_OPTIONS), "Decoder Options"));
|
||||
|
||||
QFormLayout *form = new QFormLayout();
|
||||
form->setContentsMargins(0, 0, 0, 0);
|
||||
form->setVerticalSpacing(5);
|
||||
form->setFormAlignment(Qt::AlignLeft);
|
||||
form->setLabelAlignment(Qt::AlignLeft);
|
||||
form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
dlg->layout()->addLayout(form);
|
||||
|
||||
dlg->setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODER_OPTIONS), "Decoder Options"));
|
||||
|
||||
//scroll pannel
|
||||
QWidget *scroll_pannel = new QWidget();
|
||||
@@ -114,15 +114,10 @@ void DecoderOptionsDlg::load_options_view()
|
||||
decoder_lay->setContentsMargins(0, 0, 0, 0);
|
||||
decoder_lay->setDirection(QBoxLayout::TopToBottom);
|
||||
container_panel->setLayout(decoder_lay);
|
||||
// form->addRow(container_panel);
|
||||
scroll_lay->addWidget(container_panel);
|
||||
|
||||
load_decoder_forms(container_panel);
|
||||
|
||||
if (_trace->decoder()->stack().size() > 0){
|
||||
|
||||
}
|
||||
|
||||
//Add region combobox
|
||||
_start_comboBox = new DsComboBox(dlg);
|
||||
_end_comboBox = new DsComboBox(dlg);
|
||||
@@ -132,7 +127,7 @@ void DecoderOptionsDlg::load_options_view()
|
||||
_end_comboBox->setMinimumContentsLength(7);
|
||||
_start_comboBox->setMinimumWidth(30);
|
||||
_end_comboBox->setMinimumWidth(30);
|
||||
|
||||
|
||||
// Add cursor list
|
||||
auto view = _trace->get_view();
|
||||
int dex1 = 0;
|
||||
@@ -145,10 +140,10 @@ void DecoderOptionsDlg::load_options_view()
|
||||
|
||||
for (auto c : cursor_list){
|
||||
//tr
|
||||
QString curCursor = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR), "Cursor") +
|
||||
QString cursor_name = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR), "Cursor") +
|
||||
QString::number(num);
|
||||
_start_comboBox->addItem(curCursor, QVariant((quint64)c->get_key()));
|
||||
_end_comboBox->addItem(curCursor, QVariant((quint64)c->get_key()));
|
||||
_start_comboBox->addItem(cursor_name, QVariant((quint64)c->get_key()));
|
||||
_end_comboBox->addItem(cursor_name, QVariant((quint64)c->get_key()));
|
||||
|
||||
if (c->get_key() == _cursor1)
|
||||
dex1 = num;
|
||||
@@ -196,10 +191,13 @@ void DecoderOptionsDlg::load_options_view()
|
||||
}
|
||||
|
||||
//tr
|
||||
form->addRow(_start_comboBox, new QLabel(
|
||||
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR_FOR_DECODE_START), "The cursor for decode start time")));
|
||||
form->addRow(_end_comboBox, new QLabel(
|
||||
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR_FOR_DECODE_END), "The cursor for decode end time")));
|
||||
QLabel *lb1 = new QLabel(
|
||||
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR_FOR_DECODE_START), "The cursor for decode start time"));
|
||||
QLabel *lb2 = new QLabel(
|
||||
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR_FOR_DECODE_END), "The cursor for decode end time"));
|
||||
|
||||
form->addRow(_start_comboBox, lb1);
|
||||
form->addRow(_end_comboBox, lb2);
|
||||
|
||||
// Add ButtonBox (OK/Cancel)
|
||||
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
||||
@@ -211,21 +209,33 @@ void DecoderOptionsDlg::load_options_view()
|
||||
|
||||
this->update_font();
|
||||
|
||||
int real_content_width = _content_width;
|
||||
int content_height = _contentHeight;
|
||||
|
||||
// scroll
|
||||
QSize tsize = dlg->sizeHint();
|
||||
int w = tsize.width();
|
||||
int other_height = 190 + h_ex2;
|
||||
_contentHeight += 20;
|
||||
content_height += 20;
|
||||
|
||||
int cursor_line_width = lb1->sizeHint().width() + _start_comboBox->sizeHint().width();
|
||||
|
||||
if (w < real_content_width){
|
||||
w = real_content_width;
|
||||
}
|
||||
if (w < cursor_line_width){
|
||||
w = cursor_line_width;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
other_height += 40;
|
||||
other_height += 40;
|
||||
#endif
|
||||
|
||||
int dlgHeight = _contentHeight + other_height;
|
||||
int dlgHeight = content_height + other_height;
|
||||
|
||||
float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96;
|
||||
int srcHeight = 600;
|
||||
container_panel->setFixedHeight(_contentHeight);
|
||||
container_panel->setFixedHeight(content_height);
|
||||
|
||||
if (dlgHeight * sk > srcHeight)
|
||||
{
|
||||
@@ -382,6 +392,9 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
const srd_decoder *const decoder = dec->decoder();
|
||||
assert(decoder);
|
||||
|
||||
QFont font = this->font();
|
||||
font.setPointSizeF(AppConfig::Instance().appOptions.fontSize);
|
||||
|
||||
QFormLayout *const decoder_form = new QFormLayout();
|
||||
decoder_form->setContentsMargins(0,0,0,0);
|
||||
decoder_form->setVerticalSpacing(4);
|
||||
@@ -456,13 +469,16 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
|
||||
// Add the options
|
||||
auto binding = new prop::binding::DecoderOptions(_trace->decoder(), dec);
|
||||
binding->add_properties_to_form(decoder_form, true);
|
||||
binding->add_properties_to_form(decoder_form, true, font);
|
||||
_bindings.push_back(binding);
|
||||
|
||||
auto group = new pv::widgets::DecoderGroupBox(_trace->decoder(),
|
||||
dec,
|
||||
decoder_form,
|
||||
parent);
|
||||
parent, font);
|
||||
|
||||
if (group->_content_width > _content_width)
|
||||
_content_width = group->_content_width;
|
||||
|
||||
form->addRow(group);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ private:
|
||||
|
||||
std::vector<ProbeSelector> _probe_selectors;
|
||||
bool _is_reload_form;
|
||||
int _content_width;
|
||||
};
|
||||
|
||||
}//dialogs
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "../property.h"
|
||||
#include "binding.h"
|
||||
@@ -47,8 +48,7 @@ void Binding::commit()
|
||||
}
|
||||
}
|
||||
|
||||
void Binding::add_properties_to_form(QFormLayout *layout,
|
||||
bool auto_commit)
|
||||
void Binding::add_properties_to_form(QFormLayout *layout, bool auto_commit, QFont font)
|
||||
{
|
||||
assert(layout);
|
||||
|
||||
@@ -58,6 +58,7 @@ void Binding::add_properties_to_form(QFormLayout *layout,
|
||||
|
||||
if (p->labeled_widget()){
|
||||
layout->addRow(widget);
|
||||
widget->setFont(font);
|
||||
_row_num++;
|
||||
}
|
||||
else{
|
||||
@@ -66,26 +67,15 @@ void Binding::add_properties_to_form(QFormLayout *layout,
|
||||
if (lbstr == "Data format"){
|
||||
continue;
|
||||
}
|
||||
layout->addRow(p->label(), widget);
|
||||
QLabel *lb = new QLabel(p->label());
|
||||
lb->setFont(font);
|
||||
widget->setFont(font);
|
||||
layout->addRow(lb, widget);
|
||||
_row_num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* Binding::get_property_form(QWidget *parent,
|
||||
bool auto_commit)
|
||||
{
|
||||
QWidget *const form = new QWidget(parent);
|
||||
QFormLayout *const layout = new QFormLayout(form);
|
||||
layout->setVerticalSpacing(5);
|
||||
layout->setFormAlignment(Qt::AlignLeft);
|
||||
layout->setLabelAlignment(Qt::AlignLeft);
|
||||
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
form->setLayout(layout);
|
||||
add_properties_to_form(layout, auto_commit);
|
||||
return form;
|
||||
}
|
||||
|
||||
std::map<Property*,GVariant*> Binding::get_property_value()
|
||||
{
|
||||
std::map <Property*,GVariant*> pvalue;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <QFont>
|
||||
#include <QString>
|
||||
|
||||
class QFormLayout;
|
||||
@@ -51,10 +51,7 @@ public:
|
||||
void commit();
|
||||
|
||||
void add_properties_to_form(QFormLayout *layout,
|
||||
bool auto_commit = false);
|
||||
|
||||
QWidget* get_property_form(QWidget *parent,
|
||||
bool auto_commit = false);
|
||||
bool auto_commit, QFont font);
|
||||
|
||||
std::map<Property*,GVariant*> get_property_value();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define DSVIEW_PV_PROP_BINDING_DECODEROPTIONS_H
|
||||
|
||||
#include "binding.h"
|
||||
#include <QFont>
|
||||
|
||||
#include "../property.h"
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
//#include <QScrollBar>
|
||||
//#include <QScreen>
|
||||
#include <QApplication>
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
@@ -45,10 +43,11 @@ namespace widgets {
|
||||
DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
data::decode::Decoder *dec,
|
||||
QLayout *dec_layout,
|
||||
QWidget *parent) :
|
||||
QWidget *parent, QFont font):
|
||||
QWidget(parent)
|
||||
{
|
||||
_row_num = 0;
|
||||
_content_width = 0;
|
||||
|
||||
_dec = dec;
|
||||
_decoder_stack = decoder_stack;
|
||||
@@ -98,7 +97,9 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
connect(show_button, SIGNAL(clicked()), this, SLOT(tog_icon()));
|
||||
|
||||
_row_show_button.push_back(show_button);
|
||||
_layout->addWidget(new QLabel((*i).first.title(), _widget), _row_show_button.size(), 0);
|
||||
QLabel *lb = new QLabel((*i).first.title(), _widget);
|
||||
lb->setFont(font);
|
||||
_layout->addWidget(lb, _row_show_button.size(), 0);
|
||||
_layout->addWidget(show_button, _row_show_button.size(), 2);
|
||||
}
|
||||
index++;
|
||||
@@ -107,10 +108,11 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
}
|
||||
|
||||
_layout->addLayout(dec_layout, _row_show_button.size()+1, 0, 1, 3);
|
||||
|
||||
_widget->setLayout(_layout);
|
||||
parent->layout()->addWidget(_widget);
|
||||
|
||||
|
||||
_content_width = _widget->sizeHint().width();
|
||||
|
||||
parent->layout()->addWidget(_widget);
|
||||
}
|
||||
|
||||
DecoderGroupBox::~DecoderGroupBox()
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
//#include <QToolBar>
|
||||
//#include <QScrollArea>
|
||||
#include <QFont>
|
||||
#include <QWidget>
|
||||
|
||||
namespace pv {
|
||||
@@ -48,7 +47,7 @@ class DecoderGroupBox : public QWidget
|
||||
public:
|
||||
DecoderGroupBox(pv::data::DecoderStack *decoder_stack,
|
||||
data::decode::Decoder *dec, QLayout *dec_layout,
|
||||
QWidget *parent = NULL);
|
||||
QWidget *parent, QFont font);
|
||||
~DecoderGroupBox();
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
|
||||
@@ -77,6 +76,9 @@ private:
|
||||
QPushButton *_show_button;
|
||||
std::list <QPushButton *> _row_show_button;
|
||||
int _row_num;
|
||||
|
||||
public:
|
||||
int _content_width;
|
||||
};
|
||||
|
||||
} // widgets
|
||||
|
||||
Reference in New Issue
Block a user