From c4f238292804b957f84a5e52e5fee7cd4c81f91a Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 15 Oct 2022 15:50:40 +0200 Subject: [PATCH] refactor/fix stupid qml shit --- GlosSIConfig/Resource.rc | 8 +- GlosSIConfig/UIModel.cpp | 6 + GlosSIConfig/qml/AddSelectTypeDialog.qml | 3 + GlosSIConfig/qml/InfoDialog.qml | 3 + GlosSIConfig/qml/ShortcutCards.qml | 140 +-------------------- GlosSIConfig/qml/ShortcutProps.qml | 20 +-- GlosSIConfig/qml/SteamNotFoundDialog.qml | 14 +-- GlosSIConfig/qml/main.qml | 148 ++++++++++++++++++++++- 8 files changed, 184 insertions(+), 158 deletions(-) diff --git a/GlosSIConfig/Resource.rc b/GlosSIConfig/Resource.rc index 713a137..dc73243 100644 --- a/GlosSIConfig/Resource.rc +++ b/GlosSIConfig/Resource.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,0,2034000568418 - PRODUCTVERSION 0,1,0,2034000568418 + FILEVERSION 0,1,0,2035000100080 + PRODUCTVERSION 0,1,0,2035000100080 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-34-gb568418" + VALUE "FileVersion", "0.1.0.2-35-g01efd8d" VALUE "InternalName", "GlosSIConfig" VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware" VALUE "OriginalFilename", "GlosSIConfig.exe" VALUE "ProductName", "GlosSI" - VALUE "ProductVersion", "0.1.0.2-34-gb568418" + VALUE "ProductVersion", "0.1.0.2-35-g01efd8d" END END BLOCK "VarFileInfo" diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index 82c0c4d..ee5ad7e 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -20,6 +20,7 @@ limitations under the License. #include #include #include +#include #include @@ -60,6 +61,11 @@ UIModel::UIModel() : QObject(nullptr) parseShortcutVDF(); readTargetConfigs(); updateCheck(); + + auto font = QGuiApplication::font(); + font.setPointSize(11); + font.setFamily("Roboto"); + QGuiApplication::setFont(font); } void UIModel::readTargetConfigs() diff --git a/GlosSIConfig/qml/AddSelectTypeDialog.qml b/GlosSIConfig/qml/AddSelectTypeDialog.qml index 42b36a3..857981b 100644 --- a/GlosSIConfig/qml/AddSelectTypeDialog.qml +++ b/GlosSIConfig/qml/AddSelectTypeDialog.qml @@ -15,6 +15,9 @@ limitations under the License. */ import QtQuick 6.2 import QtQuick.Controls 6.2 +import QtQuick.Controls.Material 6.2 +import QtQuick.Dialogs 6.2 + Dialog { id: dlg anchors.centerIn: parent diff --git a/GlosSIConfig/qml/InfoDialog.qml b/GlosSIConfig/qml/InfoDialog.qml index 908e718..f635235 100644 --- a/GlosSIConfig/qml/InfoDialog.qml +++ b/GlosSIConfig/qml/InfoDialog.qml @@ -15,6 +15,9 @@ limitations under the License. */ import QtQuick 6.2 import QtQuick.Controls 6.2 +import QtQuick.Controls.Material 6.2 +import QtQuick.Dialogs 6.2 + Dialog { id: dlg anchors.centerIn: parent diff --git a/GlosSIConfig/qml/ShortcutCards.qml b/GlosSIConfig/qml/ShortcutCards.qml index 830514b..59d5126 100644 --- a/GlosSIConfig/qml/ShortcutCards.qml +++ b/GlosSIConfig/qml/ShortcutCards.qml @@ -13,11 +13,11 @@ 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.Layouts 6.2 -import QtQuick.Controls 6.2 -import QtQuick.Controls.Material 6.2 -import QtQuick.Dialogs 6.2 +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs import Qt5Compat.GraphicalEffects GridView { @@ -40,8 +40,6 @@ GridView { model: uiModel.targetList; GridView.delayRemove: true - property var manualInfo: null - // TODO: animations only properly work with abstractListModel... grrr... addDisplaced: Transition { NumberAnimation { properties: "x,y"; duration: 300 } @@ -67,134 +65,6 @@ GridView { NumberAnimation { properties: "x,y"; duration: 300; easing.type: Easing.InQuad } } - Dialog { - id: manualAddDialog - anchors.centerIn: parent - 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: madcontent; property: "y"; from: parent.height; to: 16; duration: 300; easing.type: Easing.OutQuad } - NumberAnimation{target: madbackground; property: "y"; from: parent.height; to: 0; duration: 300; easing.type: Easing.OutQuad } - NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 0; to: 1; duration: 300; easing.type: Easing.OutQuad } - } - - exit: Transition { - NumberAnimation{target: madcontent; property: "y"; from: 16; to: parent.height; duration: 300; easing.type: Easing.InQuad } - NumberAnimation{target: madbackground; property: "y"; from: 0; to: parent.height; duration: 300; easing.type: Easing.InQuad } - NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 1; to: 0; duration: 300; easing.type: Easing.InQuad } - } - - background: RPane { - id: madbackground - radius: 4 - Material.elevation: 64 - bgOpacity: 0.97 - } - contentItem: Item { - id: madcontent - implicitWidth: steamscreener.width - implicitHeight: madtext.height + 16 + steamscreener.height + 16 + madrow.height - - Label { - id: madtext - text: qsTr("Add \"GlosSITarget\" as game to Steam and change it's properties (in Steam) to this:") - } - - Image { - anchors.top: madtext.bottom - anchors.left: madtext.left - anchors.topMargin: 16 - id: steamscreener - source: "qrc:/steamscreener.png" - } - - FluentTextInput { - id: madnameinput - text: manualInfo ? manualInfo.name : "" - anchors.top: steamscreener.top - anchors.left: steamscreener.left - anchors.topMargin: 72 - anchors.leftMargin: 92 - readOnly: true - background: Item {} - width: 550 - } - - FluentTextInput { - id: glossiPathInput - text: manualInfo ? manualInfo.launch : "" - anchors.top: steamscreener.top - anchors.left: steamscreener.left - anchors.topMargin: 192 - anchors.leftMargin: 24 - readOnly: true - background: Item {} - width: 550 - } - - FluentTextInput { - id: startDirInput - text: manualInfo ? manualInfo.launchDir : "" - anchors.top: steamscreener.top - anchors.left: steamscreener.left - anchors.topMargin: 266 - anchors.leftMargin: 24 - readOnly: true - background: Item {} - width: 550 - } - - FluentTextInput { - id: launchOptsInput - text: manualInfo ? manualInfo.config : "" - anchors.top: steamscreener.top - anchors.left: steamscreener.left - anchors.topMargin: 432 - anchors.leftMargin: 24 - readOnly: true - background: Item {} - width: 550 - } - - Row { - id: madrow - anchors.top: steamscreener.bottom - anchors.topMargin: 16 - spacing: 16 - - Button { - text: qsTr("OK") - onClicked: function(){ - manualAddDialog.close() - } - } - anchors.right: parent.right - } - } - } - - InfoDialog { - id: writeErrorDialog - titleText: qsTr("Error") - text: qsTr("Error writing shortcuts.vdf...\nPlease make sure Steam is running") - extraButton: true - extraButtonText: qsTr("Manual instructions") - onConfirmedExtra: function(data) { - manualAddDialog.open(); - } - } delegate: RPane { id: delegateRoot diff --git a/GlosSIConfig/qml/ShortcutProps.qml b/GlosSIConfig/qml/ShortcutProps.qml index 784fbc1..385a206 100644 --- a/GlosSIConfig/qml/ShortcutProps.qml +++ b/GlosSIConfig/qml/ShortcutProps.qml @@ -13,11 +13,12 @@ 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 +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import Qt5Compat.GraphicalEffects Item { @@ -54,7 +55,6 @@ Item { advancedTargetSettings.shortcutInfo = shortcutInfo; } if (maybeIcon) { - console.log("meh"); maybeIcon.source = shortcutInfo.icon ? shortcutInfo.icon.endsWith(".exe") ? "image://exe/" + shortcutInfo.icon @@ -221,6 +221,13 @@ Item { visible: uiModel.isWindows onClicked: uwpSelectDialog.open(); } + Button { + Layout.preferredWidth: 64 + Layout.alignment: Qt.AlignBottom + text: qsTr("EGS") + visible: uiModel.isWindows + onClicked: egsSelectDialog.open(); + } Item { height: 1 Layout.preferredWidth: 12 @@ -255,7 +262,6 @@ Item { AdvancedTargetSettings { id: advancedTargetSettings - shortcutInfo: shortcutInfo } Item { diff --git a/GlosSIConfig/qml/SteamNotFoundDialog.qml b/GlosSIConfig/qml/SteamNotFoundDialog.qml index 3b254e6..1aba489 100644 --- a/GlosSIConfig/qml/SteamNotFoundDialog.qml +++ b/GlosSIConfig/qml/SteamNotFoundDialog.qml @@ -13,10 +13,12 @@ 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 +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import Qt5Compat.GraphicalEffects Dialog { id: dlg @@ -80,10 +82,6 @@ Dialog { } Button { - anchors.right: parent.right - anchors.top: listview.bottom - anchors.topMargin: 16 - anchors.rightMargin: 2 text: qsTr("Ok") onClicked: dlg.close() } diff --git a/GlosSIConfig/qml/main.qml b/GlosSIConfig/qml/main.qml index 579cdfb..0126a17 100644 --- a/GlosSIConfig/qml/main.qml +++ b/GlosSIConfig/qml/main.qml @@ -13,9 +13,12 @@ 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.Layouts 6.2 -import QtQuick.Controls.Material 6.2 +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import Qt5Compat.GraphicalEffects Window { id: window @@ -26,6 +29,7 @@ Window { Material.accent: Material.color(Material.Blue, Material.Shade900) property bool itemSelected: false; + property var manualInfo: null title: qsTr("GlosSI - Config") @@ -125,6 +129,135 @@ Window { extraButtonText: qsTr("Remind me later") visible: !!uiModel.newVersionName } + + Dialog { + id: manualAddDialog + anchors.centerIn: parent + 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: madcontent; property: "y"; from: parent.height; to: 16; duration: 300; easing.type: Easing.OutQuad } + NumberAnimation{target: madbackground; property: "y"; from: parent.height; to: 0; duration: 300; easing.type: Easing.OutQuad } + NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 0; to: 1; duration: 300; easing.type: Easing.OutQuad } + } + + exit: Transition { + NumberAnimation{target: madcontent; property: "y"; from: 16; to: parent.height; duration: 300; easing.type: Easing.InQuad } + NumberAnimation{target: madbackground; property: "y"; from: 0; to: parent.height; duration: 300; easing.type: Easing.InQuad } + NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 1; to: 0; duration: 300; easing.type: Easing.InQuad } + } + + background: RPane { + id: madbackground + radius: 4 + Material.elevation: 64 + bgOpacity: 0.97 + } + contentItem: Item { + id: madcontent + implicitWidth: steamscreener.width + implicitHeight: madtext.height + 16 + steamscreener.height + 16 + madrow.height + + Label { + id: madtext + text: qsTr("Add \"GlosSITarget\" as game to Steam and change it's properties (in Steam) to this:") + } + + Image { + anchors.top: madtext.bottom + anchors.left: madtext.left + anchors.topMargin: 16 + id: steamscreener + source: "qrc:/steamscreener.png" + } + + FluentTextInput { + id: madnameinput + text: manualInfo ? manualInfo.name : "" + anchors.top: steamscreener.top + anchors.left: steamscreener.left + anchors.topMargin: 72 + anchors.leftMargin: 92 + readOnly: true + background: Item {} + width: 550 + } + + FluentTextInput { + id: glossiPathInput + text: manualInfo ? manualInfo.launch : "" + anchors.top: steamscreener.top + anchors.left: steamscreener.left + anchors.topMargin: 192 + anchors.leftMargin: 24 + readOnly: true + background: Item {} + width: 550 + } + + FluentTextInput { + id: startDirInput + text: manualInfo ? manualInfo.launchDir : "" + anchors.top: steamscreener.top + anchors.left: steamscreener.left + anchors.topMargin: 266 + anchors.leftMargin: 24 + readOnly: true + background: Item {} + width: 550 + } + + FluentTextInput { + id: launchOptsInput + text: manualInfo ? manualInfo.config : "" + anchors.top: steamscreener.top + anchors.left: steamscreener.left + anchors.topMargin: 432 + anchors.leftMargin: 24 + readOnly: true + background: Item {} + width: 550 + } + + Row { + id: madrow + anchors.top: steamscreener.bottom + anchors.topMargin: 16 + spacing: 16 + + Button { + text: qsTr("OK") + onClicked: function(){ + manualAddDialog.close() + } + } + anchors.right: parent.right + } + } + } + + InfoDialog { + id: writeErrorDialog + titleText: qsTr("Error") + text: qsTr("Error writing shortcuts.vdf...\nPlease make sure Steam is running") + extraButton: true + extraButtonText: qsTr("Manual instructions") + onConfirmedExtra: function(data) { + manualAddDialog.open(); + } + } Rectangle { id: titleBar @@ -318,7 +451,14 @@ Window { if (windowContent.editedIndex < 0) { uiModel.addTarget(shortcut) } else { - uiModel.updateTarget(windowContent.editedIndex, shortcut) + if (uiModel.updateTarget(windowContent.editedIndex, shortcut)) { + if (steamShortcutsChanged == false) { + steamChangedDialog.open(); + } + } else { + manualInfo = uiModel.manualProps(shortcut); + writeErrorDialog.open(); + } } } }