GlosSIConfig: Open Steam controller configurator from GlosSI

pull/195/head
Peter Repukat 2 years ago
parent a8235ca9c9
commit 5176dab9be

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

@ -33,7 +33,6 @@ limitations under the License.
#include <shlobj.h> #include <shlobj.h>
#endif #endif
#include "ExeImageProvider.h"
#include "ExeImageProvider.h" #include "ExeImageProvider.h"
#include "../version.hpp" #include "../version.hpp"
@ -170,7 +169,7 @@ bool UIModel::isInSteam(QVariant shortcut) const
return false; return false;
} }
uint32_t UIModel::getAppId(QVariant shortcut) const uint32_t UIModel::getAppId(QVariant shortcut)
{ {
if (!isInSteam(shortcut)) { if (!isInSteam(shortcut)) {
return 0; return 0;
@ -179,6 +178,10 @@ uint32_t UIModel::getAppId(QVariant shortcut) const
for (auto& steam_shortcut : shortcuts_vdf_) { for (auto& steam_shortcut : shortcuts_vdf_) {
if (map["name"].toString() == QString::fromStdString(steam_shortcut.appname)) { if (map["name"].toString() == QString::fromStdString(steam_shortcut.appname)) {
if (QString::fromStdString(steam_shortcut.exe).toLower().contains("glossitarget.exe")) { if (QString::fromStdString(steam_shortcut.exe).toLower().contains("glossitarget.exe")) {
if (steam_shortcut.appid == 0) {
parseShortcutVDF();
return getAppId(shortcut);
}
return steam_shortcut.appid; return steam_shortcut.appid;
} }
} }
@ -323,13 +326,18 @@ void UIModel::enableSteamInputXboxSupport()
} }
} }
bool UIModel::restartSteam() bool UIModel::restartSteam(const QString& steamURL)
{ {
const auto path = getSteamPath(); const auto path = getSteamPath();
if (QProcess::execute("taskkill.exe", {"/im", steam_executable_name_, "/f"}) != 0) { if (QProcess::execute("taskkill.exe", {"/im", steam_executable_name_, "/f"}) != 0) {
return false; return false;
} }
QProcess::startDetached(QString::fromStdWString(path) + "/" + steam_executable_name_); if (steamURL.isEmpty()) {
QProcess::startDetached(QString::fromStdWString(path) + "/" + steam_executable_name_);
}
else {
system((QString::fromLatin1("start ") + steamURL).toStdString().c_str());
}
return true; return true;
} }
@ -499,7 +507,7 @@ void UIModel::loadSteamGridImages()
steamgrid_proc_.write("\n"); steamgrid_proc_.write("\n");
} }
QString UIModel::getGridImagePath(QVariant shortcut) const QString UIModel::getGridImagePath(QVariant shortcut)
{ {
if (!foundSteam()) { if (!foundSteam()) {
return ""; return "";

@ -49,14 +49,14 @@ class UIModel : public QObject {
Q_INVOKABLE bool updateTarget(int index, QVariant shortcut); Q_INVOKABLE bool updateTarget(int index, QVariant shortcut);
Q_INVOKABLE void deleteTarget(int index); Q_INVOKABLE void deleteTarget(int index);
Q_INVOKABLE bool isInSteam(QVariant shortcut) const; Q_INVOKABLE bool isInSteam(QVariant shortcut) const;
Q_INVOKABLE uint32_t getAppId(QVariant shortcut) const; Q_INVOKABLE uint32_t getAppId(QVariant shortcut);
Q_INVOKABLE bool addToSteam(QVariant shortcut, const QString& shortcutspath, bool from_cmd = false); Q_INVOKABLE bool addToSteam(QVariant shortcut, const QString& shortcutspath, bool from_cmd = false);
bool addToSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false); bool addToSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false);
Q_INVOKABLE bool removeFromSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false); Q_INVOKABLE bool removeFromSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false);
Q_INVOKABLE QVariantMap manualProps(QVariant shortcut); Q_INVOKABLE QVariantMap manualProps(QVariant shortcut);
Q_INVOKABLE void enableSteamInputXboxSupport(); Q_INVOKABLE void enableSteamInputXboxSupport();
Q_INVOKABLE bool restartSteam(); Q_INVOKABLE bool restartSteam(const QString& steamURL = "");
Q_INVOKABLE void updateCheck(); Q_INVOKABLE void updateCheck();
@ -69,7 +69,7 @@ class UIModel : public QObject {
Q_INVOKABLE QVariantList egsGamesList() const; Q_INVOKABLE QVariantList egsGamesList() const;
Q_INVOKABLE void loadSteamGridImages(); Q_INVOKABLE void loadSteamGridImages();
Q_INVOKABLE QString getGridImagePath(QVariant shortcut) const; Q_INVOKABLE QString getGridImagePath(QVariant shortcut);
[[nodiscard]] bool writeShortcutsVDF(const std::wstring& mode, const std::wstring& name, [[nodiscard]] bool writeShortcutsVDF(const std::wstring& mode, const std::wstring& name,
const std::wstring& shortcutspath, bool is_admin_try = false) const; const std::wstring& shortcutspath, bool is_admin_try = false) const;

@ -34,7 +34,7 @@ GridView {
property real margins: 16 property real margins: 16
cellWidth: 292 + 16 cellWidth: 292 + 16
cellHeight: 190 + 16 cellHeight: 212 + 16
readonly property real displayedItems: Math.floor((parent.width - margins*2) / cellWidth) readonly property real displayedItems: Math.floor((parent.width - margins*2) / cellWidth)
width: displayedItems * cellWidth width: displayedItems * cellWidth
model: uiModel.targetList; model: uiModel.targetList;
@ -72,7 +72,7 @@ GridView {
bgOpacity: 0.3 bgOpacity: 0.3
radius: 8 radius: 8
width: 292 width: 292
height: 190 height: 212
Material.elevation: 4 Material.elevation: 4
clip: true clip: true
property bool isInSteam: uiModel.isInSteam(modelData); property bool isInSteam: uiModel.isInSteam(modelData);
@ -145,57 +145,73 @@ GridView {
} }
} }
Button { Column {
id: steambutton anchors.left: parent.left
anchors.left: parent.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: 72 spacing: 4
onClicked: function(){
if (delegateRoot.isInSteam) { Button {
if (!uiModel.removeFromSteam(modelData.name, "")) { highlighted: true
writeErrorDialog.open(); visible: delegateRoot.isInSteam
return; text: qsTr("Steam controller config")
} onClicked: function() {
} else { controllerConfigDialog.confirmedExtraParam = uiModel.getAppId(modelData)
if (!uiModel.addToSteam(modelData, "")) { controllerConfigDialog.confirmedParam = uiModel.getAppId(modelData)
manualInfo = uiModel.manualProps(modelData); controllerConfigDialog.open();
writeErrorDialog.open();
return;
}
}
if (steamShortcutsChanged == false) {
steamChangedDialog.open();
} }
delegateRoot.isInSteam = uiModel.isInSteam(modelData)
steamShortcutsChanged = true
} }
highlighted: delegateRoot.isInSteam
Material.accent: Material.color(Material.Red, Material.Shade800) Button {
Row { id: steambutton
anchors.centerIn: parent width: 72
spacing: 8 onClicked: function(){
Label { if (delegateRoot.isInSteam) {
anchors.verticalCenter: parent.verticalCenter if (!uiModel.removeFromSteam(modelData.name, "")) {
text: delegateRoot.isInSteam ? "-" : "+" writeErrorDialog.open();
font.bold: true return;
font.pixelSize: 24 }
} else {
if (!uiModel.addToSteam(modelData, "")) {
manualInfo = uiModel.manualProps(modelData);
writeErrorDialog.open();
return;
}
}
if (steamShortcutsChanged == false) {
steamChangedDialog.open();
}
delegateRoot.isInSteam = uiModel.isInSteam(modelData)
steamShortcutsChanged = true
} }
Image { highlighted: delegateRoot.isInSteam
anchors.verticalCenter: parent.verticalCenter Material.accent: Material.color(Material.Red, Material.Shade800)
source: "qrc:/svg/steam.svg" Row {
width: 22 anchors.centerIn: parent
height: 22 spacing: 8
smooth: true Label {
mipmap: true anchors.verticalCenter: parent.verticalCenter
ColorOverlay { text: delegateRoot.isInSteam ? "-" : "+"
anchors.fill: parent font.bold: true
source: parent font.pixelSize: 24
color: "white" }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/svg/steam.svg"
width: 22
height: 22
smooth: true
mipmap: true
ColorOverlay {
anchors.fill: parent
source: parent
color: "white"
}
} }
} }
} }
} }
Row { Row {
id: buttonrow id: buttonrow
anchors.right: parent.right anchors.right: parent.right

@ -266,6 +266,23 @@ Window {
} }
} }
InfoDialog {
id: controllerConfigDialog
titleText: qsTr("Open Steam controller config")
text: qsTr("Steams controller config can only open if a controller is connected")
+ "\n"
+ qsTr("and the shortcut is visible in Steam (Steam restarted after adding).")
buttonText: qsTr("Open")
extraButton: true
extraButtonText: qsTr("Restart and open")
onConfirmedExtra: function(data) {
uiModel.restartSteam("steam://currentcontrollerconfig/" + data + "/")
}
onConfirmed: function(data) {
Qt.openUrlExternally("steam://currentcontrollerconfig/" + data + "/");
}
}
Rectangle { Rectangle {
id: titleBar id: titleBar
visible: uiModel.isWindows visible: uiModel.isWindows

Loading…
Cancel
Save