From 3458f907cabaf231be0ef032cdd8839874eaf964 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 15 Oct 2022 16:06:34 +0200 Subject: [PATCH] GlosSIConfig: Show non-Steam-Shortcut AppIDs in Debug builds --- GlosSIConfig/UIModel.cpp | 25 +++++++++++++++++++++++++ GlosSIConfig/UIModel.h | 3 +++ GlosSIConfig/qml/ShortcutCards.qml | 26 +++----------------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index ee5ad7e..0fe35a7 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -167,6 +167,22 @@ bool UIModel::isInSteam(QVariant shortcut) return false; } +uint32_t UIModel::getAppId(QVariant shortcut) +{ + if (!isInSteam(shortcut)) { + return 0; + } + const auto map = shortcut.toMap(); + 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")) { + return steam_shortcut.appid; + } + } + } + return 0; +} + bool UIModel::addToSteam(QVariant shortcut, const QString& shortcutspath, bool from_cmd) { QDir appDir = QGuiApplication::applicationDirPath(); @@ -523,6 +539,15 @@ bool UIModel::writeShortcutsVDF(const std::wstring& mode, const std::wstring& na #endif } +bool UIModel::getIsDebug() const +{ +#ifdef _DEBUG + return true; +#else + return false; +#endif +} + bool UIModel::getIsWindows() const { return is_windows_; } bool UIModel::hasAcrylicEffect() const { return has_acrylic_affect_; } diff --git a/GlosSIConfig/UIModel.h b/GlosSIConfig/UIModel.h index ba38577..93548bb 100644 --- a/GlosSIConfig/UIModel.h +++ b/GlosSIConfig/UIModel.h @@ -25,6 +25,7 @@ class QNetworkReply; class UIModel : public QObject { Q_OBJECT + Q_PROPERTY(bool isDebug READ getIsDebug CONSTANT) Q_PROPERTY(bool isWindows READ getIsWindows CONSTANT) Q_PROPERTY(bool hasAcrlyicEffect READ hasAcrylicEffect NOTIFY acrylicChanged) Q_PROPERTY(QVariantList targetList READ getTargetList NOTIFY targetListChanged) @@ -45,6 +46,7 @@ class UIModel : public QObject { Q_INVOKABLE bool updateTarget(int index, QVariant shortcut); Q_INVOKABLE void deleteTarget(int index); Q_INVOKABLE bool isInSteam(QVariant shortcut); + 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); @@ -66,6 +68,7 @@ class UIModel : public QObject { [[nodiscard]] bool writeShortcutsVDF(const std::wstring& mode, const std::wstring& name, const std::wstring& shortcutspath, bool is_admin_try = false) const; + bool getIsDebug() const; bool getIsWindows() const; [[nodiscard]] bool hasAcrylicEffect() const; void setAcrylicEffect(bool has_acrylic_affect); diff --git a/GlosSIConfig/qml/ShortcutCards.qml b/GlosSIConfig/qml/ShortcutCards.qml index 59d5126..72e3f50 100644 --- a/GlosSIConfig/qml/ShortcutCards.qml +++ b/GlosSIConfig/qml/ShortcutCards.qml @@ -130,34 +130,14 @@ GridView { } } Row { - visible: false // TODO: dunno about this... + visible: uiModel.isDebug spacing: 4 Label { - text: qsTr("Is in") + text: qsTr("AppID: ") font.bold: true } - Image { - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/svg/steam.svg" - width: 16 - height: 16 - smooth: true - mipmap: true - ColorOverlay { - anchors.fill: parent - source: parent - color: "white" - } - } - Item { - width: 4 - height: 1 - } Label { - anchors.verticalCenter: parent.verticalCenter - text: delegateRoot.isInSteam ? qsTr("Yes") : qsTr("No") - width: 292 - typeLabel.width - 72 - elide: Text.ElideRight + text: uiModel.getAppId(modelData) } } }