DolphinQt: Add button to open graphics mod folder on settings

This commit is contained in:
Momo Cao 2023-01-12 21:47:18 -05:00
parent f4f94396e9
commit 05ed25d482
2 changed files with 17 additions and 1 deletions

View File

@ -4,15 +4,18 @@
#include "DolphinQt/Config/GraphicsModListWidget.h"
#include <QCheckBox>
#include <QDesktopServices>
#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
#include <QUrl>
#include <QVBoxLayout>
#include <QWidget>
#include <set>
#include "Common/FileUtil.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt/Config/GraphicsModWarningWidget.h"
@ -59,9 +62,10 @@ void GraphicsModListWidget::CreateWidgets()
m_mod_list->setSelectionRectVisible(true);
m_mod_list->setDragDropMode(QAbstractItemView::InternalMove);
m_open_directory_button = new QPushButton(tr("Open Directory..."));
m_refresh = new QPushButton(tr("&Refresh List"));
QHBoxLayout* hlayout = new QHBoxLayout;
hlayout->addStretch();
hlayout->addWidget(m_open_directory_button);
hlayout->addWidget(m_refresh);
left_v_layout->addWidget(m_mod_list);
@ -99,6 +103,9 @@ void GraphicsModListWidget::ConnectWidgets()
connect(m_mod_list->model(), &QAbstractItemModel::rowsMoved, this,
&GraphicsModListWidget::SaveModList);
connect(m_open_directory_button, &QPushButton::clicked, this,
&GraphicsModListWidget::OpenGraphicsModDir);
connect(m_refresh, &QPushButton::clicked, this, &GraphicsModListWidget::RefreshModList);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
@ -274,3 +281,9 @@ void GraphicsModListWidget::CalculateGameRunning(Core::State state)
m_loaded_game_is_running =
state == Core::State::Running ? m_game_id == SConfig::GetInstance().GetGameID() : false;
}
void GraphicsModListWidget::OpenGraphicsModDir()
{
QDesktopServices::openUrl(
QUrl::fromLocalFile(QString::fromStdString(File::GetUserPath(D_GRAPHICSMOD_IDX))));
}

View File

@ -58,6 +58,8 @@ private:
void ClearLayoutRecursively(QLayout* layout);
void OpenGraphicsModDir();
void CalculateGameRunning(Core::State state);
bool m_loaded_game_is_running = false;
bool m_needs_save = false;
@ -67,6 +69,7 @@ private:
QLabel* m_selected_mod_name;
QVBoxLayout* m_mod_meta_layout;
QPushButton* m_open_directory_button;
QPushButton* m_refresh;
GraphicsModWarningWidget* m_warning;