Display the profile path name in the title bar

This commit is contained in:
dreamsourcelabTAI 2023-05-29 17:20:06 +08:00
parent 192a58a1fd
commit ee0d88f91c
9 changed files with 80 additions and 18 deletions

View File

@ -99,6 +99,7 @@ void _loadApp(AppOptions &o, QSettings &st){
getFiled("logLevel", st, o.logLevel, 3);
getFiled("transDecoderDlg", st, o.transDecoderDlg, true);
getFiled("trigPosDisplayInMid", st, o.trigPosDisplayInMid, true);
getFiled("displayProfileInBar", st, o.displayProfileInBar, false);
QString fmt;
getFiled("protocalFormats", st, fmt, "");
@ -119,6 +120,7 @@ void _saveApp(AppOptions &o, QSettings &st){
setFiled("logLevel", st, o.logLevel);
setFiled("transDecoderDlg", st, o.transDecoderDlg);
setFiled("trigPosDisplayInMid", st, o.trigPosDisplayInMid);
setFiled("displayProfileInBar", st, o.displayProfileInBar);
QString fmt = FormatArrayToString(o.m_protocolFormats);
setFiled("protocalFormats", st, fmt);

View File

@ -62,6 +62,7 @@ struct AppOptions
int logLevel;
bool transDecoderDlg;
bool trigPosDisplayInMid;
bool displayProfileInBar;
std::vector<StringPair> m_protocolFormats;
};

View File

@ -48,7 +48,7 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
{
DSDialog dlg(parent, true, true);
dlg.setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DISPLAY_OPTIONS), "Display options"));
dlg.setMinimumSize(300, 200);
dlg.setMinimumSize(300, 230);
QFormLayout &lay = *(new QFormLayout());
lay.setContentsMargins(0,20,0,30);
@ -63,6 +63,11 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
QCheckBox *ck_trigInMid = new QCheckBox();
ck_trigInMid->setChecked(app._appOptions.trigPosDisplayInMid);
QCheckBox *ck_profileBar = new QCheckBox();
ck_profileBar->setChecked(app._appOptions.displayProfileInBar);
lay.setHorizontalSpacing(8);
if (mode == LOGIC){
lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_QUICK_SCROLL), "Quick scroll"), ck_quickScroll);
}
@ -70,6 +75,8 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIG_DISPLAY_MIDDLE), "Tig pos in middle"), ck_trigInMid);
}
lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DISPLAY_PROFILE_IN_BAR), "Profile in bar"), ck_profileBar);
dlg.layout()->addLayout(&lay);
dlg.exec();
@ -80,8 +87,11 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent)
if (ret){
app._appOptions.quickScroll = ck_quickScroll->isChecked();
app._appOptions.trigPosDisplayInMid = ck_trigInMid->isChecked();
app._appOptions.displayProfileInBar = ck_profileBar->isChecked();
app.SaveApp();
AppControl::Instance()->GetSession()->broadcast_msg(DSV_MSG_APP_OPTIONS_CHANGED);
}
return ret;

View File

@ -96,6 +96,8 @@ public:
#define DSV_MSG_CLEAR_DECODE_DATA 8001
#define DSV_MSG_APP_OPTIONS_CHANGED 9001
class IMessageListener
{
public:

View File

@ -81,14 +81,13 @@ MainFrame::MainFrame()
QIcon icon;
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
setWindowIcon(icon);
// Title
_titleBar = new toolbars::TitleBar(true, this);
// MainWindow
_mainWindow = new MainWindow(this);
_mainWindow = new MainWindow(_titleBar, this);
_mainWindow->setWindowFlags(Qt::Widget);
_titleBar->setTitle(_mainWindow->windowTitle());
QVBoxLayout *vbox = new QVBoxLayout();
vbox->setContentsMargins(0,0,0,0);

View File

@ -103,12 +103,16 @@
namespace pv
{
MainWindow::MainWindow(QWidget *parent)
MainWindow::MainWindow(toolbars::TitleBar *title_bar, QWidget *parent)
: QMainWindow(parent)
{
_msg = NULL;
_frame = parent;
assert(title_bar);
_title_bar = title_bar;
_session = AppControl::Instance()->GetSession();
_session->set_callback(this);
_device_agent = _session->get_device();
@ -125,6 +129,8 @@ namespace pv
_key_vaild = false;
_last_key_press_time = high_resolution_clock::now();
update_title_bar_text();
}
void MainWindow::setup_ui()
@ -196,6 +202,7 @@ namespace pv
_measure_dock->setVisible(false);
_measure_widget = new dock::MeasureDock(_measure_dock, *_view, _session);
_measure_dock->setWidget(_measure_widget);
// search dock
_search_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SEARCH_DOCK_TITLE), "Search..."), this);
_search_dock->setObjectName("search_dock");
@ -203,7 +210,7 @@ namespace pv
_search_dock->setTitleBarWidget(new QWidget(_search_dock));
_search_dock->setAllowedAreas(Qt::BottomDockWidgetArea);
_search_dock->setVisible(false);
// dock::SearchDock *_search_widget = new dock::SearchDock(_search_dock, *_view, _session);
_search_widget = new dock::SearchDock(_search_dock, *_view, _session);
_search_dock->setWidget(_search_widget);
@ -212,10 +219,6 @@ namespace pv
addDockWidget(Qt::RightDockWidgetArea, _dso_trigger_dock);
addDockWidget(Qt::RightDockWidgetArea, _measure_dock);
addDockWidget(Qt::BottomDockWidgetArea, _search_dock);
// Set the title
QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion();
setWindowTitle(QApplication::translate("MainWindow", title.toLocal8Bit().data(), 0));
// event filter
_view->installEventFilter(this);
@ -636,6 +639,11 @@ namespace pv
_dso_trigger_widget->update_view();
}
if (_device_agent->is_hardware()){
_title_ext_string = name;
update_title_bar_text();
}
return ret;
}
@ -1583,7 +1591,8 @@ namespace pv
}
void MainWindow::load_device_config()
{
{
_title_ext_string = "";
int mode = _device_agent->get_work_mode();
if (_device_agent->is_hardware())
@ -1610,7 +1619,9 @@ namespace pv
}
}
on_load_session(ses_name);
if (on_load_session(ses_name)){
_title_ext_string = ses_name;
}
}
else if (_device_agent->is_demo())
{
@ -1752,6 +1763,7 @@ namespace pv
{
reset_all_view();
load_device_config();
update_title_bar_text();
_sampling_bar->update_device_list();
_logo_bar->dsl_connected(_session->get_device()->is_hardware());
@ -1827,6 +1839,7 @@ namespace pv
_view->mode_changed();
reset_all_view();
load_device_config();
update_title_bar_text();
update_toolbar_view_status();
_sampling_bar->update_sample_rate_list();
@ -1987,7 +2000,11 @@ namespace pv
}
}
calc_min_height();
break;
break;
case DSV_MSG_APP_OPTIONS_CHANGED:
update_title_bar_text();
break;
}
}
@ -2029,4 +2046,22 @@ namespace pv
}
}
void MainWindow::update_title_bar_text()
{
// Set the title
QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion();
AppConfig &app = AppConfig::Instance();
if (_title_ext_string != "" && app._appOptions.displayProfileInBar){
title += " [" + _title_ext_string + "]";
}
if (_lst_title_string != title){
_lst_title_string = title;
setWindowTitle(QApplication::translate("MainWindow", title.toLocal8Bit().data(), 0));
_title_bar->setTitle(this->windowTitle());
}
}
} // namespace pv

View File

@ -57,6 +57,7 @@ class SamplingBar;
class TrigBar;
class FileBar;
class LogoBar;
class TitleBar;
}
namespace dock{
@ -89,7 +90,7 @@ public:
static const int Per_Chan_Height = 35;
public:
explicit MainWindow(QWidget *parent = 0);
explicit MainWindow(toolbars::TitleBar *title_bar, QWidget *parent = 0);
void openDoc();
@ -148,7 +149,8 @@ private:
QJsonDocument get_session_json_from_file(QString file);
QJsonArray get_decoder_json_from_file(QString file);
void calc_min_height();
void session_save();
void session_save();
void update_title_bar_text();
private:
//ISessionCallback
@ -200,6 +202,7 @@ private:
toolbars::TrigBar *_trig_bar;
toolbars::FileBar *_file_bar;
toolbars::LogoBar *_logo_bar; //help button, on top right
toolbars::TitleBar *_title_bar;
QDockWidget *_protocol_dock;
@ -225,6 +228,8 @@ private:
QWidget *_frame;
DsTimer _delay_prop_msg_timer;
QString _strMsg;
QString _lst_title_string;
QString _title_ext_string;
int _key_value;
bool _key_vaild;

View File

@ -65,7 +65,7 @@
},
{
"id": "IDS_DLG_QUICK_SCROLL",
"text": "快速滚动"
"text": "通过鼠标快速滚动波形"
},
{
"id": "IDS_DLG_SAVE",
@ -686,5 +686,9 @@
{
"id": "IDS_DLG_TRIG_DISPLAY_MIDDLE",
"text": "触发位置自动居中显示"
},
{
"id": "IDS_DLG_DISPLAY_PROFILE_IN_BAR",
"text": "将配置文件名显示在标题栏上"
}
]

View File

@ -65,7 +65,7 @@
},
{
"id": "IDS_DLG_QUICK_SCROLL",
"text": "Quick scroll"
"text": "Quick scroll waveform by mouse"
},
{
"id": "IDS_DLG_SAVE",
@ -686,5 +686,9 @@
{
"id": "IDS_DLG_TRIG_DISPLAY_MIDDLE",
"text": "Trig pos display at the middle"
},
{
"id": "IDS_DLG_DISPLAY_PROFILE_IN_BAR",
"text": "Display the profile in title bar"
}
]