GlosSIConfig: Add global/default settings

pull/183/head
Peter Repukat 2 years ago
parent 5ebe10298e
commit 322136a16a

@ -143,6 +143,7 @@
<None Include="GetAUMIDs.ps1" /> <None Include="GetAUMIDs.ps1" />
<None Include="qml\AdvancedTargetSettings.qml" /> <None Include="qml\AdvancedTargetSettings.qml" />
<None Include="qml\CollapsiblePane.qml" /> <None Include="qml\CollapsiblePane.qml" />
<None Include="qml\GlobalConf.qml" />
<None Include="qml\SteamInputXboxDisabledDialog.qml" /> <None Include="qml\SteamInputXboxDisabledDialog.qml" />
<None Include="qml\AddSelectTypeDialog.qml" /> <None Include="qml\AddSelectTypeDialog.qml" />
<None Include="qml\FluentTextInput.qml" /> <None Include="qml\FluentTextInput.qml" />

@ -77,6 +77,9 @@
<None Include="qml\AdvancedTargetSettings.qml"> <None Include="qml\AdvancedTargetSettings.qml">
<Filter>qml</Filter> <Filter>qml</Filter>
</None> </None>
<None Include="qml\GlobalConf.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,9,1029000008904 FILEVERSION 0,0,9,1037005000102
PRODUCTVERSION 0,0,9,1029000008904 PRODUCTVERSION 0,0,9,1037005000102
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.9.1-29-gefe89c4" VALUE "FileVersion", "0.0.9.1-37-g5ebe102"
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.9.1-29-gefe89c4" VALUE "ProductVersion", "0.0.9.1-37-g5ebe102"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

@ -305,6 +305,88 @@ void UIModel::updateCheck()
connect(manager, &QNetworkAccessManager::finished, this, &UIModel::onAvailFilesResponse); connect(manager, &QNetworkAccessManager::finished, this, &UIModel::onAvailFilesResponse);
} }
QVariantMap UIModel::getDefaultConf() const
{
auto path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path();
path /= "Roaming";
path /= "GlosSI";
path /= "default.json";
if (std::filesystem::exists(path)) {
QFile file(QString::fromStdWString(path));
if (file.open(QIODevice::ReadOnly)) {
const auto data = file.readAll();
file.close();
return QJsonDocument::fromJson(data).object().toVariantMap();
}
}
QJsonObject obj = {
{"icon", QJsonValue::Null},
{"name", QJsonValue::Null},
{"version", 1},
{"extendedLogging", false},
{"snapshotNotify", false},
{
"controller",
QJsonObject{
{"maxControllers", 1},
{"emulateDS4", false},
{"allowDesktopConfig", false}
}
},
{
"devices",
QJsonObject{
{"hideDevices", true},
{"realDeviceIds", false},
}
},
{
"launch",
QJsonObject{
{"closeOnExit", true},
{"launch", false},
{"launchAppArgs", QJsonValue::Null},
{"launchPath", QJsonValue::Null},
{"waitForChildProcs", true},
}
},
{
"window",
QJsonObject{
{"disableOverlay", false},
{"maxFps", QJsonValue::Null},
{"scale", QJsonValue::Null},
{"windowMode", false},
}
},
};
saveDefaultConf(obj.toVariantMap());
return getDefaultConf();
}
void UIModel::saveDefaultConf(QVariantMap conf) const
{
auto path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path();
path /= "Roaming";
path /= "GlosSI";
path /= "default.json";
QFile file(path);
if (!file.open(QIODevice::Text | QIODevice::ReadWrite)) {
qDebug() << "Couldn't open file for writing: " << path;
return;
}
file.write(QString(QJsonDocument::fromVariant(conf).toJson(QJsonDocument::Indented)).toStdString().data());
file.close();
}
#ifdef _WIN32 #ifdef _WIN32
QVariantList UIModel::uwpApps() { return UWPFetch::UWPAppList(); } QVariantList UIModel::uwpApps() { return UWPFetch::UWPAppList(); }
#endif #endif
@ -391,6 +473,12 @@ void UIModel::onAvailFilesResponse(QNetworkReply* reply)
QJsonObject json = QJsonDocument::fromJson(respStr).object(); QJsonObject json = QJsonDocument::fromJson(respStr).object();
const auto defaultConf = getDefaultConf();
bool snapshotNotify =
defaultConf.contains("snapshotNotify")
? defaultConf["snapshotNotify"].toJsonValue().toBool()
: false;
struct VersionInfo { struct VersionInfo {
int major; int major;
int minor; int minor;
@ -401,8 +489,9 @@ void UIModel::onAvailFilesResponse(QNetworkReply* reply)
std::vector<std::pair<QString, VersionInfo>> new_versions; std::vector<std::pair<QString, VersionInfo>> new_versions;
for (const auto& info : for (const auto& info :
json.keys() | std::ranges::views::filter([this, &json](const auto& key) { json.keys() | std::ranges::views::filter([this, &json, snapshotNotify](const auto& key) {
return notify_on_snapshots_ ? true : json[key].toObject().value("type") == "release"; return notify_on_snapshots_ ? true
: json[key].toObject().value("type") == (snapshotNotify ? "snapshot" : "release");
}) | std::ranges::views::transform([&json](const auto& key) -> std::pair<QString, VersionInfo> { }) | std::ranges::views::transform([&json](const auto& key) -> std::pair<QString, VersionInfo> {
const auto versionString = json[key].toObject().value("version").toString(); const auto versionString = json[key].toObject().value("version").toString();
const auto cleanVersion = versionString.split("-")[0]; const auto cleanVersion = versionString.split("-")[0];

@ -53,6 +53,10 @@ class UIModel : public QObject {
Q_INVOKABLE bool restartSteam(); Q_INVOKABLE bool restartSteam();
Q_INVOKABLE void updateCheck(); Q_INVOKABLE void updateCheck();
Q_INVOKABLE QVariantMap getDefaultConf() const;
Q_INVOKABLE void saveDefaultConf(QVariantMap conf) const;
#ifdef _WIN32 #ifdef _WIN32
Q_INVOKABLE QVariantList uwpApps(); Q_INVOKABLE QVariantList uwpApps();
#endif #endif

@ -20,5 +20,7 @@
<file>svg/expand_more_white_24dp.svg</file> <file>svg/expand_more_white_24dp.svg</file>
<file>GlosSI_Logo_512.png</file> <file>GlosSI_Logo_512.png</file>
<file>qml/AdvancedTargetSettings.qml</file> <file>qml/AdvancedTargetSettings.qml</file>
<file>qml/GlobalConf.qml</file>
<file>svg/settings_fill_white_24dp.svg</file>
</qresource> </qresource>
</RCC> </RCC>

@ -25,12 +25,22 @@ CollapsiblePane {
bgOpacity: 0.97 bgOpacity: 0.97
title: qsTr("Advanced ⚙️") title: qsTr("Advanced ⚙️")
property string subTitle: ""
property var shortcutInfo: ({}) property var shortcutInfo: ({})
content: content:
Column { Column {
spacing: 16 spacing: 16
Label {
id: subTitleLabel
width: parent.width
font.pixelSize: 16
text: subTitle
height: text == "" ? 0 : 24
}
RPane { RPane {
width: parent.width width: parent.width
radius: 4 radius: 4
@ -41,6 +51,7 @@ CollapsiblePane {
id: advancedLaunchCol id: advancedLaunchCol
spacing: 4 spacing: 4
height: advancedLaunchedRow.height height: advancedLaunchedRow.height
Row { Row {
id: advancedLaunchedRow id: advancedLaunchedRow
spacing: 32 spacing: 32

@ -0,0 +1,130 @@
/*
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
import QtQuick.Dialogs 6.2
Item {
id: globalConfContent
anchors.fill: parent
signal cancel()
signal done()
property var config: ({})
Component.onCompleted: function() {
config = uiModel.getDefaultConf()
}
Flickable {
id: flickable
anchors.margins: 0
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
ScrollBar.vertical: ScrollBar {
}
contentWidth: parent.width
contentHeight: confColumn.height
flickableDirection: Flickable.VerticalFlick
Column {
id: confColumn
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 32
anchors.rightMargin: 32
spacing: 4
Item {
width: 1
height: 32
}
RPane {
width: parent.width
radius: 4
Material.elevation: 32
bgOpacity: 0.97
Column {
width: parent.width
height: parent.height
spacing: 4
Row {
spacing: 32
width: parent.width
CheckBox {
id: launchApp
text: qsTr("Notify me about Snapshots")
checked: config ? config.snapshotNotify : false
onCheckedChanged: function() {
config.snapshotNotify = checked
}
}
}
}
}
Item {
width: 1
height: 4
}
AdvancedTargetSettings {
id: advancedTargetSettings
shortcutInfo: config
title: qsTr("Advanced default target settings ⚙️")
subTitle: qsTr(
"Default settings when creating new shortcuts\n"
+ "as well as settings applied when launching GlosSITarget without config")
}
Item {
width: 1
height: 32
}
}
}
Row {
spacing: 8
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: 24
anchors.bottomMargin: 16
Button {
text: qsTr("Cancel")
onClicked: function() {
cancel()
}
}
Button {
text: qsTr("💾 Save")
highlighted: true
onClicked: function() {
uiModel.saveDefaultConf(config)
done()
}
}
}
}

@ -32,34 +32,7 @@ Item {
property var shortcutInfo: ({}) property var shortcutInfo: ({})
function resetInfo() { function resetInfo() {
shortcutInfo = ({ shortcutInfo = uiModel.getDefaultConf()
"controller": {
"maxControllers": 1,
"emulateDS4": false,
"allowDesktopConfig": false
},
"devices": {
"hideDevices": true,
"realDeviceIds": false
},
"icon": null,
"launch": {
"closeOnExit": true,
"launch": false,
"launchAppArgs": null,
"launchPath": null,
"waitForChildProcs": true
},
"name": null,
"version": 1,
"window": {
"disableOverlay": false,
"maxFps": null,
"scale": null,
"windowMode": false
},
"extendedLogging": false
})
} }
Component.onCompleted: function() { Component.onCompleted: function() {
@ -267,6 +240,7 @@ Item {
AdvancedTargetSettings { AdvancedTargetSettings {
id: advancedTargetSettings id: advancedTargetSettings
shortcutInfo: shortcutInfo
} }
Item { Item {

@ -234,24 +234,46 @@ Window {
windowContent.editedIndex = index; windowContent.editedIndex = index;
} }
} }
RoundButton { Column {
id: addBtn spacing: 8
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: 24 anchors.margins: 24
width: 64 RoundButton {
height: 64 id: optionsBtn
text: "+" width: 64
contentItem: Label { height: 64
anchors.centerIn: parent text: ""
text: addBtn.text contentItem: Item {
font.pixelSize: 32 Image {
horizontalAlignment: Text.AlignHCenter anchors.centerIn: parent
verticalAlignment: Text.AlignVCenter source: "qrc:/svg/settings_fill_white_24dp.svg"
elide: Text.ElideRight width: 24
height: 24
}
}
highlighted: true
onClicked: function() {
globalConf.opacity = 1;
homeContent.opacity = 0;
}
}
RoundButton {
id: addBtn
width: 64
height: 64
text: "+"
contentItem: Label {
anchors.centerIn: parent
text: addBtn.text
font.pixelSize: 32
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
highlighted: true
onClicked: selectTypeDialog.open()
} }
highlighted: true
onClicked: selectTypeDialog.open()
} }
} }
@ -299,6 +321,46 @@ Window {
} }
} }
Item {
id: globalConf
height: parent.height
width: parent.width
opacity: 0
property real animMarg: opacity == 0 ? parent.height : 0
y: animMarg
visible: opacity === 0 ? false : true
Behavior on opacity {
ParallelAnimation {
NumberAnimation {
duration: 300
property: "opacity"
easing.type: opacity === 0 ? Easing.OutQuad : Easing.InOutQuad
}
PropertyAnimation {
duration: 300
target: globalConf
property: "animMarg";
from: globalConf.animMarg
to: globalConf.animMarg > 0 ? 0 : globalConf.parent.height;
easing.type: opacity === 0 ? Easing.OutQuad : Easing.InOutQuad
}
}
}
GlobalConf {
id: glConf
anchors.fill: parent
onCancel: function() {
globalConf.opacity = 0;
homeContent.opacity = 1;
}
onDone: function() {
globalConf.opacity = 0;
homeContent.opacity = 1;
}
}
}
Label { Label {
id: versionInfo id: versionInfo
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48" fill="#FFFFFF"><path d="m19.4 44-1-6.3q-.95-.35-2-.95t-1.85-1.25l-5.9 2.7L4 30l5.4-3.95q-.1-.45-.125-1.025Q9.25 24.45 9.25 24q0-.45.025-1.025T9.4 21.95L4 18l4.65-8.2 5.9 2.7q.8-.65 1.85-1.25t2-.9l1-6.35h9.2l1 6.3q.95.35 2.025.925Q32.7 11.8 33.45 12.5l5.9-2.7L44 18l-5.4 3.85q.1.5.125 1.075.025.575.025 1.075t-.025 1.05q-.025.55-.125 1.05L44 30l-4.65 8.2-5.9-2.7q-.8.65-1.825 1.275-1.025.625-2.025.925l-1 6.3ZM24 30.5q2.7 0 4.6-1.9 1.9-1.9 1.9-4.6 0-2.7-1.9-4.6-1.9-1.9-4.6-1.9-2.7 0-4.6 1.9-1.9 1.9-1.9 4.6 0 2.7 1.9 4.6 1.9 1.9 4.6 1.9Z"/></svg>

After

Width:  |  Height:  |  Size: 609 B

Loading…
Cancel
Save