mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12: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
3 changed files with 43 additions and 21 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "vfs_dialog.h"
|
#include "vfs_dialog.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
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");
|
tabs->addTab(dev_usb000_tab, "dev_usb000");
|
||||||
|
|
||||||
// Create buttons
|
// Create buttons
|
||||||
QPushButton* addDir = new QPushButton(tr("Add New Directory"));
|
QPushButton* resetAll = new QPushButton(tr("Reset Directories"));
|
||||||
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"));
|
|
||||||
connect(resetAll, &QAbstractButton::clicked, [=]
|
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)
|
for (int i = 0; i < tabs->count(); ++i)
|
||||||
{
|
{
|
||||||
static_cast<vfs_dialog_tab*>(tabs->widget(i))->Reset();
|
static_cast<vfs_dialog_tab*>(tabs->widget(i))->Reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QPushButton* okay = new QPushButton(tr("Okay"));
|
QPushButton* save = new QPushButton(tr("Save"));
|
||||||
okay->setAutoDefault(true);
|
save->setAutoDefault(true);
|
||||||
okay->setDefault(true);
|
save->setDefault(true);
|
||||||
|
|
||||||
connect(okay, &QAbstractButton::clicked, [=]
|
connect(save, &QAbstractButton::clicked, [=]
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tabs->count(); ++i)
|
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();
|
accept();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QPushButton* close = new QPushButton(tr("Close"));
|
||||||
|
connect(close, &QAbstractButton::clicked, this, &QDialog::reject);
|
||||||
|
|
||||||
QHBoxLayout* buttons = new QHBoxLayout;
|
QHBoxLayout* buttons = new QHBoxLayout;
|
||||||
buttons->addWidget(addDir);
|
|
||||||
buttons->addWidget(reset);
|
|
||||||
buttons->addWidget(resetAll);
|
buttons->addWidget(resetAll);
|
||||||
buttons->addStretch();
|
buttons->addStretch();
|
||||||
buttons->addWidget(okay);
|
buttons->addWidget(save);
|
||||||
|
buttons->addWidget(close);
|
||||||
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout;
|
QVBoxLayout* vbox = new QVBoxLayout;
|
||||||
vbox->addWidget(tabs);
|
vbox->addWidget(tabs);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
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));
|
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;
|
QHBoxLayout* selectedConfigLayout = new QHBoxLayout;
|
||||||
m_selectedConfigLabel = new QLabel(current_dir.isEmpty() ? EmptyPath : current_dir);
|
m_selectedConfigLabel = new QLabel(current_dir.isEmpty() ? EmptyPath : current_dir);
|
||||||
selectedConfigLayout->addWidget(new QLabel(m_info.name + tr(" directory:")));
|
selectedConfigLayout->addWidget(new QLabel(m_info.name + tr(" directory:")));
|
||||||
selectedConfigLayout->addWidget(m_selectedConfigLabel);
|
selectedConfigLayout->addWidget(m_selectedConfigLabel);
|
||||||
selectedConfigLayout->addStretch();
|
selectedConfigLayout->addStretch();
|
||||||
|
selectedConfigLayout->addWidget(addDir);
|
||||||
|
selectedConfigLayout->addWidget(removeDir);
|
||||||
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout;
|
QVBoxLayout* vbox = new QVBoxLayout;
|
||||||
vbox->addWidget(m_dirList);
|
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());
|
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()
|
void vfs_dialog_tab::SetSettings()
|
||||||
|
@ -83,3 +101,9 @@ void vfs_dialog_tab::AddNewDirectory()
|
||||||
|
|
||||||
m_dirList->setCurrentItem(new QListWidgetItem(dir, m_dirList));
|
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);
|
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 SetSettings();
|
||||||
void AddNewDirectory();
|
|
||||||
|
|
||||||
// Reset this tab without saving the settings yet
|
// Reset this tab without saving the settings yet
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void AddNewDirectory();
|
||||||
|
void RemoveDirectory();
|
||||||
|
void SetCurrentRow(int row) { m_currentRow = row; }
|
||||||
|
|
||||||
const QString EmptyPath = tr("Empty Path");
|
const QString EmptyPath = tr("Empty Path");
|
||||||
|
|
||||||
vfs_settings_info m_info;
|
vfs_settings_info m_info;
|
||||||
std::shared_ptr<gui_settings> m_gui_settings;
|
std::shared_ptr<gui_settings> m_gui_settings;
|
||||||
std::shared_ptr<emu_settings> m_emu_settings;
|
std::shared_ptr<emu_settings> m_emu_settings;
|
||||||
|
int m_currentRow = -1;
|
||||||
|
|
||||||
// UI variables needed in higher scope
|
// UI variables needed in higher scope
|
||||||
QListWidget* m_dirList;
|
QListWidget* m_dirList;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue