forked from Ivasoft/DSView
fix: restore language from dsl file
This commit is contained in:
@@ -46,15 +46,17 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
_props_box = NULL;
|
||||
_config_button = NULL;
|
||||
_cali_button = NULL;
|
||||
|
||||
QWidget *dlg = this;
|
||||
|
||||
setTitle(tr("Device Options"));
|
||||
|
||||
_props_box = new QGroupBox(tr("Mode"), this);
|
||||
_props_box->setLayout(get_property_form(_props_box));
|
||||
//_layout.addWidget(_props_box);
|
||||
_layout.addWidget(_props_box);
|
||||
|
||||
_dynamic_box = new QGroupBox(dynamic_widget(_dynamic_layout),this);
|
||||
|
||||
_dynamic_box = new QGroupBox(dynamic_widget(_dynamic_layout),
|
||||
this);
|
||||
_dynamic_box->setLayout(&_dynamic_layout);
|
||||
_layout.addWidget(_dynamic_box);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != "");
|
||||
@@ -64,8 +66,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
|
||||
layout()->addLayout(&_layout);
|
||||
|
||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
//connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(_dev_inst, SIGNAL(device_updated()), this, SLOT(reject()));
|
||||
|
||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
||||
@@ -73,6 +74,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
connect(&_mode_check, SIGNAL(timeout()), this, SLOT(mode_check()));
|
||||
_mode_check.setInterval(100);
|
||||
_mode_check.start();
|
||||
@@ -448,7 +450,6 @@ void DeviceOptions::channel_enable()
|
||||
w->setEnabled(sc->isChecked());
|
||||
}
|
||||
}
|
||||
//dynamic_widget(_dynamic_layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,6 +458,7 @@ QString DeviceOptions::dynamic_widget(QGridLayout& inner_layout) {
|
||||
if (_dev_inst->dev_inst()->mode == LOGIC) {
|
||||
logic_probes(inner_layout);
|
||||
return tr("Channels");
|
||||
|
||||
} else if (_dev_inst->dev_inst()->mode == DSO) {
|
||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_HAVE_ZERO);
|
||||
if (gvar != NULL) {
|
||||
|
||||
@@ -93,6 +93,8 @@
|
||||
#include "appcontrol.h"
|
||||
#include "dsvdef.h"
|
||||
#include "appcontrol.h"
|
||||
|
||||
#define BASE_SESSION_VERSION 2
|
||||
|
||||
|
||||
namespace pv {
|
||||
@@ -963,9 +965,20 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev, bool bDeco
|
||||
QJsonObject sessionObj = json.object();
|
||||
|
||||
// check session file version
|
||||
if (!sessionObj.contains("Version") ||
|
||||
sessionObj["Version"].toInt() != Session_Version)
|
||||
if (!sessionObj.contains("Version")){
|
||||
qDebug()<<"session file version is not exists!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sessionObj["Version"].toInt() < BASE_SESSION_VERSION){
|
||||
qDebug()<<"session file version is error!"<<sessionObj["Version"].toInt();
|
||||
return false;
|
||||
}
|
||||
|
||||
// old version(<= 1.1.2), restore the language
|
||||
if (sessionObj["Version"].toInt() == BASE_SESSION_VERSION){
|
||||
switchLanguage(sessionObj["Language"].toInt());
|
||||
}
|
||||
|
||||
SigSession *_session = _control->GetSession();
|
||||
|
||||
@@ -1150,7 +1163,7 @@ bool MainWindow::gen_session_json(QJsonObject &sessionVar){
|
||||
const sr_dev_inst *const sdi = _session->get_device()->dev_inst();
|
||||
|
||||
QJsonArray channelVar;
|
||||
sessionVar["Version"]= QJsonValue::fromVariant(Session_Version);
|
||||
sessionVar["Version"]= QJsonValue::fromVariant(BASE_SESSION_VERSION);
|
||||
sessionVar["Device"] = QJsonValue::fromVariant(sdi->driver->name);
|
||||
sessionVar["DeviceMode"] = QJsonValue::fromVariant(sdi->mode);
|
||||
sessionVar["Language"] = QJsonValue::fromVariant(app._frameOptions.language);
|
||||
|
||||
@@ -77,9 +77,6 @@ class MainWindow : public QMainWindow, public ISessionCallback, public IMainForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
static constexpr int Session_Version = 2;
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user