VERY experimental Nintendo Switch 2 emulator
C++
[desktop] Change data manager to use tabs instead of a list (#3856)
crueter0257a8d49123
diff --git a/src/yuzu/data_dialog.cpp b/src/yuzu/data_dialog.cppindex bbe5d43e05..8d50843eb3 100644--- a/src/yuzu/data_dialog.cpp+++ b/src/yuzu/data_dialog.cpp@@ -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?#define WIDGET(label, name) \- ui->page->addWidget(new DataWidget(FrontendCommon::DataManager::DataDir::name, \- QtCommon::StringLookup::DataManager##name##Tooltip, \- QStringLiteral(#name), this)); \- ui->labels->addItem(label);+ ui->pages->addTab(new DataWidget(FrontendCommon::DataManager::DataDir::name, \+ QtCommon::StringLookup::DataManager##name##Tooltip, \+ QStringLiteral(#name), this), \+ label);WIDGET(tr("Shaders"), Shaders)- WIDGET(tr("UserNAND"), UserNand)- WIDGET(tr("SysNAND"), SysNand)+ WIDGET(tr("User NAND"), UserNand)+ WIDGET(tr("System NAND"), SysNand)WIDGET(tr("Mods"), Mods)WIDGET(tr("Saves"), Saves)#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;@@ -71,25 +62,29 @@ DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir,}void DataWidget::clear() {- std::string user_id = selectProfile();- QtCommon::Content::ClearDataDir(m_dir, user_id);+ std::optional<std::string> user_id = selectProfile();+ if (!user_id) return;+ QtCommon::Content::ClearDataDir(m_dir, user_id.value());scan();}void DataWidget::open() {- std::string user_id = selectProfile();+ std::optional<std::string> user_id = selectProfile();+ if (!user_id) return;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() {- std::string user_id = selectProfile();- QtCommon::Content::ExportDataDir(m_dir, user_id, m_exportName);+ std::optional<std::string> user_id = selectProfile();+ if (!user_id) return;+ QtCommon::Content::ExportDataDir(m_dir, user_id.value(), m_exportName);}void DataWidget::download() {- std::string user_id = selectProfile();- QtCommon::Content::ImportDataDir(m_dir, user_id, std::bind(&DataWidget::scan, this));+ std::optional<std::string> user_id = selectProfile();+ if (!user_id) return;+ QtCommon::Content::ImportDataDir(m_dir, user_id.value(), std::bind(&DataWidget::scan, this));}void DataWidget::scan() {@@ -108,10 +103,11 @@ void DataWidget::scan() {QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); }));}-std::string DataWidget::selectProfile() {+std::optional<std::string> DataWidget::selectProfile() {std::string user_id{};if (m_dir == FrontendCommon::DataManager::DataDir::Saves) {user_id = GetProfileIDString();+ if (user_id.empty()) return std::nullopt;}return user_id;diff --git a/src/yuzu/data_dialog.h b/src/yuzu/data_dialog.hindex 7f988f6047..2915f00848 100644--- a/src/yuzu/data_dialog.h+++ b/src/yuzu/data_dialog.h@@ -45,7 +45,7 @@ private:FrontendCommon::DataManager::DataDir m_dir;const QString m_exportName;- std::string selectProfile();+ std::optional<std::string> selectProfile();};#endif // DATA_DIALOG_Hdiff --git a/src/yuzu/data_dialog.ui b/src/yuzu/data_dialog.uiindex 02e674d856..1e33530774 100644--- a/src/yuzu/data_dialog.ui+++ b/src/yuzu/data_dialog.ui@@ -27,31 +27,9 @@</property><layout class="QVBoxLayout" name="verticalLayout"><item>- <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0"><item>- <widget class="QListWidget" name="labels">- <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>+ <widget class="QTabWidget" name="pages"><property name="currentIndex"><number>-1</number></property>