diff --git a/dist/qt_themes/colorful/icons/48x48/trash.png b/dist/qt_themes/colorful/icons/48x48/trash.png new file mode 100644 index 0000000000..e60dce2e32 Binary files /dev/null and b/dist/qt_themes/colorful/icons/48x48/trash.png differ diff --git a/dist/qt_themes/colorful/style.qrc b/dist/qt_themes/colorful/style.qrc index 82cd367be9..fc85922d6b 100644 --- a/dist/qt_themes/colorful/style.qrc +++ b/dist/qt_themes/colorful/style.qrc @@ -18,6 +18,7 @@ SPDX-License-Identifier: GPL-2.0-or-later icons/48x48/bad_folder.png icons/48x48/chip.png icons/48x48/folder.png + icons/48x48/trash.png icons/48x48/list-add.png icons/48x48/no_avatar.png icons/48x48/sd_card.png diff --git a/dist/qt_themes/colorful_midnight_blue/style.qrc b/dist/qt_themes/colorful_midnight_blue/style.qrc index b9821c6722..2aee8ea1e1 100644 --- a/dist/qt_themes/colorful_midnight_blue/style.qrc +++ b/dist/qt_themes/colorful_midnight_blue/style.qrc @@ -11,6 +11,7 @@ SPDX-License-Identifier: GPL-2.0-or-later ../colorful/icons/48x48/bad_folder.png ../colorful/icons/48x48/chip.png ../colorful/icons/48x48/folder.png + ../colorful/icons/48x48/trash.png ../colorful/icons/48x48/list-add.png ../colorful/icons/48x48/sd_card.png ../colorful/icons/256x256/plus_folder.png diff --git a/dist/qt_themes/default/default.qrc b/dist/qt_themes/default/default.qrc index 0d8af20fc1..45a91ef2dc 100644 --- a/dist/qt_themes/default/default.qrc +++ b/dist/qt_themes/default/default.qrc @@ -14,6 +14,7 @@ SPDX-License-Identifier: GPL-2.0-or-later icons/48x48/bad_folder.png icons/48x48/chip.png icons/48x48/folder.png + icons/48x48/trash.png icons/48x48/list-add.png icons/48x48/sd_card.png icons/48x48/star.png diff --git a/dist/qt_themes/default/icons/48x48/trash.png b/dist/qt_themes/default/icons/48x48/trash.png new file mode 100644 index 0000000000..547b821de9 Binary files /dev/null and b/dist/qt_themes/default/icons/48x48/trash.png differ diff --git a/dist/qt_themes/default_dark/style.qrc b/dist/qt_themes/default_dark/style.qrc index 7de4737c2c..ac6c9fe4e9 100644 --- a/dist/qt_themes/default_dark/style.qrc +++ b/dist/qt_themes/default_dark/style.qrc @@ -13,6 +13,7 @@ SPDX-License-Identifier: GPL-2.0-or-later ../colorful/icons/48x48/bad_folder.png ../colorful/icons/48x48/chip.png ../colorful/icons/48x48/folder.png + ../colorful/icons/48x48/trash.png ../qdarkstyle/icons/48x48/no_avatar.png ../colorful/icons/48x48/list-add.png ../colorful/icons/48x48/sd_card.png diff --git a/dist/qt_themes/qdarkstyle/icons/48x48/trash.png b/dist/qt_themes/qdarkstyle/icons/48x48/trash.png new file mode 100644 index 0000000000..e59fe85c03 Binary files /dev/null and b/dist/qt_themes/qdarkstyle/icons/48x48/trash.png differ diff --git a/dist/qt_themes/qdarkstyle/style.qrc b/dist/qt_themes/qdarkstyle/style.qrc index a89fb26c68..2b5ca31e72 100644 --- a/dist/qt_themes/qdarkstyle/style.qrc +++ b/dist/qt_themes/qdarkstyle/style.qrc @@ -9,6 +9,7 @@ icons/48x48/bad_folder.png icons/48x48/chip.png icons/48x48/folder.png + icons/48x48/trash.png icons/48x48/no_avatar.png icons/48x48/list-add.png icons/48x48/sd_card.png diff --git a/src/qt_common/qt_string_lookup.h b/src/qt_common/qt_string_lookup.h index 028d301f37..de6acac8a1 100644 --- a/src/qt_common/qt_string_lookup.h +++ b/src/qt_common/qt_string_lookup.h @@ -23,11 +23,11 @@ enum StringKey { }; static constexpr const frozen::unordered_map strings = { - {SavesTooltip, "DO NOT REMOVE UNLESS YOU KNOW WHAT YOU'RE DOING!"}, - {ShadersTooltip, "Shader pipeline caches. Generally safe to remove."}, + {SavesTooltip, "Contains game save data. DO NOT REMOVE UNLESS YOU KNOW WHAT YOU'RE DOING!"}, + {ShadersTooltip, "Contains Vulkan and OpenGL pipeline caches. Generally safe to remove."}, {UserNandTooltip, "Contains updates and DLC for games."}, {SysNandTooltip, "Contains firmware and applet data."}, - {ModsTooltip, "Contains all of your mod data."}, + {ModsTooltip, "Contains game mods, patches, and cheats."}, }; static inline const QString Lookup(StringKey key) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 9663d12bf0..f4669d0914 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -236,6 +236,7 @@ add_executable(yuzu deps_dialog.ui data_dialog.h data_dialog.cpp data_dialog.ui + data_widget.ui ) set_target_properties(yuzu PROPERTIES OUTPUT_NAME "eden") diff --git a/src/yuzu/data_dialog.cpp b/src/yuzu/data_dialog.cpp index 4e61a452bf..87d81e4f43 100644 --- a/src/yuzu/data_dialog.cpp +++ b/src/yuzu/data_dialog.cpp @@ -4,17 +4,12 @@ #include "data_dialog.h" #include "frontend_common/data_manager.h" #include "qt_common/qt_content_util.h" -#include "qt_common/qt_frontend_util.h" -#include "qt_common/qt_progress_dialog.h" #include "qt_common/qt_string_lookup.h" #include "ui_data_dialog.h" #include #include -#include -#include -#include -#include +#include DataDialog::DataDialog(QWidget *parent) : QDialog(parent) @@ -22,86 +17,69 @@ DataDialog::DataDialog(QWidget *parent) { ui->setupUi(this); - std::size_t row = 0; -#define TABLE_ITEM(label, name, data_dir) \ - QTableWidgetItem *name##Label = new QTableWidgetItem(tr(label)); \ - name##Label->setToolTip( \ - QtCommon::StringLookup::Lookup(QtCommon::StringLookup::data_dir##Tooltip)); \ - ui->sizes->setItem(row, 0, name##Label); \ - DataItem *name##Item = new DataItem(FrontendCommon::DataManager::DataDir::data_dir, this); \ - ui->sizes->setItem(row, 1, name##Item); \ - ++row; + // 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)); - TABLE_ITEM("Saves", save, Saves) - TABLE_ITEM("Shaders", shaders, Shaders) - TABLE_ITEM("UserNAND", user, UserNand) - TABLE_ITEM("SysNAND", sys, SysNand) - TABLE_ITEM("Mods", mods, Mods) + WIDGET(Saves) + WIDGET(Shaders) + WIDGET(UserNand) + WIDGET(SysNand) + WIDGET(Mods) -#undef TABLE_ITEM +#undef WIDGET - QObject::connect(ui->sizes, &QTableWidget::customContextMenuRequested, this, [this]() { - auto items = ui->sizes->selectedItems(); - if (items.empty()) - return; - - QTableWidgetItem *selected = items.at(0); - DataItem *item = (DataItem *) ui->sizes->item(selected->row(), 1); - - QMenu *menu = new QMenu(this); - QAction *open = menu->addAction(tr("Open")); - QObject::connect(open, &QAction::triggered, this, [item]() { - auto data_dir - = item->data(DataItem::DATA_DIR).value(); - - QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(FrontendCommon::DataManager::GetDataDir(data_dir)))); - }); - - QAction *clear = menu->addAction(tr("Clear")); - QObject::connect(clear, &QAction::triggered, this, [item]() { - auto data_dir - = item->data(DataItem::DATA_DIR).value(); - - QtCommon::Content::ClearDataDir(data_dir); - - item->scan(); - }); - - menu->exec(QCursor::pos()); + connect(ui->labels, &QListWidget::itemSelectionChanged, this, [this]() { + ui->page->setCurrentIndex(ui->labels->currentRow()); }); } DataDialog::~DataDialog() = default; -DataItem::DataItem(FrontendCommon::DataManager::DataDir data_dir, QWidget *parent) - : QTableWidgetItem(QObject::tr("Calculating")) - , m_parent(parent) +DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir, + QtCommon::StringLookup::StringKey tooltip, + QWidget *parent) + : QWidget(parent) + , ui(std::make_unique()) , m_dir(data_dir) { - setData(DataItem::DATA_DIR, QVariant::fromValue(m_dir)); + 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); + scan(); } -bool DataItem::operator<(const QTableWidgetItem &other) const -{ - return this->data(DataRole::SIZE).toULongLong() < other.data(DataRole::SIZE).toULongLong(); +void DataWidget::clear() { + QtCommon::Content::ClearDataDir(m_dir); + scan(); } -void DataItem::reset() { - setText(QStringLiteral("0 B")); - setData(DataItem::SIZE, QVariant::fromValue(0ULL)); +void DataWidget::open() { + QDesktopServices::openUrl(QUrl::fromLocalFile( + QString::fromStdString(FrontendCommon::DataManager::GetDataDir(m_dir)))); } -void DataItem::scan() { - m_watcher = new QFutureWatcher(m_parent); +void DataWidget::scan() { + ui->size->setText(tr("Calculating...")); - m_parent->connect(m_watcher, &QFutureWatcher::finished, m_parent, [=, this]() { - u64 size = m_watcher->result(); - setText(QString::fromStdString(FrontendCommon::DataManager::ReadableBytesSize(size))); - setData(DataItem::SIZE, QVariant::fromValue(size)); + QFutureWatcher *watcher = new QFutureWatcher(this); + + connect(watcher, &QFutureWatcher::finished, this, [=, this]() { + u64 size = watcher->result(); + ui->size->setText( + QString::fromStdString(FrontendCommon::DataManager::ReadableBytesSize(size))); + watcher->deleteLater(); }); - m_watcher->setFuture( + watcher->setFuture( QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); })); } diff --git a/src/yuzu/data_dialog.h b/src/yuzu/data_dialog.h index eab1def7d0..9f367d6049 100644 --- a/src/yuzu/data_dialog.h +++ b/src/yuzu/data_dialog.h @@ -5,11 +5,10 @@ #define DATA_DIALOG_H #include -#include -#include -#include #include "frontend_common/data_manager.h" -#include +#include "qt_common/qt_string_lookup.h" + +#include "ui_data_widget.h" namespace Ui { class DataDialog; @@ -27,19 +26,21 @@ private: std::unique_ptr ui; }; -class DataItem : public QTableWidgetItem +class DataWidget : public QWidget { + Q_OBJECT public: - DataItem(FrontendCommon::DataManager::DataDir data_dir, QWidget *parent); - enum DataRole { SIZE = Qt::UserRole + 1, DATA_DIR }; + explicit DataWidget(FrontendCommon::DataManager::DataDir data_dir, + QtCommon::StringLookup::StringKey tooltip, + QWidget *parent = nullptr); - bool operator<(const QTableWidgetItem &other) const; - void reset(); +public slots: + void clear(); + void open(); void scan(); private: - QWidget *m_parent; - QFutureWatcher *m_watcher = nullptr; + std::unique_ptr ui; FrontendCommon::DataManager::DataDir m_dir; }; diff --git a/src/yuzu/data_dialog.ui b/src/yuzu/data_dialog.ui index d757a48bd6..06751e2fb1 100644 --- a/src/yuzu/data_dialog.ui +++ b/src/yuzu/data_dialog.ui @@ -6,8 +6,8 @@ 0 0 - 300 - 350 + 480 + 320 @@ -27,90 +27,86 @@ - - - Right-click on an item to either open it or clear it. Hold your mouse over an item to see more information about it. - - - true - - + + + + + + 0 + 0 + + + + + Saves + + + + + Shaders + + + + + UserNAND + + + + + SysNAND + + + + + Mods + + + + + + + + + 0 + 0 + + + + + 275 + 200 + + + + -1 + + + + - - - Qt::ContextMenuPolicy::CustomContextMenu + + + 10 - - QAbstractItemView::EditTrigger::NoEditTriggers - - - true - - - QAbstractItemView::SelectionMode::SingleSelection - - - true - - - false - - - 80 - - - true - - - false - - - - New Row - - - - - 0 - - - - - 1 - - - - - 2 - - - - - 4 - - - - - Directory - - - - - Size - - - - - - - - Qt::Orientation::Horizontal - - - QDialogButtonBox::StandardButton::Ok - - + + + + Deleting ANY data is IRREVERSABLE! + + + + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Ok + + + + diff --git a/src/yuzu/data_widget.ui b/src/yuzu/data_widget.ui new file mode 100644 index 0000000000..ed67078fa1 --- /dev/null +++ b/src/yuzu/data_widget.ui @@ -0,0 +1,147 @@ + + + DataWidget + + + + 0 + 0 + 275 + 200 + + + + Form + + + + + + + + Tooltip + + + Qt::AlignmentFlag::AlignCenter + + + true + + + + + + + + 10 + true + + + + Size + + + Qt::AlignmentFlag::AlignCenter + + + true + + + + + + + + + QLayout::SizeConstraint::SetFixedSize + + + 25 + + + + + + 1 + 1 + + + + + 52 + 42 + + + + Open with your system file manager + + + QPushButton { + border-style: solid; + border-width:1px; + border-radius:25px; + border-color: transparent; + max-width:50px; + max-height:40px; + min-width:50px; + min-height:40px; +} + + + + + + + 24 + 24 + + + + + + + + + 1 + 1 + + + + + 52 + 42 + + + + Delete all data in this directory. THIS IS 100% IRREVERSABLE! + + + QPushButton { + border-style: solid; + border-width:1px; + border-radius:25px; + border-color: transparent; + max-width:50px; + max-height:40px; + min-width:50px; + min-height:40px; +} + + + + + + + 24 + 24 + + + + + + + + + + + diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index b7f9d3b1e3..12ff4efdf1 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui @@ -165,6 +165,16 @@ + + + &Applets + + + + + + + &TAS @@ -195,11 +205,7 @@ - - - - - + @@ -503,7 +509,7 @@ - Open Home Menu + Open &Home Menu