Skip to content

Commit

Permalink
Merge pull request #192 from Alia5/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Alia5 authored Nov 4, 2022
2 parents 78a9bbd + 6ee8317 commit 9232eea
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 30 deletions.
1 change: 0 additions & 1 deletion GlosSIConfig/GlosSIConfig.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 0 additions & 3 deletions GlosSIConfig/GlosSIConfig.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
8 changes: 4 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,0,2045006300001
PRODUCTVERSION 0,1,0,2045006300001
FILEVERSION 0,1,1,002004500680
PRODUCTVERSION 0,1,1,002004500680
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.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"
Expand Down
18 changes: 14 additions & 4 deletions GlosSIConfig/UIModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand All @@ -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();
}

Expand Down
2 changes: 2 additions & 0 deletions GlosSIConfig/qml/AdvancedTargetSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ CollapsiblePane {

property var shortcutInfo: ({})

readonly property bool isAppSettings: subTitle != ""

content:
Column {
spacing: 16
Expand Down
19 changes: 19 additions & 0 deletions GlosSIConfig/qml/GlobalConf.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}
Expand Down
64 changes: 48 additions & 16 deletions GlosSIConfig/qml/SteamGridDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Dialog {
property real backdropOpacity: 1.0

property bool loading: true
property bool hasTokenError: false


onOpened: function() {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions GlosSITarget/TargetWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ void TargetWindow::createWindow()
spdlog::debug("Config file fps limit seems sane...");
setFpsLimit(Settings::window.maxFps);
}
if (Settings::window.scale > 0.3f) { // Now that's just getting ridicoulus
if (Settings::window.scale < 0.3f) { // Now that's just getting ridicoulus
ImGuiIO& io = ImGui::GetIO();
io.FontGlobalScale = Settings::window.scale;
ImGui::SFML::UpdateFontTexture();
}
else {
spdlog::warn("Not applying too low screen scale setting");
spdlog::debug("Not applying too low screen scale setting");
}

// window_.setSize({desktop_mode.width - 1, desktop_mode.height - 1 });
Expand Down

0 comments on commit 9232eea

Please sign in to comment.