From 1ddb130a0fda4cf5eaf536c822d1f4d92c859942 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 13 Mar 2024 15:41:25 +0100
Subject: [PATCH] ActionManager simplify creation of Settings>EnableAutosave

---
 GUI/View/Main/ActionManager.cpp | 33 +++++++++++++--------------------
 GUI/View/Main/ActionManager.h   |  1 -
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/GUI/View/Main/ActionManager.cpp b/GUI/View/Main/ActionManager.cpp
index ef290a0d698..991a3363232 100644
--- a/GUI/View/Main/ActionManager.cpp
+++ b/GUI/View/Main/ActionManager.cpp
@@ -124,10 +124,20 @@ void ActionManager::createMenus()
 
     // Settings Menu
     m_settings_menu = new QMenu("&Settings", m_main_window);
-    onAboutToShowSettingsMenu(); // MacOS feature: action should exist already, otherwise menuBar
-                                 //  will not add menu
-    connect(m_settings_menu, &QMenu::aboutToShow, this, &ActionManager::onAboutToShowSettingsMenu);
     m_menu_bar->addMenu(m_settings_menu);
+    m_settings_menu->setToolTipsVisible(true);
+
+    auto* action = new QWidgetAction(m_settings_menu);
+    auto* check_box = new QCheckBox("&Enable autosave", m_settings_menu);
+    action->setText("&Enable autosave");
+    action->setDefaultWidget(check_box);
+    action->setToolTip("Project will be saved periodically in project's autosave directory.\n"
+                       "When opening project, recover option will be suggested, if possible.");
+    action->setCheckable(true);
+    check_box->setChecked(gApp->autosave_enabled);
+    connect(check_box, &QCheckBox::toggled,
+            [=] { gApp->autosave_enabled = check_box->isChecked(); });
+    m_settings_menu->addAction(action);
 
     // View menu
     m_view_menu = new QMenu("&View", m_main_window);
@@ -181,23 +191,6 @@ void ActionManager::onAboutToShowFileMenu()
     }
 }
 
-void ActionManager::onAboutToShowSettingsMenu()
-{
-    m_settings_menu->clear();
-    m_settings_menu->setToolTipsVisible(true);
-    auto* action = new QWidgetAction(m_settings_menu);
-    auto* check_box = new QCheckBox("&Enable autosave", m_settings_menu);
-    action->setText("&Enable autosave");
-    action->setDefaultWidget(check_box);
-    action->setToolTip("Project will be saved periodically in project's autosave directory.\n"
-                       "When opening project, recover option will be suggested, if possible.");
-    action->setCheckable(true);
-    check_box->setChecked(gApp->autosave_enabled);
-    connect(check_box, &QCheckBox::toggled,
-            [=] { gApp->autosave_enabled = check_box->isChecked(); });
-    m_settings_menu->addAction(action);
-}
-
 void ActionManager::onAboutToShowViewMenu()
 {
     /* TODO 5mar
diff --git a/GUI/View/Main/ActionManager.h b/GUI/View/Main/ActionManager.h
index c3294ee4ff8..53ff1d04218 100644
--- a/GUI/View/Main/ActionManager.h
+++ b/GUI/View/Main/ActionManager.h
@@ -38,7 +38,6 @@ public slots:
 
 private slots:
     void onAboutToShowFileMenu();
-    void onAboutToShowSettingsMenu();
     void onAboutToShowViewMenu();
     void onAboutApplication();
 
-- 
GitLab