From 2ee37827ec17bb4288432761a994f16042740cca Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 17 Dec 2023 12:47:13 -0500 Subject: [PATCH] Fix more unqualified accesses in QML --- launcher/ui/Main.qml | 18 ++++++------ launcher/ui/Pages/AutoLoginPage.qml | 2 +- launcher/ui/Pages/LoginPage.qml | 28 +++++++++++-------- launcher/ui/Pages/NewsPage.qml | 6 ++++ launcher/ui/Settings/AccountsPage.qml | 16 +++++++---- .../ui/Settings/CompatibilityToolSetup.qml | 4 +-- launcher/ui/Settings/GeneralSettings.qml | 8 +++++- launcher/ui/Settings/ProfilesPage.qml | 10 +++++-- launcher/ui/Setup/AccountSetup.qml | 6 ++-- launcher/ui/Setup/InstallProgress.qml | 4 ++- launcher/ui/Setup/SetupPage.qml | 6 ++-- 11 files changed, 68 insertions(+), 40 deletions(-) diff --git a/launcher/ui/Main.qml b/launcher/ui/Main.qml index 5740912..cda8368 100644 --- a/launcher/ui/Main.qml +++ b/launcher/ui/Main.qml @@ -8,8 +8,6 @@ import org.kde.kirigami as Kirigami import zone.xiv.astra -import "Pages" - Kirigami.ApplicationWindow { id: appWindow @@ -78,7 +76,7 @@ Kirigami.ApplicationWindow { function openUrl(url) { if (LauncherCore.isSteamDeck) { - pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BrowserPage"), { + appWindow.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BrowserPage"), { url: url }) } else { @@ -90,14 +88,14 @@ Kirigami.ApplicationWindow { target: LauncherCore function onLoadingFinished() { - checkSetup(); + appWindow.checkSetup(); } function onSuccessfulLaunch() { if (LauncherCore.settings.closeWhenLaunched) { - hide(); + appWindow.hide(); } else { - checkSetup(); + appWindow.checkSetup(); } } @@ -105,12 +103,12 @@ Kirigami.ApplicationWindow { if (LauncherCore.settings.closeWhenLaunched) { Qt.callLater(Qt.quit); } else { - checkSetup(); + appWindow.checkSetup(); } } function onCurrentProfileChanged() { - checkSetup(); + appWindow.checkSetup(); } } @@ -120,14 +118,14 @@ Kirigami.ApplicationWindow { function onShowNewsChanged() { // workaround annoying Qt layout bug // TODO: see if this changed in Qt7 - pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage")) + appWindow.pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage")) } } Component.onCompleted: checkSetup() property Item hoverLinkIndicator: QQC2.Control { - parent: overlay.parent + parent: appWindow.overlay.parent property alias text: linkText.text opacity: text.length > 0 ? 1 : 0 diff --git a/launcher/ui/Pages/AutoLoginPage.qml b/launcher/ui/Pages/AutoLoginPage.qml index 19535a7..d2ba412 100644 --- a/launcher/ui/Pages/AutoLoginPage.qml +++ b/launcher/ui/Pages/AutoLoginPage.qml @@ -41,7 +41,7 @@ Kirigami.Page { onTriggered: { autoLoginTimer.stop(); if (LauncherCore.autoLogin(LauncherCore.autoLoginProfile)) { - pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); + root.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); } } } diff --git a/launcher/ui/Pages/LoginPage.qml b/launcher/ui/Pages/LoginPage.qml index d444ac2..bf52613 100644 --- a/launcher/ui/Pages/LoginPage.qml +++ b/launcher/ui/Pages/LoginPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -72,7 +74,7 @@ QQC2.Control { target: LauncherCore function onCurrentProfileChanged() { - updateFields(); + page.updateFields(); } } @@ -80,7 +82,7 @@ QQC2.Control { target: LauncherCore.currentProfile function onAccountChanged() { - updateFields(); + page.updateFields(); if (!LauncherCore.currentProfile.account.rememberPassword) { passwordField.forceActiveFocus(); @@ -117,14 +119,16 @@ QQC2.Control { model: LauncherCore.profileManager QQC2.MenuItem { + id: profileMenuItem + required property var profile QQC2.MenuItem { - text: profile.name + text: profileMenuItem.profile.name onClicked: { - LauncherCore.currentProfile = profile - profileMenu.close() + LauncherCore.currentProfile = profileMenuItem.profile; + profileMenu.close(); } } } @@ -160,16 +164,18 @@ QQC2.Control { model: LauncherCore.accountManager QQC2.MenuItem { + id: menuItem + required property var account QQC2.MenuItem { - text: account.name - icon.name: account.avatarUrl.length === 0 ? "actor" : "" - icon.source: account.avatarUrl + text: menuItem.account.name + icon.name: menuItem.account.avatarUrl.length === 0 ? "actor" : "" + icon.source: menuItem.account.avatarUrl onClicked: { - LauncherCore.currentProfile.account = account - accountMenu.close() + LauncherCore.currentProfile.account = menuItem.account; + accountMenu.close(); } } } @@ -238,7 +244,7 @@ QQC2.Control { id: loginButton text: i18n("Log In") - description: invalidLoginReason + description: page.invalidLoginReason icon.name: "unlock" enabled: page.isLoginValid onClicked: { diff --git a/launcher/ui/Pages/NewsPage.qml b/launcher/ui/Pages/NewsPage.qml index 1d8e738..a65e2c4 100644 --- a/launcher/ui/Pages/NewsPage.qml +++ b/launcher/ui/Pages/NewsPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -118,6 +120,8 @@ QQC2.Control { model: LauncherCore.headline !== null ? LauncherCore.headline.news : undefined FormCard.FormButtonDelegate { + required property var modelData + text: modelData.title description: Qt.formatDate(modelData.date) @@ -156,6 +160,8 @@ QQC2.Control { model: LauncherCore.headline !== null ? LauncherCore.headline.topics : undefined FormCard.FormButtonDelegate { + required property var modelData + text: modelData.title description: Qt.formatDate(modelData.date) diff --git a/launcher/ui/Settings/AccountsPage.qml b/launcher/ui/Settings/AccountsPage.qml index c3946fe..a2d58af 100644 --- a/launcher/ui/Settings/AccountsPage.qml +++ b/launcher/ui/Settings/AccountsPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts import QtQuick.Window @@ -24,29 +26,31 @@ FormCard.FormCardPage { model: LauncherCore.accountManager ColumnLayout { + id: layout + required property var account required property int index spacing: 0 FormCard.FormButtonDelegate { - text: account.name - description: account.isSapphire ? i18n("Sapphire") : i18n("Square Enix") + text: layout.account.name + description: layout.account.isSapphire ? i18n("Sapphire") : i18n("Square Enix") leading: Components.Avatar { - name: account.name - source: account.avatarUrl + name: layout.account.name + source: layout.account.avatarUrl } leadingPadding: Kirigami.Units.largeSpacing * 2 onClicked: root.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AccountSettings"), { - account: account + account: layout.account }) } FormCard.FormDelegateSeparator { - visible: index + 1 < LauncherCore.accountManager.numAccounts() + visible: layout.index + 1 < LauncherCore.accountManager.numAccounts() } } } diff --git a/launcher/ui/Settings/CompatibilityToolSetup.qml b/launcher/ui/Settings/CompatibilityToolSetup.qml index 85c319a..1789e75 100644 --- a/launcher/ui/Settings/CompatibilityToolSetup.qml +++ b/launcher/ui/Settings/CompatibilityToolSetup.qml @@ -75,8 +75,8 @@ FormCard.FormCardPage { } function onError(message) { - errorDialog.subtitle = message - errorDialog.open() + page.errorDialog.subtitle = message; + page.errorDialog.open(); } } } \ No newline at end of file diff --git a/launcher/ui/Settings/GeneralSettings.qml b/launcher/ui/Settings/GeneralSettings.qml index a4a6a26..3aee194 100644 --- a/launcher/ui/Settings/GeneralSettings.qml +++ b/launcher/ui/Settings/GeneralSettings.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Window import QtQuick.Controls as QQC2 @@ -12,6 +14,8 @@ import org.kde.kirigamiaddons.formcard as FormCard import zone.xiv.astra FormCard.FormCardPage { + id: page + title: i18nc("@title:window", "General") FormCard.FormCard { @@ -74,7 +78,9 @@ FormCard.FormCardPage { checked: LauncherCore.settings.showNews onCheckedChanged: { LauncherCore.settings.showNews = checked; - Window.window.close(); // if we don't close the dialog it crashes! + if (page.Window.window !== null) { + page.Window.window.close(); // if we don't close the dialog it crashes! + } } } diff --git a/launcher/ui/Settings/ProfilesPage.qml b/launcher/ui/Settings/ProfilesPage.qml index ce70407..570c615 100644 --- a/launcher/ui/Settings/ProfilesPage.qml +++ b/launcher/ui/Settings/ProfilesPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts import QtQuick.Window @@ -23,6 +25,8 @@ FormCard.FormCardPage { model: LauncherCore.profileManager ColumnLayout { + id: layout + required property var profile required property int index @@ -31,14 +35,14 @@ FormCard.FormCardPage { FormCard.FormButtonDelegate { id: buttonDelegate - text: profile.name + text: layout.profile.name onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "ProfileSettings"), { - profile: profile + profile: layout.profile }) } FormCard.FormDelegateSeparator { - visible: index + 1 < LauncherCore.profileManager.numProfiles() + visible: layout.index + 1 < LauncherCore.profileManager.numProfiles() } } } diff --git a/launcher/ui/Setup/AccountSetup.qml b/launcher/ui/Setup/AccountSetup.qml index a6c3c91..d0fe051 100644 --- a/launcher/ui/Setup/AccountSetup.qml +++ b/launcher/ui/Setup/AccountSetup.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts @@ -72,7 +74,7 @@ FormCard.FormCardPage { text: i18n("Add Square Enix Account") icon.name: "list-add-symbolic" - onClicked: pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AddSquareEnix"), { + onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AddSquareEnix"), { profile: page.profile }) } @@ -87,7 +89,7 @@ FormCard.FormCardPage { text: i18n("Add Sapphire Account") icon.name: "list-add-symbolic" - onClicked: pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AddSapphire"), { + onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AddSapphire"), { profile: page.profile }) } diff --git a/launcher/ui/Setup/InstallProgress.qml b/launcher/ui/Setup/InstallProgress.qml index ddb0d7e..32d9309 100644 --- a/launcher/ui/Setup/InstallProgress.qml +++ b/launcher/ui/Setup/InstallProgress.qml @@ -9,6 +9,8 @@ import org.kde.kirigami as Kirigami import zone.xiv.astra Kirigami.Page { + id: page + property var gameInstaller title: i18n("Game Installation") @@ -33,7 +35,7 @@ Kirigami.Page { Component.onCompleted: gameInstaller.installGame() Connections { - target: gameInstaller + target: page.gameInstaller function onInstallFinished() { applicationWindow().checkSetup(); diff --git a/launcher/ui/Setup/SetupPage.qml b/launcher/ui/Setup/SetupPage.qml index ff1ca5a..c73e49d 100644 --- a/launcher/ui/Setup/SetupPage.qml +++ b/launcher/ui/Setup/SetupPage.qml @@ -32,7 +32,7 @@ FormCard.FormCardPage { FormCard.FormTextDelegate { text: { - if (isInitialSetup) { + if (page.isInitialSetup) { return i18n("You must have a legitimate installation of the FFXIV to continue."); } else { return i18n("You must select a legitimate installation of FFXIV for '%1'", page.profile.name); @@ -88,7 +88,7 @@ FormCard.FormCardPage { text: i18n("Find Existing Installation") icon.name: "edit-find" - onClicked: pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "ExistingSetup"), { + onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "ExistingSetup"), { profile: page.profile }) } @@ -103,7 +103,7 @@ FormCard.FormCardPage { text: i18n("Download Game") icon.name: "cloud-download" - onClicked: pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "DownloadSetup"), { + onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "DownloadSetup"), { profile: page.profile }) }