Add "couldn't detect Steam"-dialog

pull/179/head
Peter Repukat 2 years ago
parent 431053e735
commit 14e4662df7

@ -144,6 +144,7 @@
<None Include="qml\ShortcutCards.qml" /> <None Include="qml\ShortcutCards.qml" />
<None Include="qml\ShortcutProps.qml" /> <None Include="qml\ShortcutProps.qml" />
<None Include="qml\UWPSelectDialog.qml" /> <None Include="qml\UWPSelectDialog.qml" />
<None Include="qml\SteamNotFoundDialog.qml" />
<QtRcc Include="qml.qrc" /> <QtRcc Include="qml.qrc" />
<None Include="qml\main.qml" /> <None Include="qml\main.qml" />
</ItemGroup> </ItemGroup>

@ -65,6 +65,9 @@
</None> </None>
<None Include=".clang-format" /> <None Include=".clang-format" />
<None Include="GetAUMIDs.ps1" /> <None Include="GetAUMIDs.ps1" />
<None Include="qml\SteamNotFoundDialog.qml">
<Filter>qml</Filter>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="UIModel.h"> <QtMoc Include="UIModel.h">

@ -51,8 +51,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,8,003002880001 FILEVERSION 0,0,8,102000500230
PRODUCTVERSION 0,0,8,003002880001 PRODUCTVERSION 0,0,8,102000500230
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.0.8.0-3-g288bba1" VALUE "FileVersion", "0.0.8.1-2-gc5fc23d"
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.0.8.0-3-g288bba1" VALUE "ProductVersion", "0.0.8.1-2-gc5fc23d"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@ -756,6 +756,50 @@ IDI_ICON1 ICON "..\GloSC_Icon.ico"

@ -367,12 +367,20 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name)
std::filesystem::path UIModel::getSteamPath() const std::filesystem::path UIModel::getSteamPath() const
{ {
try {
#ifdef _WIN32 #ifdef _WIN32
// TODO: check if keys/value exist // TODO: check if keys/value exist
// steam should always be open and have written reg values... // steam should always be open and have written reg values...
winreg::RegKey key{HKEY_CURRENT_USER, L"SOFTWARE\\Valve\\Steam"}; winreg::RegKey key{HKEY_CURRENT_USER, L"SOFTWARE\\Valve\\Steam"};
const auto res = key.GetStringValue(L"SteamPath"); if (!key.IsValid()) {
return res; return "";
}
const auto res = key.GetStringValue(L"SteamPath");
return res;
}
catch (...) {
return "";
}
#else #else
return L""; // TODO LINUX return L""; // TODO LINUX
#endif #endif
@ -381,19 +389,38 @@ std::filesystem::path UIModel::getSteamPath() const
std::wstring UIModel::getSteamUserId() const std::wstring UIModel::getSteamUserId() const
{ {
#ifdef _WIN32 #ifdef _WIN32
// TODO: check if keys/value exist try {
// steam should always be open and have written reg values... // TODO: check if keys/value exist
winreg::RegKey key{HKEY_CURRENT_USER, L"SOFTWARE\\Valve\\Steam\\ActiveProcess"}; // steam should always be open and have written reg values...
const auto res = std::to_wstring(key.GetDwordValue(L"ActiveUser")); winreg::RegKey key{HKEY_CURRENT_USER, L"SOFTWARE\\Valve\\Steam\\ActiveProcess"};
if (res == L"0") { if (!key.IsValid()) {
qDebug() << "Steam not open?"; return L"0";
}
const auto res = std::to_wstring(key.GetDwordValue(L"ActiveUser"));
if (res == L"0") {
qDebug() << "Steam not open?";
}
return res;
} catch(...) {
return L"0";
} }
return res;
#else #else
return L""; // TODO LINUX return L""; // TODO LINUX
#endif #endif
} }
bool UIModel::foundSteam() const
{
if (getSteamPath() == "" || getSteamUserId() == L"0") {
return false;
}
const std::filesystem::path user_config_dir = std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId();
if (!std::filesystem::exists(user_config_dir)) {
return false;
}
return true;
}
void UIModel::parseShortcutVDF() void UIModel::parseShortcutVDF()
{ {
const std::filesystem::path config_path = std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + shortcutsfile_.toStdWString(); const std::filesystem::path config_path = std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + shortcutsfile_.toStdWString();

@ -27,6 +27,7 @@ class UIModel : public QObject {
Q_PROPERTY(bool hasAcrlyicEffect READ hasAcrylicEffect NOTIFY acrylicChanged) Q_PROPERTY(bool hasAcrlyicEffect READ hasAcrylicEffect NOTIFY acrylicChanged)
Q_PROPERTY(QVariantList targetList READ getTargetList NOTIFY targetListChanged) Q_PROPERTY(QVariantList targetList READ getTargetList NOTIFY targetListChanged)
Q_PROPERTY(QVariantList uwpList READ uwpApps CONSTANT) Q_PROPERTY(QVariantList uwpList READ uwpApps CONSTANT)
Q_PROPERTY(bool foundSteam READ foundSteam CONSTANT)
public: public:
UIModel(); UIModel();
@ -68,6 +69,7 @@ class UIModel : public QObject {
std::filesystem::path getSteamPath() const; std::filesystem::path getSteamPath() const;
std::wstring getSteamUserId() const; std::wstring getSteamUserId() const;
bool foundSteam() const;
void parseShortcutVDF(); void parseShortcutVDF();
QString shortcutsfile_ = "/config/shortcuts.vdf"; QString shortcutsfile_ = "/config/shortcuts.vdf";
QString user_data_path_ = "/userdata/"; QString user_data_path_ = "/userdata/";

@ -15,5 +15,6 @@
<file>noise.png</file> <file>noise.png</file>
<file>GloSC_Icon_small.png</file> <file>GloSC_Icon_small.png</file>
<file>svg/help_outline_white_24dp.svg</file> <file>svg/help_outline_white_24dp.svg</file>
<file>qml/SteamNotFoundDialog.qml</file>
</qresource> </qresource>
</RCC> </RCC>

@ -0,0 +1,92 @@
/*
Copyright 2021-2022 Peter Repukat - FlatspotSoftware
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import QtQuick 6.2
import QtQuick.Controls 6.2
import QtQuick.Layouts 6.2
import QtQuick.Controls.Material 6.2
Dialog {
id: dlg
anchors.centerIn: parent
signal confirmed(var param)
visible: false
modal: true
dim: true
parent: Overlay.overlay
Overlay.modal: Rectangle {
color: Qt.rgba(0,0,0,0.4)
opacity: backdropOpacity
Behavior on opacity {
NumberAnimation {
duration: 300
}
}
}
property real backdropOpacity: 1.0
enter: Transition {
NumberAnimation{target: content; property: "y"; from: parent.height; to: 16; duration: 300; easing.type: Easing.OutQuad }
NumberAnimation{target: background; property: "y"; from: parent.height; to: 0; duration: 300; easing.type: Easing.OutQuad }
NumberAnimation{target: dlg; property: "backdropOpacity"; from: 0; to: 1; duration: 300; easing.type: Easing.OutQuad }
}
exit: Transition {
NumberAnimation{target: content; property: "y"; from: 16; to: parent.height; duration: 300; easing.type: Easing.InQuad }
NumberAnimation{target: background; property: "y"; from: 0; to: parent.height; duration: 300; easing.type: Easing.InQuad }
NumberAnimation{target: dlg; property: "backdropOpacity"; from: 1; to: 0; duration: 300; easing.type: Easing.InQuad }
}
background: RPane {
id: background
radius: 4
Material.elevation: 64
bgOpacity: 0.97
}
contentItem: Item {
id: content
clip: true
Column {
spacing: 4
bottomPadding: 24
Label {
id: titlelabel
text: qsTr("Could not detect Steam")
font.pixelSize: 24
font.bold: true
}
Item {
height: 24
}
Label {
text: qsTr("Please make sure that Steam is running and you are logged in.")
wrapMode: Text.WordWrap
width: parent.width
}
Button {
anchors.right: parent.right
anchors.top: listview.bottom
anchors.topMargin: 16
anchors.rightMargin: 2
text: qsTr("Ok")
onClicked: dlg.close()
}
}
}
}

@ -45,6 +45,12 @@ Window {
property bool steamShortcutsChanged: false property bool steamShortcutsChanged: false
Component.onCompleted: function() {
if (!uiModel.foundSteam) {
steamNotFoundDialog.open();
}
}
Image { Image {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
@ -55,6 +61,10 @@ Window {
opacity: 0.033 opacity: 0.033
} }
SteamNotFoundDialog {
id: steamNotFoundDialog
}
InfoDialog { InfoDialog {
id: steamChangedDialog id: steamChangedDialog
titleText: qsTr("Attention!") titleText: qsTr("Attention!")

Loading…
Cancel
Save