mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2026-09-15 14:02:29 +00:00
Users can decide whether to translate parameter names of decoder
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <QVariant>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "../data/decoderstack.h"
|
||||
#include "../prop/binding/decoderoptions.h"
|
||||
@@ -47,6 +48,7 @@
|
||||
#include "../ui/msgbox.h"
|
||||
|
||||
#include "../ui/langresource.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace dialogs {
|
||||
@@ -58,6 +60,7 @@ DecoderOptionsDlg::DecoderOptionsDlg(QWidget *parent)
|
||||
_cursor1 = 0;
|
||||
_cursor2 = 0;
|
||||
_contentHeight = 0;
|
||||
_is_reload_form = false;
|
||||
}
|
||||
|
||||
DecoderOptionsDlg::~DecoderOptionsDlg()
|
||||
@@ -163,7 +166,20 @@ void DecoderOptionsDlg::load_options_view()
|
||||
_end_comboBox->setCurrentIndex(dex2);
|
||||
|
||||
update_decode_range(); // set default sample range
|
||||
|
||||
|
||||
int h_ex2 = 0;
|
||||
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg;
|
||||
|
||||
if (LangResource::Instance()->is_lang_en() == false){
|
||||
QString trans_lable(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODER_IF_TRANS), "Translate param names"));
|
||||
QCheckBox *ck_trans = new QCheckBox();
|
||||
ck_trans->setChecked(bLang);
|
||||
connect(ck_trans, SIGNAL(released()), this, SLOT(on_trans_pramas()));
|
||||
ck_trans->setStyleSheet("margin-left:60px");
|
||||
form->addRow(ck_trans, new QLabel(trans_lable));
|
||||
h_ex2 = 30;
|
||||
}
|
||||
|
||||
//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")));
|
||||
@@ -186,7 +202,7 @@ void DecoderOptionsDlg::load_options_view()
|
||||
// scroll
|
||||
QSize tsize = dlg->sizeHint();
|
||||
int w = tsize.width();
|
||||
int other_height = 190;
|
||||
int other_height = 190 + h_ex2;
|
||||
_contentHeight += 10;
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
@@ -360,6 +376,11 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
decoder_form->setFormAlignment(Qt::AlignLeft);
|
||||
decoder_form->setLabelAlignment(Qt::AlignLeft);
|
||||
decoder_form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
|
||||
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg;
|
||||
if (LangResource::Instance()->is_lang_en()){
|
||||
bLang = false;
|
||||
}
|
||||
|
||||
// Add the mandatory channels
|
||||
for(l = decoder->channels; l; l = l->next) {
|
||||
@@ -367,8 +388,14 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
DsComboBox *const combo = create_probe_selector(parent, dec, pdch);
|
||||
|
||||
const char *desc_str = NULL;
|
||||
if (pdch->idn != NULL){
|
||||
desc_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, pdch->idn, pdch->desc);
|
||||
const char *lang_str = NULL;
|
||||
|
||||
if (pdch->idn != NULL && LangResource::Instance()->is_lang_en() == false){
|
||||
lang_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, pdch->idn, pdch->desc);
|
||||
}
|
||||
|
||||
if (lang_str != NULL && bLang){
|
||||
desc_str = lang_str;
|
||||
}
|
||||
else{
|
||||
desc_str = pdch->desc;
|
||||
@@ -391,8 +418,14 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
DsComboBox *const combo = create_probe_selector(parent, dec, pdch);
|
||||
|
||||
const char *desc_str = NULL;
|
||||
if (pdch->idn != NULL){
|
||||
desc_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, pdch->idn, pdch->desc);
|
||||
const char *lang_str = NULL;
|
||||
|
||||
if (pdch->idn != NULL && LangResource::Instance()->is_lang_en() == false){
|
||||
lang_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, pdch->idn, pdch->desc);
|
||||
}
|
||||
|
||||
if (lang_str != NULL && bLang){
|
||||
desc_str = lang_str;
|
||||
}
|
||||
else{
|
||||
desc_str = pdch->desc;
|
||||
@@ -417,7 +450,8 @@ void DecoderOptionsDlg::create_decoder_form(
|
||||
auto group = new pv::widgets::DecoderGroupBox(_trace->decoder(),
|
||||
dec,
|
||||
decoder_form,
|
||||
parent);
|
||||
parent);
|
||||
|
||||
form->addRow(group);
|
||||
}
|
||||
|
||||
@@ -473,7 +507,18 @@ void DecoderOptionsDlg::on_accept()
|
||||
}
|
||||
|
||||
this->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void DecoderOptionsDlg::on_trans_pramas()
|
||||
{
|
||||
QCheckBox *ck_box = dynamic_cast<QCheckBox*>(sender());
|
||||
assert(ck_box);
|
||||
|
||||
AppConfig::Instance()._appOptions.transDecoderDlg = ck_box->isChecked();
|
||||
AppConfig::Instance().SaveApp();
|
||||
_is_reload_form = true;
|
||||
this->close();
|
||||
}
|
||||
|
||||
}//dialogs
|
||||
}//pv
|
||||
|
||||
@@ -86,6 +86,10 @@ public:
|
||||
|
||||
void load_options(view::DecodeTrace *trace);
|
||||
|
||||
inline bool is_reload_form(){
|
||||
return _is_reload_form;
|
||||
}
|
||||
|
||||
private:
|
||||
void load_options_view();
|
||||
|
||||
@@ -105,6 +109,7 @@ private slots:
|
||||
void on_probe_selected(int);
|
||||
void on_region_set(int index);
|
||||
void on_accept();
|
||||
void on_trans_pramas();
|
||||
|
||||
private:
|
||||
std::vector<prop::binding::DecoderOptions*> _bindings;
|
||||
@@ -116,6 +121,7 @@ private:
|
||||
int _contentHeight;
|
||||
|
||||
std::vector<ProbeSelector> _probe_selectors;
|
||||
bool _is_reload_form;
|
||||
};
|
||||
|
||||
}//dialogs
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "../int.h"
|
||||
#include "../string.h"
|
||||
#include "../../ui/langresource.h"
|
||||
#include "../../config/appconfig.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -50,14 +51,26 @@ DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::deco
|
||||
const srd_decoder *const dec = _decoder->decoder();
|
||||
assert(dec);
|
||||
|
||||
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg;
|
||||
|
||||
if (LangResource::Instance()->is_lang_en()){
|
||||
bLang = false;
|
||||
}
|
||||
|
||||
for (GSList *l = dec->options; l; l = l->next)
|
||||
{
|
||||
const srd_decoder_option *const opt =
|
||||
(srd_decoder_option*)l->data;
|
||||
|
||||
const char *desc_str = NULL;
|
||||
if (opt->idn != NULL){
|
||||
desc_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, opt->idn, opt->desc);
|
||||
const char *lang_str = NULL;
|
||||
|
||||
if (opt->idn != NULL && LangResource::Instance()->is_lang_en() == false){
|
||||
lang_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, opt->idn, opt->desc);
|
||||
}
|
||||
|
||||
if (lang_str != NULL && bLang){
|
||||
desc_str = lang_str;
|
||||
}
|
||||
else{
|
||||
desc_str = opt->desc;
|
||||
|
||||
@@ -86,6 +86,10 @@ public:
|
||||
bool is_new_decoder(const char *decoder_id);
|
||||
void reload_dynamic();
|
||||
void release_dynamic();
|
||||
|
||||
inline bool is_lang_en(){
|
||||
return _cur_lang == 31;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *get_lang_key(int lang);
|
||||
|
||||
@@ -670,24 +670,34 @@ void* DecodeTrace::get_key_handel()
|
||||
bool DecodeTrace::create_popup(bool isnew)
|
||||
{
|
||||
int ret = false; //setting have changed flag
|
||||
QWidget *top = AppControl::Instance()->GetTopWindow();
|
||||
dialogs::DecoderOptionsDlg dlg(top);
|
||||
dlg.set_cursor_range(_decode_cursor1, _decode_cursor2);
|
||||
dlg.load_options(this);
|
||||
|
||||
if (QDialog::Accepted == dlg.exec())
|
||||
while (true)
|
||||
{
|
||||
for(auto dec : _decoder_stack->stack())
|
||||
QWidget *top = AppControl::Instance()->GetTopWindow();
|
||||
dialogs::DecoderOptionsDlg dlg(top);
|
||||
dlg.set_cursor_range(_decode_cursor1, _decode_cursor2);
|
||||
dlg.load_options(this);
|
||||
|
||||
int dlg_ret = dlg.exec();
|
||||
|
||||
if (QDialog::Accepted == dlg_ret)
|
||||
{
|
||||
if (dec->commit() || _decoder_stack->options_changed()) {
|
||||
_decoder_stack->set_options_changed(true);
|
||||
_decode_start = dec->decode_start();
|
||||
_decode_end = dec->decode_end();
|
||||
ret = true;
|
||||
for(auto dec : _decoder_stack->stack())
|
||||
{
|
||||
if (dec->commit() || _decoder_stack->options_changed()) {
|
||||
_decoder_stack->set_options_changed(true);
|
||||
_decode_start = dec->decode_start();
|
||||
_decode_end = dec->decode_end();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
dlg.get_cursor_range(_decode_cursor1, _decode_cursor2);
|
||||
}
|
||||
|
||||
dlg.get_cursor_range(_decode_cursor1, _decode_cursor2);
|
||||
if (QDialog::Accepted == dlg_ret || dlg.is_reload_form() == false){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -662,5 +662,9 @@
|
||||
{
|
||||
"id": "IDS_DLG_PATH_NAME",
|
||||
"text": "路径"
|
||||
},
|
||||
{
|
||||
"id": "IDS_DLG_DECODER_IF_TRANS",
|
||||
"text": "翻译参数名称"
|
||||
}
|
||||
]
|
||||
@@ -662,5 +662,9 @@
|
||||
{
|
||||
"id": "IDS_DLG_PATH_NAME",
|
||||
"text": "path"
|
||||
},
|
||||
{
|
||||
"id": "IDS_DLG_DECODER_IF_TRANS",
|
||||
"text": "Translate param names"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user