Fix shortcut names not editable

pull/212/head
Peter Repukat 1 year ago
parent efdcc8f881
commit 924a7ecba7

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,1,101000823500
PRODUCTVERSION 0,1,1,101000823500
FILEVERSION 0,1,1,204000619719
PRODUCTVERSION 0,1,1,204000619719
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.1.1.1-1-ga8235ca"
VALUE "FileVersion", "0.1.1.2-4-gf619719"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.1.1.1-1-ga8235ca"
VALUE "ProductVersion", "0.1.1.2-4-gf619719"
END
END
BLOCK "VarFileInfo"
@ -1400,6 +1400,42 @@ IDI_ICON1 ICON "..\GlosSI_Icon.ico"

@ -115,6 +115,8 @@ bool UIModel::updateTarget(int index, QVariant shortcut)
const auto map = shortcut.toMap();
const auto json = QJsonObject::fromVariantMap(map);
const auto was_in_steam_ = isInSteam(shortcut);
auto oldSteamName = targets_[index].toMap()["name"].toString();
auto oldName =
targets_[index].toMap()["name"].toString().replace(QRegularExpression("[\\\\/:*?\"<>|]"), "") + ".json";
@ -132,15 +134,19 @@ bool UIModel::updateTarget(int index, QVariant shortcut)
path /= config_dir_name_.toStdString();
path /= (map["name"].toString()).toStdString();
if (removeFromSteam(oldSteamName, QString::fromStdWString(path.wstring()))) {
if (!addToSteam(shortcut, QString::fromStdWString(path.wstring()))) {
qDebug() << "Couldn't add shortcut \"" << (map["name"].toString()) << "\" to Steam when updating";
return false;
if (was_in_steam_) {
if (removeFromSteam(oldSteamName, QString::fromStdWString(path.wstring()))) {
if (!addToSteam(shortcut, QString::fromStdWString(path.wstring()))) {
qDebug() << "Couldn't add shortcut \"" << (map["name"].toString()) << "\" to Steam when updating";
return false;
}
return true;
}
qDebug() << "Couldn't remove shortcut \"" << oldName << "\" from Steam when updating";
return false;
} else {
return true;
}
qDebug() << "Couldn't remove shortcut \"" << oldName << "\" from Steam when updating";
return false;
}
void UIModel::deleteTarget(int index)
@ -159,7 +165,9 @@ bool UIModel::isInSteam(QVariant shortcut) const
{
const auto map = shortcut.toMap();
for (auto& steam_shortcut : shortcuts_vdf_) {
if (map["name"].toString() == QString::fromStdString(steam_shortcut.appname)) {
if (
map["name"].toString() == QString::fromStdString(steam_shortcut.appname) ||
map["oldName"].toString() == QString::fromStdString(steam_shortcut.appname)) {
if (QString::fromStdString(steam_shortcut.exe).toLower().contains("glossitarget.exe")) {
return true;
}

@ -136,7 +136,11 @@ Item {
id: nameInput
placeholderText: qsTr("...")
text: shortcutInfo.name
onTextChanged: shortcutInfo.name = text
onTextChanged: function() {
shortcutInfo.oldName = shortcutInfo.oldName || shortcutInfo.name
shortcutInfo.name = nameInput.text
shortcutInfo = shortcutInfo
}
validator: RegularExpressionValidator { regularExpression: /([0-z]|\s|.)+/gm }
}
}

@ -492,12 +492,12 @@ Window {
if (windowContent.editedIndex < 0) {
uiModel.addTarget(shortcut)
} else {
if (uiModel.isInSteam(shortcut)) {
if (uiModel.updateTarget(windowContent.editedIndex, shortcut)) {
if (steamShortcutsChanged == false) {
steamChangedDialog.open();
}
} else {
if (uiModel.updateTarget(windowContent.editedIndex, shortcut)) {
if (uiModel.isInSteam(shortcut) && steamShortcutsChanged == false) {
steamChangedDialog.open();
}
} else {
if (uiModel.isInSteam(shortcut)) {
manualInfo = uiModel.manualProps(shortcut);
writeErrorDialog.open();
}

Loading…
Cancel
Save