mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-23 15:40:34 +00:00
Improvements to Virtual File System dialog:
- Replace Add Directory and Reset buttons with + and - buttons - Add a confirmation message before Reset All - Rename "Okay" to "Save" (to be in line with the rest of the UI) and add a Close option to quit without savin
This commit is contained in:
parent
f5f0a5aa19
commit
66c1143a65
@ -1,6 +1,7 @@
|
||||
#include "vfs_dialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||
|
||||
@ -35,32 +36,23 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> guiSettings, std::shared_pt
|
||||
tabs->addTab(dev_usb000_tab, "dev_usb000");
|
||||
|
||||
// Create buttons
|
||||
QPushButton* addDir = new QPushButton(tr("Add New Directory"));
|
||||
connect(addDir, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
static_cast<vfs_dialog_tab*>(tabs->currentWidget())->AddNewDirectory();
|
||||
});
|
||||
|
||||
QPushButton* reset = new QPushButton(tr("Reset"));
|
||||
connect(reset, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
static_cast<vfs_dialog_tab*>(tabs->currentWidget())->Reset();
|
||||
});
|
||||
|
||||
QPushButton* resetAll = new QPushButton(tr("Reset All"));
|
||||
QPushButton* resetAll = new QPushButton(tr("Reset Directories"));
|
||||
connect(resetAll, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Confirm Reset"), tr("Reset all file system directories?")) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < tabs->count(); ++i)
|
||||
{
|
||||
static_cast<vfs_dialog_tab*>(tabs->widget(i))->Reset();
|
||||
}
|
||||
});
|
||||
|
||||
QPushButton* okay = new QPushButton(tr("Okay"));
|
||||
okay->setAutoDefault(true);
|
||||
okay->setDefault(true);
|
||||
QPushButton* save = new QPushButton(tr("Save"));
|
||||
save->setAutoDefault(true);
|
||||
save->setDefault(true);
|
||||
|
||||
connect(okay, &QAbstractButton::clicked, [=]
|
||||
connect(save, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
for (int i = 0; i < tabs->count(); ++i)
|
||||
{
|
||||
@ -70,12 +62,14 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> guiSettings, std::shared_pt
|
||||
accept();
|
||||
});
|
||||
|
||||
QPushButton* close = new QPushButton(tr("Close"));
|
||||
connect(close, &QAbstractButton::clicked, this, &QDialog::reject);
|
||||
|
||||
QHBoxLayout* buttons = new QHBoxLayout;
|
||||
buttons->addWidget(addDir);
|
||||
buttons->addWidget(reset);
|
||||
buttons->addWidget(resetAll);
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(okay);
|
||||
buttons->addWidget(save);
|
||||
buttons->addWidget(close);
|
||||
|
||||
QVBoxLayout* vbox = new QVBoxLayout;
|
||||
vbox->addWidget(tabs);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QCoreApplication>
|
||||
#include <QPushButton>
|
||||
|
||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||
|
||||
@ -30,11 +31,22 @@ vfs_dialog_tab::vfs_dialog_tab(vfs_settings_info settingsInfo, std::shared_ptr<g
|
||||
|
||||
m_dirList->setMinimumWidth(m_dirList->sizeHintForColumn(0));
|
||||
|
||||
QPushButton* addDir = new QPushButton(tr("+"));
|
||||
addDir->setFixedWidth(addDir->sizeHint().height()); // Make button square
|
||||
connect(addDir, &QAbstractButton::clicked, this, &vfs_dialog_tab::AddNewDirectory);
|
||||
|
||||
QPushButton* removeDir = new QPushButton(tr("-"));
|
||||
removeDir->setFixedWidth(removeDir->sizeHint().height()); // Make button square
|
||||
removeDir->setEnabled(false);
|
||||
connect(removeDir, &QAbstractButton::clicked, this, &vfs_dialog_tab::RemoveDirectory);
|
||||
|
||||
QHBoxLayout* selectedConfigLayout = new QHBoxLayout;
|
||||
m_selectedConfigLabel = new QLabel(current_dir.isEmpty() ? EmptyPath : current_dir);
|
||||
selectedConfigLayout->addWidget(new QLabel(m_info.name + tr(" directory:")));
|
||||
selectedConfigLayout->addWidget(m_selectedConfigLabel);
|
||||
selectedConfigLayout->addStretch();
|
||||
selectedConfigLayout->addWidget(addDir);
|
||||
selectedConfigLayout->addWidget(removeDir);
|
||||
|
||||
QVBoxLayout* vbox = new QVBoxLayout;
|
||||
vbox->addWidget(m_dirList);
|
||||
@ -49,6 +61,12 @@ vfs_dialog_tab::vfs_dialog_tab(vfs_settings_info settingsInfo, std::shared_ptr<g
|
||||
|
||||
m_selectedConfigLabel->setText(current->text().isEmpty() ? EmptyPath : current->text());
|
||||
});
|
||||
|
||||
connect(m_dirList, &QListWidget::currentRowChanged, [this, removeDir](int row)
|
||||
{
|
||||
SetCurrentRow(row);
|
||||
removeDir->setEnabled(row > 0);
|
||||
});
|
||||
}
|
||||
|
||||
void vfs_dialog_tab::SetSettings()
|
||||
@ -83,3 +101,9 @@ void vfs_dialog_tab::AddNewDirectory()
|
||||
|
||||
m_dirList->setCurrentItem(new QListWidgetItem(dir, m_dirList));
|
||||
}
|
||||
|
||||
void vfs_dialog_tab::RemoveDirectory()
|
||||
{
|
||||
QListWidgetItem* item = m_dirList->takeItem(m_currentRow);
|
||||
delete item;
|
||||
}
|
||||
|
@ -26,17 +26,21 @@ public:
|
||||
explicit vfs_dialog_tab(vfs_settings_info info, std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, QWidget* parent = nullptr);
|
||||
|
||||
void SetSettings();
|
||||
void AddNewDirectory();
|
||||
|
||||
// Reset this tab without saving the settings yet
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
void AddNewDirectory();
|
||||
void RemoveDirectory();
|
||||
void SetCurrentRow(int row) { m_currentRow = row; }
|
||||
|
||||
const QString EmptyPath = tr("Empty Path");
|
||||
|
||||
vfs_settings_info m_info;
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
std::shared_ptr<emu_settings> m_emu_settings;
|
||||
int m_currentRow = -1;
|
||||
|
||||
// UI variables needed in higher scope
|
||||
QListWidget* m_dirList;
|
||||
|
Loading…
x
Reference in New Issue
Block a user