[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#include "data_dialog.h"
|
|
|
|
#include "frontend_common/data_manager.h"
|
|
|
|
#include "qt_common/qt_content_util.h"
|
|
|
|
#include "qt_common/qt_string_lookup.h"
|
|
|
|
#include "ui_data_dialog.h"
|
|
|
|
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QFutureWatcher>
|
2025-10-08 22:45:33 -04:00
|
|
|
#include <QtConcurrent/QtConcurrentRun>
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
|
|
|
|
DataDialog::DataDialog(QWidget *parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
, ui(std::make_unique<Ui::DataDialog>())
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
// TODO: Should we make this a single widget that pulls data from a model?
|
|
|
|
#define WIDGET(name) \
|
|
|
|
ui->page->addWidget(new DataWidget(FrontendCommon::DataManager::DataDir::name, \
|
|
|
|
QtCommon::StringLookup::name##Tooltip, \
|
|
|
|
this));
|
|
|
|
|
|
|
|
WIDGET(Saves)
|
|
|
|
WIDGET(Shaders)
|
|
|
|
WIDGET(UserNand)
|
|
|
|
WIDGET(SysNand)
|
|
|
|
WIDGET(Mods)
|
|
|
|
|
|
|
|
#undef WIDGET
|
|
|
|
|
|
|
|
connect(ui->labels, &QListWidget::itemSelectionChanged, this, [this]() {
|
|
|
|
ui->page->setCurrentIndex(ui->labels->currentRow());
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DataDialog::~DataDialog() = default;
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir,
|
|
|
|
QtCommon::StringLookup::StringKey tooltip,
|
|
|
|
QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, ui(std::make_unique<Ui::DataWidget>())
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
, m_dir(data_dir)
|
|
|
|
{
|
2025-10-08 22:45:33 -04:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->tooltip->setText(QtCommon::StringLookup::Lookup(tooltip));
|
|
|
|
|
|
|
|
ui->clear->setIcon(QIcon::fromTheme(QStringLiteral("trash")));
|
|
|
|
ui->open->setIcon(QIcon::fromTheme(QStringLiteral("folder")));
|
|
|
|
|
|
|
|
connect(ui->clear, &QPushButton::clicked, this, &DataWidget::clear);
|
|
|
|
connect(ui->open, &QPushButton::clicked, this, &DataWidget::open);
|
|
|
|
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
scan();
|
|
|
|
}
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
void DataWidget::clear() {
|
|
|
|
QtCommon::Content::ClearDataDir(m_dir);
|
|
|
|
scan();
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
}
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
void DataWidget::open() {
|
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(
|
|
|
|
QString::fromStdString(FrontendCommon::DataManager::GetDataDir(m_dir))));
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
}
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
void DataWidget::scan() {
|
|
|
|
ui->size->setText(tr("Calculating..."));
|
|
|
|
|
|
|
|
QFutureWatcher<u64> *watcher = new QFutureWatcher<u64>(this);
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
connect(watcher, &QFutureWatcher<u64>::finished, this, [=, this]() {
|
|
|
|
u64 size = watcher->result();
|
|
|
|
ui->size->setText(
|
|
|
|
QString::fromStdString(FrontendCommon::DataManager::ReadableBytesSize(size)));
|
|
|
|
watcher->deleteLater();
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
});
|
|
|
|
|
2025-10-08 22:45:33 -04:00
|
|
|
watcher->setFuture(
|
[desktop] Initial data manager prototype
Right now, all this adds is a small dialog to the Widgets frontend
showing the user how much space is taken up by their saves, shaders,
NAND, and mods. It also gives them the choice to clear these directories
(with 2x confirmation), OR open the directory in their system file
manager.
In the future, a lot more can be done with this concept. Notably, a
common import/export (a la android) could be added, the UI can obviously
be polished, etc. We could also add this to Android, but I don't think
common import/export is needed *for* Android, and should probably be
left in qt_common.
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-10-08 16:07:02 -04:00
|
|
|
QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); }));
|
|
|
|
}
|