Merge pull request #9450 from Filoppi/patch-12

Qt: Fix stock input profiles being deletable
This commit is contained in:
Léo Lam 2021-01-27 19:18:51 +01:00 committed by GitHub
commit 42b55e8fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 5 deletions

View File

@ -16,6 +16,7 @@
#include "Core/Core.h"
#include "Common/CommonPaths.h"
#include "Common/FileSearch.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
@ -195,7 +196,9 @@ void MappingWindow::UpdateProfileButtonState()
if (m_profiles_combo->findText(m_profiles_combo->currentText()) != -1)
{
const QString profile_path = m_profiles_combo->currentData().toString();
builtin = profile_path.startsWith(QString::fromStdString(File::GetSysDirectory()));
std::string sys_dir = File::GetSysDirectory();
sys_dir = ReplaceAll(sys_dir, "\\", DIR_SEP);
builtin = profile_path.startsWith(QString::fromStdString(sys_dir));
}
m_profiles_save->setEnabled(!builtin);
@ -459,7 +462,8 @@ void MappingWindow::PopulateProfileSelection()
{
std::string basename;
SplitPath(filename, nullptr, &basename, nullptr);
m_profiles_combo->addItem(QString::fromStdString(basename), QString::fromStdString(filename));
if (!basename.empty()) // Ignore files with an empty name to avoid multiple problems
m_profiles_combo->addItem(QString::fromStdString(basename), QString::fromStdString(filename));
}
m_profiles_combo->insertSeparator(m_profiles_combo->count());
@ -470,9 +474,12 @@ void MappingWindow::PopulateProfileSelection()
{
std::string basename;
SplitPath(filename, nullptr, &basename, nullptr);
// i18n: "Stock" refers to input profiles included with Dolphin
m_profiles_combo->addItem(tr("%1 (Stock)").arg(QString::fromStdString(basename)),
QString::fromStdString(filename));
if (!basename.empty())
{
// i18n: "Stock" refers to input profiles included with Dolphin
m_profiles_combo->addItem(tr("%1 (Stock)").arg(QString::fromStdString(basename)),
QString::fromStdString(filename));
}
}
m_profiles_combo->setCurrentIndex(-1);