Manager: Make the toolbar hideable

This commit is contained in:
Alexander Babikov
2025-12-07 14:40:33 +05:00
parent d2379f1a66
commit f3168b4187
3 changed files with 34 additions and 0 deletions

View File

@@ -106,6 +106,11 @@ VMManagerMainWindow::
{
auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
ui->actionHide_tool_bar->setChecked(!!config->getStringValue("hide_tool_bar").toInt());
if (ui->actionHide_tool_bar->isChecked())
ui->toolBar->setVisible(false);
else
config->setStringValue("hide_tool_bar", "0");
if (!!config->getStringValue("window_remember").toInt()) {
QString coords = config->getStringValue("window_coordinates");
if (!coords.isEmpty()) {
@@ -217,6 +222,7 @@ VMManagerMainWindow::saveSettings() const
const auto currentSelection = vmm->getCurrentSelection();
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
config->setStringValue("last_selection", currentSelection);
config->setStringValue("hide_tool_bar", (ui->toolBar->isVisible() ? "0" : "1"));
if (!!config->getStringValue("window_remember").toInt()) {
config->setStringValue("window_coordinates", QString::asprintf("%i, %i, %i, %i", this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height()));
config->setStringValue("window_maximized", this->isMaximized() ? "1" : "");
@@ -287,6 +293,15 @@ VMManagerMainWindow::setStatusRight(const QString &text) const
statusRight->setText(text);
}
void
VMManagerMainWindow::on_actionHide_tool_bar_triggered()
{
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
int isHidden = config->getStringValue("hide_tool_bar").toInt();
ui->toolBar->setVisible(!!isHidden);
config->setStringValue("hide_tool_bar", (isHidden ? "0" : "1"));
}
#if EMU_BUILD_NUM != 0
void
VMManagerMainWindow::checkForUpdatesTriggered()

View File

@@ -58,6 +58,7 @@ public slots:
private slots:
void vmmStateChanged(const VMManagerSystem *sysconfig) const;
void on_actionHide_tool_bar_triggered();
void preferencesTriggered();
#if EMU_BUILD_NUM != 0
void checkForUpdatesTriggered();

View File

@@ -41,6 +41,12 @@
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>&amp;View</string>
</property>
<addaction name="actionHide_tool_bar"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>&amp;Help</string>
@@ -50,6 +56,7 @@
<addaction name="actionAbout_Qt"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuTools"/>
<addaction name="menuHelp"/>
</widget>
@@ -198,6 +205,17 @@
<string>New machine...</string>
</property>
</action>
<action name="actionHide_tool_bar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hide &amp;toolbar</string>
</property>
<property name="toolTip">
<string>Hide tool bar</string>
</property>
</action>
<action name="actionPreferences">
<property name="text">
<string>&amp;Preferences...</string>