mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-06-06 01:13:45 -04:00
[desktop] Change data manager to use tabs instead of a list (#3856)
Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3856 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
6c76908ddb
commit
0257a8d491
3 changed files with 23 additions and 49 deletions
|
|
@ -23,27 +23,18 @@ DataDialog::DataDialog(QWidget* parent) : QDialog(parent), ui(std::make_unique<U
|
||||||
|
|
||||||
// TODO: Should we make this a single widget that pulls data from a model?
|
// TODO: Should we make this a single widget that pulls data from a model?
|
||||||
#define WIDGET(label, name) \
|
#define WIDGET(label, name) \
|
||||||
ui->page->addWidget(new DataWidget(FrontendCommon::DataManager::DataDir::name, \
|
ui->pages->addTab(new DataWidget(FrontendCommon::DataManager::DataDir::name, \
|
||||||
QtCommon::StringLookup::DataManager##name##Tooltip, \
|
QtCommon::StringLookup::DataManager##name##Tooltip, \
|
||||||
QStringLiteral(#name), this)); \
|
QStringLiteral(#name), this), \
|
||||||
ui->labels->addItem(label);
|
label);
|
||||||
|
|
||||||
WIDGET(tr("Shaders"), Shaders)
|
WIDGET(tr("Shaders"), Shaders)
|
||||||
WIDGET(tr("UserNAND"), UserNand)
|
WIDGET(tr("User NAND"), UserNand)
|
||||||
WIDGET(tr("SysNAND"), SysNand)
|
WIDGET(tr("System NAND"), SysNand)
|
||||||
WIDGET(tr("Mods"), Mods)
|
WIDGET(tr("Mods"), Mods)
|
||||||
WIDGET(tr("Saves"), Saves)
|
WIDGET(tr("Saves"), Saves)
|
||||||
|
|
||||||
#undef WIDGET
|
#undef WIDGET
|
||||||
|
|
||||||
connect(ui->labels, &QListWidget::itemSelectionChanged, this, [this]() {
|
|
||||||
const auto items = ui->labels->selectedItems();
|
|
||||||
if (items.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->page->setCurrentIndex(ui->labels->row(items[0]));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataDialog::~DataDialog() = default;
|
DataDialog::~DataDialog() = default;
|
||||||
|
|
@ -71,25 +62,29 @@ DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataWidget::clear() {
|
void DataWidget::clear() {
|
||||||
std::string user_id = selectProfile();
|
std::optional<std::string> user_id = selectProfile();
|
||||||
QtCommon::Content::ClearDataDir(m_dir, user_id);
|
if (!user_id) return;
|
||||||
|
QtCommon::Content::ClearDataDir(m_dir, user_id.value());
|
||||||
scan();
|
scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataWidget::open() {
|
void DataWidget::open() {
|
||||||
std::string user_id = selectProfile();
|
std::optional<std::string> user_id = selectProfile();
|
||||||
|
if (!user_id) return;
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(
|
QDesktopServices::openUrl(QUrl::fromLocalFile(
|
||||||
QString::fromStdString(FrontendCommon::DataManager::GetDataDirString(m_dir, user_id))));
|
QString::fromStdString(FrontendCommon::DataManager::GetDataDirString(m_dir, user_id.value()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataWidget::upload() {
|
void DataWidget::upload() {
|
||||||
std::string user_id = selectProfile();
|
std::optional<std::string> user_id = selectProfile();
|
||||||
QtCommon::Content::ExportDataDir(m_dir, user_id, m_exportName);
|
if (!user_id) return;
|
||||||
|
QtCommon::Content::ExportDataDir(m_dir, user_id.value(), m_exportName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataWidget::download() {
|
void DataWidget::download() {
|
||||||
std::string user_id = selectProfile();
|
std::optional<std::string> user_id = selectProfile();
|
||||||
QtCommon::Content::ImportDataDir(m_dir, user_id, std::bind(&DataWidget::scan, this));
|
if (!user_id) return;
|
||||||
|
QtCommon::Content::ImportDataDir(m_dir, user_id.value(), std::bind(&DataWidget::scan, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataWidget::scan() {
|
void DataWidget::scan() {
|
||||||
|
|
@ -108,10 +103,11 @@ void DataWidget::scan() {
|
||||||
QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); }));
|
QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DataWidget::selectProfile() {
|
std::optional<std::string> DataWidget::selectProfile() {
|
||||||
std::string user_id{};
|
std::string user_id{};
|
||||||
if (m_dir == FrontendCommon::DataManager::DataDir::Saves) {
|
if (m_dir == FrontendCommon::DataManager::DataDir::Saves) {
|
||||||
user_id = GetProfileIDString();
|
user_id = GetProfileIDString();
|
||||||
|
if (user_id.empty()) return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return user_id;
|
return user_id;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ private:
|
||||||
FrontendCommon::DataManager::DataDir m_dir;
|
FrontendCommon::DataManager::DataDir m_dir;
|
||||||
const QString m_exportName;
|
const QString m_exportName;
|
||||||
|
|
||||||
std::string selectProfile();
|
std::optional<std::string> selectProfile();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATA_DIALOG_H
|
#endif // DATA_DIALOG_H
|
||||||
|
|
|
||||||
|
|
@ -27,31 +27,9 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="labels">
|
<widget class="QTabWidget" name="pages">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QStackedWidget" name="page">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>275</width>
|
|
||||||
<height>200</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>-1</number>
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue