forked from Ivasoft/DSView
update app config manager
This commit is contained in:
@@ -21,9 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <libsigrok4DSL/libsigrok.h>
|
||||
#ifdef ENABLE_DECODE
|
||||
#include <libsigrokdecode4DSL/libsigrokdecode.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
@@ -33,7 +31,6 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QTranslator>
|
||||
#include <QSettings>
|
||||
#include <QDesktopServices>
|
||||
#include <QStyle>
|
||||
|
||||
@@ -130,9 +127,9 @@ int main(int argc, char *argv[])
|
||||
const int loglevel = atoi(optarg);
|
||||
sr_log_loglevel_set(loglevel);
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
srd_log_loglevel_set(loglevel);
|
||||
#endif
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -176,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
do {
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// Initialise libsigrokdecode
|
||||
if (srd_init(NULL) != SRD_OK) {
|
||||
qDebug() << "ERROR: libsigrokdecode init failed.";
|
||||
@@ -185,9 +182,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Load the protocol decoders
|
||||
srd_decoder_load_all();
|
||||
#endif
|
||||
|
||||
//load app config
|
||||
AppConfig::Instance().Load("./appconfig.json");
|
||||
AppConfig::Instance().LoadAll();
|
||||
|
||||
try {
|
||||
// Create the device manager, initialise the drivers
|
||||
@@ -206,10 +203,10 @@ int main(int argc, char *argv[])
|
||||
qDebug() << e.what();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// Destroy libsigrokdecode
|
||||
srd_exit();
|
||||
#endif
|
||||
|
||||
|
||||
} while (0);
|
||||
|
||||
|
||||
@@ -20,15 +20,11 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "appconfig.h"
|
||||
#include <assert.h>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
|
||||
#include "appconfig.h"
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QLocale>
|
||||
|
||||
#define MAX_PROTOCOL_FORMAT_LIST 15
|
||||
|
||||
StringPair::StringPair(const string &key, const string &value)
|
||||
@@ -44,12 +40,10 @@ QString FormatArrayToString(vector<StringPair> &protocolFormats){
|
||||
for (StringPair &o : protocolFormats){
|
||||
if (!str.isEmpty()){
|
||||
str += ";";
|
||||
}
|
||||
std::string line;
|
||||
line += o.m_key;
|
||||
line += "=";
|
||||
line += o.m_value;
|
||||
str += line.c_str();
|
||||
}
|
||||
str += o.m_key.c_str();
|
||||
str += "=";
|
||||
str += o.m_value.c_str();
|
||||
}
|
||||
|
||||
return str;
|
||||
@@ -68,11 +62,112 @@ void StringToFormatArray(const QString &str, vector<StringPair> &protocolFormats
|
||||
}
|
||||
}
|
||||
|
||||
//read write field
|
||||
|
||||
void getFiled(const char *key, QSettings &st, QString &f, const char *dv){
|
||||
f = st.value(key, dv).toString();
|
||||
}
|
||||
void getFiled(const char *key, QSettings &st, int &f, int dv){
|
||||
f = st.value(key, dv).toInt();
|
||||
}
|
||||
void getFiled(const char *key, QSettings &st, bool &f, bool dv){
|
||||
f = st.value(key, dv).toBool();
|
||||
}
|
||||
|
||||
void setFiled(const char *key, QSettings &st, QString f){
|
||||
st.setValue(key, f);
|
||||
}
|
||||
void setFiled(const char *key, QSettings &st, int f){
|
||||
st.setValue(key, f);
|
||||
}
|
||||
void setFiled(const char *key, QSettings &st, bool f){
|
||||
st.setValue(key, f);
|
||||
}
|
||||
|
||||
|
||||
///------ app
|
||||
void _loadApp(AppOptions &o, QSettings &st){
|
||||
st.beginGroup("Application");
|
||||
getFiled("quickScroll", st, o.quickScroll, true);
|
||||
getFiled("warnofMultiTrig", st, o.warnofMultiTrig, true);
|
||||
|
||||
|
||||
QString fmt;
|
||||
getFiled("protocalFormats", st, fmt, "");
|
||||
if (fmt != ""){
|
||||
StringToFormatArray(fmt, o.m_protocolFormats);
|
||||
}
|
||||
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
void _saveApp(AppOptions &o, QSettings &st){
|
||||
st.beginGroup("Application");
|
||||
setFiled("quickScroll", st, o.quickScroll);
|
||||
setFiled("warnofMultiTrig", st, o.warnofMultiTrig);
|
||||
|
||||
|
||||
QString fmt = FormatArrayToString(o.m_protocolFormats);
|
||||
setFiled("protocalFormats", st, fmt);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
//-----frame
|
||||
void _loadFrame(FrameOptions &o, QSettings &st){
|
||||
st.beginGroup("MainFrame");
|
||||
getFiled("style", st, o.style, "dark");
|
||||
getFiled("language", st, o.language, -1);
|
||||
getFiled("isMax", st, o.isMax, false);
|
||||
o.geometry = st.value("geometry", QByteArray()).toByteArray();
|
||||
o.windowState = st.value("windowState", QByteArray()).toByteArray();
|
||||
st.endGroup();
|
||||
|
||||
if (o.language == -1){
|
||||
//get local language
|
||||
QLocale locale;
|
||||
o.language = locale.language();
|
||||
}
|
||||
}
|
||||
|
||||
void _saveFrame(FrameOptions &o, QSettings &st){
|
||||
st.beginGroup("MainFrame");
|
||||
setFiled("style", st, o.style);
|
||||
setFiled("language", st, o.language);
|
||||
setFiled("isMax", st, o.isMax);
|
||||
st.setValue("geometry", o.geometry);
|
||||
st.setValue("windowState", o.windowState);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
//------history
|
||||
void _loadHistory(UserHistory &o, QSettings &st){
|
||||
st.beginGroup("UserHistory");
|
||||
getFiled("exportDir", st, o.exportDir, "");
|
||||
getFiled("saveDir", st, o.saveDir, "");
|
||||
getFiled("showDocuments", st, o.showDocuments, true);
|
||||
getFiled("screenShotPath", st, o.screenShotPath, "");
|
||||
getFiled("sessionDir", st, o.sessionDir, "");
|
||||
getFiled("openDir", st, o.openDir, "");
|
||||
getFiled("protocolExportPath", st, o.protocolExportPath, "");
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
void _saveHistory(UserHistory &o, QSettings &st){
|
||||
st.beginGroup("UserHistory");
|
||||
setFiled("exportDir", st, o.exportDir);
|
||||
setFiled("saveDir", st, o.saveDir);
|
||||
setFiled("showDocuments", st, o.showDocuments);
|
||||
setFiled("screenShotPath", st, o.screenShotPath);
|
||||
setFiled("sessionDir", st, o.sessionDir);
|
||||
setFiled("openDir", st, o.openDir);
|
||||
setFiled("protocolExportPath", st, o.protocolExportPath);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
//------------AppConfig
|
||||
|
||||
AppConfig::AppConfig()
|
||||
{
|
||||
_appOptions.quickScroll = true;
|
||||
{
|
||||
}
|
||||
|
||||
AppConfig::~AppConfig()
|
||||
@@ -88,111 +183,88 @@ AppConfig::~AppConfig()
|
||||
return *ins;
|
||||
}
|
||||
|
||||
bool AppConfig::Load(const char *file)
|
||||
{
|
||||
assert(file);
|
||||
m_fileName = file;
|
||||
|
||||
QFile qf(file);
|
||||
if (qf.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QByteArray bytes = qf.readAll();
|
||||
qf.close();
|
||||
|
||||
string json;
|
||||
json.append(bytes.data(), bytes.size());
|
||||
FromJson(json);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
void AppConfig::LoadAll()
|
||||
{
|
||||
QSettings st(QApplication::organizationName(), QApplication::applicationName());
|
||||
_loadApp(_appOptions, st);
|
||||
_loadHistory(_userHistory, st);
|
||||
_loadFrame(_frameOptions, st);
|
||||
}
|
||||
|
||||
bool AppConfig::Save()
|
||||
{
|
||||
if (m_fileName != "")
|
||||
{
|
||||
QFile qf(m_fileName.c_str());
|
||||
if (qf.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
string json = ToJsonString();
|
||||
QByteArray bytes(json.c_str(), json.size());
|
||||
|
||||
QTextStream _stream(&qf);
|
||||
_stream.setCodec("UTF-8");
|
||||
_stream << QString::fromUtf8(bytes);
|
||||
qf.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
string AppConfig::ToJsonString()
|
||||
void AppConfig::SaveApp()
|
||||
{
|
||||
QJsonObject jobj;
|
||||
QString profomats = FormatArrayToString(m_protocolFormats);
|
||||
jobj["ProtocolFormats"] = QJsonValue::fromVariant(profomats);
|
||||
|
||||
//application options
|
||||
QJsonObject app;
|
||||
app["QuickScroll"] = QJsonValue::fromVariant(_appOptions.quickScroll);
|
||||
|
||||
jobj["Application"] = QJsonValue::fromVariant(app);
|
||||
|
||||
QJsonDocument jdoc(jobj);
|
||||
QByteArray bytes = jdoc.toJson();
|
||||
string json;
|
||||
json.append(bytes.data(), bytes.size());
|
||||
return json;
|
||||
QSettings st(QApplication::organizationName(), QApplication::applicationName());
|
||||
_saveApp(_appOptions, st);
|
||||
}
|
||||
|
||||
void AppConfig::FromJson(string &json)
|
||||
void AppConfig::SaveHistory()
|
||||
{
|
||||
if (!json.size())
|
||||
return;
|
||||
|
||||
QByteArray bytes(json.c_str(), json.size());
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(bytes);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains("ProtocolFormats")){
|
||||
m_protocolFormats.clear();
|
||||
StringToFormatArray(jobj["ProtocolFormats"].toString(), m_protocolFormats);
|
||||
}
|
||||
|
||||
//application node
|
||||
if (jobj.contains("Application")){
|
||||
QJsonObject app = jobj["Application"].toObject();
|
||||
_appOptions.quickScroll = app["QuickScroll"].toBool();
|
||||
}
|
||||
QSettings st(QApplication::organizationName(), QApplication::applicationName());
|
||||
_saveHistory(_userHistory, st);
|
||||
}
|
||||
|
||||
void AppConfig::SaveFrame()
|
||||
{
|
||||
QSettings st(QApplication::organizationName(), QApplication::applicationName());
|
||||
_saveFrame(_frameOptions, st);
|
||||
}
|
||||
|
||||
|
||||
void AppConfig::SetProtocolFormat(const string &protocolName, const string &value)
|
||||
{
|
||||
for (StringPair &o : m_protocolFormats){
|
||||
bool bChange = false;
|
||||
for (StringPair &o : _appOptions.m_protocolFormats){
|
||||
if (o.m_key == protocolName){
|
||||
o.m_value = value;
|
||||
return;
|
||||
bChange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_protocolFormats.size() > MAX_PROTOCOL_FORMAT_LIST){
|
||||
while (m_protocolFormats.size() < MAX_PROTOCOL_FORMAT_LIST)
|
||||
|
||||
if (!bChange)
|
||||
{
|
||||
if (_appOptions.m_protocolFormats.size() > MAX_PROTOCOL_FORMAT_LIST)
|
||||
{
|
||||
m_protocolFormats.erase(m_protocolFormats.begin());
|
||||
while (_appOptions.m_protocolFormats.size() < MAX_PROTOCOL_FORMAT_LIST)
|
||||
{
|
||||
_appOptions.m_protocolFormats.erase(_appOptions.m_protocolFormats.begin());
|
||||
}
|
||||
}
|
||||
_appOptions.m_protocolFormats.push_back(StringPair(protocolName, value));
|
||||
bChange = true;
|
||||
}
|
||||
|
||||
m_protocolFormats.push_back(StringPair(protocolName,value));
|
||||
if (bChange){
|
||||
SaveApp();
|
||||
}
|
||||
}
|
||||
|
||||
string AppConfig::GetProtocolFormat(const string &protocolName)
|
||||
{
|
||||
for (StringPair &o : m_protocolFormats){
|
||||
for (StringPair &o : _appOptions.m_protocolFormats){
|
||||
if (o.m_key == protocolName){
|
||||
return o.m_value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------api
|
||||
QString GetDirectoryName(QString path)
|
||||
{
|
||||
int lstdex = path.lastIndexOf('/');
|
||||
if (lstdex != -1)
|
||||
{
|
||||
return path.left(lstdex);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
QString GetIconPath()
|
||||
{
|
||||
QString style = AppConfig::Instance()._frameOptions.style;
|
||||
if (style == ""){
|
||||
style = "dark";
|
||||
}
|
||||
return ":/icons/" + style;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,18 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//--------------------api
|
||||
|
||||
QString GetDirectoryName(QString path);
|
||||
|
||||
QString GetIconPath();
|
||||
|
||||
//------------------class
|
||||
|
||||
class StringPair
|
||||
{
|
||||
@@ -35,33 +45,57 @@ public:
|
||||
string m_value;
|
||||
};
|
||||
|
||||
struct AppOptions
|
||||
class AppOptions
|
||||
{
|
||||
bool quickScroll;
|
||||
public:
|
||||
bool quickScroll;
|
||||
bool warnofMultiTrig;
|
||||
|
||||
|
||||
vector<StringPair> m_protocolFormats;
|
||||
};
|
||||
|
||||
class FrameOptions
|
||||
{
|
||||
public:
|
||||
QString style;
|
||||
int language;
|
||||
QByteArray geometry;
|
||||
bool isMax;
|
||||
QByteArray windowState;
|
||||
};
|
||||
|
||||
class UserHistory
|
||||
{
|
||||
public:
|
||||
QString exportDir;
|
||||
QString saveDir;
|
||||
bool showDocuments;
|
||||
QString screenShotPath;
|
||||
QString sessionDir;
|
||||
QString openDir;
|
||||
QString protocolExportPath;
|
||||
};
|
||||
|
||||
|
||||
class AppConfig
|
||||
{
|
||||
private:
|
||||
AppConfig();
|
||||
|
||||
~AppConfig();
|
||||
|
||||
public:
|
||||
static AppConfig &Instance();
|
||||
bool Load(const char *file);
|
||||
bool Save();
|
||||
string ToJsonString();
|
||||
void FromJson(string &json);
|
||||
|
||||
void LoadAll();
|
||||
void SaveApp();
|
||||
void SaveHistory();
|
||||
void SaveFrame();
|
||||
|
||||
void SetProtocolFormat(const string &protocolName, const string &value);
|
||||
string GetProtocolFormat(const string &protocolName);
|
||||
|
||||
public:
|
||||
AppOptions _appOptions;
|
||||
|
||||
private:
|
||||
string m_fileName;
|
||||
vector<StringPair> m_protocolFormats;
|
||||
AppOptions _appOptions;
|
||||
UserHistory _userHistory;
|
||||
FrameOptions _frameOptions;
|
||||
};
|
||||
|
||||
@@ -33,11 +33,7 @@ SignalData::SignalData() :
|
||||
}
|
||||
|
||||
SignalData::~SignalData() {}
|
||||
|
||||
double SignalData::samplerate() const
|
||||
{
|
||||
return _samplerate;
|
||||
}
|
||||
|
||||
|
||||
void SignalData::set_samplerate(double samplerate)
|
||||
{
|
||||
|
||||
@@ -35,17 +35,17 @@ class SignalData
|
||||
public:
|
||||
SignalData();
|
||||
virtual ~SignalData() = 0;
|
||||
|
||||
public:
|
||||
double samplerate() const;
|
||||
inline double samplerate()const
|
||||
{return _samplerate; }
|
||||
|
||||
void set_samplerate(double samplerate);
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void init() = 0;
|
||||
|
||||
protected:
|
||||
mutable boost::recursive_mutex _mutex;
|
||||
|
||||
double _samplerate;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "about.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace dialogs {
|
||||
@@ -80,7 +81,11 @@ About::About(QWidget *parent) :
|
||||
QDir dir(DS_RES_PATH);
|
||||
dir.cdUp();
|
||||
#endif
|
||||
QString filename = dir.absolutePath() + "/NEWS" + QString::number(qApp->property("Language").toInt());
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int lan = app._frameOptions.language;
|
||||
|
||||
QString filename = dir.absolutePath() + "/NEWS" + QString::number(lan);
|
||||
QFile news(filename);
|
||||
if (news.open(QIODevice::ReadOnly)) {
|
||||
QTextCodec *code=QTextCodec::codecForName("UTF-8");
|
||||
|
||||
@@ -49,10 +49,10 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
|
||||
lay.setContentsMargins(0,20,0,30);
|
||||
|
||||
//show config
|
||||
AppOptions &_app = AppConfig::Instance()._appOptions;
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
QCheckBox *ck_quickScroll = new QCheckBox();
|
||||
ck_quickScroll->setChecked(_app.quickScroll);
|
||||
ck_quickScroll->setChecked(app._appOptions.quickScroll);
|
||||
lay.addRow("Quick scroll", ck_quickScroll);
|
||||
dlg.layout()->addLayout(&lay);
|
||||
|
||||
@@ -62,9 +62,8 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
|
||||
|
||||
//save config
|
||||
if (ret){
|
||||
_app.quickScroll = ck_quickScroll->isChecked();
|
||||
|
||||
AppConfig::Instance().Save();
|
||||
app._appOptions.quickScroll = ck_quickScroll->isChecked();
|
||||
app.SaveApp();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
#include "protocolexp.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QListWidget>
|
||||
#include <QFile>
|
||||
@@ -39,6 +38,7 @@
|
||||
#include "../data/decode/annotation.h"
|
||||
#include "../view/decodetrace.h"
|
||||
#include "../data/decodermodel.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -118,15 +118,20 @@ void ProtocolExp::accept()
|
||||
if(i < supportedFormats.count() - 1)
|
||||
filter.append(";;");
|
||||
}
|
||||
const QString DIR_KEY("ProtocolExportPath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
QString default_filter = _format_combobox->currentText();
|
||||
|
||||
QString default_name = settings.value(DIR_KEY).toString() + "/" + "decoder-";
|
||||
QString default_name = app._userHistory.protocolExportPath + "/" + "decoder-";
|
||||
default_name += _session.get_session_time().toString("-yyMMdd-hhmmss");
|
||||
|
||||
QString file_name = QFileDialog::getSaveFileName(
|
||||
this, tr("Export Data"), default_name,filter,&default_filter);
|
||||
this,
|
||||
tr("Export Data"),
|
||||
default_name,filter,
|
||||
&default_filter);
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QFileInfo f(file_name);
|
||||
QStringList list = default_filter.split('.').last().split(')');
|
||||
@@ -134,8 +139,12 @@ void ProtocolExp::accept()
|
||||
if(f.suffix().compare(ext))
|
||||
file_name+=tr(".")+ext;
|
||||
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.filePath(file_name));
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.openDir)
|
||||
{
|
||||
app._userHistory.protocolExportPath = fname;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
QFile file(file_name);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "../view/trace.h"
|
||||
#include "../view/dsosignal.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -62,7 +63,7 @@ WaitingDialog::WaitingDialog(QWidget *parent, SigSession &session, int key) :
|
||||
warning_tips->setFont(font);
|
||||
warning_tips->setAlignment(Qt::AlignCenter);
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
label = new QLabel(this);
|
||||
movie = new QMovie(iconPath+"/wait.gif");
|
||||
label->setMovie(movie);
|
||||
|
||||
@@ -200,7 +200,7 @@ void DsoTriggerDock::retranslateUi()
|
||||
|
||||
void DsoTriggerDock::reStyle()
|
||||
{
|
||||
//QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
|
||||
}
|
||||
|
||||
void DsoTriggerDock::paintEvent(QPaintEvent *)
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QPainter>
|
||||
#include <QRegExpValidator>
|
||||
#include <QMessageBox>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
using namespace boost;
|
||||
|
||||
@@ -183,7 +184,7 @@ void MeasureDock::retranslateUi()
|
||||
|
||||
void MeasureDock::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_dist_add_btn->setIcon(QIcon(iconPath+"/add.svg"));
|
||||
_edge_add_btn->setIcon(QIcon(iconPath+"/add.svg"));
|
||||
@@ -247,7 +248,7 @@ void MeasureDock::cursor_update()
|
||||
update_edge();
|
||||
|
||||
int index = 1;
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
for(std::list<Cursor*>::iterator i = _view.get_cursorList().begin();
|
||||
i != _view.get_cursorList().end(); i++) {
|
||||
QString curCursor = QString::number(index);
|
||||
@@ -336,7 +337,7 @@ void MeasureDock::add_dist_measure()
|
||||
row_widget->setLayout(row_layout);
|
||||
_dist_row_widget_vec.push_back(row_widget);
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
QToolButton *del_btn = new QToolButton(row_widget);
|
||||
del_btn->setIcon(QIcon(iconPath+"/del.svg"));
|
||||
del_btn->setCheckable(true);
|
||||
@@ -402,7 +403,7 @@ void MeasureDock::add_edge_measure()
|
||||
row_widget->setLayout(row_layout);
|
||||
_edge_row_widget_vec.push_back(row_widget);
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
QToolButton *del_btn = new QToolButton(row_widget);
|
||||
del_btn->setIcon(QIcon(iconPath+"/del.svg"));
|
||||
del_btn->setCheckable(true);
|
||||
|
||||
@@ -234,7 +234,7 @@ void ProtocolDock::retranslateUi()
|
||||
|
||||
void ProtocolDock::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_add_button->setIcon(QIcon(iconPath+"/add.svg"));
|
||||
_del_all_button->setIcon(QIcon(iconPath+"/del.svg"));
|
||||
@@ -777,7 +777,6 @@ void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){
|
||||
if ((*it) == handle){
|
||||
QString &name = (*it)->GetProtocolName();
|
||||
AppConfig::Instance().SetProtocolFormat(name.toStdString(), format.toStdString());
|
||||
AppConfig::Instance().Save();
|
||||
(*it)->m_decoderStatus->m_format = DecoderDataFormat::Parse(format.toStdString().c_str());
|
||||
protocol_updated();
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../dsvdef.h"
|
||||
#include <QtCore>
|
||||
#include <assert.h>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace dock {
|
||||
@@ -41,7 +42,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro
|
||||
_del_button = new QPushButton(parent);
|
||||
_format_combox = new QComboBox(parent);
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
_del_button->setFlat(true);
|
||||
_del_button->setIcon(QIcon(iconPath + "/del.svg"));
|
||||
_set_button->setFlat(true);
|
||||
@@ -107,7 +108,7 @@ void ProtocolItemLayer::on_format_select_changed(int index){
|
||||
}
|
||||
|
||||
void ProtocolItemLayer::ResetStyle(){
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
_del_button->setIcon(QIcon(iconPath + "/del.svg"));
|
||||
_set_button->setIcon(QIcon(iconPath + "/gear.svg"));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace dock {
|
||||
@@ -109,7 +110,7 @@ void SearchDock::retranslateUi()
|
||||
|
||||
void SearchDock::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_pre_button.setIcon(QIcon(iconPath+"/pre.svg"));
|
||||
_nxt_button.setIcon(QIcon(iconPath+"/next.svg"));
|
||||
|
||||
@@ -160,7 +160,7 @@ void TriggerDock::retranslateUi()
|
||||
|
||||
void TriggerDock::reStyle()
|
||||
{
|
||||
//QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
|
||||
}
|
||||
|
||||
void TriggerDock::paintEvent(QPaintEvent *)
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <QDesktopServices>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
|
||||
#include "dsvdef.h"
|
||||
#include "config/appconfig.h"
|
||||
#include "../ui/msgbox.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -132,6 +135,7 @@ MainFrame::MainFrame(DeviceManager &device_manager,
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(unfreezing()));
|
||||
//readSettings();
|
||||
|
||||
}
|
||||
|
||||
void MainFrame::changeEvent(QEvent* event)
|
||||
@@ -364,34 +368,20 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
}
|
||||
|
||||
void MainFrame::writeSettings()
|
||||
{
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
|
||||
settings.beginGroup("MainFrame");
|
||||
settings.setValue("style", qApp->property("Style").toString());
|
||||
settings.setValue("language", qApp->property("Language").toInt());
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("isMax", isMaximized());
|
||||
settings.endGroup();
|
||||
{
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
app._frameOptions.isMax = isMaximized();
|
||||
app._frameOptions.geometry = saveGeometry();
|
||||
app.SaveFrame();
|
||||
}
|
||||
|
||||
void MainFrame::readSettings()
|
||||
{
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
_mainWindow->switchLanguage(app._frameOptions.language);
|
||||
|
||||
settings.beginGroup("MainFrame");
|
||||
bool isMax = settings.value("isMax", false).toBool();
|
||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
// defaut language
|
||||
if (settings.contains("language")) {
|
||||
_mainWindow->switchLanguage(settings.value("language").toInt());
|
||||
} else {
|
||||
QLocale locale;
|
||||
_mainWindow->switchLanguage(locale.language());
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
if (geometry.isEmpty()) {
|
||||
if (app._frameOptions.geometry.isEmpty()) {
|
||||
QScreen *screen=QGuiApplication::primaryScreen ();
|
||||
const QRect availableGeometry = screen->availableGeometry();
|
||||
resize(availableGeometry.width() / 2, availableGeometry.height() / 1.5);
|
||||
@@ -399,12 +389,20 @@ void MainFrame::readSettings()
|
||||
const int origY = std::max(0, (availableGeometry.height() - height()) / 2);
|
||||
move(origX, origY);
|
||||
} else {
|
||||
restoreGeometry(geometry);
|
||||
try
|
||||
{
|
||||
QByteArray ge = app._frameOptions.geometry;
|
||||
restoreGeometry(ge);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
MsgBox::Show(NULL, "restore frame status error!");
|
||||
}
|
||||
}
|
||||
|
||||
// restore dockwidgets
|
||||
_mainWindow->restore_dock();
|
||||
_titleBar->setRestoreButton(isMax);
|
||||
_titleBar->setRestoreButton(app._frameOptions.isMax);
|
||||
}
|
||||
|
||||
void MainFrame::setTaskbarProgress(int progress)
|
||||
@@ -414,14 +412,15 @@ void MainFrame::setTaskbarProgress(int progress)
|
||||
|
||||
void MainFrame::show_doc()
|
||||
{
|
||||
const QString DOC_KEY("ShowDocuments");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
if (!settings.contains(DOC_KEY)) {
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int lan = app._frameOptions.language;
|
||||
|
||||
if (app._userHistory.showDocuments) {
|
||||
dialogs::DSDialog dlg(this, true);
|
||||
dlg.setTitle(tr("Document"));
|
||||
|
||||
QLabel tipsLabel;
|
||||
tipsLabel.setPixmap(QPixmap(":/icons/showDoc"+QString::number(_mainWindow->language())+".png"));
|
||||
tipsLabel.setPixmap(QPixmap(":/icons/showDoc"+QString::number(lan)+".png"));
|
||||
QMessageBox msg;
|
||||
msg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
msg.setContentsMargins(0, 0, 0, 0);
|
||||
@@ -441,8 +440,10 @@ void MainFrame::show_doc()
|
||||
if (msg.clickedButton() == openButton) {
|
||||
_mainWindow->openDoc();
|
||||
}
|
||||
if (msg.clickedButton() == noMoreButton)
|
||||
settings.setValue(DOC_KEY, false);
|
||||
if (msg.clickedButton() == noMoreButton){
|
||||
app._userHistory.showDocuments = false;
|
||||
app.SaveHistory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,16 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
#include <libsigrokdecode4DSL/libsigrokdecode.h>
|
||||
#include "dock/protocoldock.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
@@ -48,6 +47,7 @@
|
||||
#include <QEvent>
|
||||
#include <QtGlobal>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
#include <list>
|
||||
#include <libusb.h>
|
||||
#include "../ui/msgbox.h"
|
||||
#include "config/appconfig.h"
|
||||
|
||||
using boost::shared_ptr;
|
||||
using boost::dynamic_pointer_cast;
|
||||
@@ -174,7 +175,7 @@ void MainWindow::setup_ui()
|
||||
addToolBar(_logo_bar);
|
||||
|
||||
// Setup the dockWidget
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// protocol dock
|
||||
_protocol_dock=new QDockWidget(tr("Protocol"),this);
|
||||
_protocol_dock->setObjectName("protocol_dock");
|
||||
@@ -186,7 +187,7 @@ void MainWindow::setup_ui()
|
||||
_protocol_dock->setWidget(_protocol_widget);
|
||||
qDebug() << "Protocol decoder enabled!\n";
|
||||
|
||||
#endif
|
||||
|
||||
// measure dock
|
||||
_measure_dock=new QDockWidget(tr("Measurement"),this);
|
||||
_measure_dock->setObjectName("measure_dock");
|
||||
@@ -206,9 +207,9 @@ void MainWindow::setup_ui()
|
||||
_search_widget = new dock::SearchDock(_search_dock, *_view, _session);
|
||||
_search_dock->setWidget(_search_widget);
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
addDockWidget(Qt::RightDockWidgetArea,_protocol_dock);
|
||||
#endif
|
||||
|
||||
addDockWidget(Qt::RightDockWidgetArea,_trigger_dock);
|
||||
addDockWidget(Qt::RightDockWidgetArea,_dso_trigger_dock);
|
||||
addDockWidget(Qt::RightDockWidgetArea, _measure_dock);
|
||||
@@ -228,9 +229,9 @@ void MainWindow::setup_ui()
|
||||
_logo_bar->installEventFilter(this);
|
||||
_dso_trigger_dock->installEventFilter(this);
|
||||
_trigger_dock->installEventFilter(this);
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_protocol_dock->installEventFilter(this);
|
||||
#endif
|
||||
|
||||
_measure_dock->installEventFilter(this);
|
||||
_search_dock->installEventFilter(this);
|
||||
|
||||
@@ -239,13 +240,10 @@ void MainWindow::setup_ui()
|
||||
QString(tr("Set Default Device failed")), _1));
|
||||
|
||||
// defaut language
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
QLocale locale;
|
||||
settings.beginGroup("MainFrame");
|
||||
switchLanguage(settings.value("language", locale.language()).toInt());
|
||||
switchTheme(settings.value("style", "dark").toString());
|
||||
settings.endGroup();
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
switchLanguage(app._frameOptions.language);
|
||||
switchTheme(app._frameOptions.style);
|
||||
|
||||
// UI initial
|
||||
_measure_widget->add_dist_measure();
|
||||
|
||||
@@ -288,9 +286,9 @@ void MainWindow::setup_ui()
|
||||
connect(_logo_bar, SIGNAL(setLanguage(int)), this, SLOT(switchLanguage(int)));
|
||||
connect(_logo_bar, SIGNAL(openDoc()), this, SLOT(openDoc()));
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
connect(_protocol_widget, SIGNAL(protocol_updated()), _view, SLOT(signals_changed()));
|
||||
#endif
|
||||
|
||||
|
||||
connect(_sampling_bar, SIGNAL(device_selected()), this, SLOT(update_device_list()));
|
||||
connect(_sampling_bar, SIGNAL(device_updated()), this, SLOT(reload()));
|
||||
@@ -329,21 +327,23 @@ void MainWindow::update_device_list()
|
||||
if (_msg)
|
||||
_msg->close();
|
||||
|
||||
switchLanguage(_language);
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
switchLanguage(app._frameOptions.language);
|
||||
_session.stop_capture();
|
||||
_view->reload();
|
||||
_trigger_widget->device_updated();
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_protocol_widget->del_all_protocol();
|
||||
#endif
|
||||
|
||||
_trig_bar->reload();
|
||||
|
||||
shared_ptr<pv::device::DevInst> selected_device = _session.get_device();
|
||||
boost::shared_ptr<pv::device::DevInst> selected_device = _session.get_device();
|
||||
_device_manager.add_device(selected_device);
|
||||
_session.init_signals();
|
||||
_sampling_bar->set_device_list(_device_manager.devices(), selected_device);
|
||||
|
||||
shared_ptr<pv::device::File> file_dev;
|
||||
boost::shared_ptr<pv::device::File> file_dev;
|
||||
if((file_dev = dynamic_pointer_cast<pv::device::File>(selected_device))) {
|
||||
// check version
|
||||
if (selected_device->dev_inst()->mode == LOGIC) {
|
||||
@@ -360,11 +360,11 @@ void MainWindow::update_device_list()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// load decoders
|
||||
StoreSession ss(_session);
|
||||
ss.load_decoders(_protocol_widget, file_dev->get_decoders());
|
||||
#endif
|
||||
|
||||
|
||||
// load session
|
||||
load_session_json(file_dev->get_session(), true);
|
||||
@@ -386,7 +386,7 @@ void MainWindow::update_device_list()
|
||||
#endif
|
||||
if (dir.exists()) {
|
||||
QString str = dir.absolutePath() + "/";
|
||||
QString lang_name = ".ses" + QString::number(_language);
|
||||
QString lang_name = ".ses" + QString::number(app._frameOptions.language);
|
||||
QString ses_name = str +
|
||||
selected_device->name() +
|
||||
QString::number(selected_device->dev_inst()->mode) +
|
||||
@@ -712,11 +712,14 @@ void MainWindow::session_save()
|
||||
#else
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
#endif
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
if(dir.mkpath(path)) {
|
||||
dir.cd(path);
|
||||
QString driver_name = _session.get_device()->name();
|
||||
QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
|
||||
QString lang_name = ".ses" + QString::number(_language);
|
||||
QString lang_name = ".ses" + QString::number(app._frameOptions.language);
|
||||
QString file_name = dir.absolutePath() + "/" +
|
||||
driver_name + mode_name +
|
||||
lang_name + ".dsc";
|
||||
@@ -725,9 +728,9 @@ void MainWindow::session_save()
|
||||
store_session(file_name);
|
||||
}
|
||||
}
|
||||
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
settings.setValue("windowState", saveState());
|
||||
|
||||
app._frameOptions.windowState = saveState();
|
||||
app.SaveFrame();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
@@ -739,9 +742,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
void MainWindow::on_protocol(bool visible)
|
||||
{
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_protocol_dock->setVisible(visible);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_trigger(bool visible)
|
||||
@@ -761,8 +764,8 @@ void MainWindow::on_trigger(bool visible)
|
||||
void MainWindow::commit_trigger(bool instant)
|
||||
{
|
||||
int i = 0;
|
||||
const QString TRIG_KEY("WarnofMultiTrig");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
ds_trigger_init();
|
||||
|
||||
@@ -781,8 +784,7 @@ void MainWindow::commit_trigger(bool instant)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!settings.contains(TRIG_KEY) &&
|
||||
i > 1) {
|
||||
if (app._appOptions.warnofMultiTrig && i > 1) {
|
||||
dialogs::DSMessageBox msg(this);
|
||||
msg.mBox()->setText(tr("Trigger"));
|
||||
msg.mBox()->setInformativeText(tr("Trigger setted on multiple channels! "
|
||||
@@ -806,7 +808,10 @@ void MainWindow::commit_trigger(bool instant)
|
||||
}
|
||||
}
|
||||
if (msg.mBox()->clickedButton() == noMoreButton)
|
||||
settings.setValue(TRIG_KEY, false);
|
||||
{
|
||||
app._appOptions.warnofMultiTrig = false;
|
||||
app.SaveApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -824,9 +829,8 @@ void MainWindow::on_search(bool visible)
|
||||
|
||||
void MainWindow::on_screenShot()
|
||||
{
|
||||
const QString DIR_KEY("ScreenShotPath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
QString default_name = settings.value(DIR_KEY).toString() + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
QString default_name = app._userHistory.screenShotPath + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
|
||||
QPixmap pixmap;
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
@@ -838,10 +842,16 @@ void MainWindow::on_screenShot()
|
||||
tr("Save As"), default_name,
|
||||
tr("%1 Files (*.%2);;All Files (*)")
|
||||
.arg(format.toUpper()).arg(format));
|
||||
if (!fileName.isEmpty()) {
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.filePath(fileName));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
pixmap.save(fileName, format.toLatin1());
|
||||
|
||||
fileName = GetDirectoryName(fileName);
|
||||
|
||||
if (app._userHistory.screenShotPath != fileName){
|
||||
app._userHistory.screenShotPath = fileName;
|
||||
app.SaveHistory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,6 +925,8 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev)
|
||||
return false;
|
||||
}
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
// check language
|
||||
if (sessionObj.contains("Language")) {
|
||||
switchLanguage(sessionObj["Language"].toInt());
|
||||
@@ -922,7 +934,7 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev)
|
||||
bool language_matched = _session.get_device()->set_config(NULL, NULL, SR_CONF_OPERATION_MODE,
|
||||
g_variant_new_string(sessionObj["Operation Mode"].toString().toUtf8()));
|
||||
if (!language_matched) {
|
||||
if (_language != QLocale::Chinese)
|
||||
if (app._frameOptions.language != QLocale::Chinese)
|
||||
switchLanguage(QLocale::Chinese);
|
||||
else
|
||||
switchLanguage(QLocale::English);
|
||||
@@ -930,11 +942,11 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev)
|
||||
}
|
||||
|
||||
// clear decoders
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
if (sdi->mode == LOGIC) {
|
||||
_protocol_widget->del_all_protocol();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// load device settings
|
||||
GVariant *gvar_opts;
|
||||
@@ -1075,13 +1087,13 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev)
|
||||
}
|
||||
on_trigger(false);
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// load decoders
|
||||
if (sessionObj.contains("decoder")) {
|
||||
StoreSession ss(_session);
|
||||
ss.load_decoders(_protocol_widget, sessionObj["decoder"].toArray());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// load measure
|
||||
if (sessionObj.contains("measure")) {
|
||||
@@ -1103,6 +1115,8 @@ bool MainWindow::store_session(QString name)
|
||||
outStream.setCodec("UTF-8");
|
||||
//outStream.setGenerateByteOrderMark(true); // UTF-8 without BOM
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
GVariant *gvar_opts;
|
||||
GVariant *gvar;
|
||||
gsize num_opts;
|
||||
@@ -1112,7 +1126,7 @@ bool MainWindow::store_session(QString name)
|
||||
sessionVar["Version"]= QJsonValue::fromVariant(Session_Version);
|
||||
sessionVar["Device"] = QJsonValue::fromVariant(sdi->driver->name);
|
||||
sessionVar["DeviceMode"] = QJsonValue::fromVariant(sdi->mode);
|
||||
sessionVar["Language"] = QJsonValue::fromVariant(_language);
|
||||
sessionVar["Language"] = QJsonValue::fromVariant(app._frameOptions.language);
|
||||
|
||||
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_SESSIONS, &gvar_opts) != SR_OK))
|
||||
return false; /* Driver supports no device instance sessions. */
|
||||
@@ -1180,10 +1194,10 @@ bool MainWindow::store_session(QString name)
|
||||
sessionVar["trigger"] = _trigger_widget->get_session();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
StoreSession ss(_session);
|
||||
sessionVar["decoder"] = ss.json_decoders();
|
||||
#endif
|
||||
|
||||
|
||||
if (_session.get_device()->dev_inst()->mode == DSO) {
|
||||
sessionVar["measure"] = _view->get_viewstatus()->get_session();
|
||||
@@ -1198,9 +1212,20 @@ bool MainWindow::store_session(QString name)
|
||||
|
||||
void MainWindow::restore_dock()
|
||||
{
|
||||
// default dockwidget size
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
restoreState(settings.value("windowState").toByteArray());
|
||||
// default dockwidget size
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
QByteArray st = app._frameOptions.windowState;
|
||||
if (!st.isEmpty()){
|
||||
try
|
||||
{
|
||||
restoreState(st);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
MsgBox::Show(NULL, "restore window status error!");
|
||||
}
|
||||
}
|
||||
|
||||
if (_session.get_device()->dev_inst()->mode != DSO) {
|
||||
_dso_trigger_dock->setVisible(false);
|
||||
_trig_bar->update_trig_btn(_trigger_dock->isVisible());
|
||||
@@ -1209,9 +1234,9 @@ void MainWindow::restore_dock()
|
||||
_trig_bar->update_trig_btn(_dso_trigger_dock->isVisible());
|
||||
}
|
||||
if (_session.get_device()->dev_inst()->mode != LOGIC) {
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
on_protocol(false);
|
||||
#endif
|
||||
|
||||
}
|
||||
_trig_bar->update_protocol_btn(_protocol_dock->isVisible());
|
||||
_trig_bar->update_measure_btn(_measure_dock->isVisible());
|
||||
@@ -1223,7 +1248,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
(void) object;
|
||||
|
||||
if ( event->type() == QEvent::KeyPress ) {
|
||||
const vector< shared_ptr<view::Signal> > sigs(_session.get_signals());
|
||||
const vector< boost::shared_ptr<view::Signal> > sigs(_session.get_signals());
|
||||
QKeyEvent *ke = (QKeyEvent *) event;
|
||||
switch(ke->key()) {
|
||||
case Qt::Key_S:
|
||||
@@ -1238,11 +1263,11 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
else
|
||||
on_trigger(!_trigger_dock->isVisible());
|
||||
break;
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
case Qt::Key_D:
|
||||
on_protocol(!_protocol_dock->isVisible());
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Qt::Key_M:
|
||||
on_measure(!_measure_dock->isVisible());
|
||||
break;
|
||||
@@ -1268,8 +1293,8 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
_view->zoom(-1);
|
||||
break;
|
||||
case Qt::Key_0:
|
||||
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, sigs) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
if (dsoSig->get_index() == 0)
|
||||
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
|
||||
@@ -1281,8 +1306,8 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, sigs) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
if (dsoSig->get_index() == 1)
|
||||
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
|
||||
@@ -1294,8 +1319,8 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, sigs) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
if (dsoSig->get_vDialActive()) {
|
||||
dsoSig->go_vDialNext(true);
|
||||
@@ -1306,8 +1331,8 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, sigs) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
if (dsoSig->get_vDialActive()) {
|
||||
dsoSig->go_vDialPre(true);
|
||||
@@ -1324,46 +1349,51 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int MainWindow::language() const
|
||||
{
|
||||
return _language;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::switchLanguage(int language)
|
||||
{
|
||||
shared_ptr<pv::device::DevInst> dev = _session.get_device();
|
||||
boost::shared_ptr<pv::device::DevInst> dev = _session.get_device();
|
||||
dev->set_config(NULL, NULL, SR_CONF_LANGUAGE, g_variant_new_int16(language));
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
if (_language != language) {
|
||||
_language = language;
|
||||
if (_language != QLocale::English) {
|
||||
_qtTrans.load(":/qt_"+QString::number(_language));
|
||||
qApp->installTranslator(&_qtTrans);
|
||||
_myTrans.load(":/my_"+QString::number(_language));
|
||||
qApp->installTranslator(&_myTrans);
|
||||
retranslateUi();
|
||||
} else {
|
||||
qApp->removeTranslator(&_qtTrans);
|
||||
qApp->removeTranslator(&_myTrans);
|
||||
retranslateUi();
|
||||
}
|
||||
qApp->setProperty("Language", _language);
|
||||
if (app._frameOptions.language != language)
|
||||
{
|
||||
app._frameOptions.language = language;
|
||||
app.SaveFrame();
|
||||
}
|
||||
|
||||
if (language != QLocale::English)
|
||||
{
|
||||
_qtTrans.load(":/qt_" + QString::number(language));
|
||||
qApp->installTranslator(&_qtTrans);
|
||||
_myTrans.load(":/my_" + QString::number(language));
|
||||
qApp->installTranslator(&_myTrans);
|
||||
retranslateUi();
|
||||
}
|
||||
else
|
||||
{
|
||||
qApp->removeTranslator(&_qtTrans);
|
||||
qApp->removeTranslator(&_myTrans);
|
||||
retranslateUi();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::switchTheme(QString style)
|
||||
{
|
||||
if (_style != style) {
|
||||
_style = style;
|
||||
qApp->setProperty("Style", _style);
|
||||
QString qssRes = ":/"+_style+".qss";
|
||||
QFile qss(qssRes);
|
||||
qss.open(QFile::ReadOnly | QFile::Text);
|
||||
qApp->setStyleSheet(qss.readAll());
|
||||
qss.close();
|
||||
_session.data_updated();
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
if (app._frameOptions.style != style)
|
||||
{
|
||||
app._frameOptions.style = style;
|
||||
app.SaveFrame();
|
||||
}
|
||||
|
||||
QString qssRes = ":/" + style + ".qss";
|
||||
QFile qss(qssRes);
|
||||
qss.open(QFile::ReadOnly | QFile::Text);
|
||||
qApp->setStyleSheet(qss.readAll());
|
||||
qss.close();
|
||||
_session.data_updated();
|
||||
}
|
||||
|
||||
void MainWindow::openDoc()
|
||||
@@ -1374,8 +1404,10 @@ void MainWindow::openDoc()
|
||||
QDir dir(DS_RES_PATH);
|
||||
dir.cdUp();
|
||||
#endif
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int lan = app._frameOptions.language;
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("file:///"+dir.absolutePath() + "/ug"+QString::number(_language)+".pdf"));
|
||||
QUrl("file:///"+dir.absolutePath() + "/ug"+QString::number(lan)+".pdf"));
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
|
||||
public slots:
|
||||
void session_save();
|
||||
int language() const;
|
||||
|
||||
void openDoc();
|
||||
|
||||
void switchLanguage(int language);
|
||||
@@ -190,10 +190,10 @@ private:
|
||||
toolbars::FileBar *_file_bar;
|
||||
toolbars::LogoBar *_logo_bar; //help button, on top right
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
QDockWidget *_protocol_dock;
|
||||
dock::ProtocolDock *_protocol_widget;
|
||||
#endif
|
||||
|
||||
|
||||
QDockWidget *_trigger_dock;
|
||||
QDockWidget *_dso_trigger_dock;
|
||||
@@ -204,8 +204,6 @@ private:
|
||||
QDockWidget *_search_dock;
|
||||
dock::SearchDock * _search_widget;
|
||||
|
||||
int _language;
|
||||
QString _style;
|
||||
QTranslator _qtTrans;
|
||||
QTranslator _myTrans;
|
||||
};
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
#include <libsigrokdecode4DSL/libsigrokdecode.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "sigsession.h"
|
||||
#include "mainwindow.h"
|
||||
@@ -110,9 +110,9 @@ SigSession::SigSession(DeviceManager &device_manager) :
|
||||
_noData_cnt = 0;
|
||||
_data_lock = false;
|
||||
_data_updated = false;
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_decoder_model = new pv::data::DecoderModel(this);
|
||||
#endif
|
||||
|
||||
_lissajous_trace = NULL;
|
||||
_math_trace = NULL;
|
||||
_saving = false;
|
||||
@@ -173,9 +173,9 @@ void SigSession::set_device(boost::shared_ptr<device::DevInst> dev_inst)
|
||||
}
|
||||
|
||||
_dev_inst = dev_inst;
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_decode_traces.clear();
|
||||
#endif
|
||||
|
||||
_group_traces.clear();
|
||||
|
||||
if (_dev_inst) {
|
||||
@@ -324,11 +324,11 @@ void SigSession::set_cur_snap_samplerate(uint64_t samplerate)
|
||||
if (_group_data)
|
||||
_group_data->set_samplerate(_cur_snap_samplerate);
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// DecoderStack
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
|
||||
d->decoder()->set_samplerate(_cur_snap_samplerate);
|
||||
#endif
|
||||
|
||||
// Math
|
||||
if (_math_trace && _math_trace->enabled())
|
||||
_math_trace->get_math_stack()->set_samplerate(_dev_inst->get_sample_rate());
|
||||
@@ -415,7 +415,7 @@ void SigSession::container_init()
|
||||
if (_math_trace)
|
||||
_math_trace->get_math_stack()->init();
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// DecoderModel
|
||||
//pv::data::DecoderModel *decoder_model = get_decoder_model();
|
||||
//decoder_model->setDecoderStack(NULL);
|
||||
@@ -425,7 +425,7 @@ void SigSession::container_init()
|
||||
assert(d);
|
||||
d->decoder()->init();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SigSession::start_capture(bool instant,
|
||||
@@ -489,13 +489,13 @@ void SigSession::start_capture(bool instant,
|
||||
void SigSession::stop_capture()
|
||||
{
|
||||
data_unlock();
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
for (vector< boost::shared_ptr<view::DecodeTrace> >::iterator i =
|
||||
_decode_traces.begin();
|
||||
i != _decode_traces.end();
|
||||
i++)
|
||||
(*i)->decoder()->stop_decode();
|
||||
#endif
|
||||
|
||||
if (get_capture_state() != Running)
|
||||
return;
|
||||
|
||||
@@ -707,10 +707,10 @@ void SigSession::init_signals()
|
||||
if (_group_data)
|
||||
_group_data->clear();
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
// Clear the decode traces
|
||||
_decode_traces.clear();
|
||||
#endif
|
||||
|
||||
|
||||
// Detect what data types we will receive
|
||||
if(_dev_inst) {
|
||||
@@ -865,13 +865,13 @@ void SigSession::refresh(int holdtime)
|
||||
if (_logic_data) {
|
||||
_logic_data->init();
|
||||
//_cur_logic_snapshot.reset();
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
|
||||
{
|
||||
assert(d);
|
||||
d->decoder()->init();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
if (_dso_data) {
|
||||
_dso_data->init();
|
||||
@@ -1143,6 +1143,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
|
||||
|
||||
if (_data_lock && packet->type != SR_DF_END)
|
||||
return;
|
||||
|
||||
if (packet->type != SR_DF_END &&
|
||||
packet->status != SR_PKT_OK) {
|
||||
_error = Pkt_data_err;
|
||||
@@ -1207,10 +1208,10 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
|
||||
_cur_logic_snapshot->capture_ended();
|
||||
_cur_dso_snapshot->capture_ended();
|
||||
_cur_analog_snapshot->capture_ended();
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
|
||||
d->frame_ended();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (packet->status != SR_PKT_OK) {
|
||||
@@ -1366,7 +1367,7 @@ uint16_t SigSession::get_ch_num(int type)
|
||||
return num_channels;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
bool SigSession::add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus)
|
||||
{
|
||||
bool ret = false;
|
||||
@@ -1506,7 +1507,7 @@ pv::data::DecoderModel* SigSession::get_decoder_model() const
|
||||
{
|
||||
return _decoder_model;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void SigSession::spectrum_rebuild()
|
||||
{
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
std::vector< boost::shared_ptr<view::GroupSignal> >
|
||||
get_group_signals();
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus);
|
||||
|
||||
std::vector< boost::shared_ptr<view::DecodeTrace> >
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
void rst_decoder(view::DecodeTrace *signal);
|
||||
|
||||
pv::data::DecoderModel* get_decoder_model() const;
|
||||
#endif
|
||||
|
||||
|
||||
std::vector< boost::shared_ptr<view::SpectrumTrace> >
|
||||
get_spectrum_traces();
|
||||
@@ -323,10 +323,10 @@ private:
|
||||
//mutable boost::mutex _signals_mutex;
|
||||
std::vector< boost::shared_ptr<view::Signal> > _signals;
|
||||
std::vector< boost::shared_ptr<view::GroupSignal> > _group_traces;
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
std::vector< boost::shared_ptr<view::DecodeTrace> > _decode_traces;
|
||||
pv::data::DecoderModel *_decoder_model;
|
||||
#endif
|
||||
|
||||
std::vector< boost::shared_ptr<view::SpectrumTrace> > _spectrum_traces;
|
||||
boost::shared_ptr<view::LissajousTrace> _lissajous_trace;
|
||||
boost::shared_ptr<view::MathTrace> _math_trace;
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
#include <pv/dock/protocoldock.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "config/appconfig.h"
|
||||
|
||||
using boost::dynamic_pointer_cast;
|
||||
using boost::mutex;
|
||||
using boost::shared_ptr;
|
||||
using boost::thread;
|
||||
using boost::lock_guard;
|
||||
using std::deque;
|
||||
@@ -161,10 +161,20 @@ bool StoreSession::save_start(QString session_file)
|
||||
_error = tr("No data to save.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//root dir
|
||||
QString default_name;
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
if (app._userHistory.saveDir != "")
|
||||
{
|
||||
default_name = app._userHistory.saveDir + "/" + _session.get_device()->name() + "-";
|
||||
}
|
||||
else{
|
||||
default_name = _session.get_device()->name() + "-";
|
||||
}
|
||||
|
||||
const QString DIR_KEY("SavePath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
QString default_name = settings.value(DIR_KEY).toString() + "/" + _session.get_device()->name() + "-";
|
||||
for (const GSList *l = _session.get_device()->get_dev_mode_list();
|
||||
l; l = l->next) {
|
||||
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
||||
@@ -173,26 +183,32 @@ bool StoreSession::save_start(QString session_file)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default_name += _session.get_session_time().toString("-yyMMdd-hhmmss");
|
||||
|
||||
// Show the dialog
|
||||
_file_name = QFileDialog::getSaveFileName(
|
||||
NULL, tr("Save File"), default_name,
|
||||
QString svFilePath = QFileDialog::getSaveFileName(
|
||||
NULL,
|
||||
tr("Save File"),
|
||||
default_name,
|
||||
tr("DSView Data (*.dsl)"));
|
||||
|
||||
if (!_file_name.isEmpty()) {
|
||||
QFileInfo f(_file_name);
|
||||
if (!svFilePath.isEmpty()) {
|
||||
QFileInfo f(svFilePath);
|
||||
if(f.suffix().compare("dsl"))
|
||||
_file_name.append(tr(".dsl"));
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.filePath(_file_name));
|
||||
svFilePath.append(tr(".dsl"));
|
||||
|
||||
_file_name = svFilePath;
|
||||
svFilePath = GetDirectoryName(svFilePath);
|
||||
|
||||
if (svFilePath != app._userHistory.saveDir){
|
||||
app._userHistory.saveDir = svFilePath;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
QString meta_file = meta_gen(snapshot);
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
QString decoders_file = decoders_gen();
|
||||
#else
|
||||
QString decoders_file = NULL;
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (meta_file == NULL) {
|
||||
@@ -233,15 +249,15 @@ bool StoreSession::save_start(QString session_file)
|
||||
return false;
|
||||
}
|
||||
|
||||
void StoreSession::save_proc(shared_ptr<data::Snapshot> snapshot)
|
||||
void StoreSession::save_proc(boost::shared_ptr<data::Snapshot> snapshot)
|
||||
{
|
||||
assert(snapshot);
|
||||
|
||||
int ret = SR_ERR;
|
||||
int num = 0;
|
||||
shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
shared_ptr<data::DsoSnapshot> dso_snapshot;
|
||||
boost::shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
boost::shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
boost::shared_ptr<data::DsoSnapshot> dso_snapshot;
|
||||
|
||||
if ((logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
|
||||
uint16_t to_save_probes = 0;
|
||||
@@ -424,7 +440,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
|
||||
fprintf(meta, "total blocks = %d\n", snapshot->get_block_num());
|
||||
}
|
||||
|
||||
shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
boost::shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
if ((logic_snapshot = dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
|
||||
uint16_t to_save_probes = 0;
|
||||
for (l = sdi->channels; l; l = l->next) {
|
||||
@@ -479,7 +495,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
|
||||
} else if (sdi->mode == LOGIC) {
|
||||
fprintf(meta, "trigger time = %lld\n", _session.get_session_time().toMSecsSinceEpoch());
|
||||
} else if (sdi->mode == ANALOG) {
|
||||
shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
boost::shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
if ((analog_snapshot = dynamic_pointer_cast<data::AnalogSnapshot>(snapshot))) {
|
||||
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
|
||||
fprintf(meta, "bits = %d\n", tmp_u8*8);
|
||||
@@ -574,7 +590,8 @@ bool StoreSession::export_start()
|
||||
std::set<int> type_set;
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> sig, _session.get_signals()) {
|
||||
assert(sig);
|
||||
type_set.insert(sig->get_type());
|
||||
int _tp = sig->get_type();
|
||||
type_set.insert(_tp);
|
||||
}
|
||||
|
||||
if (type_set.size() > 1) {
|
||||
@@ -594,9 +611,16 @@ bool StoreSession::export_start()
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString DIR_KEY("ExportPath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
QString default_name = settings.value(DIR_KEY).toString() + "/" + _session.get_device()->name() + "-";
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
QString default_name;
|
||||
if (app._userHistory.exportDir != "")
|
||||
{
|
||||
default_name = app._userHistory.exportDir + "/" + _session.get_device()->name() + "-";
|
||||
}
|
||||
else{
|
||||
default_name = _session.get_device()->name() + "-";
|
||||
}
|
||||
|
||||
for (const GSList *l = _session.get_device()->get_dev_mode_list();
|
||||
l; l = l->next) {
|
||||
@@ -616,17 +640,28 @@ bool StoreSession::export_start()
|
||||
if(i < supportedFormats.count() - 1)
|
||||
filter.append(";;");
|
||||
}
|
||||
_file_name = QFileDialog::getSaveFileName(
|
||||
NULL, tr("Export Data"), default_name,filter,&filter);
|
||||
|
||||
if (!_file_name.isEmpty()) {
|
||||
QString svFilePath = QFileDialog::getSaveFileName(
|
||||
NULL,
|
||||
tr("Export Data"),
|
||||
default_name,
|
||||
filter,
|
||||
&filter);
|
||||
|
||||
if (!svFilePath.isEmpty()) {
|
||||
QFileInfo f(_file_name);
|
||||
QStringList list = filter.split('.').last().split(')');
|
||||
_suffix = list.first();
|
||||
if(f.suffix().compare(_suffix))
|
||||
_file_name += tr(".") + _suffix;
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.filePath(_file_name));
|
||||
svFilePath += tr(".") + _suffix;
|
||||
|
||||
_file_name = svFilePath;
|
||||
svFilePath = GetDirectoryName(svFilePath);
|
||||
|
||||
if (svFilePath != app._userHistory.exportDir ){
|
||||
app._userHistory.exportDir = svFilePath;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
const struct sr_output_module** supportedModules = sr_output_list();
|
||||
while(*supportedModules){
|
||||
@@ -651,13 +686,13 @@ bool StoreSession::export_start()
|
||||
return false;
|
||||
}
|
||||
|
||||
void StoreSession::export_proc(shared_ptr<data::Snapshot> snapshot)
|
||||
void StoreSession::export_proc(boost::shared_ptr<data::Snapshot> snapshot)
|
||||
{
|
||||
assert(snapshot);
|
||||
|
||||
shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
shared_ptr<data::DsoSnapshot> dso_snapshot;
|
||||
boost::shared_ptr<data::LogicSnapshot> logic_snapshot;
|
||||
boost::shared_ptr<data::AnalogSnapshot> analog_snapshot;
|
||||
boost::shared_ptr<data::DsoSnapshot> dso_snapshot;
|
||||
int channel_type;
|
||||
|
||||
if ((logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
|
||||
@@ -835,7 +870,7 @@ void StoreSession::export_proc(shared_ptr<data::Snapshot> snapshot)
|
||||
out << (char*) data_out->str;
|
||||
g_string_free(data_out,TRUE);
|
||||
}
|
||||
|
||||
|
||||
_units_stored += size;
|
||||
progress_updated();
|
||||
}
|
||||
@@ -876,7 +911,7 @@ void StoreSession::export_proc(shared_ptr<data::Snapshot> snapshot)
|
||||
progress_updated();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
QString StoreSession::decoders_gen()
|
||||
{
|
||||
QDir dir;
|
||||
@@ -1129,7 +1164,7 @@ void StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray dec_arra
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
double StoreSession::get_integer(GVariant *var)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <QObject>
|
||||
|
||||
#include <libsigrok4DSL/libsigrok.h>
|
||||
@@ -75,15 +75,15 @@ private:
|
||||
void save_proc(boost::shared_ptr<pv::data::Snapshot> snapshot);
|
||||
QString meta_gen(boost::shared_ptr<data::Snapshot> snapshot);
|
||||
void export_proc(boost::shared_ptr<pv::data::Snapshot> snapshot);
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
QString decoders_gen();
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
QJsonArray json_decoders();
|
||||
void load_decoders(dock::ProtocolDock *widget, QJsonArray dec_array);
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
QList<QString> getSuportedExportFormats();
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "filebar.h"
|
||||
#include "../device/devinst.h"
|
||||
#include "../ui/msgbox.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -54,6 +54,7 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
|
||||
_action_default = new QAction(this);
|
||||
_action_default->setObjectName(QString::fromUtf8("actionDefault"));
|
||||
|
||||
//second level menu
|
||||
_menu_session = new QMenu(this);
|
||||
_menu_session->setObjectName(QString::fromUtf8("menuSession"));
|
||||
_menu_session->addAction(_action_load);
|
||||
@@ -107,7 +108,7 @@ void FileBar::changeEvent(QEvent *event)
|
||||
void FileBar::retranslateUi()
|
||||
{
|
||||
_file_button.setText(tr("File"));
|
||||
_menu_session->setTitle(tr("Con&fig..."));
|
||||
_menu_session->setTitle(tr("Con&fig...")); //load,save session file
|
||||
_action_load->setText(tr("&Load..."));
|
||||
_action_store->setText(tr("S&tore..."));
|
||||
_action_default->setText(tr("&Default..."));
|
||||
@@ -119,7 +120,7 @@ void FileBar::retranslateUi()
|
||||
|
||||
void FileBar::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_action_load->setIcon(QIcon(iconPath+"/open.svg"));
|
||||
_action_store->setIcon(QIcon(iconPath+"/save.svg"));
|
||||
@@ -134,15 +135,23 @@ void FileBar::reStyle()
|
||||
|
||||
void FileBar::on_actionOpen_triggered()
|
||||
{
|
||||
const QString DIR_KEY("OpenPath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
//open data file
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
// Show the dialog
|
||||
const QString file_name = QFileDialog::getOpenFileName(
|
||||
this, tr("Open File"), settings.value(DIR_KEY).toString(), tr(
|
||||
"DSView Data (*.dsl)"));
|
||||
if (!file_name.isEmpty()) {
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(file_name));
|
||||
this,
|
||||
tr("Open File"),
|
||||
app._userHistory.openDir,
|
||||
tr("DSView Data (*.dsl)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.openDir){
|
||||
app._userHistory.openDir = fname;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
load_file(file_name);
|
||||
}
|
||||
}
|
||||
@@ -162,16 +171,23 @@ void FileBar::show_session_error(
|
||||
}
|
||||
|
||||
void FileBar::on_actionLoad_triggered()
|
||||
{
|
||||
const QString DIR_KEY("SessionLoadPath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
// Show the dialog
|
||||
{
|
||||
//load session file
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
const QString file_name = QFileDialog::getOpenFileName(
|
||||
this, tr("Open Session"), settings.value(DIR_KEY).toString(), tr(
|
||||
"DSView Session (*.dsc)"));
|
||||
this,
|
||||
tr("Open Session"),
|
||||
app._userHistory.sessionDir,
|
||||
tr("DSView Session (*.dsc)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(file_name));
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.sessionDir){
|
||||
app._userHistory.sessionDir = fname;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
load_session(file_name);
|
||||
}
|
||||
}
|
||||
@@ -205,17 +221,27 @@ void FileBar::on_actionDefault_triggered()
|
||||
|
||||
void FileBar::on_actionStore_triggered()
|
||||
{
|
||||
const QString DIR_KEY("SessionStorePath");
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
//store session file
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
QString file_name = QFileDialog::getSaveFileName(
|
||||
this, tr("Save Session"), settings.value(DIR_KEY).toString(),
|
||||
this,
|
||||
tr("Save Session"),
|
||||
app._userHistory.sessionDir,
|
||||
tr("DSView Session (*.dsc)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QFileInfo f(file_name);
|
||||
if(f.suffix().compare("dsc"))
|
||||
file_name.append(tr(".dsc"));
|
||||
QDir CurrentDir;
|
||||
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(file_name));
|
||||
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.sessionDir){
|
||||
app._userHistory.sessionDir = fname;
|
||||
app.SaveHistory();
|
||||
}
|
||||
|
||||
store_session(file_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "logobar.h"
|
||||
#include "../dialogs/about.h"
|
||||
#include "../dialogs/dsmessagebox.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace toolbars {
|
||||
@@ -116,7 +116,8 @@ void LogoBar::retranslateUi()
|
||||
_manual->setText(tr("&Manual"));
|
||||
_issue->setText(tr("&Bug Report"));
|
||||
|
||||
if (qApp->property("Language") == QLocale::Chinese)
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
if (app._frameOptions.language == QLocale::Chinese)
|
||||
_language->setIcon(QIcon(":/icons/Chinese.svg"));
|
||||
else
|
||||
_language->setIcon(QIcon(":/icons/English.svg"));
|
||||
@@ -124,7 +125,7 @@ void LogoBar::retranslateUi()
|
||||
|
||||
void LogoBar::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_about->setIcon(QIcon(iconPath+"/about.svg"));
|
||||
_manual->setIcon(QIcon(iconPath+"/manual.svg"));
|
||||
@@ -138,7 +139,7 @@ void LogoBar::reStyle()
|
||||
void LogoBar::dsl_connected(bool conn)
|
||||
{
|
||||
_connected = conn;
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
if (_connected)
|
||||
_logo_button.setIcon(QIcon(iconPath+"/logo_color.svg"));
|
||||
else
|
||||
@@ -175,7 +176,7 @@ void LogoBar::on_actionCn_triggered()
|
||||
{
|
||||
_language->setIcon(QIcon::fromTheme("file",
|
||||
QIcon(":/icons/Chinese.svg")));
|
||||
setLanguage(QLocale::Chinese);
|
||||
setLanguage(QLocale::Chinese);
|
||||
}
|
||||
|
||||
void LogoBar::on_actionAbout_triggered()
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QAbstractItemView>
|
||||
#include <QApplication>
|
||||
|
||||
#include "../devicemanager.h"
|
||||
#include "../device/devinst.h"
|
||||
@@ -39,9 +38,9 @@
|
||||
#include "../dialogs/dsmessagebox.h"
|
||||
#include "../view/dsosignal.h"
|
||||
#include "../dialogs/interval.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using boost::shared_ptr;
|
||||
using std::map;
|
||||
using std::max;
|
||||
using std::min;
|
||||
@@ -149,7 +148,7 @@ void SamplingBar::changeEvent(QEvent *event)
|
||||
|
||||
void SamplingBar::retranslateUi()
|
||||
{
|
||||
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
boost::shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->dev_inst()) {
|
||||
if (dev_inst->name().contains("virtual-demo"))
|
||||
_device_type.setText(tr("Demo"));
|
||||
@@ -194,7 +193,7 @@ void SamplingBar::retranslateUi()
|
||||
|
||||
void SamplingBar::reStyle()
|
||||
{
|
||||
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
boost::shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->dev_inst()) {
|
||||
if (dev_inst->name().contains("virtual-demo"))
|
||||
_device_type.setIcon(QIcon(":/icons/demo.svg"));
|
||||
@@ -215,8 +214,8 @@ void SamplingBar::reStyle()
|
||||
}
|
||||
}
|
||||
|
||||
if (!qApp->property("Style").isNull()) {
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
if (true) {
|
||||
QString iconPath = GetIconPath();
|
||||
_configure_button.setIcon(QIcon(iconPath+"/params.svg"));
|
||||
_mode_button.setIcon(_session.get_run_mode() == pv::SigSession::Single ? QIcon(iconPath+"/modes.svg") :
|
||||
QIcon(iconPath+"/moder.svg"));
|
||||
@@ -229,8 +228,8 @@ void SamplingBar::reStyle()
|
||||
}
|
||||
|
||||
void SamplingBar::set_device_list(
|
||||
const std::list< shared_ptr<pv::device::DevInst> > &devices,
|
||||
shared_ptr<pv::device::DevInst> selected)
|
||||
const std::list<boost::shared_ptr<pv::device::DevInst> > &devices,
|
||||
boost::shared_ptr<pv::device::DevInst> selected)
|
||||
{
|
||||
int selected_index = -1;
|
||||
|
||||
@@ -241,7 +240,7 @@ void SamplingBar::set_device_list(
|
||||
_device_selector.clear();
|
||||
_device_selector_map.clear();
|
||||
|
||||
BOOST_FOREACH (shared_ptr<pv::device::DevInst> dev_inst, devices) {
|
||||
BOOST_FOREACH (boost::shared_ptr<pv::device::DevInst> dev_inst, devices) {
|
||||
assert(dev_inst);
|
||||
const QString title = dev_inst->format_device_title();
|
||||
const void *id = dev_inst->get_id();
|
||||
@@ -267,11 +266,11 @@ void SamplingBar::set_device_list(
|
||||
_updating_device_selector = false;
|
||||
}
|
||||
|
||||
shared_ptr<pv::device::DevInst> SamplingBar::get_selected_device() const
|
||||
boost::shared_ptr<pv::device::DevInst> SamplingBar::get_selected_device() const
|
||||
{
|
||||
const int index = _device_selector.currentIndex();
|
||||
if (index < 0)
|
||||
return shared_ptr<pv::device::DevInst>();
|
||||
return boost::shared_ptr<pv::device::DevInst>();
|
||||
|
||||
const void *const id =
|
||||
_device_selector.itemData(index).value<void*>();
|
||||
@@ -280,9 +279,9 @@ shared_ptr<pv::device::DevInst> SamplingBar::get_selected_device() const
|
||||
map<const void*, boost::weak_ptr<device::DevInst> >::
|
||||
const_iterator iter = _device_selector_map.find(id);
|
||||
if (iter == _device_selector_map.end())
|
||||
return shared_ptr<pv::device::DevInst>();
|
||||
return boost::shared_ptr<pv::device::DevInst>();
|
||||
|
||||
return shared_ptr<pv::device::DevInst>((*iter).second);
|
||||
return boost::shared_ptr<pv::device::DevInst>((*iter).second);
|
||||
}
|
||||
|
||||
void SamplingBar::on_configure()
|
||||
@@ -290,7 +289,7 @@ void SamplingBar::on_configure()
|
||||
hide_calibration();
|
||||
|
||||
int ret;
|
||||
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
boost::shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
assert(dev_inst);
|
||||
|
||||
pv::dialogs::DeviceOptions dlg(this, dev_inst);
|
||||
@@ -401,8 +400,8 @@ void SamplingBar::set_sampling(bool sampling)
|
||||
_configure_button.setEnabled(!sampling);
|
||||
_device_selector.setEnabled(!sampling);
|
||||
|
||||
if (!qApp->property("Style").isNull()) {
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
if (true) {
|
||||
QString iconPath = GetIconPath();
|
||||
if (_instant) {
|
||||
_instant_button.setIcon(sampling ? QIcon(iconPath+"/stop.svg") : QIcon(iconPath+"/single.svg"));
|
||||
} else {
|
||||
@@ -439,7 +438,7 @@ void SamplingBar::update_sample_rate_selector()
|
||||
|
||||
disconnect(&_sample_rate, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplerate_sel(int)));
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
return;
|
||||
|
||||
@@ -513,7 +512,7 @@ void SamplingBar::update_sample_rate_selector_value()
|
||||
void SamplingBar::on_samplerate_sel(int index)
|
||||
{
|
||||
(void)index;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst->dev_inst()->mode != DSO)
|
||||
update_sample_count_selector();
|
||||
}
|
||||
@@ -539,7 +538,7 @@ void SamplingBar::update_sample_count_selector()
|
||||
assert(!_updating_sample_count);
|
||||
_updating_sample_count = true;
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
if (gvar != NULL) {
|
||||
stream_mode = g_variant_get_boolean(gvar);
|
||||
@@ -672,7 +671,7 @@ void SamplingBar::update_sample_count_selector_value()
|
||||
|
||||
GVariant* gvar;
|
||||
double duration;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst->dev_inst()->mode == DSO) {
|
||||
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
||||
if (gvar != NULL) {
|
||||
@@ -715,7 +714,7 @@ void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
(void)index;
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
commit_hori_res();
|
||||
duration_changed();
|
||||
@@ -753,7 +752,7 @@ double SamplingBar::commit_hori_res()
|
||||
const double hori_res = _sample_count.itemData(
|
||||
_sample_count.currentIndex()).value<double>();
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const uint64_t sample_limit = dev_inst->get_sample_limit();
|
||||
GVariant* gvar;
|
||||
uint64_t max_sample_rate;
|
||||
@@ -781,7 +780,7 @@ double SamplingBar::commit_hori_res()
|
||||
void SamplingBar::commit_settings()
|
||||
{
|
||||
bool test = false;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->owner()) {
|
||||
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_TEST);
|
||||
if (gvar != NULL) {
|
||||
@@ -799,7 +798,7 @@ void SamplingBar::commit_settings()
|
||||
const uint64_t sample_rate = _sample_rate.itemData(
|
||||
_sample_rate.currentIndex()).value<uint64_t>();
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst) {
|
||||
if (sample_rate != dev_inst->get_sample_rate())
|
||||
dev_inst->set_config(NULL, NULL,
|
||||
@@ -831,7 +830,7 @@ void SamplingBar::on_run_stop()
|
||||
enable_instant(false);
|
||||
commit_settings();
|
||||
_instant = false;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
return;
|
||||
if (dev_inst->dev_inst()->mode == DSO) {
|
||||
@@ -883,7 +882,7 @@ void SamplingBar::on_instant_stop()
|
||||
enable_instant(false);
|
||||
commit_settings();
|
||||
_instant = true;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
return;
|
||||
if (dev_inst->dev_inst()->mode == DSO) {
|
||||
@@ -922,7 +921,7 @@ void SamplingBar::on_device_selected()
|
||||
_session.stop_capture();
|
||||
_session.session_save();
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
return;
|
||||
|
||||
@@ -937,7 +936,7 @@ void SamplingBar::on_device_selected()
|
||||
void SamplingBar::enable_toggle(bool enable)
|
||||
{
|
||||
bool test = false;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const boost::shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst && dev_inst->owner()) {
|
||||
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_TEST);
|
||||
if (gvar != NULL) {
|
||||
@@ -985,7 +984,7 @@ void SamplingBar::show_session_error(
|
||||
|
||||
void SamplingBar::reload()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
if (_session.get_device()->dev_inst()->mode == LOGIC) {
|
||||
if (_session.get_device()->name() == "virtual-session") {
|
||||
_mode_action->setVisible(false);
|
||||
@@ -1016,7 +1015,7 @@ void SamplingBar::reload()
|
||||
|
||||
void SamplingBar::on_mode()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
QAction *act = qobject_cast<QAction *>(sender());
|
||||
if (act == _action_single) {
|
||||
_mode_button.setIcon(QIcon(iconPath+"/modes.svg"));
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <assert.h>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
#include "../dsvdef.h"
|
||||
|
||||
@@ -107,7 +107,7 @@ void TitleBar::changeEvent(QEvent *event)
|
||||
|
||||
void TitleBar::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
if (_isTop) {
|
||||
_minimizeButton->setIcon(QIcon(iconPath+"/minimize.svg"));
|
||||
@@ -167,7 +167,7 @@ QString TitleBar::title() const
|
||||
|
||||
void TitleBar::showMaxRestore()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
if (parentWidget()->isMaximized()) {
|
||||
_maximizeButton->setIcon(QIcon(iconPath+"/maximize.svg"));
|
||||
normalShow();
|
||||
@@ -179,7 +179,7 @@ void TitleBar::showMaxRestore()
|
||||
|
||||
void TitleBar::setRestoreButton(bool max)
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
if (!max) {
|
||||
_maximizeButton->setIcon(QIcon(iconPath+"/maximize.svg"));
|
||||
} else {
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#include "../dialogs/mathoptions.h"
|
||||
#include "../view/trace.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QPainter>
|
||||
#include "../dialogs/applicationpardlg.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace toolbars {
|
||||
@@ -47,15 +47,15 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
|
||||
_measure_button(this),
|
||||
_search_button(this),
|
||||
_function_button(this),
|
||||
_display_button(this)
|
||||
_setting_button(this)
|
||||
{
|
||||
setMovable(false);
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
_trig_button.setCheckable(true);
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
_protocol_button.setCheckable(true);
|
||||
#endif
|
||||
|
||||
_measure_button.setCheckable(true);
|
||||
_search_button.setCheckable(true);
|
||||
|
||||
@@ -95,15 +95,15 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
|
||||
_display_menu->addAction(_action_lissajous);
|
||||
_display_menu->addMenu(_themes);
|
||||
|
||||
_display_button.setPopupMode(QToolButton::InstantPopup);
|
||||
_display_button.setMenu(_display_menu);
|
||||
_setting_button.setPopupMode(QToolButton::InstantPopup);
|
||||
_setting_button.setMenu(_display_menu);
|
||||
|
||||
_trig_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_protocol_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_measure_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_search_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_function_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_display_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
_setting_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
|
||||
_protocol_button.setContentsMargins(0,0,0,0);
|
||||
|
||||
@@ -112,7 +112,7 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
|
||||
_measure_action = addWidget(&_measure_button);
|
||||
_search_action = addWidget(&_search_button);
|
||||
_function_action = addWidget(&_function_button);
|
||||
_display_action = addWidget(&_display_button); //must be created
|
||||
_display_action = addWidget(&_setting_button); //must be created
|
||||
|
||||
retranslateUi();
|
||||
|
||||
@@ -145,7 +145,7 @@ void TrigBar::retranslateUi()
|
||||
_measure_button.setText(tr("Measure"));
|
||||
_search_button.setText(tr("Search"));
|
||||
_function_button.setText(tr("Function"));
|
||||
_display_button.setText(tr("Setting"));
|
||||
_setting_button.setText(tr("Setting"));
|
||||
|
||||
_action_lissajous->setText(tr("&Lissajous"));
|
||||
|
||||
@@ -161,14 +161,14 @@ void TrigBar::retranslateUi()
|
||||
|
||||
void TrigBar::reStyle()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
|
||||
_trig_button.setIcon(QIcon(iconPath+"/trigger.svg"));
|
||||
_protocol_button.setIcon(QIcon(iconPath+"/protocol.svg"));
|
||||
_measure_button.setIcon(QIcon(iconPath+"/measure.svg"));
|
||||
_search_button.setIcon(QIcon(iconPath+"/search-bar.svg"));
|
||||
_function_button.setIcon(QIcon(iconPath+"/function.svg"));
|
||||
_display_button.setIcon(QIcon(iconPath+"/display.svg"));
|
||||
_setting_button.setIcon(QIcon(iconPath+"/display.svg"));
|
||||
|
||||
_action_fft->setIcon(QIcon(iconPath+"/fft.svg"));
|
||||
_action_math->setIcon(QIcon(iconPath+"/math.svg"));
|
||||
@@ -178,7 +178,9 @@ void TrigBar::reStyle()
|
||||
|
||||
_appParam_action->setIcon(QIcon(iconPath+"/params.svg"));
|
||||
|
||||
_themes->setIcon(QIcon(iconPath+"/"+qApp->property("Style").toString()+".svg"));
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
_themes->setIcon(QIcon(iconPath+"/"+ app._frameOptions.language +".svg"));
|
||||
}
|
||||
|
||||
void TrigBar::protocol_clicked()
|
||||
@@ -228,7 +230,7 @@ void TrigBar::enable_toggle(bool enable)
|
||||
_measure_button.setDisabled(!enable);
|
||||
_search_button.setDisabled(!enable);
|
||||
_function_button.setDisabled(!enable);
|
||||
_display_button.setDisabled(!enable);
|
||||
_setting_button.setDisabled(!enable);
|
||||
}
|
||||
|
||||
void TrigBar::enable_protocol(bool enable)
|
||||
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
QToolButton _measure_button;
|
||||
QToolButton _search_button;
|
||||
QToolButton _function_button;
|
||||
QToolButton _display_button;
|
||||
QToolButton _setting_button;
|
||||
QAction* _trig_action;
|
||||
QAction* _protocol_action;
|
||||
QAction* _measure_action;
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QAction>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
@@ -36,6 +35,7 @@
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QScrollArea>
|
||||
#include <QApplication>
|
||||
|
||||
#include "decodetrace.h"
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QStyleOption>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
using boost::shared_ptr;
|
||||
using namespace std;
|
||||
@@ -105,8 +105,11 @@ void DevMode::set_device()
|
||||
_close_button->setDisabled(true);
|
||||
disconnect(_close_button, SIGNAL(clicked()), this, SLOT(on_close()));
|
||||
|
||||
if (!qApp->property("Style").isNull()) {
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString() + "/";
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int lan = app._frameOptions.language;
|
||||
|
||||
if (true) {
|
||||
QString iconPath = GetIconPath() + "/";
|
||||
for (const GSList *l = dev_inst->get_dev_mode_list();
|
||||
l; l = l->next) {
|
||||
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
||||
@@ -114,7 +117,7 @@ void DevMode::set_device()
|
||||
|
||||
QAction *action = new QAction(this);
|
||||
action->setIcon(QIcon(iconPath+"square-"+icon_name));
|
||||
if (qApp->property("Language") == QLocale::Chinese)
|
||||
if (lan == QLocale::Chinese)
|
||||
action->setText(mode->name_cn);
|
||||
else
|
||||
action->setText(mode->name);
|
||||
@@ -123,7 +126,7 @@ void DevMode::set_device()
|
||||
_mode_list[action] = mode;
|
||||
if (dev_inst->dev_inst()->mode == _mode_list[action]->mode) {
|
||||
_mode_btn->setIcon(QIcon(iconPath+icon_name));
|
||||
if (qApp->property("Language") == QLocale::Chinese)
|
||||
if (lan== QLocale::Chinese)
|
||||
_mode_btn->setText(mode->name_cn);
|
||||
else
|
||||
_mode_btn->setText(mode->name);
|
||||
@@ -159,7 +162,10 @@ void DevMode::on_mode_change()
|
||||
if (dev_inst->dev_inst()->mode == _mode_list[action]->mode)
|
||||
return;
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int lan = app._frameOptions.language;
|
||||
|
||||
for(std::map<QAction *, const sr_dev_mode *>::const_iterator i = _mode_list.begin();
|
||||
i != _mode_list.end(); i++) {
|
||||
if ((*i).first == action) {
|
||||
@@ -175,7 +181,7 @@ void DevMode::on_mode_change()
|
||||
|
||||
QString icon_name = "/" + QString::fromLocal8Bit((*i).second->icon);
|
||||
_mode_btn->setIcon(QIcon(iconPath+icon_name));
|
||||
if (qApp->property("Language") == QLocale::Chinese)
|
||||
if (lan == QLocale::Chinese)
|
||||
_mode_btn->setText((*i).second->name_cn);
|
||||
else
|
||||
_mode_btn->setText((*i).second->name);
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
@@ -45,6 +44,7 @@
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QStyleOption>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
*/
|
||||
|
||||
#include "selectableitem.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPalette>
|
||||
#include <QApplication>
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
#include <extdef.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
#include "signal.h"
|
||||
#include "view.h"
|
||||
|
||||
@@ -22,17 +22,17 @@
|
||||
|
||||
#include <extdef.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <math.h>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QApplication>
|
||||
|
||||
#include "trace.h"
|
||||
#include "view.h"
|
||||
#include "../device/devinst.h"
|
||||
#include "../sigsession.h"
|
||||
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
@@ -378,10 +377,10 @@ vector< boost::shared_ptr<Trace> > View::get_traces(int type)
|
||||
{
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
const vector< boost::shared_ptr<GroupSignal> > groups(_session.get_group_signals());
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
const vector< boost::shared_ptr<DecodeTrace> > decode_sigs(
|
||||
_session.get_decode_signals());
|
||||
#endif
|
||||
|
||||
const vector< boost::shared_ptr<SpectrumTrace> > spectrums(_session.get_spectrum_traces());
|
||||
|
||||
vector< boost::shared_ptr<Trace> > traces;
|
||||
@@ -389,12 +388,12 @@ vector< boost::shared_ptr<Trace> > View::get_traces(int type)
|
||||
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
|
||||
traces.push_back(t);
|
||||
}
|
||||
#ifdef ENABLE_DECODE
|
||||
|
||||
BOOST_FOREACH(boost::shared_ptr<Trace> t, decode_sigs) {
|
||||
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
|
||||
traces.push_back(t);
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_FOREACH(boost::shared_ptr<Trace> t, groups) {
|
||||
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
|
||||
traces.push_back(t);
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
#include "border.h"
|
||||
#include "../mainframe.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QLinearGradient>
|
||||
#include <QRadialGradient>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
namespace pv {
|
||||
namespace widgets {
|
||||
@@ -56,7 +56,10 @@ void Border::paintEvent(QPaintEvent *)
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
QLinearGradient linearGrad(QPointF(width(), height()), QPointF(0, 0));
|
||||
if (qApp->property("Style").toString() == "dark") {
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
QString style = app._frameOptions.style;
|
||||
|
||||
if (style == "dark") {
|
||||
linearGrad.setColorAt(0, dark_border0);
|
||||
linearGrad.setColorAt(0.25, dark_border1);
|
||||
linearGrad.setColorAt(0.5, dark_border2);
|
||||
@@ -71,7 +74,7 @@ void Border::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
QRadialGradient radialGrad(QPointF(0, 0), width());
|
||||
if (qApp->property("Style").toString() == "dark") {
|
||||
if (style == "dark") {
|
||||
radialGrad.setColorAt(0, dark_border0);
|
||||
radialGrad.setColorAt(0.25, dark_border1);
|
||||
radialGrad.setColorAt(0.5, dark_border2);
|
||||
|
||||
@@ -32,8 +32,10 @@
|
||||
#include <QVariant>
|
||||
#include <QScrollBar>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -55,7 +57,7 @@ DecoderGroupBox::DecoderGroupBox(boost::shared_ptr<data::DecoderStack> &decoder_
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidgetResizable(true);
|
||||
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
_layout->addWidget(new QLabel(QString("<h3>%1</h3>").arg(_dec->decoder()->name), _widget),
|
||||
0, 0);
|
||||
_layout->setColumnStretch(0, 1);
|
||||
@@ -129,7 +131,7 @@ bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e)
|
||||
|
||||
void DecoderGroupBox::tog_icon()
|
||||
{
|
||||
QString iconPath = ":/icons/" + qApp->property("Style").toString();
|
||||
QString iconPath = GetIconPath();
|
||||
QPushButton *sc = dynamic_cast<QPushButton*>(sender());
|
||||
QVariant id = sc->property("index");
|
||||
int index = id.toInt();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef DSVIEW_PV_WIDGETS_DECODERGROUPBOX_H
|
||||
#define DSVIEW_PV_WIDGETS_DECODERGROUPBOX_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
#include <QToolBar>
|
||||
|
||||
Reference in New Issue
Block a user