forked from Ivasoft/DSView
fix dock panel can not restore bug
This commit is contained in:
@@ -111,13 +111,31 @@ void _saveApp(AppOptions &o, QSettings &st){
|
||||
setFiled("warnofMultiTrig", st, o.warnofMultiTrig);
|
||||
setFiled("originalData", st, o.originalData);
|
||||
|
||||
|
||||
QString fmt = FormatArrayToString(o.m_protocolFormats);
|
||||
setFiled("protocalFormats", st, fmt);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
//-----frame
|
||||
|
||||
void _loadDockOptions(DockOptions &o, QSettings &st, const char *group){
|
||||
st.beginGroup(group);
|
||||
getFiled("decodeDoc", st, o.decodeDoc, false);
|
||||
getFiled("triggerDoc", st, o.triggerDoc, false);
|
||||
getFiled("measureDoc", st, o.measureDoc, false);
|
||||
getFiled("searchDoc", st, o.searchDoc, false);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
void _saveDockOptions(DockOptions &o, QSettings &st, const char *group){
|
||||
st.beginGroup(group);
|
||||
setFiled("decodeDoc", st, o.decodeDoc);
|
||||
setFiled("triggerDoc", st, o.triggerDoc);
|
||||
setFiled("measureDoc", st, o.measureDoc);
|
||||
setFiled("searchDoc", st, o.searchDoc);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
void _loadFrame(FrameOptions &o, QSettings &st){
|
||||
st.beginGroup("MainFrame");
|
||||
getFiled("style", st, o.style, "dark");
|
||||
@@ -127,6 +145,11 @@ void _loadFrame(FrameOptions &o, QSettings &st){
|
||||
getFiled("top", st, o.top, 0);
|
||||
getFiled("right", st, o.right, 0);
|
||||
getFiled("bottom", st, o.bottom, 0);
|
||||
|
||||
_loadDockOptions(o._logicDock, st, "LOGIC_DOCK");
|
||||
_loadDockOptions(o._analogDock, st, "ANALOG_DOCK");
|
||||
_loadDockOptions(o._dsoDock, st, "DSO_DOCK");
|
||||
|
||||
o.windowState = st.value("windowState", QByteArray()).toByteArray();
|
||||
st.endGroup();
|
||||
|
||||
@@ -149,8 +172,13 @@ void _saveFrame(FrameOptions &o, QSettings &st){
|
||||
setFiled("left", st, o.left);
|
||||
setFiled("top", st, o.top);
|
||||
setFiled("right", st, o.right);
|
||||
setFiled("bottom", st, o.bottom);
|
||||
setFiled("bottom", st, o.bottom);
|
||||
st.setValue("windowState", o.windowState);
|
||||
|
||||
_saveDockOptions(o._logicDock, st, "LOGIC_DOCK");
|
||||
_saveDockOptions(o._analogDock, st, "ANALOG_DOCK");
|
||||
_saveDockOptions(o._dsoDock, st, "DSO_DOCK");
|
||||
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,13 @@ struct AppOptions
|
||||
std::vector<StringPair> m_protocolFormats;
|
||||
};
|
||||
|
||||
struct DockOptions{
|
||||
bool decodeDoc;
|
||||
bool triggerDoc;
|
||||
bool measureDoc;
|
||||
bool searchDoc;
|
||||
};
|
||||
|
||||
struct FrameOptions
|
||||
{
|
||||
QString style;
|
||||
@@ -68,6 +75,10 @@ struct FrameOptions
|
||||
int bottom;
|
||||
bool isMax;
|
||||
QByteArray windowState;
|
||||
|
||||
DockOptions _logicDock;
|
||||
DockOptions _analogDock;
|
||||
DockOptions _dsoDock;
|
||||
};
|
||||
|
||||
struct UserHistory
|
||||
@@ -103,5 +114,5 @@ public:
|
||||
public:
|
||||
AppOptions _appOptions;
|
||||
UserHistory _userHistory;
|
||||
FrameOptions _frameOptions;
|
||||
FrameOptions _frameOptions;
|
||||
};
|
||||
|
||||
@@ -303,6 +303,7 @@ void MainWindow::setup_ui()
|
||||
|
||||
//delay to update device list
|
||||
QTimer::singleShot(200, this, SLOT(update_device_list()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -436,6 +437,8 @@ void MainWindow::update_device_list()
|
||||
"Please replug it into a USB 3.0 port.");
|
||||
}
|
||||
}
|
||||
|
||||
_trig_bar->restore_status();
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,7 +1263,7 @@ void MainWindow::restore_dock()
|
||||
if (!st.isEmpty()){
|
||||
try
|
||||
{
|
||||
restoreState(st);
|
||||
restoreState(st);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ const QString TrigBar::LIGHT_STYLE = "light";
|
||||
TrigBar::TrigBar(SigSession *session, QWidget *parent) :
|
||||
QToolBar("Trig Bar", parent),
|
||||
_session(session),
|
||||
_enable(true),
|
||||
|
||||
_trig_button(this),
|
||||
_protocol_button(this),
|
||||
_measure_button(this),
|
||||
@@ -51,6 +51,8 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) :
|
||||
_function_button(this),
|
||||
_setting_button(this)
|
||||
{
|
||||
_enable = true;
|
||||
|
||||
setMovable(false);
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
@@ -187,13 +189,21 @@ void TrigBar::reStyle()
|
||||
}
|
||||
|
||||
void TrigBar::protocol_clicked()
|
||||
{
|
||||
{
|
||||
sig_protocol(_protocol_button.isChecked());
|
||||
|
||||
DockOptions *opt = getDockOptions();
|
||||
opt->decodeDoc = _protocol_button.isChecked();
|
||||
AppConfig::Instance().SaveFrame();
|
||||
}
|
||||
|
||||
void TrigBar::trigger_clicked()
|
||||
{
|
||||
sig_trigger(_trig_button.isChecked());
|
||||
|
||||
DockOptions *opt = getDockOptions();
|
||||
opt->triggerDoc = _trig_button.isChecked();
|
||||
AppConfig::Instance().SaveFrame();
|
||||
}
|
||||
|
||||
void TrigBar::update_trig_btn(bool checked)
|
||||
@@ -219,11 +229,19 @@ void TrigBar::update_search_btn(bool checked)
|
||||
void TrigBar::measure_clicked()
|
||||
{
|
||||
sig_measure(_measure_button.isChecked());
|
||||
|
||||
DockOptions *opt = getDockOptions();
|
||||
opt->measureDoc = _measure_button.isChecked();
|
||||
AppConfig::Instance().SaveFrame();
|
||||
}
|
||||
|
||||
void TrigBar::search_clicked()
|
||||
{
|
||||
sig_search(_search_button.isChecked());
|
||||
|
||||
DockOptions *opt = getDockOptions();
|
||||
opt->searchDoc = _search_button.isChecked();
|
||||
AppConfig::Instance().SaveFrame();
|
||||
}
|
||||
|
||||
void TrigBar::enable_toggle(bool enable)
|
||||
@@ -264,6 +282,7 @@ void TrigBar::close_all()
|
||||
void TrigBar::reload()
|
||||
{
|
||||
close_all();
|
||||
|
||||
if (_session->get_device()->dev_inst()->mode == LOGIC) {
|
||||
_trig_action->setVisible(true);
|
||||
_protocol_action->setVisible(true);
|
||||
@@ -271,6 +290,7 @@ void TrigBar::reload()
|
||||
_search_action->setVisible(true);
|
||||
_function_action->setVisible(false);
|
||||
_action_lissajous->setVisible(false);
|
||||
|
||||
} else if (_session->get_device()->dev_inst()->mode == ANALOG) {
|
||||
_trig_action->setVisible(false);
|
||||
_protocol_action->setVisible(false);
|
||||
@@ -278,6 +298,7 @@ void TrigBar::reload()
|
||||
_search_action->setVisible(false);
|
||||
_function_action->setVisible(false);
|
||||
_action_lissajous->setVisible(false);
|
||||
|
||||
} else if (_session->get_device()->dev_inst()->mode == DSO) {
|
||||
_trig_action->setVisible(true);
|
||||
_protocol_action->setVisible(false);
|
||||
@@ -286,6 +307,7 @@ void TrigBar::reload()
|
||||
_function_action->setVisible(true);
|
||||
_action_lissajous->setVisible(true);
|
||||
}
|
||||
|
||||
enable_toggle(true);
|
||||
update();
|
||||
}
|
||||
@@ -329,5 +351,45 @@ void TrigBar::on_actionLissajous_triggered()
|
||||
dlg.ShowDlg(this);
|
||||
}
|
||||
|
||||
|
||||
void TrigBar::restore_status()
|
||||
{
|
||||
DockOptions *opt = getDockOptions();
|
||||
int mode = _session->get_device()->dev_inst()->mode;
|
||||
|
||||
if (opt->decodeDoc){
|
||||
_protocol_button.setChecked(true);
|
||||
sig_protocol(true);
|
||||
}
|
||||
|
||||
if (opt->triggerDoc){
|
||||
_trig_button.setChecked(true);
|
||||
sig_trigger(true);
|
||||
}
|
||||
|
||||
if (opt->measureDoc){
|
||||
_measure_button.setChecked(true);
|
||||
sig_measure(true);
|
||||
}
|
||||
|
||||
if (opt->searchDoc){
|
||||
_search_button.setChecked(true);
|
||||
sig_search(true);
|
||||
}
|
||||
}
|
||||
|
||||
DockOptions* TrigBar::getDockOptions()
|
||||
{
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
int mode = _session->get_device()->dev_inst()->mode;
|
||||
|
||||
if (mode == LOGIC)
|
||||
return &app._frameOptions._logicDock;
|
||||
else if (mode == DSO)
|
||||
return &app._frameOptions._dsoDock;
|
||||
else
|
||||
return &app._frameOptions._analogDock;
|
||||
}
|
||||
|
||||
} // namespace toolbars
|
||||
} // namespace pv
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
class DockOptions;
|
||||
|
||||
namespace pv {
|
||||
|
||||
class SigSession;
|
||||
@@ -56,6 +58,7 @@ private:
|
||||
void changeEvent(QEvent *event);
|
||||
void retranslateUi();
|
||||
void reStyle();
|
||||
DockOptions* getDockOptions();
|
||||
|
||||
signals:
|
||||
void sig_setTheme(QString style);
|
||||
@@ -85,32 +88,35 @@ public slots:
|
||||
void on_actionMath_triggered();
|
||||
void on_application_param();
|
||||
|
||||
public:
|
||||
void restore_status();
|
||||
|
||||
private:
|
||||
SigSession *_session;
|
||||
bool _enable;
|
||||
SigSession *_session;
|
||||
bool _enable;
|
||||
QToolButton _trig_button;
|
||||
QToolButton _protocol_button;
|
||||
QToolButton _measure_button;
|
||||
QToolButton _search_button;
|
||||
QToolButton _function_button;
|
||||
QToolButton _setting_button;
|
||||
QAction* _trig_action;
|
||||
QAction* _protocol_action;
|
||||
QAction* _measure_action;
|
||||
QAction* _search_action;
|
||||
QAction* _function_action;
|
||||
QAction* _display_action;
|
||||
QAction *_trig_action;
|
||||
QAction *_protocol_action;
|
||||
QAction *_measure_action;
|
||||
QAction *_search_action;
|
||||
QAction *_function_action;
|
||||
QAction *_display_action;
|
||||
|
||||
QMenu* _function_menu;
|
||||
QAction* _action_fft;
|
||||
QAction* _action_math;
|
||||
QMenu *_function_menu;
|
||||
QAction *_action_fft;
|
||||
QAction *_action_math;
|
||||
|
||||
QMenu* _display_menu;
|
||||
QMenu *_themes;
|
||||
QAction *_appParam_action;
|
||||
QAction *_dark_style;
|
||||
QAction *_light_style;
|
||||
QAction* _action_lissajous;
|
||||
QMenu *_display_menu;
|
||||
QMenu *_themes;
|
||||
QAction *_appParam_action;
|
||||
QAction *_dark_style;
|
||||
QAction *_light_style;
|
||||
QAction *_action_lissajous;
|
||||
};
|
||||
|
||||
} // namespace toolbars
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.0, 2021-12-03T14:57:33. -->
|
||||
<!-- Written by QtCreator 4.11.0, 2021-12-03T18:50:47. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
Reference in New Issue
Block a user