rpcsx/rpcs3/rpcs3qt/vfs_dialog.cpp

107 lines
3.4 KiB
C++
Raw Normal View History

2020-12-05 13:08:24 +01:00
#include "vfs_dialog.h"
2020-02-22 20:42:49 +01:00
#include "vfs_dialog_tab.h"
2022-05-08 20:18:42 +02:00
#include "vfs_dialog_usb_tab.h"
2020-02-22 20:42:49 +01:00
#include "gui_settings.h"
2020-02-22 20:42:49 +01:00
#include <QTabWidget>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QMessageBox>
2020-02-22 20:42:49 +01:00
#include <QVBoxLayout>
#include "Emu/System.h"
#include "Emu/vfs_config.h"
[Qt/Input] Improve pad_settings_dialog a bit (#3611) * Input: further work on remapping Xinput and begin work on remapping DS4 * Input: Improve pad_settings_dialog a bit and begin Remapping for XInput * Input: begin evdev remapping and change all handlers to use cfg::string * Input: finish work on remapping evdev and some more crap * Input: finish work on remapping Xinput and DS4 * Input: add DS4 Colors to DS4 config * Input: Improve DS4 deadzone scaling Jarves made some mistakes, so I'll fix them in the follow up commit * Input: fix Jarves fixes on DS4 deadzone and remove unnecessary usage of toUtf8 * Input: add primitive batterychecks to XInput and DS4 * Input: add mmjoystick remapping * Input: Fix evdev and some Vibration issues * Input: adjust capabilities to fix stick input for games like LoS 2 also fix threshold slider minimum also add ps button to all the handlers * Input: Further evdev work based on danilaml code review and own debugging: Fixed path issue, <= 0 issue, some captures, const, axis with same codes. Adds a map to each device that differentiates negative and positive axis mappings. adjusted rest of the file to tabs (ListDevices and beginning of threadProc) * Input: use 20ms vibration update time for xbox one elite controllers. * Input: Fix return type of Clamp() * Input: Evdev Fix * Input: Evdev Optional GetNextButtonPress presumably better than the other * Input: review changes * Input: evdev: fix wrong index in axis handling move bindpadtodevice down to keep consistency between handlers and not get crazy * Input: evdev: fix expensive add_device in GetNextButtonPress * cleanup * Input: mmjoy: fix type * Input: evdev: final fixes * Input: evdev: exclude unnecessary buttons while mapping Xbox 360 or DS4 * Input: add deadzone preview by passing necessary values in callback use 0.5 of max value for threshold in pad dialog * Input: get rid of all-uppercase variables
2017-11-27 22:31:15 +01:00
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
2022-05-08 20:18:42 +02:00
vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> _gui_settings, QWidget* parent)
: QDialog(parent), m_gui_settings(std::move(_gui_settings))
{
2022-05-08 20:18:42 +02:00
setWindowTitle(tr("Virtual File System"));
setObjectName("vfs_dialog");
QTabWidget* tabs = new QTabWidget();
2017-07-11 01:27:58 +02:00
tabs->setUsesScrollButtons(false);
g_cfg_vfs.load();
2017-09-19 20:07:04 +02:00
// Create tabs
2022-05-08 20:18:42 +02:00
vfs_dialog_tab* emulator_tab = new vfs_dialog_tab("$(EmulatorDir)", gui::fs_emulator_dir_list, &g_cfg_vfs.emulator_dir, m_gui_settings, this);
vfs_dialog_tab* dev_hdd0_tab = new vfs_dialog_tab("dev_hdd0", gui::fs_dev_hdd0_list, &g_cfg_vfs.dev_hdd0, m_gui_settings, this);
vfs_dialog_tab* dev_hdd1_tab = new vfs_dialog_tab("dev_hdd1", gui::fs_dev_hdd1_list, &g_cfg_vfs.dev_hdd1, m_gui_settings, this);
vfs_dialog_tab* dev_flash_tab = new vfs_dialog_tab("dev_flash", gui::fs_dev_flash_list, &g_cfg_vfs.dev_flash, m_gui_settings, this);
vfs_dialog_tab* dev_flash2_tab = new vfs_dialog_tab("dev_flash2", gui::fs_dev_flash2_list, &g_cfg_vfs.dev_flash2, m_gui_settings, this);
vfs_dialog_tab* dev_flash3_tab = new vfs_dialog_tab("dev_flash3", gui::fs_dev_flash3_list, &g_cfg_vfs.dev_flash3, m_gui_settings, this);
vfs_dialog_usb_tab* dev_usb_tab = new vfs_dialog_usb_tab(&g_cfg_vfs.dev_usb, m_gui_settings, this);
2021-04-17 16:22:17 +02:00
2017-07-11 01:27:58 +02:00
tabs->addTab(emulator_tab, "$(EmulatorDir)");
tabs->addTab(dev_hdd0_tab, "dev_hdd0");
tabs->addTab(dev_hdd1_tab, "dev_hdd1");
2018-06-23 08:26:11 +02:00
tabs->addTab(dev_flash_tab, "dev_flash");
2021-04-17 16:22:17 +02:00
tabs->addTab(dev_flash2_tab, "dev_flash2");
tabs->addTab(dev_flash3_tab, "dev_flash3");
2022-05-08 20:18:42 +02:00
tabs->addTab(dev_usb_tab, "dev_usb");
// Create buttons
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close | QDialogButtonBox::Save | QDialogButtonBox::RestoreDefaults);
buttons->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Reset Directories"));
buttons->button(QDialogButtonBox::Save)->setDefault(true);
2022-05-08 20:18:42 +02:00
connect(buttons, &QDialogButtonBox::clicked, this, [this, buttons, tabs](QAbstractButton* button)
{
if (button == buttons->button(QDialogButtonBox::RestoreDefaults))
{
if (QMessageBox::question(this, tr("Confirm Reset"), tr("Reset all file system directories?")) != QMessageBox::Yes)
return;
for (int i = 0; i < tabs->count(); ++i)
{
2022-05-08 20:18:42 +02:00
if (i < tabs->count() - 1)
{
static_cast<vfs_dialog_tab*>(tabs->widget(i))->reset();
}
else
{
static_cast<vfs_dialog_usb_tab*>(tabs->widget(i))->reset();
}
}
}
else if (button == buttons->button(QDialogButtonBox::Save))
{
for (int i = 0; i < tabs->count(); ++i)
{
2022-05-08 20:18:42 +02:00
if (i < tabs->count() - 1)
{
static_cast<vfs_dialog_tab*>(tabs->widget(i))->set_settings();
}
else
{
static_cast<vfs_dialog_usb_tab*>(tabs->widget(i))->set_settings();
}
}
g_cfg_vfs.save();
// Recreate folder structure for new VFS paths
if (Emu.IsStopped())
{
Emu.Init();
}
accept();
}
else if (button == buttons->button(QDialogButtonBox::Close))
{
reject();
}
});
QVBoxLayout* vbox = new QVBoxLayout;
vbox->addWidget(tabs);
vbox->addWidget(buttons);
setLayout(vbox);
buttons->button(QDialogButtonBox::Save)->setFocus();
}