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
FILEVERSION 0,1,1,002004500680
PRODUCTVERSION 0,1,1,002004500680
FILEVERSION 0,1,1,101000823500
PRODUCTVERSION 0,1,1,101000823500
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.0-2-g45bd68e"
VALUE "FileVersion", "0.1.1.1-1-ga8235ca"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.1.1.0-2-g45bd68e"
VALUE "ProductVersion", "0.1.1.1-1-ga8235ca"
END
END
BLOCK "VarFileInfo"
@ -1252,6 +1252,154 @@ IDI_ICON1 ICON "..\GlosSI_Icon.ico"

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

@ -49,14 +49,14 @@ class UIModel : public QObject {
Q_INVOKABLE bool updateTarget(int index, QVariant shortcut);
Q_INVOKABLE void deleteTarget(int index);
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);
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 QVariantMap manualProps(QVariant shortcut);
Q_INVOKABLE void enableSteamInputXboxSupport();
Q_INVOKABLE bool restartSteam();
Q_INVOKABLE bool restartSteam(const QString& steamURL = "");
Q_INVOKABLE void updateCheck();
@ -69,7 +69,7 @@ class UIModel : public QObject {
Q_INVOKABLE QVariantList egsGamesList() const;
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,
const std::wstring& shortcutspath, bool is_admin_try = false) const;

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

Loading…
Cancel
Save