1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Qt: Fix vfs dialog reset and add some translations

Reset would crash the app, because a cleared item received a signal on currentItemChanged.
Also, Reset did not reset the list as one might think, but clean it and then result in wrong behaviour.
Furthermore the settings were saved, regardless of accepting the dialog or not.
This commit is contained in:
Megamouse 2018-04-07 19:36:54 +02:00 committed by Ani
parent 78bb9a7278
commit 69b5f25644
2 changed files with 18 additions and 16 deletions

View File

@ -31,10 +31,8 @@ vfs_dialog_tab::vfs_dialog_tab(const vfs_settings_info& settingsInfo, std::share
m_dirList->setMinimumWidth(m_dirList->sizeHintForColumn(0));
QHBoxLayout* selectedConfigLayout = new QHBoxLayout;
QLabel* selectedMessage = new QLabel(m_info.name + " directory:");
m_selectedConfigLabel = new QLabel();
m_selectedConfigLabel->setText(current_dir.isEmpty() ? EmptyPath : current_dir);
selectedConfigLayout->addWidget(selectedMessage);
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();
@ -46,6 +44,9 @@ vfs_dialog_tab::vfs_dialog_tab(const vfs_settings_info& settingsInfo, std::share
connect(m_dirList, &QListWidget::currentItemChanged, [this](QListWidgetItem* current, QListWidgetItem*)
{
if (!current)
return;
m_selectedConfigLabel->setText(current->text().isEmpty() ? EmptyPath : current->text());
});
}
@ -66,21 +67,19 @@ void vfs_dialog_tab::SetSettings()
void vfs_dialog_tab::Reset()
{
const QString current_dir = qstr(m_info.cfg_node->to_string());
m_dirList->clear();
m_info.cfg_node->from_default();
m_selectedConfigLabel->setText(current_dir.isEmpty() ? EmptyPath : current_dir);
m_dirList->addItem(new QListWidgetItem(current_dir));
m_gui_settings->SetValue(m_info.listLocation, QStringList(current_dir));
m_dirList->setCurrentItem(new QListWidgetItem(qstr(m_info.cfg_node->def), m_dirList));
}
void vfs_dialog_tab::AddNewDirectory()
{
QString dir = QFileDialog::getExistingDirectory(nullptr, "Choose a directory", QCoreApplication::applicationDirPath());
if (dir != "")
{
if (dir.endsWith("/") == false) dir += '/';
new QListWidgetItem(dir, m_dirList);
m_selectedConfigLabel->setText(dir);
}
QString dir = QFileDialog::getExistingDirectory(nullptr, tr("Choose a directory"), QCoreApplication::applicationDirPath());
if (dir.isEmpty())
return;
if (!dir.endsWith("/"))
dir += '/';
m_dirList->setCurrentItem(new QListWidgetItem(dir, m_dirList));
}

View File

@ -27,7 +27,10 @@ public:
void SetSettings();
void AddNewDirectory();
// Reset this tab without saving the settings yet
void Reset();
private:
const QString EmptyPath = tr("Empty Path");