mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 04:10:04 +00:00
Save the general state of the docks (position, size, corner, etc)
This commit is contained in:
parent
3789845a36
commit
bc62236351
4 changed files with 33 additions and 3 deletions
|
|
@ -460,7 +460,25 @@ void MainWindow::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QMainWindow::showEvent(event);
|
QMainWindow::showEvent(event);
|
||||||
|
|
||||||
resizeDocks({ui->radarToolboxDock}, {194}, Qt::Horizontal);
|
// restore the UI state
|
||||||
|
std::string uiState =
|
||||||
|
settings::UiSettings::Instance().main_ui_state().GetValue();
|
||||||
|
|
||||||
|
bool restored =
|
||||||
|
restoreState(QByteArray::fromBase64(QByteArray::fromStdString(uiState)));
|
||||||
|
if (!restored)
|
||||||
|
{
|
||||||
|
resizeDocks({ui->radarToolboxDock}, {194}, Qt::Horizontal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
// save the UI state
|
||||||
|
QByteArray uiState = saveState().toBase64();
|
||||||
|
settings::UiSettings::Instance().main_ui_state().StageValue(uiState.data());
|
||||||
|
|
||||||
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpenNexrad_triggered()
|
void MainWindow::on_actionOpenNexrad_triggered()
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public:
|
||||||
void keyPressEvent(QKeyEvent* ev) override final;
|
void keyPressEvent(QKeyEvent* ev) override final;
|
||||||
void keyReleaseEvent(QKeyEvent* ev) override final;
|
void keyReleaseEvent(QKeyEvent* ev) override final;
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ActiveMapMoved(double latitude, double longitude);
|
void ActiveMapMoved(double latitude, double longitude);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public:
|
||||||
timelineExpanded_.SetDefault(true);
|
timelineExpanded_.SetDefault(true);
|
||||||
alertDockVisible_.SetDefault(false);
|
alertDockVisible_.SetDefault(false);
|
||||||
radarToolboxDockVisible_.SetDefault(true);
|
radarToolboxDockVisible_.SetDefault(true);
|
||||||
|
mainUIState_.SetDefault("");
|
||||||
}
|
}
|
||||||
|
|
||||||
~UiSettingsImpl() {}
|
~UiSettingsImpl() {}
|
||||||
|
|
@ -32,6 +33,7 @@ public:
|
||||||
SettingsVariable<bool> timelineExpanded_ {"timeline_expanded"};
|
SettingsVariable<bool> timelineExpanded_ {"timeline_expanded"};
|
||||||
SettingsVariable<bool> alertDockVisible_ {"alert_dock_visible"};
|
SettingsVariable<bool> alertDockVisible_ {"alert_dock_visible"};
|
||||||
SettingsVariable<bool> radarToolboxDockVisible_ {"radar_toolbox_dock_visible"};
|
SettingsVariable<bool> radarToolboxDockVisible_ {"radar_toolbox_dock_visible"};
|
||||||
|
SettingsVariable<std::string> mainUIState_ {"main_ui_state"};
|
||||||
};
|
};
|
||||||
|
|
||||||
UiSettings::UiSettings() :
|
UiSettings::UiSettings() :
|
||||||
|
|
@ -43,7 +45,8 @@ UiSettings::UiSettings() :
|
||||||
&p->mapSettingsExpanded_,
|
&p->mapSettingsExpanded_,
|
||||||
&p->timelineExpanded_,
|
&p->timelineExpanded_,
|
||||||
&p->alertDockVisible_,
|
&p->alertDockVisible_,
|
||||||
&p->radarToolboxDockVisible_});
|
&p->radarToolboxDockVisible_,
|
||||||
|
&p->mainUIState_});
|
||||||
SetDefaults();
|
SetDefaults();
|
||||||
}
|
}
|
||||||
UiSettings::~UiSettings() = default;
|
UiSettings::~UiSettings() = default;
|
||||||
|
|
@ -86,6 +89,11 @@ SettingsVariable<bool>& UiSettings::radar_toolbox_dock_visible() const
|
||||||
return p->radarToolboxDockVisible_;
|
return p->radarToolboxDockVisible_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsVariable<std::string>& UiSettings::main_ui_state() const
|
||||||
|
{
|
||||||
|
return p->mainUIState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UiSettings::Shutdown()
|
bool UiSettings::Shutdown()
|
||||||
{
|
{
|
||||||
|
|
@ -99,6 +107,7 @@ bool UiSettings::Shutdown()
|
||||||
dataChanged |= p->timelineExpanded_.Commit();
|
dataChanged |= p->timelineExpanded_.Commit();
|
||||||
dataChanged |= p->alertDockVisible_.Commit();
|
dataChanged |= p->alertDockVisible_.Commit();
|
||||||
dataChanged |= p->radarToolboxDockVisible_.Commit();
|
dataChanged |= p->radarToolboxDockVisible_.Commit();
|
||||||
|
dataChanged |= p->mainUIState_.Commit();
|
||||||
|
|
||||||
return dataChanged;
|
return dataChanged;
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +126,8 @@ bool operator==(const UiSettings& lhs, const UiSettings& rhs)
|
||||||
lhs.p->mapSettingsExpanded_ == rhs.p->mapSettingsExpanded_ &&
|
lhs.p->mapSettingsExpanded_ == rhs.p->mapSettingsExpanded_ &&
|
||||||
lhs.p->timelineExpanded_ == rhs.p->timelineExpanded_ &&
|
lhs.p->timelineExpanded_ == rhs.p->timelineExpanded_ &&
|
||||||
lhs.p->alertDockVisible_ == rhs.p->alertDockVisible_ &&
|
lhs.p->alertDockVisible_ == rhs.p->alertDockVisible_ &&
|
||||||
lhs.p->radarToolboxDockVisible_ == rhs.p->radarToolboxDockVisible_);
|
lhs.p->radarToolboxDockVisible_ == rhs.p->radarToolboxDockVisible_ &&
|
||||||
|
lhs.p->mainUIState_ == rhs.p->mainUIState_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace settings
|
} // namespace settings
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public:
|
||||||
SettingsVariable<bool>& timeline_expanded() const;
|
SettingsVariable<bool>& timeline_expanded() const;
|
||||||
SettingsVariable<bool>& alert_dock_visible() const;
|
SettingsVariable<bool>& alert_dock_visible() const;
|
||||||
SettingsVariable<bool>& radar_toolbox_dock_visible() const;
|
SettingsVariable<bool>& radar_toolbox_dock_visible() const;
|
||||||
|
SettingsVariable<std::string>& main_ui_state() const;
|
||||||
|
|
||||||
bool Shutdown();
|
bool Shutdown();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue