From 8fb6ad5b72cbda024882f1f78769aa2b84c817c1 Mon Sep 17 00:00:00 2001
From: DenisD3D
Date: Mon, 1 Apr 2024 18:51:19 +0200
Subject: [PATCH] Add main menu button
---
src/screens/snakewindow.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/screens/snakewindow.cpp b/src/screens/snakewindow.cpp
index 9125f0a..93dd0fd 100644
--- a/src/screens/snakewindow.cpp
+++ b/src/screens/snakewindow.cpp
@@ -26,14 +26,15 @@ SnakeWindow::SnakeWindow(QWidget *pParent, Qt::WindowFlags flags)
const auto menuBar = new QMenuBar;
const auto fileMenu = new QMenu(tr("&File"), this);
+ const QAction *mainMenuAction = fileMenu->addAction(tr("&Main Menu"));
const QAction *fullScreenAction = fileMenu->addAction(tr("Full &Screen"));
const QAction *exitAction = fileMenu->addAction(tr("E&xit"));
menuBar->addMenu(fileMenu);
- // Toggle full screen when the "Full Screen" action is triggered
+ connect(mainMenuAction, &QAction::triggered, this, [this] {
+ stackedWidget->setCurrentWidget(mainMenu);
+ });
connect(fullScreenAction, &QAction::triggered, this, &SnakeWindow::toggleFullScreen);
-
- // Connect the "Exit" action to the application's quit slot
connect(exitAction, &QAction::triggered, qApp, &QApplication::quit);