GlosSIConfig: Allow special chars in shortcut names

pull/148/head
Peter Repukat 2 years ago
parent 9e616ae13e
commit e57f83f78c

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,4,001005510001
PRODUCTVERSION 0,0,4,001005510001
FILEVERSION 0,0,4,1
PRODUCTVERSION 0,0,4,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.0.4.0-1-g5510a01"
VALUE "FileVersion", "0.0.4.1"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSi"
VALUE "ProductVersion", "0.0.4.0-1-g5510a01"
VALUE "ProductVersion", "0.0.4.1"
END
END
BLOCK "VarFileInfo"
@ -910,6 +910,26 @@ END

@ -83,7 +83,7 @@ void UIModel::readConfigs()
json["maxFps"] = filejson["window"]["maxFps"];
json["scale"] = filejson["window"]["scale"];
json["name"] = QString(name).replace(QRegularExpression("\\.json"), "");
json["name"] = filejson.contains("name") ? filejson["name"] : QString(name).replace(QRegularExpression("\\.json"), "");
targets_.append(json.toVariantMap());
});
@ -110,7 +110,7 @@ void UIModel::updateTarget(int index, QVariant shortcut)
const auto map = shortcut.toMap();
const auto json = QJsonObject::fromVariantMap(map);
auto oldName = targets_[index].toMap()["name"].toString() + ".json";
auto oldName = targets_[index].toMap()["name"].toString().replace(QRegularExpression("[\\\\/:*?\"<>|]"), "") + ".json";
auto path = config_path_;
path /= config_dir_name_.toStdString();
path /= (oldName).toStdString();
@ -124,7 +124,7 @@ void UIModel::updateTarget(int index, QVariant shortcut)
void UIModel::deleteTarget(int index)
{
auto oldName = targets_[index].toMap()["name"].toString() + ".json";
auto oldName = targets_[index].toMap()["name"].toString().replace(QRegularExpression("[\\\\/:*?\"<>|]"), "") + ".json";
auto path = config_path_;
path /= config_dir_name_.toStdString();
path /= (oldName).toStdString();
@ -211,7 +211,7 @@ bool UIModel::addToSteam(const QString& name, const QString& shortcutspath, bool
qDebug() << "trying to add " << name << " to steam";
const auto target = std::find_if(targets_.begin(), targets_.end(), [&name](const auto& target) {
const auto map = target.toMap();
const auto target_name = map["name"].toString();
const auto target_name = map["name"].toString().replace(QRegularExpression("[\\\\/:*?\"<>|]"), "");
return name == target_name;
});
if (target != targets_.end()) {
@ -240,7 +240,7 @@ QVariantMap UIModel::manualProps(QVariant shortcut)
{
QDir appDir = QGuiApplication::applicationDirPath();
const auto map = shortcut.toMap();
const auto name = map["name"].toString();
const auto name = map["name"].toString().replace(QRegularExpression("[\\\\/:*?\"<>|]"), "");
const auto maybeLaunchPath = map["launchPath"].toString();
const auto launch = map["launch"].toBool();
@ -337,7 +337,7 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name)
{
auto path = config_path_;
path /= config_dir_name_.toStdWString();
path /= (name + ".json").toStdWString();
path /= (QString(name).replace(QRegularExpression("[\\\\/:*?\"<>|]"), "") + ".json").toStdWString();
QFile file(path);
if (!file.open(QIODevice::Text | QIODevice::ReadWrite)) {
// meh
@ -346,6 +346,7 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name)
QJsonObject fileJson;
fileJson["version"] = json["version"];
fileJson["icon"] = json["icon"];
fileJson["name"] = json["name"];
QJsonObject launchObject;
launchObject["launch"] = json["launch"];

Loading…
Cancel
Save