From be765f8d883697d2284343f9ee6c858987622857 Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Mon, 14 Nov 2022 16:33:25 -0300
Subject: feat: Add empty menu

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 26 ++++++++++++++++++++++++++
 launcher/ui/MainWindow.h   |  2 ++
 2 files changed, 28 insertions(+)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 85b00b67..31d0f6c2 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -264,6 +264,8 @@ public:
 
     TranslatedAction actionLockToolbars;
 
+    TranslatedAction actionChangeTheme;
+
     QVector<TranslatedToolButton *> all_toolbuttons;
 
     QWidget *centralWidget = nullptr;
@@ -428,6 +430,11 @@ public:
         actionLockToolbars.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Lock Toolbars"));
         actionLockToolbars->setCheckable(true);
         all_actions.append(&actionLockToolbars);
+
+        actionChangeTheme = TranslatedAction(MainWindow);
+        actionChangeTheme->setObjectName(QStringLiteral("actionChangeTheme"));
+        actionChangeTheme.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Themes"));
+        all_actions.append(&actionChangeTheme);
     }
 
     void createMainToolbar(QMainWindow *MainWindow)
@@ -528,6 +535,8 @@ public:
 
         viewMenu = menuBar->addMenu(tr("&View"));
         viewMenu->setSeparatorsCollapsible(false);
+        viewMenu->addAction(actionChangeTheme);
+        viewMenu->addSeparator();
         viewMenu->addAction(actionCAT);
         viewMenu->addSeparator();
 
@@ -822,6 +831,7 @@ public:
         createInstanceToolbar(MainWindow);
 
         MainWindow->updateToolsMenu();
+        MainWindow->updateThemeMenu();
 
         retranslateUi(MainWindow);
 
@@ -1271,6 +1281,22 @@ void MainWindow::updateToolsMenu()
     ui->actionLaunchInstance->setMenu(launchMenu);
 }
 
+void MainWindow::updateThemeMenu()
+{
+    QMenu *themeMenu = ui->actionChangeTheme->menu();
+
+    if (themeMenu)
+    {
+        themeMenu->clear();
+    }
+    else
+    {
+        themeMenu = new QMenu(this);
+    }
+
+    ui->actionChangeTheme->setMenu(themeMenu);
+}
+
 void MainWindow::repopulateAccountsMenu()
 {
     accountMenu->clear();
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index f9d1f1c7..47e221b7 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -170,6 +170,8 @@ private slots:
 
     void updateToolsMenu();
 
+    void updateThemeMenu();
+
     void instanceActivated(QModelIndex);
 
     void instanceChanged(const QModelIndex &current, const QModelIndex &previous);
-- 
cgit 


From 0e916244f03cd8bd296f6cc4fe2be34a745ecab4 Mon Sep 17 00:00:00 2001
From: leo78913 <leo3758@riseup.net>
Date: Mon, 14 Nov 2022 19:59:26 -0300
Subject: feat: Add themes and their logic.

Signed-off-by: leo78913 <leo3758@riseup.net>
---
 launcher/ui/MainWindow.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 8d5e0c83..cbdb2b8f 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -106,6 +106,7 @@
 #include "ui/dialogs/UpdateDialog.h"
 #include "ui/dialogs/EditAccountDialog.h"
 #include "ui/dialogs/ExportInstanceDialog.h"
+#include "ui/themes/ITheme.h"
 
 #include "UpdateController.h"
 #include "KonamiCode.h"
@@ -1313,6 +1314,25 @@ void MainWindow::updateThemeMenu()
         themeMenu = new QMenu(this);
     }
 
+    auto themes = APPLICATION->getValidApplicationThemes();
+
+    QActionGroup* ThemesGroup = new QActionGroup( this );
+
+    for (int i = 0; i < themes.size(); i++)
+    {
+
+        auto *theme = themes[i];
+        QAction * themeAction = themeMenu->addAction(theme->name());
+
+        themeAction->setCheckable(true);
+        themeAction->setActionGroup(ThemesGroup);
+
+        connect(themeAction, &QAction::triggered, [theme]() {
+            APPLICATION->setApplicationTheme(theme->name().toLower(),false);
+
+        });
+    }
+
     ui->actionChangeTheme->setMenu(themeMenu);
 }
 
-- 
cgit 


From ef53455b6610844a633624fa172b7bf80310651c Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Tue, 15 Nov 2022 05:19:46 -0300
Subject: fix: Build on QT6

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index cbdb2b8f..a00fb402 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -49,7 +49,7 @@
 
 #include <QKeyEvent>
 #include <QAction>
-
+#include <QActionGroup>
 #include <QApplication>
 #include <QButtonGroup>
 #include <QHBoxLayout>
-- 
cgit 


From aa3ea79f94887aedc91c52860d5a7b6557900a6f Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Tue, 15 Nov 2022 05:38:31 -0300
Subject: fix: Check the current theme box on startup.

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index a00fb402..f8a37596 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1305,12 +1305,9 @@ void MainWindow::updateThemeMenu()
 {
     QMenu *themeMenu = ui->actionChangeTheme->menu();
 
-    if (themeMenu)
-    {
+    if (themeMenu) {
         themeMenu->clear();
-    }
-    else
-    {
+    } else {
         themeMenu = new QMenu(this);
     }
 
@@ -1320,11 +1317,13 @@ void MainWindow::updateThemeMenu()
 
     for (int i = 0; i < themes.size(); i++)
     {
-
         auto *theme = themes[i];
         QAction * themeAction = themeMenu->addAction(theme->name());
 
         themeAction->setCheckable(true);
+        if (APPLICATION->settings()->get("ApplicationTheme").toString() == theme->id()) {
+            themeAction->setChecked(true);
+        }
         themeAction->setActionGroup(ThemesGroup);
 
         connect(themeAction, &QAction::triggered, [theme]() {
-- 
cgit 


From a12f892841399163fbc12e72c61c7ed6fae882cf Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Tue, 15 Nov 2022 05:46:24 -0300
Subject: fix: Check the box when the theme is changed via settings

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index f8a37596..e2ab3b46 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1965,6 +1965,7 @@ void MainWindow::globalSettingsClosed()
     proxymodel->sort(0);
     updateMainToolBar();
     updateToolsMenu();
+    updateThemeMenu();
     updateStatusCenter();
     // This needs to be done to prevent UI elements disappearing in the event the config is changed
     // but Prism Launcher exits abnormally, causing the window state to never be saved:
-- 
cgit 


From 6fe626ab9ad9f76b793f09ceb5e8e8cced3f15ba Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Tue, 15 Nov 2022 06:09:13 -0300
Subject: feat: Make the changes persistent.

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index e2ab3b46..f62d9760 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1327,8 +1327,8 @@ void MainWindow::updateThemeMenu()
         themeAction->setActionGroup(ThemesGroup);
 
         connect(themeAction, &QAction::triggered, [theme]() {
-            APPLICATION->setApplicationTheme(theme->name().toLower(),false);
-
+            APPLICATION->setApplicationTheme(theme->id(),false);
+            APPLICATION->settings()->set("ApplicationTheme", theme->id());
         });
     }
 
-- 
cgit 


From 37a117d2effc21b23b86ada80951bfd23671a64b Mon Sep 17 00:00:00 2001
From: RedsonBr140 <redson@riseup.net>
Date: Wed, 16 Nov 2022 12:24:28 -0300
Subject: chore: Var definition inside the for loop

Co-authored-by: flow <flowlnlnln@gmail.com>
Signed-off-by: RedsonBr140 <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index f62d9760..1f8444af 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1315,9 +1315,7 @@ void MainWindow::updateThemeMenu()
 
     QActionGroup* ThemesGroup = new QActionGroup( this );
 
-    for (int i = 0; i < themes.size(); i++)
-    {
-        auto *theme = themes[i];
+    for (auto* theme : themes) {
         QAction * themeAction = themeMenu->addAction(theme->name());
 
         themeAction->setCheckable(true);
-- 
cgit 


From bd3a693e700bc0b1ea9bbc72631ccd13ba755277 Mon Sep 17 00:00:00 2001
From: RedsonBr140 <redson@riseup.net>
Date: Thu, 17 Nov 2022 06:20:53 -0300
Subject: chore: Change var name

Co-authored-by: Sefa Eyeoglu <contact@scrumplex.net>
Signed-off-by: RedsonBr140 <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 1f8444af..dcf1be99 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1313,7 +1313,7 @@ void MainWindow::updateThemeMenu()
 
     auto themes = APPLICATION->getValidApplicationThemes();
 
-    QActionGroup* ThemesGroup = new QActionGroup( this );
+    QActionGroup* themesGroup = new QActionGroup( this );
 
     for (auto* theme : themes) {
         QAction * themeAction = themeMenu->addAction(theme->name());
-- 
cgit 


From f72ac94c111a788d197e78fd4e0433513965807a Mon Sep 17 00:00:00 2001
From: Redson <redson@riseup.net>
Date: Thu, 17 Nov 2022 06:39:05 -0300
Subject: fix: Fix usage below

Signed-off-by: Redson <redson@riseup.net>
---
 launcher/ui/MainWindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'launcher')

diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index dcf1be99..e1ea13d3 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1322,7 +1322,7 @@ void MainWindow::updateThemeMenu()
         if (APPLICATION->settings()->get("ApplicationTheme").toString() == theme->id()) {
             themeAction->setChecked(true);
         }
-        themeAction->setActionGroup(ThemesGroup);
+        themeAction->setActionGroup(themesGroup);
 
         connect(themeAction, &QAction::triggered, [theme]() {
             APPLICATION->setApplicationTheme(theme->id(),false);
-- 
cgit