Skip to content

Commit

Permalink
Add notification for add to steam to clarify that it also works on ex…
Browse files Browse the repository at this point in the history
…isting shortcuts to get the official artwork + controller layout + give option to remind me later for remote play setup question
  • Loading branch information
streetpea committed Jan 6, 2025
1 parent 77b802b commit dee8e22
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 15 deletions.
5 changes: 5 additions & 0 deletions gui/include/qmlsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class QmlSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(bool remotePlayAsk READ remotePlayAsk WRITE setRemotePlayAsk NOTIFY remotePlayAskChanged)
Q_PROPERTY(bool addSteamShortcutAsk READ addSteamShortcutAsk WRITE setAddSteamShortcutAsk NOTIFY addSteamShortcutAskChanged)
Q_PROPERTY(bool hideCursor READ hideCursor WRITE setHideCursor NOTIFY hideCursorChanged)
Q_PROPERTY(int resolutionLocalPS4 READ resolutionLocalPS4 WRITE setResolutionLocalPS4 NOTIFY resolutionLocalPS4Changed)
Q_PROPERTY(int resolutionRemotePS4 READ resolutionRemotePS4 WRITE setResolutionRemotePS4 NOTIFY resolutionRemotePS4Changed)
Expand Down Expand Up @@ -200,6 +201,9 @@ class QmlSettings : public QObject
bool remotePlayAsk() const;
void setRemotePlayAsk(bool asked);

bool addSteamShortcutAsk() const;
void setAddSteamShortcutAsk(bool asked);

bool hideCursor() const;
void setHideCursor(bool enabled);

Expand Down Expand Up @@ -526,6 +530,7 @@ class QmlSettings : public QObject
#endif
void fullscreenDoubleClickChanged();
void remotePlayAskChanged();
void addSteamShortcutAskChanged();
void hideCursorChanged();
void fpsLocalPS4Changed();
void fpsRemotePS4Changed();
Expand Down
4 changes: 4 additions & 0 deletions gui/include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ class Settings : public QObject

bool GetRemotePlayAsk() const { return settings.value("settings/remote_play_ask", true).toBool(); }
void SetRemotePlayAsk(bool asked) { settings.setValue("settings/remote_play_ask", asked); }

bool GetAddSteamShortcutAsk() const { return settings.value("settings/add_steam_shortcut_ask", true).toBool(); }
void SetAddSteamShortcutAsk(bool asked) { settings.setValue("settings/add_steam_shortcut_ask", asked); }

bool GetLogVerbose() const { return settings.value("settings/log_verbose", false).toBool(); }
void SetLogVerbose(bool enabled) { settings.setValue("settings/log_verbose", enabled); }
uint32_t GetLogLevelMask();
Expand Down
5 changes: 3 additions & 2 deletions gui/src/qml/ConfirmDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Dialog {
id: dialog
property alias text: label.text
property var callback
property bool newDialogOpen: false
property Item restoreFocusItem
parent: Overlay.overlay
x: Math.round((root.width - width) / 2)
Expand All @@ -16,11 +17,11 @@ Dialog {
Material.roundedScale: Material.MediumScale
onOpened: label.forceActiveFocus(Qt.TabFocusReason)
onAccepted: {
newDialogOpen = true;
restoreFocus();
callback();
}
onRejected: restoreFocus()
onClosed: restoreFocus()
onClosed: if(!newDialogOpen) { restoreFocus() }

function restoreFocus() {
if (restoreFocusItem)
Expand Down
20 changes: 17 additions & 3 deletions gui/src/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.streetpea.chiaking
Item {
id: root
property list<Item> restoreFocusItems

property bool initialAsk: false
Material.theme: Material.Dark
Material.accent: "#00a7ff"

Expand Down Expand Up @@ -133,6 +133,16 @@ Item {
confirmDialog.open();
}

function showRemindDialog(title, text, remotePlay, callback) {
remindDialog.title = title;
remindDialog.text = text;
remindDialog.remotePlay = remotePlay;
remindDialog.callback = callback;
remindDialog.restoreFocusItem = Window.window.activeFocusItem;
remindDialog.open();
}


function showRegistDialog(host, ps5) {
stack.push(registDialogComponent, {host: host, ps5: ps5});
}
Expand Down Expand Up @@ -179,8 +189,8 @@ Item {
stack.push(consolePinDialogComponent, {consoleIndex: consoleIndex});
}

function showSteamShortcutDialog() {
stack.push(steamShortcutDialogComponent)
function showSteamShortcutDialog(fromReminder) {
stack.push(steamShortcutDialogComponent, {fromReminder: fromReminder});
}

function showPSNTokenDialog(psnurl, expired) {
Expand Down Expand Up @@ -317,6 +327,10 @@ Item {
id: confirmDialog
}

RemindDialog {
id: remindDialog
}

Connections {
target: Chiaki

Expand Down
22 changes: 14 additions & 8 deletions gui/src/qml/MainView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ Pane {
id: consolePane
StackView.onActivated: {
forceActiveFocus(Qt.TabFocusReason);
if(Chiaki.settings.remotePlayAsk)
if(!root.initialAsk)
{
if(!Chiaki.settings.psnRefreshToken || !Chiaki.settings.psnAuthToken || !Chiaki.settings.psnAuthTokenExpiry || !Chiaki.settings.psnAccountId)
root.initialAsk = true;
if(Chiaki.settings.addSteamShortcutAsk)
root.showRemindDialog(qsTr("Official Steam artwork + controller layout"), qsTr("Would you like to either create a new non-Steam game for chiaki-ng\nor update an existing non-Steam game with the official artwork and controller layout?") + "\n\n" + qsTr("(Note: If you select no now and want to do this later, click the button or press R3 from the main menu.)"), false, () => root.showSteamShortcutDialog(true));
else if(Chiaki.settings.remotePlayAsk)
{
Chiaki.settings.remotePlayAsk = false;
root.showConfirmDialog(qsTr("Remote Play via PSN"), qsTr("Would you like to connect to PSN to play outside of your home network without port forwarding?") + "\n\n" + qsTr("(Note: If you select no now and want to do this later, go to the Config section of the settings.)"), () => root.showPSNTokenDialog(false));
if(!Chiaki.settings.psnRefreshToken || !Chiaki.settings.psnAuthToken || !Chiaki.settings.psnAuthTokenExpiry || !Chiaki.settings.psnAccountId)
{
Chiaki.settings.remotePlayAsk = false;
root.showRemindDialog(qsTr("Remote Play via PSN"), qsTr("Would you like to connect to PSN to play outside of your home network without port forwarding?") + "\n\n" + qsTr("(Note: If you select no now and want to do this later, go to the Config section of the settings.)"), true, () => root.showPSNTokenDialog(false));
}
else
Chiaki.settings.remotePlayAsk = false;
}
else
Chiaki.settings.remotePlayAsk = false;
}
}
Keys.onUpPressed: {
Expand Down Expand Up @@ -55,7 +61,7 @@ Pane {
event.accepted = true;
break;
case Qt.Key_F1:
if (typeof Chiaki.createSteamShortcut === "function") root.showSteamShortcutDialog();
if (typeof Chiaki.createSteamShortcut === "function") root.showSteamShortcutDialog(false);
event.accepted = true;
break;
case Qt.Key_F2:
Expand Down Expand Up @@ -100,7 +106,7 @@ Pane {
flat: true
text: "Create Steam Shortcut"
focusPolicy: Qt.NoFocus
onClicked: root.showSteamShortcutDialog()
onClicked: root.showSteamShortcutDialog(false)
Material.roundedScale: Material.SmallScale
visible: typeof Chiaki.createSteamShortcut === "function"
Image {
Expand Down
4 changes: 3 additions & 1 deletion gui/src/qml/PSNTokenDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ DialogView {
onAccepted: {
logDialog.open()
Chiaki.initPsnAuth(url.text.trim(), function(msg, ok, done) {
if(ok)
Chiaki.settings.remotePlayAsk = false;
if (!done)
logArea.text += msg + "\n";
else
Expand Down Expand Up @@ -345,7 +347,7 @@ DialogView {
standardButtons: Dialog.Cancel
Material.roundedScale: Material.MediumScale
onOpened: logArea.forceActiveFocus(Qt.TabFocusReason)
onClosed: root.showMainView()
onClosed: root.showMainView();

Flickable {
id: logFlick
Expand Down
136 changes: 136 additions & 0 deletions gui/src/qml/RemindDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import "controls" as C

import org.streetpea.chiaking

Dialog {
id: dialog
property alias text: label.text
property var remotePlay
property var callback
property bool newDialogOpen: false
property Item restoreFocusItem
parent: Overlay.overlay
x: Math.round((root.width - width) / 2)
y: Math.round((root.height - height) / 2)
modal: true
Material.roundedScale: Material.MediumScale
onOpened: label.forceActiveFocus(Qt.TabFocusReason)
onAccepted: {
newDialogOpen = true;
restoreFocus();
callback();
}
onRejected: {
if(dialog.remotePlay)
Chiaki.settings.remotePlayAsk = false;
else
Chiaki.settings.addSteamShortcutAsk = false;
}
onClosed: {
if(newDialogOpen)
return;
restoreFocus();
if(!remotePlay && Chiaki.settings.remotePlayAsk)
{
if(!Chiaki.settings.psnRefreshToken || !Chiaki.settings.psnAuthToken || !Chiaki.settings.psnAuthTokenExpiry || !Chiaki.settings.psnAccountId)
root.showRemindDialog(qsTr("Remote Play via PSN"), qsTr("Would you like to connect to PSN to play outside of your home network without port forwarding?") + "\n\n" + qsTr("(Note: If you select no now and want to do this later, go to the Config section of the settings.)"), true, () => root.showPSNTokenDialog(false));
else
Chiaki.settings.remotePlayAsk = false;
}
}

function restoreFocus() {
if (restoreFocusItem)
restoreFocusItem.forceActiveFocus(Qt.TabFocusReason);
label.focus = false;
}

Component.onCompleted: {
header.horizontalAlignment = Text.AlignHCenter;
// Qt 6.6: Workaround dialog background becoming immediately transparent during close animation
header.background = null;
}

ColumnLayout {
spacing: 20

Label {
id: label
Keys.onEscapePressed: dialog.reject()
Keys.onReturnPressed: dialog.accept()
Keys.onYesPressed: dialog.close()
}

RowLayout {
Layout.alignment: Qt.AlignCenter
spacing: 20

Button {
text: qsTr("Yes")
Material.background: Material.accent
flat: true
leftPadding: 50
onClicked: dialog.accept()
Material.roundedScale: Material.SmallScale

Image {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: 12
}
width: 28
height: 28
sourceSize: Qt.size(width, height)
source: root.controllerButton("cross")
}
}

Button {
Material.background: Material.accent
text: qsTr("No")
flat: true
leftPadding: 50
onClicked: dialog.reject()
Material.roundedScale: Material.SmallScale

Image {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: 12
}
width: 28
height: 28
sourceSize: Qt.size(width, height)
source: root.controllerButton("moon")
}
}

Button {
Material.background: Material.accent
text: qsTr("Remind Me Later")
flat: true
leftPadding: 50
onClicked: dialog.close()
Material.roundedScale: Material.SmallScale

Image {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: 12
}
width: 28
height: 28
sourceSize: Qt.size(width, height)
source: root.controllerButton("pyramid")
}
}
}
}
}
16 changes: 15 additions & 1 deletion gui/src/qml/SteamShortcutDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,28 @@ import org.streetpea.chiaking
import "controls" as C

DialogView {
id: dialog
property bool opening: false
property bool fromReminder
title: qsTr("Create Non-Steam Game")
buttonText: qsTr("Create")
buttonEnabled: name.text.trim() && !opening
function close() {
root.closeDialog();
if(dialog.fromReminder && Chiaki.settings.remotePlayAsk)
{
if(!Chiaki.settings.psnRefreshToken || !Chiaki.settings.psnAuthToken || !Chiaki.settings.psnAuthTokenExpiry || !Chiaki.settings.psnAccountId)
root.showRemindDialog(qsTr("Remote Play via PSN"), qsTr("Would you like to connect to PSN to play outside of your home network without port forwarding?") + "\n\n" + qsTr("(Note: If you select no now and want to do this later, go to the Config section of the settings.)"), true, () => root.showPSNTokenDialog(false));
else
Chiaki.settings.remotePlayAsk = false;
}
}
onAccepted: {
opening = true;
logDialog.open();
Chiaki.createSteamShortcut(name.text.trim(), options.text.trim(), function(msg, ok, done) {
if(ok)
Chiaki.settings.addSteamShortcutAsk = false;
if (!done)
logArea.text += msg + "\n";
else
Expand Down Expand Up @@ -127,7 +141,7 @@ DialogView {
standardButtons: Dialog.Close
Material.roundedScale: Material.MediumScale
onOpened: restartArea.forceActiveFocus(Qt.TabFocusReason)
onClosed: stack.pop()
onClosed: dialog.close()

Flickable {
id: restartFlick
Expand Down
1 change: 1 addition & 0 deletions gui/src/qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<file>MainView.qml</file>
<file>StreamView.qml</file>
<file>ConfirmDialog.qml</file>
<file>RemindDialog.qml</file>
<file>DialogView.qml</file>
<file>ManualHostDialog.qml</file>
<file>RegistDialog.qml</file>
Expand Down
12 changes: 12 additions & 0 deletions gui/src/qmlsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ void QmlSettings::setRemotePlayAsk(bool asked)
emit remotePlayAskChanged();
}

bool QmlSettings::addSteamShortcutAsk() const
{
return settings->GetAddSteamShortcutAsk();
}

void QmlSettings::setAddSteamShortcutAsk(bool asked)
{
settings->SetAddSteamShortcutAsk(asked);
emit addSteamShortcutAskChanged();
}

bool QmlSettings::hideCursor() const
{
return settings->GetHideCursor();
Expand Down Expand Up @@ -1414,6 +1425,7 @@ void QmlSettings::setSettings(Settings *new_settings)
void QmlSettings::refreshAllKeys()
{
emit remotePlayAskChanged();
emit addSteamShortcutAskChanged();
emit hideCursorChanged();
emit resolutionLocalPS4Changed();
emit resolutionRemotePS4Changed();
Expand Down

0 comments on commit dee8e22

Please sign in to comment.