2
0
forked from Ivasoft/DSView

User can set the fonts

This commit is contained in:
dreamsourcelabTAI
2023-06-09 14:48:36 +08:00
parent b12476a16b
commit 6468461d6c
60 changed files with 1022 additions and 290 deletions

View File

@@ -345,6 +345,7 @@ set(DSView_SOURCES
DSView/pv/utility/array.cpp DSView/pv/utility/array.cpp
DSView/pv/deviceagent.cpp DSView/pv/deviceagent.cpp
DSView/pv/ui/langresource.cpp DSView/pv/ui/langresource.cpp
DSView/pv/ui/fun.cpp
) )
set(DSView_HEADERS set(DSView_HEADERS
@@ -437,6 +438,7 @@ set(DSView_HEADERS
DSView/pv/utility/path.h DSView/pv/utility/path.h
DSView/pv/utility/array.h DSView/pv/utility/array.h
DSView/pv/deviceagent.h DSView/pv/deviceagent.h
DSView/pv/ui/fun.h
) )
#=============================================================================== #===============================================================================

View File

@@ -198,13 +198,13 @@ bool bHighScale = true;
AppControl *control = AppControl::Instance(); AppControl *control = AppControl::Instance();
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
app.LoadAll(); //load app config app.LoadAll(); //load app config
LangResource::Instance()->Load(app._frameOptions.language); LangResource::Instance()->Load(app.frameOptions.language);
if (app._appOptions.ableSaveLog){ if (app.appOptions.ableSaveLog){
dsv_log_enalbe_logfile(app._appOptions.appendLogMode); dsv_log_enalbe_logfile(app.appOptions.appendLogMode);
if (app._appOptions.logLevel >= logLevel){ if (app.appOptions.logLevel >= logLevel){
dsv_log_level(app._appOptions.logLevel); dsv_log_level(app.appOptions.logLevel);
} }
} }

View File

@@ -27,6 +27,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QWidget> #include <QWidget>
#include <string> #include <string>
#include <assert.h>
#include "sigsession.h" #include "sigsession.h"
#include "dsvdef.h" #include "dsvdef.h"
#include "config/appconfig.h" #include "config/appconfig.h"
@@ -145,10 +146,36 @@ void AppControl::UnInit()
_session->uninit(); _session->uninit();
} }
bool AppControl::TopWindowIsMaximized() bool AppControl::TopWindowIsMaximized()
{ {
if (_topWindow != NULL){ if (_topWindow != NULL){
return _topWindow->isMaximized(); return _topWindow->isMaximized();
} }
return false; return false;
} }
void AppControl::add_font_form(IFontForm *form)
{
assert(form);
_font_forms.push_back(form);
}
void AppControl::remove_font_form(IFontForm *form)
{
assert(form);
for (auto it = _font_forms.begin(); it != _font_forms.end(); it++)
{
if ( *(it) == form){
_font_forms.erase(it);
break;
}
}
}
void AppControl::update_font_forms()
{
for (auto f : _font_forms){
f->update_font();
}
}

View File

@@ -22,9 +22,11 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
struct sr_context; struct sr_context;
class QWidget; class QWidget;
class IFontForm;
namespace pv{ namespace pv{
class SigSession; class SigSession;
@@ -64,10 +66,15 @@ public:
bool TopWindowIsMaximized(); bool TopWindowIsMaximized();
void add_font_form(IFontForm *form);
void remove_font_form(IFontForm *form);
void update_font_forms();
public: public:
std::string _open_file_name; std::string _open_file_name;
private: private:
pv::SigSession *_session; pv::SigSession *_session;
QWidget *_topWindow; QWidget *_topWindow;
std::vector<IFontForm*> _font_forms;
}; };

View File

@@ -37,7 +37,8 @@ StringPair::StringPair(const std::string &key, const std::string &value)
} }
//------------function //------------function
QString FormatArrayToString(std::vector<StringPair> &protocolFormats){ static QString FormatArrayToString(std::vector<StringPair> &protocolFormats)
{
QString str; QString str;
for (StringPair &o : protocolFormats){ for (StringPair &o : protocolFormats){
@@ -52,7 +53,8 @@ QString FormatArrayToString(std::vector<StringPair> &protocolFormats){
return str; return str;
} }
void StringToFormatArray(const QString &str, std::vector<StringPair> &protocolFormats){ static void StringToFormatArray(const QString &str, std::vector<StringPair> &protocolFormats)
{
QStringList arr = str.split(";"); QStringList arr = str.split(";");
for (int i=0; i<arr.size(); i++){ for (int i=0; i<arr.size(); i++){
QString line = arr[i]; QString line = arr[i];
@@ -65,31 +67,49 @@ void StringToFormatArray(const QString &str, std::vector<StringPair> &protocolFo
} }
} }
//read write field //----------------read write field
static void getFiled(const char *key, QSettings &st, QString &f, const char *dv)
void getFiled(const char *key, QSettings &st, QString &f, const char *dv){ {
f = st.value(key, dv).toString(); f = st.value(key, dv).toString();
} }
void getFiled(const char *key, QSettings &st, int &f, int dv){
static void setFiled(const char *key, QSettings &st, QString f)
{
st.setValue(key, f);
}
static void getFiled(const char *key, QSettings &st, int &f, int dv)
{
f = st.value(key, dv).toInt(); f = st.value(key, dv).toInt();
} }
void getFiled(const char *key, QSettings &st, bool &f, bool dv){
static void setFiled(const char *key, QSettings &st, int f)
{
st.setValue(key, f);
}
static void getFiled(const char *key, QSettings &st, bool &f, bool dv)
{
f = st.value(key, dv).toBool(); f = st.value(key, dv).toBool();
} }
void setFiled(const char *key, QSettings &st, QString f){ static void setFiled(const char *key, QSettings &st, bool 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); st.setValue(key, f);
} }
static void getFiled(const char *key, QSettings &st, float &f, float dv)
{
f = st.value(key, dv).toInt();
}
static void setFiled(const char *key, QSettings &st, float f)
{
st.setValue(key, f);
}
///------ app ///------ app
void _loadApp(AppOptions &o, QSettings &st){ static void _loadApp(AppOptions &o, QSettings &st)
{
st.beginGroup("Application"); st.beginGroup("Application");
getFiled("quickScroll", st, o.quickScroll, true); getFiled("quickScroll", st, o.quickScroll, true);
getFiled("warnofMultiTrig", st, o.warnofMultiTrig, true); getFiled("warnofMultiTrig", st, o.warnofMultiTrig, true);
@@ -111,7 +131,8 @@ void _loadApp(AppOptions &o, QSettings &st){
st.endGroup(); st.endGroup();
} }
void _saveApp(AppOptions &o, QSettings &st){ static void _saveApp(AppOptions &o, QSettings &st)
{
st.beginGroup("Application"); st.beginGroup("Application");
setFiled("quickScroll", st, o.quickScroll); setFiled("quickScroll", st, o.quickScroll);
setFiled("warnofMultiTrig", st, o.warnofMultiTrig); setFiled("warnofMultiTrig", st, o.warnofMultiTrig);
@@ -131,7 +152,8 @@ void _saveApp(AppOptions &o, QSettings &st){
//-----frame //-----frame
void _loadDockOptions(DockOptions &o, QSettings &st, const char *group){ static void _loadDockOptions(DockOptions &o, QSettings &st, const char *group)
{
st.beginGroup(group); st.beginGroup(group);
getFiled("decodeDoc", st, o.decodeDock, false); getFiled("decodeDoc", st, o.decodeDock, false);
getFiled("triggerDoc", st, o.triggerDock, false); getFiled("triggerDoc", st, o.triggerDock, false);
@@ -140,7 +162,8 @@ void _loadDockOptions(DockOptions &o, QSettings &st, const char *group){
st.endGroup(); st.endGroup();
} }
void _saveDockOptions(DockOptions &o, QSettings &st, const char *group){ static void _saveDockOptions(DockOptions &o, QSettings &st, const char *group)
{
st.beginGroup(group); st.beginGroup(group);
setFiled("decodeDoc", st, o.decodeDock); setFiled("decodeDoc", st, o.decodeDock);
setFiled("triggerDoc", st, o.triggerDock); setFiled("triggerDoc", st, o.triggerDock);
@@ -149,7 +172,8 @@ void _saveDockOptions(DockOptions &o, QSettings &st, const char *group){
st.endGroup(); st.endGroup();
} }
void _loadFrame(FrameOptions &o, QSettings &st){ static void _loadFrame(FrameOptions &o, QSettings &st)
{
st.beginGroup("MainFrame"); st.beginGroup("MainFrame");
getFiled("style", st, o.style, THEME_STYLE_DARK); getFiled("style", st, o.style, THEME_STYLE_DARK);
getFiled("language", st, o.language, -1); getFiled("language", st, o.language, -1);
@@ -177,7 +201,8 @@ void _loadFrame(FrameOptions &o, QSettings &st){
} }
} }
void _saveFrame(FrameOptions &o, QSettings &st){ static void _saveFrame(FrameOptions &o, QSettings &st)
{
st.beginGroup("MainFrame"); st.beginGroup("MainFrame");
setFiled("style", st, o.style); setFiled("style", st, o.style);
setFiled("language", st, o.language); setFiled("language", st, o.language);
@@ -196,7 +221,8 @@ void _saveFrame(FrameOptions &o, QSettings &st){
} }
//------history //------history
void _loadHistory(UserHistory &o, QSettings &st){ static void _loadHistory(UserHistory &o, QSettings &st)
{
st.beginGroup("UserHistory"); st.beginGroup("UserHistory");
getFiled("exportDir", st, o.exportDir, ""); getFiled("exportDir", st, o.exportDir, "");
getFiled("saveDir", st, o.saveDir, ""); getFiled("saveDir", st, o.saveDir, "");
@@ -209,7 +235,8 @@ void _loadHistory(UserHistory &o, QSettings &st){
st.endGroup(); st.endGroup();
} }
void _saveHistory(UserHistory &o, QSettings &st){ static void _saveHistory(UserHistory &o, QSettings &st)
{
st.beginGroup("UserHistory"); st.beginGroup("UserHistory");
setFiled("exportDir", st, o.exportDir); setFiled("exportDir", st, o.exportDir);
setFiled("saveDir", st, o.saveDir); setFiled("saveDir", st, o.saveDir);
@@ -222,6 +249,45 @@ void _saveHistory(UserHistory &o, QSettings &st){
st.endGroup(); st.endGroup();
} }
//------font
static void _loadFont(FontOptions &o, QSettings &st)
{
st.beginGroup("FontSetting");
getFiled("toolbarName", st, o.toolbar.name, "");
getFiled("toolbarSize", st, o.toolbar.size, 10);
getFiled("channelLabelName", st, o.channelLabel.name, "");
getFiled("channelLabelSize", st, o.channelLabel.size, 10);
getFiled("channelBodyName", st, o.channelBody.name, "");
getFiled("channelBodySize", st, o.channelBody.size, 9);
getFiled("rulerName", st, o.ruler.name, "");
getFiled("ruleSize", st, o.ruler.size, 9);
getFiled("titleName", st, o.title.name, "");
getFiled("titleSize", st, o.title.size, 10);
getFiled("otherName", st, o.other.name, "");
getFiled("otherSize", st, o.other.size, 10);
st.endGroup();
}
static void _saveFont(FontOptions &o, QSettings &st)
{
st.beginGroup("FontSetting");
setFiled("toolbarName", st, o.toolbar.name);
setFiled("toolbarSize", st, o.toolbar.size);
setFiled("channelLabelName", st, o.channelLabel.name);
setFiled("channelLabelSize", st, o.channelLabel.size);
setFiled("channelBodyName", st, o.channelBody.name);
setFiled("channelBodySize", st, o.channelBody.size);
setFiled("rulerName", st, o.ruler.name);
setFiled("ruleSize", st, o.ruler.size);
setFiled("titleName", st, o.title.name);
setFiled("titleSize", st, o.title.size);
setFiled("otherName", st, o.other.name);
setFiled("otherSize", st, o.other.size);
st.endGroup();
}
//------------AppConfig //------------AppConfig
AppConfig::AppConfig() AppConfig::AppConfig()
@@ -249,36 +315,42 @@ AppConfig::~AppConfig()
void AppConfig::LoadAll() void AppConfig::LoadAll()
{ {
QSettings st(QApplication::organizationName(), QApplication::applicationName()); QSettings st(QApplication::organizationName(), QApplication::applicationName());
_loadApp(_appOptions, st); _loadApp(appOptions, st);
_loadHistory(_userHistory, st); _loadHistory(userHistory, st);
_loadFrame(_frameOptions, st); _loadFrame(frameOptions, st);
_loadFont(fontOptions, st);
//dsv_dbg("Config file path:\"%s\"", st.fileName().toUtf8().data()); //dsv_dbg("Config file path:\"%s\"", st.fileName().toUtf8().data());
} }
void AppConfig::SaveApp() void AppConfig::SaveApp()
{ {
QSettings st(QApplication::organizationName(), QApplication::applicationName()); QSettings st(QApplication::organizationName(), QApplication::applicationName());
_saveApp(_appOptions, st); _saveApp(appOptions, st);
} }
void AppConfig::SaveHistory() void AppConfig::SaveHistory()
{ {
QSettings st(QApplication::organizationName(), QApplication::applicationName()); QSettings st(QApplication::organizationName(), QApplication::applicationName());
_saveHistory(_userHistory, st); _saveHistory(userHistory, st);
} }
void AppConfig::SaveFrame() void AppConfig::SaveFrame()
{ {
QSettings st(QApplication::organizationName(), QApplication::applicationName()); QSettings st(QApplication::organizationName(), QApplication::applicationName());
_saveFrame(_frameOptions, st); _saveFrame(frameOptions, st);
} }
void AppConfig::SaveFont()
{
QSettings st(QApplication::organizationName(), QApplication::applicationName());
_saveFont(fontOptions, st);
}
void AppConfig::SetProtocolFormat(const std::string &protocolName, const std::string &value) void AppConfig::SetProtocolFormat(const std::string &protocolName, const std::string &value)
{ {
bool bChange = false; bool bChange = false;
for (StringPair &o : _appOptions.m_protocolFormats){ for (StringPair &o : appOptions.m_protocolFormats){
if (o.m_key == protocolName){ if (o.m_key == protocolName){
o.m_value = value; o.m_value = value;
bChange = true; bChange = true;
@@ -288,14 +360,14 @@ void AppConfig::SetProtocolFormat(const std::string &protocolName, const std::st
if (!bChange) if (!bChange)
{ {
if (_appOptions.m_protocolFormats.size() > MAX_PROTOCOL_FORMAT_LIST) if (appOptions.m_protocolFormats.size() > MAX_PROTOCOL_FORMAT_LIST)
{ {
while (_appOptions.m_protocolFormats.size() < MAX_PROTOCOL_FORMAT_LIST) while (appOptions.m_protocolFormats.size() < MAX_PROTOCOL_FORMAT_LIST)
{ {
_appOptions.m_protocolFormats.erase(_appOptions.m_protocolFormats.begin()); appOptions.m_protocolFormats.erase(appOptions.m_protocolFormats.begin());
} }
} }
_appOptions.m_protocolFormats.push_back(StringPair(protocolName, value)); appOptions.m_protocolFormats.push_back(StringPair(protocolName, value));
bChange = true; bChange = true;
} }
@@ -306,7 +378,7 @@ void AppConfig::SetProtocolFormat(const std::string &protocolName, const std::st
std::string AppConfig::GetProtocolFormat(const std::string &protocolName) std::string AppConfig::GetProtocolFormat(const std::string &protocolName)
{ {
for (StringPair &o : _appOptions.m_protocolFormats){ for (StringPair &o : appOptions.m_protocolFormats){
if (o.m_key == protocolName){ if (o.m_key == protocolName){
return o.m_value; return o.m_value;
} }
@@ -317,7 +389,7 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName)
//-------------api //-------------api
QString GetIconPath() QString GetIconPath()
{ {
QString style = AppConfig::Instance()._frameOptions.style; QString style = AppConfig::Instance().frameOptions.style;
if (style == ""){ if (style == ""){
style = THEME_STYLE_DARK; style = THEME_STYLE_DARK;
} }

View File

@@ -106,6 +106,22 @@ struct UserHistory
QString exportFormat; QString exportFormat;
}; };
struct FontParam
{
QString name;
float size;
};
struct FontOptions
{
FontParam toolbar;
FontParam channelLabel;
FontParam channelBody;
FontParam ruler;
FontParam title;
FontParam other;
};
class AppConfig class AppConfig
{ {
private: private:
@@ -120,17 +136,19 @@ public:
void SaveApp(); void SaveApp();
void SaveHistory(); void SaveHistory();
void SaveFrame(); void SaveFrame();
void SaveFont();
void SetProtocolFormat(const std::string &protocolName, const std::string &value); void SetProtocolFormat(const std::string &protocolName, const std::string &value);
std::string GetProtocolFormat(const std::string &protocolName); std::string GetProtocolFormat(const std::string &protocolName);
inline bool IsLangCn() inline bool IsLangCn()
{ {
return _frameOptions.language == LAN_CN; return frameOptions.language == LAN_CN;
} }
public: public:
AppOptions _appOptions; AppOptions appOptions;
UserHistory _userHistory; UserHistory userHistory;
FrameOptions _frameOptions; FrameOptions frameOptions;
FontOptions fontOptions;
}; };

View File

@@ -86,7 +86,7 @@ About::About(QWidget *parent) :
QDir dir(GetAppDataDir()); QDir dir(GetAppDataDir());
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int lan = app._frameOptions.language; int lan = app.frameOptions.language;
QString filename = dir.absolutePath() + "/NEWS" + QString::number(lan); QString filename = dir.absolutePath() + "/NEWS" + QString::number(lan);
QFile news(filename); QFile news(filename);

View File

@@ -22,13 +22,21 @@
#include "applicationpardlg.h" #include "applicationpardlg.h"
#include "dsdialog.h" #include "dsdialog.h"
#include <QFormLayout> #include <QFormLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox> #include <QCheckBox>
#include <QString> #include <QString>
#include "../config/appconfig.h" #include <QFontDatabase>
#include <QGroupBox>
#include <QLabel>
#include <vector>
#include "../config/appconfig.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../appcontrol.h" #include "../appcontrol.h"
#include "../sigsession.h" #include "../sigsession.h"
#include "../ui/dscombobox.h"
#include "../log.h"
namespace pv namespace pv
{ {
@@ -44,6 +52,47 @@ ApplicationParamDlg::~ApplicationParamDlg()
{ {
} }
void ApplicationParamDlg::bind_font_name_list(QComboBox *box, QString v)
{
int selDex = -1;
QString defName(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DEFAULT_FONT), "Default"));
box->addItem(defName);
QFontDatabase fDataBase;
for (QString family : fDataBase.families()) {
if (family.indexOf("[") == -1)
{
box->addItem(family);
if (selDex == -1 && family == v){
selDex = box->count() - 1;
}
}
}
if (selDex == -1)
selDex = 0;
box->setCurrentIndex(selDex);
}
void ApplicationParamDlg::bind_font_size_list(QComboBox *box, float size)
{
int selDex = -1;
for(int i=9; i<=15; i++)
{
box->addItem(QString::number(i));
if (i == size){
selDex = box->count() - 1;
}
}
if (selDex == -1)
selDex = 0;
box->setCurrentIndex(selDex);
}
bool ApplicationParamDlg::ShowDlg(QWidget *parent) bool ApplicationParamDlg::ShowDlg(QWidget *parent)
{ {
DSDialog dlg(parent, true, true); DSDialog dlg(parent, true, true);
@@ -58,16 +107,16 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
int mode = AppControl::Instance()->GetSession()->get_device()->get_work_mode(); int mode = AppControl::Instance()->GetSession()->get_device()->get_work_mode();
QCheckBox *ck_quickScroll = new QCheckBox(); QCheckBox *ck_quickScroll = new QCheckBox();
ck_quickScroll->setChecked(app._appOptions.quickScroll); ck_quickScroll->setChecked(app.appOptions.quickScroll);
QCheckBox *ck_trigInMid = new QCheckBox(); QCheckBox *ck_trigInMid = new QCheckBox();
ck_trigInMid->setChecked(app._appOptions.trigPosDisplayInMid); ck_trigInMid->setChecked(app.appOptions.trigPosDisplayInMid);
QCheckBox *ck_profileBar = new QCheckBox(); QCheckBox *ck_profileBar = new QCheckBox();
ck_profileBar->setChecked(app._appOptions.displayProfileInBar); ck_profileBar->setChecked(app.appOptions.displayProfileInBar);
QCheckBox *ck_abortData = new QCheckBox(); QCheckBox *ck_abortData = new QCheckBox();
ck_abortData->setChecked(app._appOptions.swapBackBufferAlways); ck_abortData->setChecked(app.appOptions.swapBackBufferAlways);
lay.setHorizontalSpacing(8); lay.setHorizontalSpacing(8);
@@ -81,6 +130,66 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DISPLAY_PROFILE_IN_BAR), "Profile in bar"), ck_profileBar); lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DISPLAY_PROFILE_IN_BAR), "Profile in bar"), ck_profileBar);
//----------------Font setting.
std::vector<FontBindInfo> font_bind_list;
FontBindInfo ft1 = {NULL, NULL, S_ID(IDS_DLG_TOOLBAR_FONT), "Toolbar",
&app.fontOptions.toolbar.name, &app.fontOptions.toolbar.size};
font_bind_list.push_back(ft1);
FontBindInfo ft2 = {NULL, NULL, S_ID(IDS_DLG_CHANNEL_NAME_FONT), "Channel Name",
&app.fontOptions.channelLabel.name, &app.fontOptions.channelLabel.size};
font_bind_list.push_back(ft2);
FontBindInfo ft3 = {NULL, NULL, S_ID(IDS_DLG_CHANNEL_BODY_FONT), "Channel Body",
&app.fontOptions.channelBody.name, &app.fontOptions.channelBody.size};
font_bind_list.push_back(ft3);
FontBindInfo ft4 = {NULL, NULL, S_ID(IDS_DLG_RULER_FONT), "Ruler",
&app.fontOptions.ruler.name, &app.fontOptions.ruler.size};
font_bind_list.push_back(ft4);
FontBindInfo ft5 = {NULL, NULL, S_ID(IDS_DLG_TITLE_FONT), "Titel",
&app.fontOptions.title.name, &app.fontOptions.title.size};
font_bind_list.push_back(ft5);
FontBindInfo ft6 = {NULL, NULL, S_ID(IDS_DLG_OTHER_FONT), "Other",
&app.fontOptions.other.name, &app.fontOptions.other.size};
font_bind_list.push_back(ft6);
QWidget *lineSpace = new QWidget();
lineSpace->setFixedHeight(8);
lay.addRow(lineSpace);
QGroupBox *ftGroup = new QGroupBox();
ftGroup->setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_FONT_GROUP), "Font"));
QVBoxLayout *ftPannelLay = new QVBoxLayout();
ftGroup->setLayout(ftPannelLay);
ftPannelLay->setContentsMargins(5,15,5,10);
for (FontBindInfo &inf : font_bind_list)
{
QWidget *ftWid = new QWidget();
QHBoxLayout *ftLay = new QHBoxLayout();
ftLay->setContentsMargins(0,0,0,0);
ftWid->setLayout(ftLay);
QString ftLb = LangResource::Instance()->get_lang_text(STR_PAGE_DLG,
inf.lang_id.toUtf8().data(), inf.lang_def);
ftLay->addWidget(new QLabel(ftLb));
QComboBox *ftCbName = new DsComboBox();
bind_font_name_list(ftCbName, *inf.ptr_name);
ftLay->addWidget(ftCbName);
QComboBox *ftCbSize = new DsComboBox();
ftCbSize->setFixedWidth(50);
bind_font_size_list(ftCbSize, *inf.ptr_size);
ftLay->addWidget(ftCbSize);
ftPannelLay->addWidget(ftWid);
inf.name_box = ftCbName;
inf.size_box = ftCbSize;
}
lay.addRow(ftGroup);
dlg.layout()->addLayout(&lay); dlg.layout()->addLayout(&lay);
dlg.exec(); dlg.exec();
@@ -89,14 +198,56 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
//save config //save config
if (ret){ if (ret){
app._appOptions.quickScroll = ck_quickScroll->isChecked();
app._appOptions.trigPosDisplayInMid = ck_trigInMid->isChecked();
app._appOptions.displayProfileInBar = ck_profileBar->isChecked();
app._appOptions.swapBackBufferAlways = ck_abortData->isChecked();
app.SaveApp(); bool bAppChanged = false;
bool bFontChanged = false;
AppControl::Instance()->GetSession()->broadcast_msg(DSV_MSG_APP_OPTIONS_CHANGED); if (app.appOptions.quickScroll != ck_quickScroll->isChecked()){
app.appOptions.quickScroll = ck_quickScroll->isChecked();
bAppChanged = true;
}
if (app.appOptions.trigPosDisplayInMid != ck_trigInMid->isChecked()){
app.appOptions.trigPosDisplayInMid = ck_trigInMid->isChecked();
bAppChanged = true;
}
if (app.appOptions.displayProfileInBar != ck_profileBar->isChecked()){
app.appOptions.displayProfileInBar = ck_profileBar->isChecked();
bAppChanged = true;
}
if (app.appOptions.swapBackBufferAlways != ck_abortData->isChecked()){
app.appOptions.swapBackBufferAlways = ck_abortData->isChecked();
bAppChanged = true;
}
for (FontBindInfo &inf : font_bind_list)
{
QString oldName = *inf.ptr_name;
float oldSize = *inf.ptr_size;
if (inf.name_box->currentIndex() > 0)
*inf.ptr_name = inf.name_box->currentText();
else
*inf.ptr_name = "";
if (inf.size_box->currentIndex() >= 0)
*inf.ptr_size = inf.size_box->currentText().toFloat();
else
*inf.ptr_size = 9;
if (oldName != *inf.ptr_name || oldSize != *inf.ptr_size){
bFontChanged = true;
}
}
if (bFontChanged){
app.SaveFont();
AppControl::Instance()->GetSession()->broadcast_msg(DSV_MSG_FONT_OPTIONS_CHANGED);
}
if (bAppChanged){
app.SaveApp();
AppControl::Instance()->GetSession()->broadcast_msg(DSV_MSG_APP_OPTIONS_CHANGED);
}
} }
return ret; return ret;

View File

@@ -22,7 +22,19 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
class QComboBox;
struct FontBindInfo
{
QComboBox *name_box;
QComboBox *size_box;
QString lang_id;
char *lang_def;
QString *ptr_name;
float *ptr_size;
};
namespace pv namespace pv
{ {
@@ -37,10 +49,14 @@ namespace pv
bool ShowDlg(QWidget *parent); bool ShowDlg(QWidget *parent);
//IDlgCallback
private: private:
//IDlgCallback
void OnDlgResult(bool bYes); void OnDlgResult(bool bYes);
void bind_font_name_list(QComboBox *box, QString v);
void bind_font_size_list(QComboBox *box, float size);
}; };

View File

@@ -168,7 +168,7 @@ void DecoderOptionsDlg::load_options_view()
update_decode_range(); // set default sample range update_decode_range(); // set default sample range
int h_ex2 = 0; int h_ex2 = 0;
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg; bool bLang = AppConfig::Instance().appOptions.transDecoderDlg;
if (LangResource::Instance()->is_lang_en() == false){ if (LangResource::Instance()->is_lang_en() == false){
QWidget *sp1 = new QWidget(); QWidget *sp1 = new QWidget();
@@ -390,7 +390,7 @@ void DecoderOptionsDlg::create_decoder_form(
decoder_form->setLabelAlignment(Qt::AlignLeft); decoder_form->setLabelAlignment(Qt::AlignLeft);
decoder_form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); decoder_form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg; bool bLang = AppConfig::Instance().appOptions.transDecoderDlg;
if (LangResource::Instance()->is_lang_en()){ if (LangResource::Instance()->is_lang_en()){
bLang = false; bLang = false;
} }
@@ -527,7 +527,7 @@ void DecoderOptionsDlg::on_trans_pramas()
QCheckBox *ck_box = dynamic_cast<QCheckBox*>(sender()); QCheckBox *ck_box = dynamic_cast<QCheckBox*>(sender());
assert(ck_box); assert(ck_box);
AppConfig::Instance()._appOptions.transDecoderDlg = ck_box->isChecked(); AppConfig::Instance().appOptions.transDecoderDlg = ck_box->isChecked();
AppConfig::Instance().SaveApp(); AppConfig::Instance().SaveApp();
_is_reload_form = true; _is_reload_form = true;
this->accept(); this->accept();

View File

@@ -29,6 +29,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QAbstractButton> #include <QAbstractButton>
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../config/appconfig.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
@@ -125,6 +127,8 @@ int DSDialog::exec()
connect(_base_button, SIGNAL(rejected()), this, SLOT(reject())); connect(_base_button, SIGNAL(rejected()), this, SLOT(reject()));
connect(_base_button, SIGNAL(accepted()), this, SLOT(accept())); connect(_base_button, SIGNAL(accepted()), this, SLOT(accept()));
} }
update_font();
return QDialog::exec(); return QDialog::exec();
} }
@@ -156,7 +160,7 @@ void DSDialog::build_base(bool hasClose)
this->setGraphicsEffect(_shadow); this->setGraphicsEffect(_shadow);
_titlebar = new toolbars::TitleBar(false, this, hasClose); _titlebar = new toolbars::TitleBar(false, this, hasClose);
_main_layout->addWidget(_titlebar); _main_layout->addWidget(_titlebar);
_titleSpaceLine = new QWidget(this); _titleSpaceLine = new QWidget(this);
_titleSpaceLine->setFixedHeight(15); _titleSpaceLine->setFixedHeight(15);
@@ -170,5 +174,24 @@ void DSDialog::build_base(bool hasClose)
_main_layout->setContentsMargins(10,5,10,10); _main_layout->setContentsMargins(10,5,10,10);
} }
void DSDialog::update_font()
{
FontOptions &st = AppConfig::Instance().fontOptions;
QFont font = this->font();
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
if (_titlebar != NULL){
_titlebar->update_font();
}
}
void DSDialog::show()
{
update_font();
QWidget::show();
}
} // namespace dialogs } // namespace dialogs
} // namespace pv } // namespace pv

View File

@@ -40,7 +40,7 @@ namespace dialogs {
class Shadow; class Shadow;
//DSView any dialog base class //DSView any dialog base class
class DSDialog : public QDialog class DSDialog : public QDialog, IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -67,6 +67,11 @@ public:
void SetTitleSpace(int h); void SetTitleSpace(int h);
//IFontForm
void update_font();
void show();
protected: protected:
void accept(); void accept();
void reject(); void reject();

View File

@@ -29,8 +29,9 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QAbstractButton> #include <QAbstractButton>
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../config/appconfig.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
@@ -127,5 +128,19 @@ void DSMessageBox::on_button(QAbstractButton *btn)
reject(); reject();
} }
int DSMessageBox::exec()
{
FontOptions &st = AppConfig::Instance().fontOptions;
QFont font = this->font();
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
if (_titlebar != NULL){
_titlebar->update_font();
}
return QDialog::exec();
}
} // namespace dialogs } // namespace dialogs
} // namespace pv } // namespace pv

View File

@@ -45,6 +45,8 @@ public:
~DSMessageBox(); ~DSMessageBox();
QMessageBox *mBox(); QMessageBox *mBox();
int exec();
inline int IsYes(){return _bClickYes;} inline int IsYes(){return _bClickYes;}

View File

@@ -128,7 +128,7 @@ void ProtocolExp::accept()
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QString default_filter = _format_combobox->currentText(); QString default_filter = _format_combobox->currentText();
QString default_name = app._userHistory.protocolExportPath + "/" + "decoder-"; QString default_name = app.userHistory.protocolExportPath + "/" + "decoder-";
default_name += _session->get_session_time().toString("-yyMMdd-hhmmss"); default_name += _session->get_session_time().toString("-yyMMdd-hhmmss");
QString file_name = QFileDialog::getSaveFileName( QString file_name = QFileDialog::getSaveFileName(
@@ -149,9 +149,9 @@ void ProtocolExp::accept()
file_name += "." + ext; file_name += "." + ext;
QString fname = path::GetDirectoryName(file_name); QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.openDir) if (fname != app.userHistory.openDir)
{ {
app._userHistory.protocolExportPath = fname; app.userHistory.protocolExportPath = fname;
app.SaveHistory(); app.SaveHistory();
} }
_fileName = file_name; _fileName = file_name;

View File

@@ -158,8 +158,8 @@ void StoreProgress::accept()
if (_isExport && _store_session.IsLogicDataType()){ if (_isExport && _store_session.IsLogicDataType()){
bool ck = _ckOrigin->isChecked(); bool ck = _ckOrigin->isChecked();
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._appOptions.originalData != ck){ if (app.appOptions.originalData != ck){
app._appOptions.originalData = ck; app.appOptions.originalData = ck;
app.SaveApp(); app.SaveApp();
} }
} }
@@ -223,7 +223,7 @@ void StoreProgress::export_run()
{ {
QGridLayout *lay = new QGridLayout(); QGridLayout *lay = new QGridLayout();
lay->setContentsMargins(5, 0, 0, 0); lay->setContentsMargins(5, 0, 0, 0);
bool isOrg = AppConfig::Instance()._appOptions.originalData; bool isOrg = AppConfig::Instance().appOptions.originalData;
_ckOrigin = new QRadioButton(); _ckOrigin = new QRadioButton();
_ckOrigin->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_ORIGINAL_DATA), "Original data")); _ckOrigin->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_ORIGINAL_DATA), "Original data"));

View File

@@ -57,7 +57,7 @@ WaitingDialog::WaitingDialog(QWidget *parent, SigSession *session, int key) :
this->setWindowOpacity(0.7); this->setWindowOpacity(0.7);
QFont font; QFont font;
font.setPointSize(10); font.setPointSize(9);
font.setBold(true); font.setBold(true);
QLabel *warning_tips = new QLabel(this); QLabel *warning_tips = new QLabel(this);

View File

@@ -22,23 +22,21 @@
#include "dsotriggerdock.h" #include "dsotriggerdock.h"
#include "../sigsession.h" #include "../sigsession.h"
#include "../dialogs/dsmessagebox.h" #include "../dialogs/dsmessagebox.h"
#include "../view/dsosignal.h" #include "../view/dsosignal.h"
#include <QObject> #include <QObject>
#include <QLabel> #include <QLabel>
#include <QRadioButton> #include <QRadioButton>
#include <QPainter> #include <QPainter>
#include <QStyleOption> #include <QStyleOption>
#include <QVector> #include <QVector>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QEvent> #include <QEvent>
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../log.h" #include "../log.h"
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../config/appconfig.h"
#include "../ui/fun.h"
using namespace boost; using namespace boost;
using namespace std; using namespace std;
@@ -173,6 +171,8 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) :
_widget->setObjectName("dsoTriggerWidget"); _widget->setObjectName("dsoTriggerWidget");
retranslateUi(); retranslateUi();
update_font();
} }
DsoTriggerDock::~DsoTriggerDock() DsoTriggerDock::~DsoTriggerDock()
@@ -491,5 +491,15 @@ void DsoTriggerDock::update_view()
connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int)));
} }
void DsoTriggerDock::update_font()
{
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
this->parentWidget()->setFont(font);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@@ -33,6 +33,7 @@
#include <vector> #include <vector>
#include "../ui/dscombobox.h" #include "../ui/dscombobox.h"
#include "../interface/icallbacks.h"
namespace pv { namespace pv {
@@ -40,7 +41,7 @@ class SigSession;
namespace dock { namespace dock {
class DsoTriggerDock : public QScrollArea class DsoTriggerDock : public QScrollArea, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -59,6 +60,9 @@ private:
void reStyle(); void reStyle();
bool check_trig_channel(); bool check_trig_channel();
//IFontForm
void update_font();
signals: signals:
void set_trig_pos(int percent); void set_trig_pos(int percent);

View File

@@ -38,6 +38,8 @@
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include <QObject> #include <QObject>
#include <QPainter> #include <QPainter>
#include "../appcontrol.h"
#include "../ui/fun.h"
using namespace boost; using namespace boost;
@@ -144,6 +146,8 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession *session) :
_widget->setObjectName("measureWidget"); _widget->setObjectName("measureWidget");
retranslateUi(); retranslateUi();
update_font();
} }
MeasureDock::~MeasureDock() MeasureDock::~MeasureDock()
@@ -702,5 +706,15 @@ void MeasureDock::del_cursor()
_view.update(); _view.update();
} }
void MeasureDock::update_font()
{
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
this->parentWidget()->setFont(font);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@@ -41,7 +41,8 @@
#include <vector> #include <vector>
#include "../ui/dscombobox.h" #include "../ui/dscombobox.h"
#include "../interface/icallbacks.h"
namespace pv { namespace pv {
@@ -54,7 +55,7 @@ namespace view {
namespace dock { namespace dock {
class MeasureDock : public QScrollArea class MeasureDock : public QScrollArea, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -73,6 +74,9 @@ private:
void retranslateUi(); void retranslateUi();
void reStyle(); void reStyle();
//IFontForm
void update_font();
private: private:
DsComboBox* create_probe_selector(QWidget *parent); DsComboBox* create_probe_selector(QWidget *parent);
void update_probe_selector(DsComboBox *selector); void update_probe_selector(DsComboBox *selector);

View File

@@ -52,8 +52,9 @@
#include "../data/decode/decoderstatus.h" #include "../data/decode/decoderstatus.h"
#include "../data/decode/decoder.h" #include "../data/decode/decoder.h"
#include "../log.h" #include "../log.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../appcontrol.h"
#include "../ui/fun.h"
using namespace std; using namespace std;
@@ -221,6 +222,8 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
connect(_ann_search_edit, SIGNAL(editingFinished()), this, SLOT(search_changed())); connect(_ann_search_edit, SIGNAL(editingFinished()), this, SLOT(search_changed()));
connect(_pro_search_button, SIGNAL(clicked()), this, SLOT(show_protocol_select())); connect(_pro_search_button, SIGNAL(clicked()), this, SLOT(show_protocol_select()));
update_font();
} }
ProtocolDock::~ProtocolDock() ProtocolDock::~ProtocolDock()
@@ -1028,5 +1031,15 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
} }
} }
void ProtocolDock::update_font()
{
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
this->parentWidget()->setFont(font);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@@ -72,7 +72,8 @@ class ProtocolDock : public QScrollArea,
public IProtocolItemLayerCallback, public IProtocolItemLayerCallback,
public IKeywordActive, public IKeywordActive,
public ISearchItemClick, public ISearchItemClick,
public IDecoderPannel public IDecoderPannel,
public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -115,6 +116,9 @@ private:
//IDecoderPannel //IDecoderPannel
void update_deocder_item_name(void *trace_handel, const char *name); void update_deocder_item_name(void *trace_handel, const char *name);
//IFontForm
void update_font();
signals: signals:
void protocol_updated(); void protocol_updated();

View File

@@ -25,6 +25,9 @@
#include <QPoint> #include <QPoint>
#include <QLineEdit> #include <QLineEdit>
#include <QScrollBar> #include <QScrollBar>
#include "../config/appconfig.h"
#include "../appcontrol.h"
#include "../ui/fun.h"
//----------------------ComboButtonItem //----------------------ComboButtonItem
@@ -126,11 +129,16 @@ void SearchComboBox::ShowDlg(QWidget *editline)
} }
edit->setFocus(); edit->setFocus();
this->show();
connect(edit, SIGNAL(textEdited(const QString &)), connect(edit, SIGNAL(textEdited(const QString &)),
this, SLOT(on_keyword_changed(const QString &))); this, SLOT(on_keyword_changed(const QString &)));
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
this->show();
} }
void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle) void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle)

View File

@@ -41,6 +41,8 @@
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../appcontrol.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace dock { namespace dock {
@@ -82,6 +84,8 @@ SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) :
retranslateUi(); retranslateUi();
update_font();
connect(&_pre_button, SIGNAL(clicked()), this, SLOT(on_previous())); connect(&_pre_button, SIGNAL(clicked()), this, SLOT(on_previous()));
connect(&_nxt_button, SIGNAL(clicked()),this, SLOT(on_next())); connect(&_nxt_button, SIGNAL(clicked()),this, SLOT(on_next()));
} }
@@ -249,5 +253,13 @@ void SearchDock::on_set()
} }
} }
void SearchDock::update_font()
{
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
_search_value->setFont(font);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@@ -43,6 +43,7 @@
#include "../widgets/fakelineedit.h" #include "../widgets/fakelineedit.h"
#include "../ui/dscombobox.h" #include "../ui/dscombobox.h"
#include "../interface/icallbacks.h"
namespace pv { namespace pv {
@@ -58,7 +59,7 @@ namespace widgets {
namespace dock { namespace dock {
class SearchDock : public QWidget class SearchDock : public QWidget, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -73,6 +74,9 @@ private:
void retranslateUi(); void retranslateUi();
void reStyle(); void reStyle();
//IFontForm
void update_font();
public slots: public slots:
void on_previous(); void on_previous();
void on_next(); void on_next();

View File

@@ -44,6 +44,8 @@
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../log.h" #include "../log.h"
#include "../data/decode/annotationrestable.h" #include "../data/decode/annotationrestable.h"
#include "../appcontrol.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace dock { namespace dock {
@@ -123,6 +125,8 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) :
_widget->setObjectName("triggerWidget"); _widget->setObjectName("triggerWidget");
retranslateUi(); retranslateUi();
update_font();
} }
TriggerDock::~TriggerDock() TriggerDock::~TriggerDock()
@@ -966,7 +970,7 @@ void TriggerDock::try_commit_trigger()
} }
} }
if (app._appOptions.warnofMultiTrig && num > 1) { if (app.appOptions.warnofMultiTrig && num > 1) {
dialogs::DSMessageBox msg(this); dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TRIGGER), "Trigger")); msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TRIGGER), "Trigger"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SET_TRI_MULTI_CHANNEL), msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SET_TRI_MULTI_CHANNEL),
@@ -991,7 +995,7 @@ void TriggerDock::try_commit_trigger()
if (msg.mBox()->clickedButton() == noMoreButton) if (msg.mBox()->clickedButton() == noMoreButton)
{ {
app._appOptions.warnofMultiTrig = false; app.appOptions.warnofMultiTrig = false;
app.SaveApp(); app.SaveApp();
} }
} }
@@ -1064,5 +1068,15 @@ void TriggerDock::on_serial_hex_changed()
_is_serial_val_setting = false; _is_serial_val_setting = false;
} }
void TriggerDock::update_font()
{
QFont font = this->font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.other);
ui::set_form_font(this, font);
this->parentWidget()->setFont(font);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@@ -39,10 +39,9 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QScrollArea> #include <QScrollArea>
#include <vector> #include <vector>
#include "../ui/dscombobox.h"
#include "../ui/dscombobox.h" #include "../interface/icallbacks.h"
namespace pv { namespace pv {
@@ -50,7 +49,7 @@ class SigSession;
namespace dock { namespace dock {
class TriggerDock : public QScrollArea class TriggerDock : public QScrollArea, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -87,6 +86,9 @@ private:
*/ */
bool commit_trigger(); bool commit_trigger();
//IFontForm
void update_font();
private slots: private slots:
void simple_trigger(); void simple_trigger();
void adv_trigger(); void adv_trigger();

View File

@@ -94,6 +94,7 @@ public:
#define DSV_MSG_CLEAR_DECODE_DATA 8001 #define DSV_MSG_CLEAR_DECODE_DATA 8001
#define DSV_MSG_APP_OPTIONS_CHANGED 9001 #define DSV_MSG_APP_OPTIONS_CHANGED 9001
#define DSV_MSG_FONT_OPTIONS_CHANGED 9002
class IMessageListener class IMessageListener
{ {
@@ -107,4 +108,10 @@ public:
virtual void update_deocder_item_name(void *trace_handel, const char *name)=0; virtual void update_deocder_item_name(void *trace_handel, const char *name)=0;
}; };
class IFontForm
{
public:
virtual void update_font()=0;
};
#endif #endif

View File

@@ -43,12 +43,14 @@
#include <QApplication> #include <QApplication>
#include <QFile> #include <QFile>
#include <QGuiApplication> #include <QGuiApplication>
#include <QFont>
#include "dsvdef.h" #include "dsvdef.h"
#include "config/appconfig.h" #include "config/appconfig.h"
#include "ui/msgbox.h" #include "ui/msgbox.h"
#include "appcontrol.h" #include "appcontrol.h"
#include "ui/langresource.h" #include "ui/langresource.h"
#include "log.h"
#include <algorithm> #include <algorithm>
@@ -402,16 +404,16 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QRect rc = geometry(); QRect rc = geometry();
app._frameOptions.left = rc.left(); app.frameOptions.left = rc.left();
app._frameOptions.top = rc.top(); app.frameOptions.top = rc.top();
app._frameOptions.right = rc.right(); app.frameOptions.right = rc.right();
app._frameOptions.bottom = rc.bottom(); app.frameOptions.bottom = rc.bottom();
} }
void MainFrame::writeSettings() void MainFrame::writeSettings()
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
app._frameOptions.isMax = isMaximized(); app.frameOptions.isMax = isMaximized();
if (!isMaximized()){ if (!isMaximized()){
saveWindowRegion(); saveWindowRegion();
@@ -427,14 +429,14 @@ void MainFrame::readSettings()
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._frameOptions.language > 0){ if (app.frameOptions.language > 0){
_mainWindow->switchLanguage(app._frameOptions.language); _mainWindow->switchLanguage(app.frameOptions.language);
} }
int left = app._frameOptions.left; int left = app.frameOptions.left;
int top = app._frameOptions.top; int top = app.frameOptions.top;
int right = app._frameOptions.right; int right = app.frameOptions.right;
int bottom = app._frameOptions.bottom; int bottom = app.frameOptions.bottom;
int screen_width = QGuiApplication::primaryScreen()->availableGeometry().width(); int screen_width = QGuiApplication::primaryScreen()->availableGeometry().width();
int screen_height = QGuiApplication::primaryScreen()->availableGeometry().height(); int screen_height = QGuiApplication::primaryScreen()->availableGeometry().height();
@@ -455,7 +457,7 @@ void MainFrame::readSettings()
bReset = true; bReset = true;
} }
if (app._frameOptions.isMax) if (app.frameOptions.isMax)
{ {
showMaximized(); // show max by system api showMaximized(); // show max by system api
} }
@@ -474,7 +476,7 @@ void MainFrame::readSettings()
// restore dockwidgets // restore dockwidgets
_mainWindow->restore_dock(); _mainWindow->restore_dock();
_titleBar->setRestoreButton(app._frameOptions.isMax); _titleBar->setRestoreButton(app.frameOptions.isMax);
} }
#ifdef _WIN32 #ifdef _WIN32
@@ -506,9 +508,9 @@ void MainFrame::setTaskbarProgress(int progress)
void MainFrame::show_doc() void MainFrame::show_doc()
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int lan = app._frameOptions.language; int lan = app.frameOptions.language;
if (app._userHistory.showDocuments) { if (app.userHistory.showDocuments) {
dialogs::DSDialog dlg(this, true); dialogs::DSDialog dlg(this, true);
dlg.setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DOCUMENT), "Document")); dlg.setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DOCUMENT), "Document"));
@@ -542,7 +544,7 @@ void MainFrame::show_doc()
_mainWindow->openDoc(); _mainWindow->openDoc();
} }
if (msg.clickedButton() == noMoreButton){ if (msg.clickedButton() == noMoreButton){
app._userHistory.showDocuments = false; app.userHistory.showDocuments = false;
app.SaveHistory(); app.SaveHistory();
} }
} }

View File

@@ -112,6 +112,7 @@ namespace pv
assert(title_bar); assert(title_bar);
_title_bar = title_bar; _title_bar = title_bar;
AppControl::Instance()->add_font_form(title_bar);
_session = AppControl::Instance()->GetSession(); _session = AppControl::Instance()->GetSession();
_session->set_callback(this); _session->set_callback(this);
@@ -147,7 +148,7 @@ namespace pv
setCentralWidget(_central_widget); setCentralWidget(_central_widget);
// Setup the sampling bar // Setup the sampling bar
_sampling_bar = new toolbars::SamplingBar(_session, this); _sampling_bar = new toolbars::SamplingBar(_session, this);
_sampling_bar->setObjectName("sampling_bar"); _sampling_bar->setObjectName("sampling_bar");
_trig_bar = new toolbars::TrigBar(_session, this); _trig_bar = new toolbars::TrigBar(_session, this);
_trig_bar->setObjectName("trig_bar"); _trig_bar->setObjectName("trig_bar");
@@ -162,7 +163,7 @@ namespace pv
_trigger_dock->setFeatures(QDockWidget::DockWidgetMovable); _trigger_dock->setFeatures(QDockWidget::DockWidgetMovable);
_trigger_dock->setAllowedAreas(Qt::RightDockWidgetArea); _trigger_dock->setAllowedAreas(Qt::RightDockWidgetArea);
_trigger_dock->setVisible(false); _trigger_dock->setVisible(false);
_trigger_widget = new dock::TriggerDock(_trigger_dock, _session); _trigger_widget = new dock::TriggerDock(_trigger_dock, _session);
_trigger_dock->setWidget(_trigger_widget); _trigger_dock->setWidget(_trigger_widget);
_dso_trigger_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_DOCK_TITLE), "Trigger Setting..."), this); _dso_trigger_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_DOCK_TITLE), "Trigger Setting..."), this);
@@ -183,6 +184,11 @@ namespace pv
addToolBar(_file_bar); addToolBar(_file_bar);
addToolBar(_logo_bar); addToolBar(_logo_bar);
AppControl::Instance()->add_font_form(_sampling_bar);
AppControl::Instance()->add_font_form(_trig_bar);
AppControl::Instance()->add_font_form(_file_bar);
AppControl::Instance()->add_font_form(_logo_bar);
// Setup the dockWidget // Setup the dockWidget
_protocol_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_PROTOCOL_DOCK_TITLE), "Decode Protocol"), this); _protocol_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_PROTOCOL_DOCK_TITLE), "Decode Protocol"), this);
_protocol_dock->setObjectName("protocol_dock"); _protocol_dock->setObjectName("protocol_dock");
@@ -234,8 +240,8 @@ namespace pv
// defaut language // defaut language
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
switchLanguage(app._frameOptions.language); switchLanguage(app.frameOptions.language);
switchTheme(app._frameOptions.style); switchTheme(app.frameOptions.style);
// UI initial // UI initial
_measure_widget->add_dist_measure(); _measure_widget->add_dist_measure();
@@ -244,6 +250,13 @@ namespace pv
_sampling_bar->set_view(_view); _sampling_bar->set_view(_view);
// Add the font form
AppControl::Instance()->add_font_form(_protocol_widget);
AppControl::Instance()->add_font_form(_dso_trigger_widget);
AppControl::Instance()->add_font_form(_measure_widget);
AppControl::Instance()->add_font_form(_search_widget);
AppControl::Instance()->add_font_form(_trigger_widget);
// event // event
connect(&_event, SIGNAL(session_error()), this, SLOT(on_session_error())); connect(&_event, SIGNAL(session_error()), this, SLOT(on_session_error()));
connect(&_event, SIGNAL(signals_changed()), this, SLOT(on_signals_changed())); connect(&_event, SIGNAL(signals_changed()), this, SLOT(on_signals_changed()));
@@ -420,7 +433,7 @@ namespace pv
save_config_to_file(sessionFile); save_config_to_file(sessionFile);
} }
app._frameOptions.windowState = saveState(); app.frameOptions.windowState = saveState();
app.SaveFrame(); app.SaveFrame();
} }
@@ -440,7 +453,7 @@ namespace pv
QString base_path = dir.absolutePath() + "/" + driver_name + mode_name; QString base_path = dir.absolutePath() + "/" + driver_name + mode_name;
if (!isNewFormat){ if (!isNewFormat){
lang_name = QString::number(app._frameOptions.language); lang_name = QString::number(app.frameOptions.language);
} }
return base_path + ".ses" + lang_name + ".dsc"; return base_path + ".ses" + lang_name + ".dsc";
@@ -508,7 +521,7 @@ namespace pv
void MainWindow::on_screenShot() void MainWindow::on_screenShot()
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QString default_name = app._userHistory.screenShotPath + "/" + APP_NAME + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss"); QString default_name = app.userHistory.screenShotPath + "/" + APP_NAME + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
int x = parentWidget()->pos().x(); int x = parentWidget()->pos().x();
int y = parentWidget()->pos().y(); int y = parentWidget()->pos().y();
@@ -560,9 +573,9 @@ namespace pv
fileName = path::GetDirectoryName(fileName); fileName = path::GetDirectoryName(fileName);
if (app._userHistory.screenShotPath != fileName) if (app.userHistory.screenShotPath != fileName)
{ {
app._userHistory.screenShotPath = fileName; app.userHistory.screenShotPath = fileName;
app.SaveHistory(); app.SaveHistory();
} }
} }
@@ -667,7 +680,7 @@ namespace pv
sessionVar["Version"] = QJsonValue::fromVariant(SESSION_FORMAT_VERSION); sessionVar["Version"] = QJsonValue::fromVariant(SESSION_FORMAT_VERSION);
sessionVar["Device"] = QJsonValue::fromVariant(_device_agent->driver_name()); sessionVar["Device"] = QJsonValue::fromVariant(_device_agent->driver_name());
sessionVar["DeviceMode"] = QJsonValue::fromVariant(_device_agent->get_work_mode()); sessionVar["DeviceMode"] = QJsonValue::fromVariant(_device_agent->get_work_mode());
sessionVar["Language"] = QJsonValue::fromVariant(app._frameOptions.language); sessionVar["Language"] = QJsonValue::fromVariant(app.frameOptions.language);
sessionVar["Title"] = QJsonValue::fromVariant(title); sessionVar["Title"] = QJsonValue::fromVariant(title);
if (_device_agent->is_hardware() && _device_agent->get_work_mode() == LOGIC) if (_device_agent->is_hardware() && _device_agent->get_work_mode() == LOGIC)
@@ -1173,7 +1186,7 @@ namespace pv
{ {
// default dockwidget size // default dockwidget size
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QByteArray st = app._frameOptions.windowState; QByteArray st = app.frameOptions.windowState;
if (!st.isEmpty()) if (!st.isEmpty())
{ {
try try
@@ -1341,9 +1354,9 @@ namespace pv
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._frameOptions.language != language && language > 0) if (app.frameOptions.language != language && language > 0)
{ {
app._frameOptions.language = language; app.frameOptions.language = language;
app.SaveFrame(); app.SaveFrame();
LangResource::Instance()->Load(language); LangResource::Instance()->Load(language);
} }
@@ -1372,9 +1385,9 @@ namespace pv
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._frameOptions.style != style) if (app.frameOptions.style != style)
{ {
app._frameOptions.style = style; app.frameOptions.style = style;
app.SaveFrame(); app.SaveFrame();
} }
@@ -1407,7 +1420,7 @@ namespace pv
{ {
QDir dir(GetAppDataDir()); QDir dir(GetAppDataDir());
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int lan = app._frameOptions.language; int lan = app.frameOptions.language;
QDesktopServices::openUrl( QDesktopServices::openUrl(
QUrl("file:///" + dir.absolutePath() + "/ug" + QString::number(lan) + ".pdf")); QUrl("file:///" + dir.absolutePath() + "/ug" + QString::number(lan) + ".pdf"));
} }
@@ -2040,7 +2053,11 @@ namespace pv
case DSV_MSG_APP_OPTIONS_CHANGED: case DSV_MSG_APP_OPTIONS_CHANGED:
update_title_bar_text(); update_title_bar_text();
break; break;
case DSV_MSG_FONT_OPTIONS_CHANGED:
AppControl::Instance()->update_font_forms();
break;
} }
} }
@@ -2088,7 +2105,7 @@ namespace pv
QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion(); QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion();
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (_title_ext_string != "" && app._appOptions.displayProfileInBar){ if (_title_ext_string != "" && app.appOptions.displayProfileInBar){
title += " [" + _title_ext_string + "]"; title += " [" + _title_ext_string + "]";
} }

View File

@@ -51,7 +51,7 @@ DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::deco
const srd_decoder *const dec = _decoder->decoder(); const srd_decoder *const dec = _decoder->decoder();
assert(dec); assert(dec);
bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg; bool bLang = AppConfig::Instance().appOptions.transDecoderDlg;
if (LangResource::Instance()->is_lang_en()){ if (LangResource::Instance()->is_lang_en()){
bLang = false; bLang = false;

View File

@@ -2122,7 +2122,7 @@ namespace pv
if (is_repeat_mode()) if (is_repeat_mode())
{ {
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
bool swapBackBufferAlways = app._appOptions.swapBackBufferAlways; bool swapBackBufferAlways = app.appOptions.swapBackBufferAlways;
if (!swapBackBufferAlways && !_is_working && _capture_times > 1){ if (!swapBackBufferAlways && !_is_working && _capture_times > 1){
bAddDecoder = false; bAddDecoder = false;
bSwapBuffer = false; bSwapBuffer = false;

View File

@@ -738,7 +738,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
//set export all data flag //set export all data flag
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int origin_flag = app._appOptions.originalData ? 1 : 0; int origin_flag = app.appOptions.originalData ? 1 : 0;
data::LogicSnapshot *logic_snapshot = NULL; data::LogicSnapshot *logic_snapshot = NULL;
data::AnalogSnapshot *analog_snapshot = NULL; data::AnalogSnapshot *analog_snapshot = NULL;
@@ -1368,9 +1368,9 @@ QString StoreSession::MakeSaveFile(bool bDlg)
QString default_name; QString default_name;
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._userHistory.saveDir != "") if (app.userHistory.saveDir != "")
{ {
default_name = app._userHistory.saveDir + "/" + _session->get_device()->name() + "-"; default_name = app.userHistory.saveDir + "/" + _session->get_device()->name() + "-";
} }
else{ else{
QDir _dir; QDir _dir;
@@ -1406,9 +1406,9 @@ QString StoreSession::MakeSaveFile(bool bDlg)
QString _dir_path = path::GetDirectoryName(default_name); QString _dir_path = path::GetDirectoryName(default_name);
if (_dir_path != app._userHistory.saveDir) if (_dir_path != app.userHistory.saveDir)
{ {
app._userHistory.saveDir = _dir_path; app.userHistory.saveDir = _dir_path;
app.SaveHistory(); app.SaveHistory();
} }
} }
@@ -1428,9 +1428,9 @@ QString StoreSession::MakeExportFile(bool bDlg)
QString default_name; QString default_name;
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._userHistory.exportDir != "") if (app.userHistory.exportDir != "")
{ {
default_name = app._userHistory.exportDir + "/" + _session->get_device()->name() + "-"; default_name = app.userHistory.exportDir + "/" + _session->get_device()->name() + "-";
} }
else{ else{
QDir _dir; QDir _dir;
@@ -1457,9 +1457,9 @@ QString StoreSession::MakeExportFile(bool bDlg)
} }
QString selfilter; QString selfilter;
if (app._userHistory.exportFormat != "" if (app.userHistory.exportFormat != ""
&& _session->get_device()->get_work_mode() == LOGIC){ && _session->get_device()->get_work_mode() == LOGIC){
selfilter.append(app._userHistory.exportFormat); selfilter.append(app.userHistory.exportFormat);
} }
else{ else{
selfilter.append(".csv"); selfilter.append(".csv");
@@ -1481,15 +1481,15 @@ QString StoreSession::MakeExportFile(bool bDlg)
bool bChange = false; bool bChange = false;
QString _dir_path = path::GetDirectoryName(default_name); QString _dir_path = path::GetDirectoryName(default_name);
if (_dir_path != app._userHistory.exportDir) if (_dir_path != app.userHistory.exportDir)
{ {
app._userHistory.exportDir = _dir_path; app.userHistory.exportDir = _dir_path;
bChange = true; bChange = true;
} }
if (selfilter != app._userHistory.exportFormat if (selfilter != app.userHistory.exportFormat
&& _session->get_device()->get_work_mode() == LOGIC){ && _session->get_device()->get_work_mode() == LOGIC){
app._userHistory.exportFormat = selfilter; app.userHistory.exportFormat = selfilter;
bChange = true; bChange = true;
} }

View File

@@ -29,10 +29,9 @@
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../utility/path.h" #include "../utility/path.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../log.h" #include "../log.h"
#include "../interface/icallbacks.h" #include "../ui/fun.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
@@ -94,6 +93,8 @@ FileBar::FileBar(SigSession *session, QWidget *parent) :
connect(_action_save, SIGNAL(triggered()), this, SIGNAL(sig_save())); connect(_action_save, SIGNAL(triggered()), this, SIGNAL(sig_save()));
connect(_action_export, SIGNAL(triggered()), this, SIGNAL(sig_export())); connect(_action_export, SIGNAL(triggered()), this, SIGNAL(sig_export()));
connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered())); connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered()));
update_font();
} }
void FileBar::changeEvent(QEvent *event) void FileBar::changeEvent(QEvent *event)
@@ -116,8 +117,6 @@ void FileBar::retranslateUi()
_action_save->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_SAVE), "&Save...")); _action_save->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_SAVE), "&Save..."));
_action_export->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_EXPORT), "&Export...")); _action_export->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_EXPORT), "&Export..."));
_action_capture->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_CAPTURE), "&Capture...")); _action_capture->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FILE_CAPTURE), "&Capture..."));
auto_resize();
} }
void FileBar::reStyle() void FileBar::reStyle()
@@ -151,13 +150,13 @@ void FileBar::on_actionOpen_triggered()
const QString file_name = QFileDialog::getOpenFileName( const QString file_name = QFileDialog::getOpenFileName(
this, this,
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_OPEN_FILE), "Open File"), L_S(STR_PAGE_DLG, S_ID(IDS_DLG_OPEN_FILE), "Open File"),
app._userHistory.openDir, app.userHistory.openDir,
"DSView Data (*.dsl)"); "DSView Data (*.dsl)");
if (!file_name.isEmpty()) { if (!file_name.isEmpty()) {
QString fname = path::GetDirectoryName(file_name); QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.openDir){ if (fname != app.userHistory.openDir){
app._userHistory.openDir = fname; app.userHistory.openDir = fname;
app.SaveHistory(); app.SaveHistory();
} }
@@ -172,13 +171,13 @@ void FileBar::on_actionLoad_triggered()
const QString file_name = QFileDialog::getOpenFileName( const QString file_name = QFileDialog::getOpenFileName(
this, this,
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_OPEN_SEESION), "Open Session"), L_S(STR_PAGE_DLG, S_ID(IDS_DLG_OPEN_SEESION), "Open Session"),
app._userHistory.sessionDir, app.userHistory.sessionDir,
"DSView Session (*.dsc)"); "DSView Session (*.dsc)");
if (!file_name.isEmpty()) { if (!file_name.isEmpty()) {
QString fname = path::GetDirectoryName(file_name); QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.sessionDir){ if (fname != app.userHistory.sessionDir){
app._userHistory.sessionDir = fname; app.userHistory.sessionDir = fname;
app.SaveHistory(); app.SaveHistory();
} }
@@ -220,7 +219,7 @@ void FileBar::on_actionStore_triggered()
QString file_name = QFileDialog::getSaveFileName( QString file_name = QFileDialog::getSaveFileName(
this, this,
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_SEESION), "Save Session"), L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_SEESION), "Save Session"),
app._userHistory.sessionDir, app.userHistory.sessionDir,
"DSView Session (*.dsc)"); "DSView Session (*.dsc)");
if (!file_name.isEmpty()) { if (!file_name.isEmpty()) {
@@ -229,8 +228,8 @@ void FileBar::on_actionStore_triggered()
file_name.append(".dsc"); file_name.append(".dsc");
QString fname = path::GetDirectoryName(file_name); QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.sessionDir){ if (fname != app.userHistory.sessionDir){
app._userHistory.sessionDir = fname; app.userHistory.sessionDir = fname;
app.SaveHistory(); app.SaveHistory();
} }
@@ -255,15 +254,12 @@ void FileBar::update_view_status()
_menu_session->setEnabled(bEnable && is_hardware); _menu_session->setEnabled(bEnable && is_hardware);
} }
void FileBar::auto_resize() void FileBar::update_font()
{ {
std::vector<QToolButton*> wids; FontOptions &st = AppConfig::Instance().fontOptions;
wids.push_back(&_file_button); QFont font = this->font();
ui::set_font_param(font, st.toolbar);
for(auto bt : wids){ ui::set_toolbar_font(this, font);
int w = bt->fontMetrics().boundingRect(bt->text()).width();
bt->setMinimumWidth(w+5);
}
} }
} // namespace toolbars } // namespace toolbars

View File

@@ -29,13 +29,14 @@
#include <QMenu> #include <QMenu>
#include "../sigsession.h" #include "../sigsession.h"
#include "../interface/icallbacks.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
//toolbar button,referenced by MainWindow //toolbar button,referenced by MainWindow
//TODO: load session file, sorte session, load log data file, sorte data, export data //TODO: load session file, sorte session, load log data file, sorte data, export data
class FileBar : public QToolBar class FileBar : public QToolBar, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -46,13 +47,14 @@ public:
QString genDefaultSessionFile(); QString genDefaultSessionFile();
void auto_resize();
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
void retranslateUi(); void retranslateUi();
void reStyle(); void reStyle();
//IFontForm
void update_font();
signals: signals:
void sig_load_file(QString); void sig_load_file(QString);
void sig_save(); void sig_save();

View File

@@ -46,7 +46,7 @@
#include "../log.h" #include "../log.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
@@ -123,6 +123,8 @@ LogoBar::LogoBar(SigSession *session, QWidget *parent) :
connect(_issue, SIGNAL(triggered()), this, SLOT(on_actionIssue_triggered())); connect(_issue, SIGNAL(triggered()), this, SLOT(on_actionIssue_triggered()));
connect(_update, SIGNAL(triggered()), this, SLOT(on_action_update())); connect(_update, SIGNAL(triggered()), this, SLOT(on_action_update()));
connect(_log, SIGNAL(triggered()), this, SLOT(on_action_setting_log())); connect(_log, SIGNAL(triggered()), this, SLOT(on_action_setting_log()));
update_font();
} }
void LogoBar::changeEvent(QEvent *event) void LogoBar::changeEvent(QEvent *event)
@@ -148,7 +150,7 @@ void LogoBar::retranslateUi()
_log->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_HELP_LOG), "L&og Options")); _log->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_HELP_LOG), "L&og Options"));
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._frameOptions.language == LAN_CN) if (app.frameOptions.language == LAN_CN)
_language->setIcon(QIcon(":/icons/Chinese.svg")); _language->setIcon(QIcon(":/icons/Chinese.svg"));
else else
_language->setIcon(QIcon(":/icons/English.svg")); _language->setIcon(QIcon(":/icons/English.svg"));
@@ -216,7 +218,7 @@ void LogoBar::on_actionIssue_triggered()
void LogoBar::on_action_update() void LogoBar::on_action_update()
{ {
if (AppConfig::Instance()._frameOptions.language == LAN_CN){ if (AppConfig::Instance().frameOptions.language == LAN_CN){
QDesktopServices::openUrl(QUrl(QLatin1String("https://dreamsourcelab.cn/download/"))); QDesktopServices::openUrl(QUrl(QLatin1String("https://dreamsourcelab.cn/download/")));
} }
else{ else{
@@ -250,14 +252,14 @@ void LogoBar::on_action_setting_log()
for (int i=0; i<=5; i++){ for (int i=0; i<=5; i++){
cbBox->addItem(QString::number(i)); cbBox->addItem(QString::number(i));
} }
cbBox->setCurrentIndex(app._appOptions.logLevel); cbBox->setCurrentIndex(app.appOptions.logLevel);
QCheckBox *ckSave = new QCheckBox(); QCheckBox *ckSave = new QCheckBox();
ckSave->setChecked(app._appOptions.ableSaveLog); ckSave->setChecked(app.appOptions.ableSaveLog);
lay->addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_FILE), "Save To File"), ckSave); lay->addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_FILE), "Save To File"), ckSave);
QCheckBox *ckRebuild = new QCheckBox(); QCheckBox *ckRebuild = new QCheckBox();
ckRebuild->setChecked(app._appOptions.appendLogMode); ckRebuild->setChecked(app.appOptions.appendLogMode);
lay->addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_APPEND_MODE), "Append mode"), ckRebuild); lay->addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_APPEND_MODE), "Append mode"), ckRebuild);
QPushButton *btOpen = new QPushButton(); QPushButton *btOpen = new QPushButton();
@@ -292,12 +294,12 @@ void LogoBar::on_action_setting_log()
int level = cbBox->currentIndex(); int level = cbBox->currentIndex();
bool appendLogMode = ckRebuild->isChecked(); bool appendLogMode = ckRebuild->isChecked();
if (ableSave != app._appOptions.ableSaveLog if (ableSave != app.appOptions.ableSaveLog
|| level != app._appOptions.logLevel || level != app.appOptions.logLevel
|| appendLogMode != app._appOptions.appendLogMode){ || appendLogMode != app.appOptions.appendLogMode){
app._appOptions.ableSaveLog = ableSave; app.appOptions.ableSaveLog = ableSave;
app._appOptions.logLevel = level; app.appOptions.logLevel = level;
app._appOptions.appendLogMode = appendLogMode; app.appOptions.appendLogMode = appendLogMode;
app.SaveApp(); app.SaveApp();
dsv_log_level(level); dsv_log_level(level);
@@ -346,5 +348,13 @@ void LogoBar::on_clear_log_file()
} }
} }
void LogoBar::update_font()
{
FontOptions &st = AppConfig::Instance().fontOptions;
QFont font = this->font();
ui::set_font_param(font, st.toolbar);
ui::set_toolbar_font(this, font);
}
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@@ -33,13 +33,12 @@
#include "../sigsession.h" #include "../sigsession.h"
#include "../interface/icallbacks.h" #include "../interface/icallbacks.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
//The tool button for help,is a ui class,referenced by MainWindow //The tool button for help,is a ui class,referenced by MainWindow
//TODO: switch language,submit bug descript, //TODO: switch language,submit bug descript,
class LogoBar : public QToolBar class LogoBar : public QToolBar, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -60,6 +59,9 @@ private:
void retranslateUi(); void retranslateUi();
void reStyle(); void reStyle();
//IFontForm
void update_font();
signals: signals:
//post event message to open user help document, MainWindow class receive it //post event message to open user help document, MainWindow class receive it
void sig_open_doc(); void sig_open_doc();

View File

@@ -38,6 +38,7 @@
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../view/view.h" #include "../view/view.h"
#include "../ui/fun.h"
#define SINGLE_ACTION_ICON "/once.svg" #define SINGLE_ACTION_ICON "/once.svg"
#define REPEAT_ACTION_ICON "/repeat.svg" #define REPEAT_ACTION_ICON "/repeat.svg"
@@ -124,9 +125,10 @@ namespace pv
_run_stop_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
_run_stop_action = addWidget(&_run_stop_button); _run_stop_action = addWidget(&_run_stop_button);
_instant_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); _instant_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
_instant_action = addWidget(&_instant_button); _instant_action = addWidget(&_instant_button);
update_view_status(); update_view_status();
update_font();
connect(&_device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(on_device_selected())); connect(&_device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(on_device_selected()));
connect(&_configure_button, SIGNAL(clicked()), this, SLOT(on_configure())); connect(&_configure_button, SIGNAL(clicked()), this, SLOT(on_configure()));
@@ -209,8 +211,6 @@ namespace pv
_action_single->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_SINGLE), "&Single")); _action_single->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_SINGLE), "&Single"));
_action_repeat->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_REPEAT), "&Repetitive")); _action_repeat->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_REPEAT), "&Repetitive"));
_action_loop->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_LOOP), "&Loop")); _action_loop->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_CAPTURE_MODE_LOOP), "&Loop"));
auto_resize();
} }
void SamplingBar::reStyle() void SamplingBar::reStyle()
@@ -1251,18 +1251,12 @@ namespace pv
on_instant_stop(); on_instant_stop();
} }
void SamplingBar::auto_resize() void SamplingBar::update_font()
{ {
std::vector<QToolButton*> wids; FontOptions &st = AppConfig::Instance().fontOptions;
wids.push_back(&_configure_button); QFont font = this->font();
wids.push_back(&_mode_button); ui::set_font_param(font, st.toolbar);
wids.push_back(&_run_stop_button); ui::set_toolbar_font(this, font);
wids.push_back(&_instant_button);
for(auto bt : wids){
int w = bt->fontMetrics().boundingRect(bt->text()).width();
bt->setMinimumWidth(w+5);
}
} }
} // namespace toolbars } // namespace toolbars

View File

@@ -33,6 +33,7 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include "../ui/dscombobox.h" #include "../ui/dscombobox.h"
#include "../interface/icallbacks.h"
#include <QDialog> #include <QDialog>
struct st_dev_inst; struct st_dev_inst;
@@ -58,7 +59,7 @@ namespace pv
namespace toolbars namespace toolbars
{ {
class SamplingBar : public QToolBar class SamplingBar : public QToolBar, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -100,8 +101,6 @@ namespace pv
void commit_settings(); void commit_settings();
void auto_resize();
signals: signals:
void sig_store_session_data(); void sig_store_session_data();
@@ -123,6 +122,9 @@ namespace pv
bool action_run_stop(); bool action_run_stop();
bool action_instant_stop(); bool action_instant_stop();
//IFontForm
void update_font();
private slots: private slots:
void on_collect_mode(); void on_collect_mode();

View File

@@ -33,8 +33,8 @@
#include <assert.h> #include <assert.h>
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../appcontrol.h" #include "../appcontrol.h"
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
@@ -89,7 +89,9 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
lay1->setContentsMargins(0,0,0,0); lay1->setContentsMargins(0,0,0,0);
lay1->setSpacing(0); lay1->setSpacing(0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
update_font();
} }
TitleBar::~TitleBar(){ TitleBar::~TitleBar(){
@@ -234,6 +236,13 @@ void TitleBar::mouseDoubleClickEvent(QMouseEvent *event)
QWidget::mouseDoubleClickEvent(event); QWidget::mouseDoubleClickEvent(event);
} }
void TitleBar::update_font()
{
FontOptions &st = AppConfig::Instance().fontOptions;
QFont font = this->font();
ui::set_font_param(font, st.title);
_title->setFont(font);
}
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@@ -23,6 +23,7 @@
#define DSVIEW_PV_TOOLBARS_TITLEBAR_H #define DSVIEW_PV_TOOLBARS_TITLEBAR_H
#include <QWidget> #include <QWidget>
#include "../interface/icallbacks.h"
class QToolButton; class QToolButton;
class QHBoxLayout; class QHBoxLayout;
@@ -31,7 +32,7 @@ class QLabel;
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
class TitleBar : public QWidget class TitleBar : public QWidget, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -42,6 +43,9 @@ public:
void setTitle(QString title); void setTitle(QString title);
QString title(); QString title();
//IFontForm
void update_font();
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
void reStyle(); void reStyle();

View File

@@ -33,6 +33,7 @@
#include "../dialogs/applicationpardlg.h" #include "../dialogs/applicationpardlg.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../ui/fun.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
@@ -121,6 +122,8 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) :
connect(_dark_style, SIGNAL(triggered()), this, SLOT(on_actionDark_triggered())); connect(_dark_style, SIGNAL(triggered()), this, SLOT(on_actionDark_triggered()));
connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered())); connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered()));
connect(_action_dispalyOptions, SIGNAL(triggered()), this, SLOT(on_display_setting())); connect(_action_dispalyOptions, SIGNAL(triggered()), this, SLOT(on_display_setting()));
update_font();
} }
//语言变化 //语言变化
@@ -153,8 +156,6 @@ void TrigBar::retranslateUi()
_action_math->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FUNCTION_MATH), "Math")); _action_math->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_FUNCTION_MATH), "Math"));
_action_dispalyOptions->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_DISPLAY_OPTIONS), "Options")); _action_dispalyOptions->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_DISPLAY_OPTIONS), "Options"));
auto_resize();
} }
void TrigBar::reStyle() void TrigBar::reStyle()
@@ -177,7 +178,7 @@ void TrigBar::reStyle()
_action_dispalyOptions->setIcon(QIcon(iconPath+"/gear.svg")); _action_dispalyOptions->setIcon(QIcon(iconPath+"/gear.svg"));
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QString icon_fname = iconPath +"/"+ app._frameOptions.style +".svg"; QString icon_fname = iconPath +"/"+ app.frameOptions.style +".svg";
_themes->setIcon(QIcon(icon_fname)); _themes->setIcon(QIcon(icon_fname));
} }
@@ -326,11 +327,11 @@ void TrigBar::on_actionLissajous_triggered()
int mode = _session->get_device()->get_work_mode(); int mode = _session->get_device()->get_work_mode();
if (mode == LOGIC) if (mode == LOGIC)
return &app._frameOptions._logicDock; return &app.frameOptions._logicDock;
else if (mode == DSO) else if (mode == DSO)
return &app._frameOptions._dsoDock; return &app.frameOptions._dsoDock;
else else
return &app._frameOptions._analogDock; return &app.frameOptions._analogDock;
} }
void TrigBar::update_view_status() void TrigBar::update_view_status()
@@ -354,36 +355,29 @@ void TrigBar::on_actionLissajous_triggered()
} }
} }
void TrigBar::auto_resize() void TrigBar::update_checked_status()
{ {
std::vector<QToolButton*> wids; DockOptions *opt = getDockOptions();
wids.push_back(&_trig_button); assert(opt);
wids.push_back(&_protocol_button);
wids.push_back(&_measure_button);
wids.push_back(&_search_button);
wids.push_back(&_setting_button);
for(auto bt : wids){
int w = bt->fontMetrics().boundingRect(bt->text()).width();
bt->setMinimumWidth(w+5);
}
}
void TrigBar::update_checked_status() _trig_button.setCheckable(true);
{ _protocol_button.setCheckable(true);
DockOptions *opt = getDockOptions(); _measure_button.setCheckable(true);
assert(opt); _search_button.setCheckable(true);
_trig_button.setCheckable(true); _trig_button.setChecked(opt->triggerDock);
_protocol_button.setCheckable(true); _protocol_button.setChecked(opt->decodeDock);
_measure_button.setCheckable(true); _measure_button.setChecked(opt->measureDock);
_search_button.setCheckable(true); _search_button.setChecked(opt->searchDock);
}
_trig_button.setChecked(opt->triggerDock); void TrigBar::update_font()
_protocol_button.setChecked(opt->decodeDock); {
_measure_button.setChecked(opt->measureDock); FontOptions &st = AppConfig::Instance().fontOptions;
_search_button.setChecked(opt->searchDock); QFont font = this->font();
} ui::set_font_param(font, st.toolbar);
ui::set_toolbar_font(this, font);
}
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@@ -27,6 +27,7 @@
#include <QToolButton> #include <QToolButton>
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include "../interface/icallbacks.h"
class DockOptions; class DockOptions;
@@ -38,7 +39,7 @@ namespace toolbars {
//boolbar, referenced by MainWindow //boolbar, referenced by MainWindow
//TODO:show the property panel about protocol\trigger //TODO:show the property panel about protocol\trigger
class TrigBar : public QToolBar class TrigBar : public QToolBar, public IFontForm
{ {
Q_OBJECT Q_OBJECT
@@ -46,7 +47,6 @@ public:
explicit TrigBar(SigSession *session, QWidget *parent = 0); explicit TrigBar(SigSession *session, QWidget *parent = 0);
void reload(); void reload();
void update_view_status(); void update_view_status();
void auto_resize();
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
@@ -55,6 +55,9 @@ private:
DockOptions* getDockOptions(); DockOptions* getDockOptions();
void update_checked_status(); void update_checked_status();
//IFontForm
void update_font();
signals: signals:
void sig_setTheme(QString style); void sig_setTheme(QString style);
void sig_protocol(bool visible); //post decode button click event,to show or hide protocol property panel void sig_protocol(bool visible); //post decode button click event,to show or hide protocol property panel

View File

@@ -74,7 +74,7 @@ DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent)
popup->setMaximumHeight(750); popup->setMaximumHeight(750);
} }
if (AppConfig::Instance()._frameOptions.style == THEME_STYLE_DARK){ if (AppConfig::Instance().frameOptions.style == THEME_STYLE_DARK){
popup->setStyleSheet("background-color:#262626;"); popup->setStyleSheet("background-color:#262626;");
} }
else{ else{

142
DSView/pv/ui/fun.cpp Normal file
View File

@@ -0,0 +1,142 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2023 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "fun.h"
#include <assert.h>
#include <QPushButton>
#include <QToolButton>
#include <QComboBox>
#include <QLabel>
#include <QAction>
#include <QToolBar>
#include <QWidget>
#include <QLineEdit>
#include <QTableWidget>
#include <QGroupBox>
#include <QTextEdit>
#include <QRadioButton>
#include "../config/appconfig.h"
namespace ui
{
void set_font_param(QFont &font, struct FontParam &param)
{
font.setPointSizeF(param.size >= 9.0f ? param.size : 9.0f);
if (param.name != ""){
font.setFamily(param.name);
}
}
void set_toolbar_font(QToolBar *bar, QFont &font)
{
assert(bar);
auto buttons = bar->findChildren<QToolButton*>();
for(auto o : buttons)
{
o->setFont(font);
}
auto buttons2 = bar->findChildren<QPushButton*>();
for(auto o : buttons2)
{
o->setFont(font);
}
auto comboxs = bar->findChildren<QComboBox*>();
for(auto o : comboxs)
{
o->setFont(font);
}
auto labels = bar->findChildren<QLabel*>();
for(auto o : labels)
{
o->setFont(font);
}
auto actions = bar->findChildren<QAction*>();
for(auto o : actions)
{
o->setFont(font);
}
}
void set_form_font(QWidget *wid, QFont &font)
{
assert(wid);
auto buttons2 = wid->findChildren<QPushButton*>();
for(auto o : buttons2)
{
o->setFont(font);
}
auto comboxs = wid->findChildren<QComboBox*>();
for(auto o : comboxs)
{
o->setFont(font);
}
auto labels = wid->findChildren<QLabel*>();
for(auto o : labels)
{
o->setFont(font);
}
auto edits = wid->findChildren<QLineEdit*>();
for(auto o : edits)
{
o->setFont(font);
}
auto textEdits = wid->findChildren<QTextEdit*>();
for(auto o : textEdits)
{
o->setFont(font);
}
auto radios = wid->findChildren<QRadioButton*>();
for(auto o : radios)
{
o->setFont(font);
}
// Magnify the size.
font.setPointSizeF(font.pointSizeF() + 1);
auto tabs = wid->findChildren<QTableWidget*>();
for(auto o : tabs)
{
o->setFont(font);
}
auto groups = wid->findChildren<QGroupBox*>();
for(auto o : groups)
{
o->setFont(font);
}
}
} // namespace ui

42
DSView/pv/ui/fun.h Normal file
View File

@@ -0,0 +1,42 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2023 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _UI_FUN_H
#define _UI_FUN_H
#include <QFont>
struct FontParam;
class QToolBar;
class QWidget;
namespace ui
{
void set_font_param(QFont &font, struct FontParam &param);
void set_toolbar_font(QToolBar *bar, QFont &font);
void set_form_font(QWidget *wid, QFont &font);
} // namespace ui
#endif

View File

@@ -51,8 +51,8 @@
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../appcontrol.h" #include "../appcontrol.h"
#include "../dialogs/decoderoptionsdlg.h" #include "../dialogs/decoderoptionsdlg.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../config/appconfig.h"
using namespace boost; using namespace boost;
using namespace std; using namespace std;
@@ -209,11 +209,6 @@ void DecodeTrace::paint_back(QPainter &p, int left, int right, QColor fore, QCol
}; };
p.drawPolygon(points, countof(points)); p.drawPolygon(points, countof(points));
// Draw the outline
QFont font=p.font();
font.setPointSize(DefaultFontSize);
p.setFont(font);
// Draw the text // Draw the text
p.setPen(fore); p.setPen(fore);
p.drawText(r, f, h); p.drawText(r, f, h);
@@ -412,7 +407,7 @@ void DecodeTrace::draw_nodetail(QPainter &p,
p.drawLine(info_left, y, info_left+5, y + height/2 + 0.5); p.drawLine(info_left, y, info_left+5, y + height/2 + 0.5);
p.drawLine(info_right, y, info_right-5, y - height/2 + 0.5); p.drawLine(info_right, y, info_right-5, y - height/2 + 0.5);
p.drawLine(info_right, y, info_right-5, y + height/2 + 0.5); p.drawLine(info_right, y, info_right-5, y + height/2 + 0.5);
p.setPen(fore); p.setPen(fore);
p.drawText(nodetail_rect, Qt::AlignCenter | Qt::AlignVCenter, info); p.drawText(nodetail_rect, Qt::AlignCenter | Qt::AlignVCenter, info);
} }
@@ -435,9 +430,6 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &
p.drawRoundedRect(rect, h / 2, h / 2); p.drawRoundedRect(rect, h / 2, h / 2);
p.setPen(text_color); p.setPen(text_color);
QFont font=p.font();
font.setPointSize(DefaultFontSize);
p.setFont(font);
p.drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, text); p.drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, text);
} }
@@ -498,10 +490,6 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
if (best_annotation.isEmpty()) if (best_annotation.isEmpty())
best_annotation = annotations.back(); best_annotation = annotations.back();
// If not ellide the last in the list
QFont font=p.font();
font.setPointSize(DefaultFontSize);
p.setFont(font);
p.drawText(rect, Qt::AlignCenter, p.fontMetrics().elidedText( p.drawText(rect, Qt::AlignCenter, p.fontMetrics().elidedText(
best_annotation, Qt::ElideRight, rect.width())); best_annotation, Qt::ElideRight, rect.width()));
} }
@@ -516,9 +504,7 @@ void DecodeTrace::draw_error(QPainter &p, const QString &message,
const QRectF bounding_rect = p.boundingRect(text_rect, const QRectF bounding_rect = p.boundingRect(text_rect,
Qt::AlignCenter, message); Qt::AlignCenter, message);
p.setPen(Qt::red); p.setPen(Qt::red);
QFont font=p.font();
font.setPointSize(DefaultFontSize);
p.setFont(font);
if (bounding_rect.width() < text_rect.width()) if (bounding_rect.width() < text_rect.width())
p.drawText(text_rect, Qt::AlignCenter, L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODETRACE_ERROR1), "Error:")+message); p.drawText(text_rect, Qt::AlignCenter, L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODETRACE_ERROR1), "Error:")+message);
else else

View File

@@ -79,7 +79,6 @@ private:
static const QColor Colours[16]; static const QColor Colours[16];
static const QColor OutlineColours[16]; static const QColor OutlineColours[16];
static const int DefaultFontSize = 10;
static const int ControlRectWidth = 5; static const int ControlRectWidth = 5;
static const int MaxAnnType = 100; static const int MaxAnnType = 100;

View File

@@ -124,7 +124,7 @@ void DevMode::set_device()
_close_button->setDisabled(true); _close_button->setDisabled(true);
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int lan = app._frameOptions.language; int lan = app.frameOptions.language;
QString iconPath = GetIconPath() + "/"; QString iconPath = GetIconPath() + "/";
@@ -201,7 +201,7 @@ void DevMode::on_mode_change()
QString iconPath = GetIconPath(); QString iconPath = GetIconPath();
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
int lan = app._frameOptions.language; int lan = app.frameOptions.language;
for(auto i = _mode_list.begin();i != _mode_list.end(); i++) for(auto i = _mode_list.begin();i != _mode_list.end(); i++)
{ {

View File

@@ -32,6 +32,7 @@
#include <QApplication> #include <QApplication>
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
#include <QFont>
#include "view.h" #include "view.h"
#include "trace.h" #include "trace.h"
@@ -43,7 +44,9 @@
#include "../sigsession.h" #include "../sigsession.h"
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../appcontrol.h"
#include "../config/appconfig.h"
#include "../ui/fun.h"
using namespace std; using namespace std;
@@ -124,6 +127,11 @@ void Header::paintEvent(QPaintEvent*)
QColor fore(QWidget::palette().color(QWidget::foregroundRole())); QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
fore.setAlpha(View::ForeAlpha); fore.setAlpha(View::ForeAlpha);
FontOptions &st = AppConfig::Instance().fontOptions;
QFont font(painter.font());
ui::set_font_param(font, st.channelLabel);
painter.setFont(font);
for(auto t : traces) for(auto t : traces)
{ {
t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point, fore); t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point, fore);

View File

@@ -38,6 +38,8 @@
#include <QPainter> #include <QPainter>
#include <QStyleOption> #include <QStyleOption>
#include "../appcontrol.h" #include "../appcontrol.h"
#include "../config/appconfig.h"
#include "../ui/fun.h"
using namespace std; using namespace std;
@@ -194,6 +196,11 @@ void Ruler::paintEvent(QPaintEvent*)
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
QFont font = p.font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.ruler);
p.setFont(font);
SigSession *session = AppControl::Instance()->GetSession(); SigSession *session = AppControl::Instance()->GetSession();
// Draw tick mark // Draw tick mark

View File

@@ -496,7 +496,7 @@ void View::receive_trigger(quint64 trig_pos)
_show_trig_cursor = true; _show_trig_cursor = true;
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (app._appOptions.trigPosDisplayInMid){ if (app.appOptions.trigPosDisplayInMid){
set_scale_offset(_scale, (time / _scale) - (get_view_width() / 2)); set_scale_offset(_scale, (time / _scale) - (get_view_width() / 2));
} }
} }

View File

@@ -42,9 +42,9 @@
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../appcontrol.h" #include "../appcontrol.h"
#include "../log.h" #include "../log.h"
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../ui/fun.h"
using namespace std; using namespace std;
@@ -155,6 +155,11 @@ void Viewport::doPaint()
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
QFont font = p.font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.channelBody);
p.setFont(font);
_view.session().check_update(); _view.session().check_update();
QColor fore(QWidget::palette().color(QWidget::foregroundRole())); QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
QColor back(QWidget::palette().color(QWidget::backgroundRole())); QColor back(QWidget::palette().color(QWidget::backgroundRole()));
@@ -550,11 +555,14 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
bool triggered; bool triggered;
if (_view.session().get_capture_status(triggered, captured_progress)){ if (_view.session().get_capture_status(triggered, captured_progress)){
p.setPen(View::Blue); p.setPen(View::Blue);
QFont font=p.font();
font.setPointSize(10); QFont font = p.font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.channelBody);
font.setBold(true); font.setBold(true);
p.setFont(font); p.setFont(font);
QRect status_rect = QRect(cenPos.x() - radius, cenPos.y() + radius * 0.4, radius * 2, radius * 0.5); QRect status_rect = QRect(cenPos.x() - radius, cenPos.y() + radius * 0.4, radius * 2, radius * 0.5);
if (triggered) { if (triggered) {
@@ -584,6 +592,7 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
font.setPointSize(50); font.setPointSize(50);
font.setBold(true); font.setBold(true);
p.setFont(font); p.setFont(font);
p.drawText(_view.get_view_rect(), Qt::AlignCenter | Qt::AlignVCenter, QString::number(progress100)+"%"); p.drawText(_view.get_view_rect(), Qt::AlignCenter | Qt::AlignVCenter, QString::number(progress100)+"%");
prgRate(progress100); prgRate(progress100);
} }
@@ -874,7 +883,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
{ {
assert(event); assert(event);
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll; bool quickScroll = AppConfig::Instance().appOptions.quickScroll;
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized(); bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
if (_type != TIME_VIEW){ if (_type != TIME_VIEW){

View File

@@ -37,6 +37,9 @@
#include "../ui/langresource.h" #include "../ui/langresource.h"
#include "../log.h" #include "../log.h"
#include "../config/appconfig.h"
#include "../appcontrol.h"
#include "../ui/fun.h"
using namespace std; using namespace std;
@@ -66,6 +69,11 @@ void ViewStatus::paintEvent(QPaintEvent *)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QColor fore(QWidget::palette().color(QWidget::foregroundRole())); QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
QFont font = p.font();
FontOptions &st = AppConfig::Instance().fontOptions;
ui::set_font_param(font, st.channelBody);
p.setFont(font);
int mode = _session->get_device()->get_work_mode(); int mode = _session->get_device()->get_work_mode();
if (mode == LOGIC) { if (mode == LOGIC) {

View File

@@ -57,7 +57,7 @@ void Border::paintEvent(QPaintEvent *)
painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::Antialiasing, true);
QLinearGradient linearGrad(QPointF(width(), height()), QPointF(0, 0)); QLinearGradient linearGrad(QPointF(width(), height()), QPointF(0, 0));
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
QString style = app._frameOptions.style; QString style = app.frameOptions.style;
if (style == THEME_STYLE_DARK) { if (style == THEME_STYLE_DARK) {
linearGrad.setColorAt(0, dark_border0); linearGrad.setColorAt(0, dark_border0);

View File

@@ -65,7 +65,6 @@ QWidget:item:selected
QPushButton#flat{ QPushButton#flat{
text-align:left; text-align:left;
border:none; border:none;
/*font-size:14px;*/
} }
QPushButton#flat:hover QPushButton#flat:hover
@@ -1316,7 +1315,7 @@ QToolButton::menu-indicator
} }
QToolButton{ QToolButton{
/*font-size:14px;*/
} }
QToolButton#ModeButton::menu-indicator QToolButton#ModeButton::menu-indicator

View File

@@ -62,7 +62,6 @@ QWidget:item:selected
QPushButton#flat{ QPushButton#flat{
text-align:left; text-align:left;
border:none; border:none;
/*font-size:14px;*/
} }
QPushButton#flat:hover QPushButton#flat:hover
@@ -1356,7 +1355,7 @@ QToolButton::menu-indicator
} }
QToolButton{ QToolButton{
/*font-size:14px;*/
} }
QToolButton#ModeButton::menu-indicator QToolButton#ModeButton::menu-indicator

View File

@@ -702,5 +702,37 @@
{ {
"id": "IDS_DLG_USE_ABORT_DATA_REPEAT", "id": "IDS_DLG_USE_ABORT_DATA_REPEAT",
"text": "重复模式下允许使用中途停止的数据" "text": "重复模式下允许使用中途停止的数据"
},
{
"id": "IDS_DLG_FONT_GROUP",
"text": "字体设置"
},
{
"id": "IDS_DLG_TOOLBAR_FONT",
"text": "工具栏"
},
{
"id": "IDS_DLG_CHANNEL_NAME_FONT",
"text": "通道名称"
},
{
"id": "IDS_DLG_CHANNEL_BODY_FONT",
"text": "通道内容"
},
{
"id": "IDS_DLG_RULER_FONT",
"text": "刻度"
},
{
"id": "IDS_DLG_TITLE_FONT",
"text": "标题"
},
{
"id": "IDS_DLG_OTHER_FONT",
"text": "其它"
},
{
"id": "IDS_DLG_DEFAULT_FONT",
"text": "默认"
} }
] ]

View File

@@ -702,5 +702,37 @@
{ {
"id": "IDS_DLG_USE_ABORT_DATA_REPEAT", "id": "IDS_DLG_USE_ABORT_DATA_REPEAT",
"text": "Allow use of the midway stopped data on repeat mode" "text": "Allow use of the midway stopped data on repeat mode"
},
{
"id": "IDS_DLG_FONT_GROUP",
"text": "Font Setting"
},
{
"id": "IDS_DLG_TOOLBAR_FONT",
"text": "Toolbar"
},
{
"id": "IDS_DLG_CHANNEL_NAME_FONT",
"text": "Channel Name"
},
{
"id": "IDS_DLG_CHANNEL_BODY_FONT",
"text": "Channel Body"
},
{
"id": "IDS_DLG_RULER_FONT",
"text": "Ruler"
},
{
"id": "IDS_DLG_TITLE_FONT",
"text": "Title"
},
{
"id": "IDS_DLG_OTHER_FONT",
"text": "Other"
},
{
"id": "IDS_DLG_DEFAULT_FONT",
"text": "Default"
} }
] ]