Browse Source

implement key install and fw label

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/3016/head
crueter 2 weeks ago
parent
commit
c849ac554c
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 109
      src/Eden/Interface/MainWindowInterface.cpp
  2. 42
      src/Eden/Interface/MainWindowInterface.h
  3. 51
      src/Eden/Main/Main.qml
  4. 2
      src/Eden/Native/EdenApplication.cpp

109
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);
}

42
src/Eden/Interface/MainWindowInterface.h

@ -2,12 +2,52 @@
#include <QObject>
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{};
};

51
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
}
}
}
}

2
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);
// :)

Loading…
Cancel
Save