Skip to content

Commit

Permalink
Merge pull request #195 from Alia5/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Alia5 authored Nov 10, 2022
2 parents 9232eea + 128e7f4 commit fb64104
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 57 deletions.
156 changes: 152 additions & 4 deletions GlosSIConfig/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -1252,6 +1252,154 @@ IDI_ICON1 ICON "..\GlosSI_Icon.ico"


























































































































































Expand Down
18 changes: 13 additions & 5 deletions GlosSIConfig/UIModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ limitations under the License.
#include <shlobj.h>
#endif

#include "ExeImageProvider.h"
#include "ExeImageProvider.h"
#include "../version.hpp"

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 "";
Expand Down
6 changes: 3 additions & 3 deletions GlosSIConfig/UIModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand Down
104 changes: 60 additions & 44 deletions GlosSIConfig/qml/ShortcutCards.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit fb64104

Please sign in to comment.