GlosSIConfig: User configurable steamgridDB API key

Fuck this!
pull/192/head
Peter Repukat 2 years ago
parent 45bd68e595
commit 6ee8317f77

@ -164,7 +164,6 @@
<ItemGroup>
<ClInclude Include="ExeImageProvider.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="steamgrid_api_keys.h" />
<ClInclude Include="UWPFetch.h" />
<ClInclude Include="WinEventFilter.h" />
</ItemGroup>

@ -105,9 +105,6 @@
<ClInclude Include="ExeImageProvider.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="steamgrid_api_keys.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Xml Include="manifest.xml">

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,0,2045006300001
PRODUCTVERSION 0,1,0,2045006300001
FILEVERSION 0,1,1,002004500680
PRODUCTVERSION 0,1,1,002004500680
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.0.2-45-g63fdab1"
VALUE "FileVersion", "0.1.1.0-2-g45bd68e"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.1.0.2-45-g63fdab1"
VALUE "ProductVersion", "0.1.1.0-2-g45bd68e"
END
END
BLOCK "VarFileInfo"

@ -36,7 +36,6 @@ limitations under the License.
#include "ExeImageProvider.h"
#include "ExeImageProvider.h"
#include "../version.hpp"
#include "steamgrid_api_keys.h"
UIModel::UIModel() : QObject(nullptr)
{
@ -375,6 +374,7 @@ QVariantMap UIModel::getDefaultConf() const
{"version", 1},
{"extendedLogging", false},
{"snapshotNotify", false},
{"steamgridApiKey", QJsonValue::Null},
{"controller", QJsonObject{{"maxControllers", 1}, {"emulateDS4", false}, {"allowDesktopConfig", false}}},
{"devices",
QJsonObject{
@ -489,8 +489,11 @@ void UIModel::loadSteamGridImages()
std::filesystem::path path = QCoreApplication::applicationDirPath().toStdWString();
path /= "steamgrid.exe";
auto api_key = getDefaultConf().value("steamgridApiKey").toString();
steamgrid_output_.clear();
steamgrid_proc_.setProgram(path.string().c_str());
steamgrid_proc_.setArguments({"-nonsteamonly", "--onlymissingartwork", "--steamgriddb", steamgridb_key});
steamgrid_proc_.setArguments({"-nonsteamonly", "--onlymissingartwork", "--steamgriddb", api_key});
connect(&steamgrid_proc_, &QProcess::readyReadStandardOutput, this, &UIModel::onSteamGridReadReady);
steamgrid_proc_.start();
steamgrid_proc_.write("\n");
@ -678,8 +681,12 @@ void UIModel::onAvailFilesResponse(QNetworkReply* reply)
void UIModel::onSteamGridReadReady()
{
steamgrid_output_.push_back(QString::fromLocal8Bit(steamgrid_proc_.readAllStandardOutput()));
const auto output = QString::fromLocal8Bit(steamgrid_proc_.readAllStandardOutput());
steamgrid_output_.push_back(output);
emit steamgridOutputChanged();
if (output.toLower().contains("token is missing or invalid")) {
steamgrid_proc_.kill();
}
}
void UIModel::writeTarget(const QJsonObject& json, const QString& name) const
@ -693,7 +700,10 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name) const
return;
}
file.write(QString(QJsonDocument(json).toJson(QJsonDocument::Indented)).toStdString().data());
auto json_ob = QJsonDocument(json).object();
json_ob.remove("steamgridApiKey");
file.write(QString(QJsonDocument(json_ob).toJson(QJsonDocument::Indented)).toStdString().data());
file.close();
}

@ -29,6 +29,8 @@ CollapsiblePane {
property var shortcutInfo: ({})
readonly property bool isAppSettings: subTitle != ""
content:
Column {
spacing: 16

@ -81,6 +81,25 @@ Item {
config.snapshotNotify = checked
}
}
}
Row {
leftPadding: 12
Row {
spacing: 16
Label {
topPadding: 8
id: apiKeyLabel
font.bold: true
text: qsTr("SteamGridDB-API-Key")
}
FluentTextInput {
width: 128
id: apiKeyInput
placeholderText: qsTr("...")
text: config.steamgridApiKey
onTextChanged: config.steamgridApiKey = text
}
}
}
}
}

@ -40,6 +40,7 @@ Dialog {
property real backdropOpacity: 1.0
property bool loading: true
property bool hasTokenError: false
onOpened: function() {
@ -80,25 +81,55 @@ Dialog {
font.bold: true
}
BusyIndicator {
id: busyIndicator
running: visible
Item {
id: topContentContainer
anchors.top: titlelabel.bottom
anchors.topMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
opacity: loading ? 1 : 0
height: loading ? 72 : 0
Behavior on opacity {
NumberAnimation {
duration: 350
easing.type: Easing.InOutQuad
}
}
visible: loading
anchors.left: parent.left
anchors.right: parent.right
height: loading || hasTokenError ? 72 : 0
BusyIndicator {
id: busyIndicator
running: visible
anchors.horizontalCenter: parent.horizontalCenter
opacity: loading ? 1 : 0
height: loading ? 72 : 0
Behavior on opacity {
NumberAnimation {
duration: 350
easing.type: Easing.InOutQuad
}
}
visible: loading
}
Label {
id: tokenErrorInfo
anchors.horizontalCenter: parent.horizontalCenter
opacity: hasTokenError ? 1 : 0
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.Wrap
font.bold: true
color: "yellow"
textFormat: TextEdit.RichText
onLinkActivated: Qt.openUrlExternally(link)
Behavior on opacity {
NumberAnimation {
duration: 350
easing.type: Easing.InOutQuad
}
}
visible: hasTokenError
text: qsTr("Please go to <a href=\"https://www.steamgriddb.com/profile/preferences/api\">SteamGridDB</a> and gerenate a new API token. Then paste it into the settings dialog.")
}
}
ListView {
anchors.top: busyIndicator.bottom
anchors.top: topContentContainer.bottom
anchors.topMargin: 16
anchors.bottom: parent.bottom
anchors.bottomMargin: 16
@ -110,9 +141,10 @@ Dialog {
model: uiModel.steamgridOutput
ScrollBar.vertical: ScrollBar {
}
onCountChanged: {
listview.positionViewAtIndex(listview.count - 1, ListView.Visible)
loading = !listview.model[listview.count - 1].includes("Press enter")
onCountChanged: function() {
listview.positionViewAtIndex(listview.count - 1, ListView.Visible);
hasTokenError = listview.model.some((l) => l.includes("missing or invalid"));
loading = !(listview.model.some((l) => l.includes("Press enter")) || hasTokenError);
}
Behavior on opacity {

Loading…
Cancel
Save