From c849ac554c8d136358e7dc26cfa35dc1f9a8ef40 Mon Sep 17 00:00:00 2001 From: crueter Date: Tue, 9 Dec 2025 01:03:53 -0500 Subject: [PATCH] implement key install and fw label Signed-off-by: crueter --- src/Eden/Interface/MainWindowInterface.cpp | 109 ++++++++++++++++++++- src/Eden/Interface/MainWindowInterface.h | 42 +++++++- src/Eden/Main/Main.qml | 51 +++++++++- src/Eden/Native/EdenApplication.cpp | 2 +- 4 files changed, 199 insertions(+), 5 deletions(-) diff --git a/src/Eden/Interface/MainWindowInterface.cpp b/src/Eden/Interface/MainWindowInterface.cpp index acf04d3080..513feebcb3 100644 --- a/src/Eden/Interface/MainWindowInterface.cpp +++ b/src/Eden/Interface/MainWindowInterface.cpp @@ -1,16 +1,123 @@ +#include "Eden/Models/GameListModel.h" #include "MainWindowInterface.h" +#include "frontend_common/content_manager.h" + #include "qt_common/util/content.h" +#include "qt_common/util/game.h" + +#include "qt_common/abstract/frontend.h" -MainWindowInterface::MainWindowInterface(QObject* parent) : QObject{parent} {} +MainWindowInterface::MainWindowInterface(GameListModel* model, QObject* parent) + : QObject{parent}, m_gameList(model) { + checkFirmwareDecryption(); +} void MainWindowInterface::installFirmware() { QtCommon::Content::InstallFirmware(); + checkFirmwareDecryption(); } void MainWindowInterface::installFirmwareZip() { QtCommon::Content::InstallFirmwareZip(); + checkFirmwareDecryption(); } void MainWindowInterface::verifyIntegrity() { QtCommon::Content::VerifyInstalledContents(); } + +void MainWindowInterface::checkFirmwareDecryption() { + if (!ContentManager::AreKeysPresent()) { + QtCommon::Frontend::Warning(tr("Derivation Components Missing"), + tr("Encryption keys are missing.")); + } + + setFirmwareVersion(); +} + +void MainWindowInterface::installDecryptionKeys() { + QtCommon::Content::InstallKeys(); + + m_gameList->populateAsync(UISettings::values.game_dirs); + checkFirmwareDecryption(); +} + +void MainWindowInterface::setFirmwareVersion() { + const auto pair = FirmwareManager::GetFirmwareVersion(*QtCommon::system.get()); + const auto firmware_data = pair.first; + const auto result = pair.second; + + if (result.IsError() || !FirmwareManager::CheckFirmwarePresence(*QtCommon::system.get())) { + LOG_INFO(Frontend, "Installed firmware: No firmware available"); + setFirmwareGood(false); + return; + } + + setFirmwareGood(true); + + const std::string display_version(firmware_data.display_version.data()); + const std::string display_title(firmware_data.display_title.data()); + + LOG_INFO(Frontend, "Installed firmware: {}", display_version); + + setFirmwareDisplay(QString::fromStdString(display_version)); + setFirmwareTooltip(QString::fromStdString(display_title)); +} + +void MainWindowInterface::openRootDataFolder() { + QtCommon::Game::OpenRootDataFolder(); +} + +void MainWindowInterface::openNANDFolder() +{ + QtCommon::Game::OpenNANDFolder(); +} + +void MainWindowInterface::openSDMCFolder() +{ + QtCommon::Game::OpenSDMCFolder(); +} + +void MainWindowInterface::openModFolder() +{ + QtCommon::Game::OpenModFolder(); +} + +void MainWindowInterface::openLogFolder() +{ + QtCommon::Game::OpenLogFolder(); +} + + +QString MainWindowInterface::firmwareDisplay() const { + return m_firmwareDisplay; +} + +void MainWindowInterface::setFirmwareDisplay(const QString& newFirmwareDisplay) { + if (m_firmwareDisplay == newFirmwareDisplay) + return; + m_firmwareDisplay = newFirmwareDisplay; + emit firmwareDisplayChanged(m_firmwareDisplay); +} + +QString MainWindowInterface::firmwareTooltip() const { + return m_firmwareTooltip; +} + +void MainWindowInterface::setFirmwareTooltip(const QString& newFirmwareTooltip) { + if (m_firmwareTooltip == newFirmwareTooltip) + return; + m_firmwareTooltip = newFirmwareTooltip; + emit firmwareTooltipChanged(m_firmwareTooltip); +} + +bool MainWindowInterface::firmwareGood() const { + return m_firmwareGood; +} + +void MainWindowInterface::setFirmwareGood(bool newFirmwareGood) { + if (m_firmwareGood == newFirmwareGood) + return; + m_firmwareGood = newFirmwareGood; + emit firmwareGoodChanged(m_firmwareGood); +} diff --git a/src/Eden/Interface/MainWindowInterface.h b/src/Eden/Interface/MainWindowInterface.h index f64c716f16..4080d01536 100644 --- a/src/Eden/Interface/MainWindowInterface.h +++ b/src/Eden/Interface/MainWindowInterface.h @@ -2,12 +2,52 @@ #include +class GameListModel; class MainWindowInterface : public QObject { Q_OBJECT + Q_PROPERTY(bool firmwareGood READ firmwareGood WRITE setFirmwareGood NOTIFY firmwareGoodChanged FINAL) + Q_PROPERTY(QString firmwareTooltip READ firmwareTooltip WRITE setFirmwareTooltip NOTIFY + firmwareTooltipChanged FINAL) + Q_PROPERTY(QString firmwareDisplay READ firmwareDisplay WRITE setFirmwareDisplay NOTIFY + firmwareDisplayChanged FINAL) + public: - explicit MainWindowInterface(QObject* parent = nullptr); + explicit MainWindowInterface(GameListModel* model, QObject* parent = nullptr); Q_INVOKABLE void installFirmware(); Q_INVOKABLE void installFirmwareZip(); Q_INVOKABLE void verifyIntegrity(); + Q_INVOKABLE void checkFirmwareDecryption(); + + Q_INVOKABLE void installDecryptionKeys(); + + bool firmwareGood() const; + void setFirmwareGood(bool newFirmwareGood); + + QString firmwareTooltip() const; + void setFirmwareTooltip(const QString& newFirmwareTooltip); + + QString firmwareDisplay() const; + void setFirmwareDisplay(const QString& newFirmwareDisplay); + +public slots: + void openRootDataFolder(); + void openNANDFolder(); + void openSDMCFolder(); + void openModFolder(); + void openLogFolder(); + +signals: + void firmwareGoodChanged(bool firmwareGood); + void firmwareTooltipChanged(QString firmwareTooltip); + void firmwareDisplayChanged(QString firmwareDisplay); + +private: + GameListModel* m_gameList; + void setFirmwareVersion(); + + bool m_firmwareGood = false; + + QString m_firmwareDisplay{}; + QString m_firmwareTooltip{}; }; diff --git a/src/Eden/Main/Main.qml b/src/Eden/Main/Main.qml index fdd57276e3..aaf396d382 100644 --- a/src/Eden/Main/Main.qml +++ b/src/Eden/Main/Main.qml @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick import QtQuick.Controls +import QtQuick.Layouts import Eden.Config import Eden.Items @@ -73,8 +74,30 @@ ApplicationWindow { MenuSeparator {} - Action { - text: qsTr("Open &eden Directory") + Menu { + title: qsTr("Open &Eden Folders") + + Action { + text: qsTr("&Root Data Folder") + onTriggered: MainWindowInterface.openRootDataFolder() + } + + Action { + text: qsTr("&NAND Folder") + onTriggered: MainWindowInterface.openNANDFolder() + } + Action { + text: qsTr("&SDMC Folder") + onTriggered: MainWindowInterface.openSDMCFolder() + } + Action { + text: qsTr("&Mod Folder") + onTriggered: MainWindowInterface.openModFolder() + } + Action { + text: qsTr("&Log Folder") + onTriggered: MainWindowInterface.openLogFolder() + } } MenuSeparator {} @@ -158,6 +181,7 @@ ApplicationWindow { Action { text: qsTr("Install &Decryption Keys") + onTriggered: MainWindowInterface.installDecryptionKeys() } Menu { @@ -223,5 +247,28 @@ ApplicationWindow { right: parent.right bottom: parent.bottom } + + RowLayout { + id: right + + spacing: 10 + + anchors { + top: parent.top + bottom: parent.bottom + right: parent.right + + rightMargin: 15 + } + + Label { + id: firmware + font.pixelSize: 14 + visible: MainWindowInterface.firmwareGood + + text: MainWindowInterface.firmwareDisplay + ToolTip.text: MainWindowInterface.firmwareTooltip + } + } } } diff --git a/src/Eden/Native/EdenApplication.cpp b/src/Eden/Native/EdenApplication.cpp index 6541a508cf..e46d1db412 100644 --- a/src/Eden/Native/EdenApplication.cpp +++ b/src/Eden/Native/EdenApplication.cpp @@ -103,7 +103,7 @@ int EdenApplication::run() { ctx->setContextProperty(QStringLiteral("TitleManager"), title); // MainWindow interface - MainWindowInterface* mwint = new MainWindowInterface(&engine); + MainWindowInterface* mwint = new MainWindowInterface(gameListModel, &engine); ctx->setContextProperty(QStringLiteral("MainWindowInterface"), mwint); // :)