[Qt] style adjustments 4

rename more members and clean headers
adjust some connects
This commit is contained in:
Megamouse 2017-09-06 19:32:33 +02:00 committed by Ani
parent a95e01290e
commit 95231c4dee
12 changed files with 182 additions and 144 deletions

View File

@ -175,17 +175,17 @@ emu_settings::emu_settings(const std::string& path) : QObject()
fs::create_path(fs::get_config_dir() + path); fs::create_path(fs::get_config_dir() + path);
// Load default config // Load default config
currentSettings = YAML::Load(g_cfg_defaults); m_currentSettings = YAML::Load(g_cfg_defaults);
// Add global config // Add global config
config = fs::file(fs::get_config_dir() + "/config.yml", fs::read + fs::write + fs::create); m_config = fs::file(fs::get_config_dir() + "/config.yml", fs::read + fs::write + fs::create);
currentSettings += YAML::Load(config.to_string()); m_currentSettings += YAML::Load(m_config.to_string());
// Add game config // Add game config
if (!path.empty() && fs::is_file(fs::get_config_dir() + path + "/config.yml")) if (!path.empty() && fs::is_file(fs::get_config_dir() + path + "/config.yml"))
{ {
config = fs::file(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write); m_config = fs::file(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write);
currentSettings += YAML::Load(config.to_string()); m_currentSettings += YAML::Load(m_config.to_string());
} }
} }
@ -196,17 +196,17 @@ emu_settings::~emu_settings()
void emu_settings::SaveSettings() void emu_settings::SaveSettings()
{ {
YAML::Emitter out; YAML::Emitter out;
emitData(out, currentSettings); emitData(out, m_currentSettings);
if (!m_path.empty()) if (!m_path.empty())
{ {
config = fs::file(fs::get_config_dir() + m_path + "/config.yml", fs::read + fs::write + fs::create); m_config = fs::file(fs::get_config_dir() + m_path + "/config.yml", fs::read + fs::write + fs::create);
} }
// Save config // Save config
config.seek(0); m_config.seek(0);
config.trunc(0); m_config.trunc(0);
config.write(out.c_str(), out.size()); m_config.write(out.c_str(), out.size());
} }
void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged) void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged)
@ -269,12 +269,12 @@ void emu_settings::EnhanceCheckBox(QCheckBox* checkbox, SettingsType type)
std::vector<std::string> emu_settings::GetLoadedLibraries() std::vector<std::string> emu_settings::GetLoadedLibraries()
{ {
return currentSettings["Core"]["Load libraries"].as<std::vector<std::string>, std::initializer_list<std::string>>({}); return m_currentSettings["Core"]["Load libraries"].as<std::vector<std::string>, std::initializer_list<std::string>>({});
} }
void emu_settings::SaveSelectedLibraries(const std::vector<std::string>& libs) void emu_settings::SaveSelectedLibraries(const std::vector<std::string>& libs)
{ {
currentSettings["Core"]["Load libraries"] = libs; m_currentSettings["Core"]["Load libraries"] = libs;
} }
QStringList emu_settings::GetSettingOptions(SettingsType type) const QStringList emu_settings::GetSettingOptions(SettingsType type) const
@ -284,10 +284,10 @@ QStringList emu_settings::GetSettingOptions(SettingsType type) const
std::string emu_settings::GetSetting(SettingsType type) const std::string emu_settings::GetSetting(SettingsType type) const
{ {
return cfg_adapter::get_node(currentSettings, SettingsLoc[type]).Scalar(); return cfg_adapter::get_node(m_currentSettings, SettingsLoc[type]).Scalar();
} }
void emu_settings::SetSetting(SettingsType type, const std::string& val) void emu_settings::SetSetting(SettingsType type, const std::string& val)
{ {
cfg_adapter::get_node(currentSettings, SettingsLoc[type]) = val; cfg_adapter::get_node(m_currentSettings, SettingsLoc[type]) = val;
} }

View File

@ -206,7 +206,7 @@ private:
{ dev_usb000Location, { "VFS", "/dev_usb000/"}}, { dev_usb000Location, { "VFS", "/dev_usb000/"}},
}; };
YAML::Node currentSettings; // The current settings as a YAML node. YAML::Node m_currentSettings; // The current settings as a YAML node.
fs::file config; //! File to read/write the config settings. fs::file m_config; //! File to read/write the config settings.
std::string m_path; std::string m_path;
}; };

View File

@ -6,17 +6,17 @@ constexpr auto qstr = QString::fromStdString;
instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, const std::shared_ptr<cpu_thread>& _cpu, CPUDisAsm* _disasm) instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, const std::shared_ptr<cpu_thread>& _cpu, CPUDisAsm* _disasm)
: QDialog(parent) : QDialog(parent)
, pc(_pc) , m_pc(_pc)
, cpu(_cpu) , cpu(_cpu)
, disasm(_disasm) , m_disasm(_disasm)
{ {
setWindowTitle(tr("Edit instruction")); setWindowTitle(tr("Edit instruction"));
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setMinimumSize(300, sizeHint().height()); setMinimumSize(300, sizeHint().height());
const auto cpu = _cpu.get(); const auto cpu = _cpu.get();
cpu_offset = g_system == system_type::ps3 && cpu->id_type() != 1 ? static_cast<SPUThread&>(*cpu).offset : 0; m_cpu_offset = g_system == system_type::ps3 && cpu->id_type() != 1 ? static_cast<SPUThread&>(*cpu).offset : 0;
QString instruction = qstr(fmt::format("%08x", vm::ps3::read32(cpu_offset + pc).value())); QString instruction = qstr(fmt::format("%08x", vm::ps3::read32(m_cpu_offset + m_pc).value()));
QVBoxLayout* vbox_panel(new QVBoxLayout()); QVBoxLayout* vbox_panel(new QVBoxLayout());
QHBoxLayout* hbox_panel(new QHBoxLayout()); QHBoxLayout* hbox_panel(new QHBoxLayout());
@ -29,26 +29,23 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, c
button_ok->setFixedWidth(80); button_ok->setFixedWidth(80);
button_cancel->setFixedWidth(80); button_cancel->setFixedWidth(80);
QLabel* t1_text = new QLabel(tr("Address: "), this); m_instr = new QLineEdit(this);
QLabel* t2_text = new QLabel(tr("Instruction: "), this); m_instr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
QLabel* t3_text = new QLabel(tr("Preview: "), this); m_instr->setPlaceholderText(instruction);
QLabel* t1_addr = new QLabel(qstr(fmt::format("%08x", pc)), this); m_instr->setText(instruction);
t2_instr = new QLineEdit(this); m_instr->setMaxLength(8);
t2_instr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_instr->setMaximumWidth(65);
t2_instr->setPlaceholderText(instruction);
t2_instr->setText(instruction); m_preview = new QLabel("", this);
t2_instr->setMaxLength(8);
t2_instr->setMaximumWidth(65);
t3_preview = new QLabel("", this);
// Layouts // Layouts
vbox_left_panel->addWidget(t1_text); vbox_left_panel->addWidget(new QLabel(tr("Address: ")));
vbox_left_panel->addWidget(t2_text); vbox_left_panel->addWidget(new QLabel(tr("Instruction: ")));
vbox_left_panel->addWidget(t3_text); vbox_left_panel->addWidget(new QLabel(tr("Preview: ")));
vbox_right_panel->addWidget(t1_addr); vbox_right_panel->addWidget(new QLabel(qstr(fmt::format("%08x", m_pc))));
vbox_right_panel->addWidget(t2_instr); vbox_right_panel->addWidget(m_instr);
vbox_right_panel->addWidget(t3_preview); vbox_right_panel->addWidget(m_preview);
vbox_right_panel->setAlignment(Qt::AlignLeft); vbox_right_panel->setAlignment(Qt::AlignLeft);
hbox_b_panel->addWidget(button_ok); hbox_b_panel->addWidget(button_ok);
@ -69,15 +66,19 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, c
connect(button_ok, &QAbstractButton::pressed, [=]() connect(button_ok, &QAbstractButton::pressed, [=]()
{ {
bool ok; bool ok;
ulong opcode = t2_instr->text().toULong(&ok, 16); ulong opcode = m_instr->text().toULong(&ok, 16);
if (!ok) if (!ok)
{
QMessageBox::critical(this, tr("Error"), tr("This instruction could not be parsed.\nNo changes were made.")); QMessageBox::critical(this, tr("Error"), tr("This instruction could not be parsed.\nNo changes were made."));
}
else else
vm::ps3::write32(cpu_offset + pc, (u32)opcode); {
vm::ps3::write32(m_cpu_offset + m_pc, (u32)opcode);
}
accept(); accept();
}); });
connect(button_cancel, &QAbstractButton::pressed, this, &instruction_editor_dialog::reject); connect(button_cancel, &QAbstractButton::pressed, this, &instruction_editor_dialog::reject);
connect(t2_instr, &QLineEdit::textChanged, this, &instruction_editor_dialog::updatePreview); connect(m_instr, &QLineEdit::textChanged, this, &instruction_editor_dialog::updatePreview);
updatePreview(); updatePreview();
} }
@ -85,22 +86,22 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, c
void instruction_editor_dialog::updatePreview() void instruction_editor_dialog::updatePreview()
{ {
bool ok; bool ok;
ulong opcode = t2_instr->text().toULong(&ok, 16); ulong opcode = m_instr->text().toULong(&ok, 16);
Q_UNUSED(opcode); Q_UNUSED(opcode);
if (ok) if (ok)
{ {
if (g_system == system_type::psv) if (g_system == system_type::psv)
{ {
t3_preview->setText(tr("Preview for ARMv7Thread not implemented yet.")); m_preview->setText(tr("Preview for ARMv7Thread not implemented yet."));
} }
else else
{ {
t3_preview->setText(tr("Preview disabled.")); m_preview->setText(tr("Preview disabled."));
} }
} }
else else
{ {
t3_preview->setText(tr("Could not parse instruction.")); m_preview->setText(tr("Could not parse instruction."));
} }
} }

View File

@ -17,11 +17,11 @@
class instruction_editor_dialog : public QDialog class instruction_editor_dialog : public QDialog
{ {
u32 pc; u32 m_pc;
u32 cpu_offset; u32 m_cpu_offset;
CPUDisAsm* disasm; CPUDisAsm* m_disasm;
QLineEdit* t2_instr; QLineEdit* m_instr;
QLabel* t3_preview; QLabel* m_preview;
public: public:
std::weak_ptr<cpu_thread> cpu; std::weak_ptr<cpu_thread> cpu;

View File

@ -97,8 +97,18 @@ void msg_dialog_frame::Create(const std::string& msg)
{ {
m_button_yes->setFocus(); m_button_yes->setFocus();
} }
connect(m_button_yes, &QAbstractButton::clicked, [=] {on_close(CELL_MSGDIALOG_BUTTON_YES); m_dialog->accept(); });
connect(m_button_no, &QAbstractButton::clicked, [=] {on_close(CELL_MSGDIALOG_BUTTON_NO); m_dialog->accept(); }); connect(m_button_yes, &QAbstractButton::clicked, [=]
{
on_close(CELL_MSGDIALOG_BUTTON_YES);
m_dialog->accept();
});
connect(m_button_no, &QAbstractButton::clicked, [=]
{
on_close(CELL_MSGDIALOG_BUTTON_NO);
m_dialog->accept();
});
} }
if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK) if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK)
@ -117,13 +127,31 @@ void msg_dialog_frame::Create(const std::string& msg)
{ {
m_button_ok->setFocus(); m_button_ok->setFocus();
} }
connect(m_button_ok, &QAbstractButton::clicked, [=] { on_close(CELL_MSGDIALOG_BUTTON_OK); m_dialog->accept(); });
connect(m_button_ok, &QAbstractButton::clicked, [=]
{
on_close(CELL_MSGDIALOG_BUTTON_OK);
m_dialog->accept();
});
} }
m_dialog->setLayout(layout); m_dialog->setLayout(layout);
connect(m_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }}); connect(m_dialog, &QDialog::rejected, [=]
connect(m_dialog, &QDialog::destroyed, [=] {if (--dialog_count <= 0) dialog_nr = 0;}); {
if (!type.disable_cancel)
{
on_close(CELL_MSGDIALOG_BUTTON_ESCAPE);
}
});
connect(m_dialog, &QDialog::destroyed, [=]
{
if (--dialog_count <= 0)
{
dialog_nr = 0;
}
});
//Fix size //Fix size
m_dialog->setFixedSize(m_dialog->sizeHint()); m_dialog->setFixedSize(m_dialog->sizeHint());
@ -206,29 +234,29 @@ void msg_dialog_frame::CreateOsk(const std::string& msg, char16_t* osk_text, u32
{ {
static const auto& lineEditWidth = []() {return QLabel("This is the very length of the lineedit due to hidpi reasons.").sizeHint().width(); }; static const auto& lineEditWidth = []() {return QLabel("This is the very length of the lineedit due to hidpi reasons.").sizeHint().width(); };
if (osk_dialog) if (m_osk_dialog)
{ {
osk_dialog->close(); m_osk_dialog->close();
delete osk_dialog; delete m_osk_dialog;
} }
osk_dialog = new custom_dialog(type.disable_cancel); m_osk_dialog = new custom_dialog(type.disable_cancel);
osk_dialog->setModal(true); m_osk_dialog->setModal(true);
osk_text_return = osk_text; m_osk_text_return = osk_text;
//Title //Title
osk_dialog->setWindowTitle(qstr(msg)); m_osk_dialog->setWindowTitle(qstr(msg));
osk_dialog->setWindowFlags(osk_dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); m_osk_dialog->setWindowFlags(m_osk_dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
//Text Input //Text Input
QLineEdit* input = new QLineEdit(osk_dialog); QLineEdit* input = new QLineEdit(m_osk_dialog);
input->setFixedWidth(lineEditWidth()); input->setFixedWidth(lineEditWidth());
input->setMaxLength(charlimit); input->setMaxLength(charlimit);
input->setText(QString::fromStdU16String(std::u16string(osk_text_return))); input->setText(QString::fromStdU16String(std::u16string(m_osk_text_return)));
input->setFocus(); input->setFocus();
//Ok Button //Ok Button
QPushButton* button_ok = new QPushButton("Ok", osk_dialog); QPushButton* button_ok = new QPushButton("Ok", m_osk_dialog);
//Layout //Layout
QHBoxLayout* buttonsLayout = new QHBoxLayout; QHBoxLayout* buttonsLayout = new QHBoxLayout;
@ -237,25 +265,38 @@ void msg_dialog_frame::CreateOsk(const std::string& msg, char16_t* osk_text, u32
buttonsLayout->addWidget(button_ok); buttonsLayout->addWidget(button_ok);
buttonsLayout->addStretch(); buttonsLayout->addStretch();
QFormLayout* layout = new QFormLayout(osk_dialog); QFormLayout* layout = new QFormLayout(m_osk_dialog);
layout->setFormAlignment(Qt::AlignHCenter); layout->setFormAlignment(Qt::AlignHCenter);
layout->addRow(input); layout->addRow(input);
layout->addRow(buttonsLayout); layout->addRow(buttonsLayout);
osk_dialog->setLayout(layout); m_osk_dialog->setLayout(layout);
//Events //Events
connect(input, &QLineEdit::textChanged, [=] { on_osk_input_entered(); }); connect(input, &QLineEdit::textChanged, [=]
connect(input, &QLineEdit::returnPressed, osk_dialog, &QDialog::accept); {
connect(button_ok, &QAbstractButton::clicked, osk_dialog, &QDialog::accept); on_osk_input_entered();
connect(osk_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }}); });
connect(osk_dialog, &QDialog::accepted, [=] {
std::memcpy(osk_text_return, reinterpret_cast<const char16_t*>(input->text().constData()), ((input->text()).size() + 1) * sizeof(char16_t)); connect(input, &QLineEdit::returnPressed, m_osk_dialog, &QDialog::accept);
connect(button_ok, &QAbstractButton::clicked, m_osk_dialog, &QDialog::accept);
connect(m_osk_dialog, &QDialog::rejected, [=]
{
if (!type.disable_cancel)
{
on_close(CELL_MSGDIALOG_BUTTON_ESCAPE);
}
});
connect(m_osk_dialog, &QDialog::accepted, [=]
{
std::memcpy(m_osk_text_return, reinterpret_cast<const char16_t*>(input->text().constData()), ((input->text()).size() + 1) * sizeof(char16_t));
on_close(CELL_MSGDIALOG_BUTTON_OK); on_close(CELL_MSGDIALOG_BUTTON_OK);
}); });
//Fix size //Fix size
osk_dialog->layout()->setSizeConstraint(QLayout::SetFixedSize); m_osk_dialog->layout()->setSizeConstraint(QLayout::SetFixedSize);
osk_dialog->show(); m_osk_dialog->show();
} }
msg_dialog_frame::msg_dialog_frame(QWindow* taskbarTarget) : m_taskbarTarget(taskbarTarget) {} msg_dialog_frame::msg_dialog_frame(QWindow* taskbarTarget) : m_taskbarTarget(taskbarTarget) {}
@ -282,9 +323,9 @@ msg_dialog_frame::~msg_dialog_frame()
{ {
m_dialog->deleteLater(); m_dialog->deleteLater();
} }
if (osk_dialog) if (m_osk_dialog)
{ {
osk_dialog->deleteLater(); m_osk_dialog->deleteLater();
} }
} }

View File

@ -51,10 +51,11 @@ class msg_dialog_frame : public QObject, public MsgDialogBase
QProgressBar* m_gauge1 = nullptr; QProgressBar* m_gauge1 = nullptr;
QProgressBar* m_gauge2 = nullptr; QProgressBar* m_gauge2 = nullptr;
custom_dialog* osk_dialog = nullptr;
char16_t* osk_text_return;
QWindow* m_taskbarTarget; // Window which will be targeted by custom taskbars. QWindow* m_taskbarTarget; // Window which will be targeted by custom taskbars.
custom_dialog* m_osk_dialog = nullptr;
char16_t* m_osk_text_return;
const int m_gauge_max = 100; const int m_gauge_max = 100;
public: public:

View File

@ -13,7 +13,7 @@ constexpr auto qstr = QString::fromStdString;
//Show up the savedata list, either to choose one to save/load or to manage saves. //Show up the savedata list, either to choose one to save/load or to manage saves.
//I suggest to use function callbacks to give save data list or get save data entry. (Not implemented or stubbed) //I suggest to use function callbacks to give save data list or get save data entry. (Not implemented or stubbed)
save_data_list_dialog::save_data_list_dialog(const std::vector<SaveDataEntry>& entries, s32 focusedEntry, bool is_saving, QWidget* parent) save_data_list_dialog::save_data_list_dialog(const std::vector<SaveDataEntry>& entries, s32 focusedEntry, bool is_saving, QWidget* parent)
: QDialog(parent), m_save_entries(entries), m_selectedEntry(-1), selectedEntryLabel(nullptr) : QDialog(parent), m_save_entries(entries), m_entry(-1), m_entry_label(nullptr)
{ {
setWindowTitle(tr("Save Data Interface")); setWindowTitle(tr("Save Data Interface"));
setWindowIcon(QIcon(":/rpcs3.ico")); setWindowIcon(QIcon(":/rpcs3.ico"));
@ -40,15 +40,16 @@ save_data_list_dialog::save_data_list_dialog(const std::vector<SaveDataEntry>& e
push_select->setDefault(true); push_select->setDefault(true);
hbox_action->addWidget(push_select); hbox_action->addWidget(push_select);
selectedEntryLabel = new QLabel(this); m_entry_label = new QLabel(this);
UpdateSelectionLabel(); UpdateSelectionLabel();
} }
if (is_saving) if (is_saving)
{ {
QPushButton *saveNewEntry = new QPushButton(tr("Save New Entry"), this); QPushButton *saveNewEntry = new QPushButton(tr("Save New Entry"), this);
connect(saveNewEntry, &QAbstractButton::clicked, this, [&]() { connect(saveNewEntry, &QAbstractButton::clicked, this, [&]()
m_selectedEntry = -1; // Set the return properly. {
m_entry = -1; // Set the return properly.
accept(); accept();
}); });
hbox_action->addWidget(saveNewEntry); hbox_action->addWidget(saveNewEntry);
@ -63,23 +64,22 @@ save_data_list_dialog::save_data_list_dialog(const std::vector<SaveDataEntry>& e
// events // events
connect(push_cancel, &QAbstractButton::clicked, this, &save_data_list_dialog::close); connect(push_cancel, &QAbstractButton::clicked, this, &save_data_list_dialog::close);
connect(m_list, &QTableWidget::itemDoubleClicked, this, &save_data_list_dialog::OnEntryInfo); connect(m_list, &QTableWidget::itemDoubleClicked, this, &save_data_list_dialog::OnEntryInfo);
connect(m_list, &QTableWidget::currentCellChanged, this, [&](int cr, int cc, int pr, int pc) { connect(m_list, &QTableWidget::currentCellChanged, this, [&](int cr, int cc, int pr, int pc)
m_selectedEntry = cr; {
m_entry = cr;
UpdateSelectionLabel(); UpdateSelectionLabel();
Q_UNUSED(cr); Q_UNUSED(pr); Q_UNUSED(pc); Q_UNUSED(cr); Q_UNUSED(pr); Q_UNUSED(pc);
}); });
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, [=](int col) { connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_data_list_dialog::OnSort);
OnSort(col);
});
// main layout // main layout
QVBoxLayout* vbox_main = new QVBoxLayout(); QVBoxLayout* vbox_main = new QVBoxLayout();
vbox_main->setAlignment(Qt::AlignCenter); vbox_main->setAlignment(Qt::AlignCenter);
vbox_main->addWidget(m_list); vbox_main->addWidget(m_list);
if (selectedEntryLabel != nullptr) if (m_entry_label != nullptr)
{ {
vbox_main->addWidget(selectedEntryLabel); vbox_main->addWidget(m_entry_label);
} }
vbox_main->addLayout(hbox_action); vbox_main->addLayout(hbox_action);
setLayout(vbox_main); setLayout(vbox_main);
@ -102,16 +102,16 @@ save_data_list_dialog::save_data_list_dialog(const std::vector<SaveDataEntry>& e
void save_data_list_dialog::UpdateSelectionLabel() void save_data_list_dialog::UpdateSelectionLabel()
{ {
if (selectedEntryLabel != nullptr) if (m_entry_label != nullptr)
{ {
if (m_list->currentRow() == -1) if (m_list->currentRow() == -1)
{ {
selectedEntryLabel->setText(tr("Currently Selected: None")); m_entry_label->setText(tr("Currently Selected: None"));
} }
else else
{ {
int entry = m_list->item(m_list->currentRow(), 0)->data(Qt::UserRole).toInt(); int entry = m_list->item(m_list->currentRow(), 0)->data(Qt::UserRole).toInt();
selectedEntryLabel->setText(tr("Currently Selected: ") + qstr(m_save_entries[entry].dirName)); m_entry_label->setText(tr("Currently Selected: ") + qstr(m_save_entries[entry].dirName));
} }
} }
} }
@ -121,32 +121,32 @@ s32 save_data_list_dialog::GetSelection()
int res = result(); int res = result();
if (res == QDialog::Accepted) if (res == QDialog::Accepted)
{ {
if (m_selectedEntry == -1) if (m_entry == -1)
{ // Save new entry { // Save new entry
return -1; return -1;
} }
return m_list->item(m_selectedEntry, 0)->data(Qt::UserRole).toInt(); return m_list->item(m_entry, 0)->data(Qt::UserRole).toInt();
} }
// Cancel is pressed. May promote to enum or figure out proper cellsavedata code to use later. // Cancel is pressed. May promote to enum or figure out proper cellsavedata code to use later.
return -2; return -2;
} }
void save_data_list_dialog::OnSort(int idx) void save_data_list_dialog::OnSort(int logicalIndex)
{ {
if (idx >= 0) if (logicalIndex >= 0)
{ {
if (idx == m_sortColumn) if (logicalIndex == m_sort_column)
{ {
m_sortAscending ^= true; m_sort_ascending ^= true;
} }
else else
{ {
m_sortAscending = true; m_sort_ascending = true;
} }
Qt::SortOrder colSortOrder = m_sortAscending ? Qt::AscendingOrder : Qt::DescendingOrder; Qt::SortOrder sort_order = m_sort_ascending ? Qt::AscendingOrder : Qt::DescendingOrder;
m_list->sortByColumn(m_sortColumn, colSortOrder); m_list->sortByColumn(m_sort_column, sort_order);
m_sortColumn = idx; m_sort_column = logicalIndex;
} }
} }

View File

@ -22,17 +22,17 @@ public:
s32 GetSelection(); s32 GetSelection();
private Q_SLOTS: private Q_SLOTS:
void OnEntryInfo(); void OnEntryInfo();
void OnSort(int logicalIndex);
private: private:
void UpdateSelectionLabel(void); void UpdateSelectionLabel(void);
void UpdateList(void); void UpdateList(void);
void OnSort(int id);
s32 m_selectedEntry; s32 m_entry;
QLabel* selectedEntryLabel; QLabel* m_entry_label;
QTableWidget* m_list; QTableWidget* m_list;
std::vector<SaveDataEntry> m_save_entries; std::vector<SaveDataEntry> m_save_entries;
int m_sortColumn; int m_sort_column;
bool m_sortAscending; bool m_sort_ascending;
}; };

View File

@ -77,7 +77,7 @@ namespace
} }
save_manager_dialog::save_manager_dialog(std::string dir, QWidget* parent) : QDialog(parent), save_manager_dialog::save_manager_dialog(std::string dir, QWidget* parent) : QDialog(parent),
m_save_entries(), m_dir(dir), m_sortColumn(1), m_sortAscending(true) m_save_entries(), m_dir(dir), m_sort_column(1), m_sort_ascending(true)
{ {
setWindowTitle(tr("Save Manager")); setWindowTitle(tr("Save Manager"));
setWindowIcon(QIcon(":/rpcs3.ico")); setWindowIcon(QIcon(":/rpcs3.ico"));
@ -121,13 +121,10 @@ void save_manager_dialog::Init(std::string dir)
// Connects and events // Connects and events
connect(push_close, &QAbstractButton::clicked, this, &save_manager_dialog::close); connect(push_close, &QAbstractButton::clicked, this, &save_manager_dialog::close);
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_manager_dialog::OnSort);
connect(m_list, &QTableWidget::itemDoubleClicked, this, &save_manager_dialog::OnEntryInfo); connect(m_list, &QTableWidget::itemDoubleClicked, this, &save_manager_dialog::OnEntryInfo);
connect(m_list, &QTableWidget::customContextMenuRequested, this, &save_manager_dialog::ShowContextMenu); connect(m_list, &QTableWidget::customContextMenuRequested, this, &save_manager_dialog::ShowContextMenu);
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, [=](int col) {
OnSort(col);
});
connect(m_list, &QTableWidget::cellChanged, [&](int row, int col) connect(m_list, &QTableWidget::cellChanged, [&](int row, int col)
{ {
int originalIndex = m_list->item(row, 0)->data(Qt::UserRole).toInt(); int originalIndex = m_list->item(row, 0)->data(Qt::UserRole).toInt();
@ -203,21 +200,21 @@ void save_manager_dialog::UpdateList()
/** /**
* Copied method to do sort from save_data_list_dialog * Copied method to do sort from save_data_list_dialog
*/ */
void save_manager_dialog::OnSort(int idx) void save_manager_dialog::OnSort(int logicalIndex)
{ {
if (idx >= 0) if (logicalIndex >= 0)
{ {
if (idx == m_sortColumn) if (logicalIndex == m_sort_column)
{ {
m_sortAscending ^= true; m_sort_ascending ^= true;
} }
else else
{ {
m_sortAscending = true; m_sort_ascending = true;
} }
Qt::SortOrder colSortOrder = m_sortAscending ? Qt::AscendingOrder : Qt::DescendingOrder; Qt::SortOrder sort_order = m_sort_ascending ? Qt::AscendingOrder : Qt::DescendingOrder;
m_list->sortByColumn(m_sortColumn, colSortOrder); m_list->sortByColumn(m_sort_column, sort_order);
m_sortColumn = idx; m_sort_column = logicalIndex;
} }
} }
@ -258,11 +255,11 @@ void save_manager_dialog::ShowContextMenu(const QPoint &pos)
QMenu* menu = new QMenu(); QMenu* menu = new QMenu();
int idx = m_list->currentRow(); int idx = m_list->currentRow();
saveIDAct = new QAction(tr("SaveID"), this); QAction* saveIDAct = new QAction(tr("SaveID"), this);
titleAct = new QAction(tr("Title"), this); QAction* titleAct = new QAction(tr("Title"), this);
subtitleAct = new QAction(tr("Subtitle"), this); QAction* subtitleAct = new QAction(tr("Subtitle"), this);
removeAct = new QAction(tr("&Remove"), this); QAction* removeAct = new QAction(tr("&Remove"), this);
infoAct = new QAction(tr("&Info"), this); QAction* infoAct = new QAction(tr("&Info"), this);
//This is also a stub for the sort setting. Ids is set according to their sort-type integer. //This is also a stub for the sort setting. Ids is set according to their sort-type integer.
m_sort_options = new QMenu(tr("&Sort")); m_sort_options = new QMenu(tr("&Sort"));

View File

@ -21,12 +21,11 @@ public:
private Q_SLOTS: private Q_SLOTS:
void OnEntryInfo(); void OnEntryInfo();
void OnEntryRemove(); void OnEntryRemove();
void OnSort(int logicalIndex);
private: private:
void Init(std::string dir); void Init(std::string dir);
void UpdateList(); void UpdateList();
void OnSort(int id);
void ShowContextMenu(const QPoint &pos); void ShowContextMenu(const QPoint &pos);
QTableWidget* m_list; QTableWidget* m_list;
@ -35,12 +34,6 @@ private:
QMenu* m_sort_options; QMenu* m_sort_options;
int m_sortColumn; int m_sort_column;
bool m_sortAscending; bool m_sort_ascending;
QAction* saveIDAct;
QAction* titleAct;
QAction* subtitleAct;
QAction* removeAct;
QAction* infoAct;
}; };

View File

@ -12,7 +12,7 @@ inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString();
vfs_dialog::vfs_dialog(QWidget* parent) : QDialog(parent), vfs_dialog::vfs_dialog(QWidget* parent) : QDialog(parent),
m_gui_settings(), m_emu_settings("") m_gui_settings(), m_emu_settings("")
{ {
tabs = new QTabWidget(); QTabWidget* tabs = new QTabWidget();
tabs->setUsesScrollButtons(false); tabs->setUsesScrollButtons(false);
// Create tabs // Create tabs
@ -39,25 +39,32 @@ vfs_dialog::vfs_dialog(QWidget* parent) : QDialog(parent),
// Create buttons // Create buttons
QPushButton* addDir = new QPushButton(tr("Add New Directory")); QPushButton* addDir = new QPushButton(tr("Add New Directory"));
connect(addDir, &QAbstractButton::pressed, [this]() { connect(addDir, &QAbstractButton::pressed, [=]
{
static_cast<vfs_dialog_tab*>(tabs->currentWidget())->AddNewDirectory(); static_cast<vfs_dialog_tab*>(tabs->currentWidget())->AddNewDirectory();
}); });
QPushButton* reset = new QPushButton(tr("Reset")); QPushButton* reset = new QPushButton(tr("Reset"));
connect(reset, &QAbstractButton::pressed, [this]() { connect(reset, &QAbstractButton::pressed, [=]
{
static_cast<vfs_dialog_tab*>(tabs->currentWidget())->Reset(); static_cast<vfs_dialog_tab*>(tabs->currentWidget())->Reset();
}); });
QPushButton* resetAll = new QPushButton(tr("Reset All")); QPushButton* resetAll = new QPushButton(tr("Reset All"));
connect(resetAll, &QAbstractButton::pressed, [this]() { connect(resetAll, &QAbstractButton::pressed, [=]
{
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* okay = new QPushButton(tr("Okay"));
okay->setAutoDefault(true); okay->setAutoDefault(true);
okay->setDefault(true); okay->setDefault(true);
connect(okay, &QAbstractButton::pressed, [this]() { connect(okay, &QAbstractButton::pressed, [=]
{
for (int i = 0; i < tabs->count(); ++i) for (int i = 0; i < tabs->count(); ++i)
{ {
static_cast<vfs_dialog_tab*>(tabs->widget(i))->SaveSettings(); static_cast<vfs_dialog_tab*>(tabs->widget(i))->SaveSettings();

View File

@ -15,6 +15,4 @@ public:
private: private:
gui_settings m_gui_settings; gui_settings m_gui_settings;
emu_settings m_emu_settings; emu_settings m_emu_settings;
QTabWidget* tabs;
}; };