chore: applicationWindow property removed from Global singleton

Closes: #16455
This commit is contained in:
Michał Cieślak 2024-10-04 13:01:08 +02:00 committed by Michał
parent ffc5da3805
commit 9503def18b
17 changed files with 61 additions and 176 deletions

View File

@ -31,11 +31,6 @@ ApplicationWindow {
onCurrentPageChanged: testsReRunTimer.restart() onCurrentPageChanged: testsReRunTimer.restart()
// We need to set Global.applicationWindow to test components that relies on it e.g. ConfirmChangePasswordModal
Component.onCompleted: {
Global.applicationWindow = this;
}
QtObject { QtObject {
id: d id: d

View File

@ -206,10 +206,7 @@ QtObject {
messageModule.addNewMessagesMarker() messageModule.addNewMessagesMarker()
} }
property bool playAnimation: { readonly property bool isChatActive: {
if (!Global.applicationWindow.active)
return false
if (root.getSectionId() !== mainModule.activeSection.id) if (root.getSectionId() !== mainModule.activeSection.id)
return false return false

View File

@ -1,7 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import shared.stores 1.0 import shared.stores 1.0
import utils 1.0
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
@ -17,6 +16,7 @@ QtObject {
} }
property CommunityTokensStore communityTokensStore property CommunityTokensStore communityTokensStore
property alias active: feesBroker.active
property QtObject d: QtObject { property QtObject d: QtObject {
id: internal id: internal
@ -122,7 +122,8 @@ QtObject {
readonly property Component setSignerFeeSubscriptionComponent: SetSignerFeeSubscription {} readonly property Component setSignerFeeSubscriptionComponent: SetSignerFeeSubscription {}
readonly property SubscriptionBroker feesBroker: SubscriptionBroker { readonly property SubscriptionBroker feesBroker: SubscriptionBroker {
active: Global.applicationWindow.active id: feesBroker
onRequest: internal.computeFee(topic) onRequest: internal.computeFee(topic)
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
@ -594,6 +595,7 @@ StatusSectionLayout {
readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker { readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker {
communityTokensStore: root.rootStore.communityTokensStore communityTokensStore: root.rootStore.communityTokensStore
active: root.Window.window.active
} }
function goTo(section: int, subSection: int) { function goTo(section: int, subSection: int) {

View File

@ -1,6 +1,7 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Window 2.15
import QtQml.Models 2.15 import QtQml.Models 2.15
import QtGraphicalEffects 1.15 import QtGraphicalEffects 1.15
@ -93,9 +94,9 @@ StatusDialog {
ShaderEffectSource { ShaderEffectSource {
id: blurSource id: blurSource
sourceItem: Global.applicationWindow.contentItem sourceItem: Window.window.contentItem
width: Global.applicationWindow.contentItem.width width: Window.window.contentItem.width
height: Global.applicationWindow.contentItem.height height: Window.window.contentItem.height
live: false live: false
visible: false visible: false

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtMultimedia 5.15 import QtMultimedia 5.15
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
@ -576,11 +577,13 @@ Item {
} }
Connections { Connections {
target: Global.applicationWindow target: Window.window
function onActiveChanged() { function onActiveChanged() {
if (Global.applicationWindow.active) appMain.rootStore.windowActivated() if (Window.window.active)
else appMain.rootStore.windowDeactivated() appMain.rootStore.windowActivated()
else
appMain.rootStore.windowDeactivated()
} }
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import QtQml.Models 2.15 import QtQml.Models 2.15
import QtQml 2.15 import QtQml 2.15
@ -1112,6 +1113,7 @@ QtObject {
readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker { readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker {
communityTokensStore: root.communityTokensStore communityTokensStore: root.communityTokensStore
active: finalisePopup.contentItem.Window.window.active
} }
chainId: finalisePopup.ownerTokenDetails.chainId chainId: finalisePopup.ownerTokenDetails.chainId

View File

@ -1,10 +1,10 @@
import QtQuick 2.13 import QtQuick 2.15
import QtQuick.Window 2.15
import utils 1.0 import utils 1.0
MouseArea { MouseArea {
id: statusMacWindowButtons id: root
signal close() signal close()
signal minimised() signal minimised()
@ -20,6 +20,12 @@ MouseArea {
readonly property color inactiveBorder: Style.current.name === Constants.lightThemeName ? "#10000000" readonly property color inactiveBorder: Style.current.name === Constants.lightThemeName ? "#10000000"
: "#10FFFFFF" : "#10FFFFFF"
QtObject {
id: d
readonly property bool windowActive: root.Window.window.active
}
Row { Row {
id: layout id: layout
spacing: 8 spacing: 8
@ -30,15 +36,13 @@ MouseArea {
radius: width / 2 radius: width / 2
antialiasing: true antialiasing: true
color: closeSensor.pressed ? "#B24F47" : (Global.applicationWindow.active || statusMacWindowButtons.containsMouse ? Qt.lighter("#E9685C", 1.07) color: closeSensor.pressed ? "#B24F47" : (d.windowActive || root.containsMouse ? Qt.lighter("#E9685C", 1.07) : inactive)
: inactive ) border.color:closeSensor.pressed ? "#943229" : (d.windowActive ? "#D14C40" : inactiveBorder)
border.color:closeSensor.pressed ? "#943229" : (Global.applicationWindow.active ? "#D14C40"
: inactiveBorder)
border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0 border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
visible: statusMacWindowButtons.containsMouse visible: root.containsMouse
source: Style.png("traffic_lights/" + (closeSensor.pressed ? "close_pressed" : "close")) source: Style.png("traffic_lights/" + (closeSensor.pressed ? "close_pressed" : "close"))
scale: 0.25 scale: 0.25
} }
@ -48,7 +52,7 @@ MouseArea {
id: closeSensor id: closeSensor
anchors.fill: parent anchors.fill: parent
onClicked: statusMacWindowButtons.close() onClicked: root.close()
} }
} }
@ -58,16 +62,14 @@ MouseArea {
radius: width / 2 radius: width / 2
antialiasing: true antialiasing: true
color: miniSensor.pressed ? "#878E3B" : (Global.applicationWindow.active || statusMacWindowButtons.containsMouse ? Qt.lighter("#EDB84C", 1.07) color: miniSensor.pressed ? "#878E3B" : (d.windowActive || root.containsMouse ? Qt.lighter("#EDB84C", 1.07) : inactive)
: inactive) border.color:miniSensor.pressed ? "#986E29" : (d.windowActive ? "#D79F3D" : inactiveBorder)
border.color:miniSensor.pressed ? "#986E29" : (Global.applicationWindow.active ? "#D79F3D"
: inactiveBorder)
border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0 border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
anchors.verticalCenterOffset: -0.25 anchors.verticalCenterOffset: -0.25
visible: statusMacWindowButtons.containsMouse visible: root.containsMouse
source: Style.png("traffic_lights/" + (miniSensor.pressed ? "minimise_pressed" : "minimise")) source: Style.png("traffic_lights/" + (miniSensor.pressed ? "minimise_pressed" : "minimise"))
scale: 0.27 scale: 0.27
} }
@ -76,7 +78,7 @@ MouseArea {
id: miniSensor id: miniSensor
anchors.fill: parent anchors.fill: parent
onClicked: statusMacWindowButtons.minimised() onClicked: root.minimised()
} }
} }
@ -86,15 +88,13 @@ MouseArea {
radius: width / 2 radius: width / 2
antialiasing: true antialiasing: true
color: maxiSensor.pressed ? "#48943f" : (Global.applicationWindow.active || statusMacWindowButtons.containsMouse ? Qt.lighter("#62C454", 1.06) color: maxiSensor.pressed ? "#48943f" : (d.windowActive || root.containsMouse ? Qt.lighter("#62C454", 1.06) : inactive)
: inactive) border.color: maxiSensor.pressed ? "#357225" : (d.windowActive ? "#53A73E" : inactiveBorder)
border.color: maxiSensor.pressed ? "#357225" : (Global.applicationWindow.active ? "#53A73E"
: inactiveBorder)
border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0 border.width: Style.current.name === Constants.lightThemeName ? 0.5 : 0
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
visible: statusMacWindowButtons.containsMouse visible: root.containsMouse
source: Style.png("traffic_lights/" + (maxiSensor.pressed ? "maximize_pressed" : "maximize")) source: Style.png("traffic_lights/" + (maxiSensor.pressed ? "maximize_pressed" : "maximize"))
scale: 0.25 scale: 0.25
} }
@ -103,7 +103,7 @@ MouseArea {
id: maxiSensor id: maxiSensor
anchors.fill: parent anchors.fill: parent
onClicked: statusMacWindowButtons.maximized() onClicked: root.maximized()
} }
} }
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtGraphicalEffects 1.15 import QtGraphicalEffects 1.15
import utils 1.0 import utils 1.0
@ -72,7 +73,7 @@ Rectangle {
if (!active || !flickable) if (!active || !flickable)
return; return;
const item = Global.applicationWindow.activeFocusItem; const item = Window.window.activeFocusItem;
const h1 = this.height; const h1 = this.height;
const y1 = this.mapToGlobal(0, 0).y; const y1 = this.mapToGlobal(0, 0).y;
const h2 = item.height; const h2 = item.height;

View File

@ -1,10 +1,8 @@
import QtQuick 2.3 import QtQuick 2.15
import QtGraphicalEffects 1.13 import QtQuick.Window 2.15
import shared 1.0 import QtGraphicalEffects 1.15
import shared.panels 1.0 import shared.panels 1.0
import utils 1.0
Item { Item {
id: root id: root
@ -12,7 +10,8 @@ Item {
property int imageWidth: 350 property int imageWidth: 350
property url source property url source
property bool isActiveChannel: false property bool isActiveChannel: false
property bool playing: Global.applicationWindow.active property bool playing: Window.window.active
property bool isAnimated: !!source && source.toString().endsWith('.gif') property bool isAnimated: !!source && source.toString().endsWith('.gif')
property alias imageAlias: imageMessage property alias imageAlias: imageMessage
property bool allCornersRounded: false property bool allCornersRounded: false

View File

@ -1,14 +1,13 @@
import QtQuick 2.13 import QtQuick 2.15
import QtQuick.Window 2.2 import QtQuick.Controls 2.15
import QtQuick.Controls 2.13 import QtQuick.Window 2.15
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.15
import StatusQ.Popups.Dialog 0.1 import StatusQ.Popups.Dialog 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import utils 1.0 import utils 1.0
import shared 1.0
import shared.popups 1.0 import shared.popups 1.0
StatusDialog { StatusDialog {
@ -30,8 +29,8 @@ StatusDialog {
QtObject { QtObject {
id: d id: d
property int maxHeight: Global.applicationWindow.height - 80 property int maxHeight: root.contentItem.Window.window.height - 80
property int maxWidth: Global.applicationWindow.width - 80 property int maxWidth: root.contentItem.Window.window.width - 80
readonly property int radius: Style.current.radius readonly property int radius: Style.current.radius
} }

View File

@ -1,115 +0,0 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import shared 1.0
import shared.panels 1.0
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
Rectangle {
id: root
property string chatId: ""
property string name: "channelName"
property string message: "My latest message\n with a return"
property int chatType: Constants.chatType.unknown
color: "#F7F7F7"
width: 366
height: 75
anchors.top: Global.applicationWindow.top
radius: Style.current.radius
Loader {
id: identicon
sourceComponent: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewAnonymous ? statusIdenticon : userOrChannelIdenticon
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
height: 40
width: 40
}
Component {
id: userOrChannelIdenticon
StatusSmartIdenticon {
id: contactImage
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
asset.width: 40
asset.height: 40
asset.letterSize: 15
asset.color: Theme.palette.miscColor5
name: root.name
}
}
Component {
id: statusIdenticon
SVGImage {
source: Style.png("status-logo-icon")
width: 40
height: 40
}
}
StyledText {
id: name
anchors.bottom: messagePreview.top
anchors.bottomMargin: 2
anchors.left: identicon.right
anchors.leftMargin: Style.current.smallPadding
anchors.right: openButton.left
anchors.rightMargin: Style.current.smallPadding
elide: Text.ElideRight
text: root.name
font.weight: Font.Medium
font.pixelSize: 15
color: Style.current.evenDarkerGrey
}
StyledText {
id: messagePreview
anchors.bottom: identicon.bottom
anchors.bottomMargin: 2
anchors.left: identicon.right
anchors.leftMargin: Style.current.smallPadding
anchors.right: openButton.left
anchors.rightMargin: Style.current.padding
elide: Text.ElideRight
clip: true // This is needed because emojis don't ellide correctly
font.pixelSize: 14
color: Style.current.evenDarkerGrey
text: root.message
}
Rectangle {
id: openButton
anchors.right: parent.right
height: parent.height
width: 85
color: "transparent"
Rectangle {
height: parent.height
width: 1.2
anchors.left: parent.left
color: "#D9D9D9"
}
StyledText {
font.weight: Font.Medium
font.pixelSize: 14
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Open")
color: Style.current.darkerGrey
}
}
}

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import QtMultimedia 5.15 import QtMultimedia 5.15
import StatusQ.Popups.Dialog 0.1 import StatusQ.Popups.Dialog 0.1
@ -24,8 +25,8 @@ StatusDialog {
QtObject { QtObject {
id: d id: d
readonly property int maxHeight: Global.applicationWindow.height - 80 readonly property int maxHeight: root.contentItem.Window.window.height - 80
readonly property int maxWidth: Global.applicationWindow.width - 80 readonly property int maxWidth: root.contentItem.Window.window.width - 80
} }
onOpened: { onOpened: {

View File

@ -16,7 +16,6 @@ StatusImageModal 1.0 StatusImageModal.qml
StatusVideoModal 1.0 StatusVideoModal.qml StatusVideoModal 1.0 StatusVideoModal.qml
StatusImageRadioButton 1.0 StatusImageRadioButton.qml StatusImageRadioButton 1.0 StatusImageRadioButton.qml
StatusInputListPopup 1.0 StatusInputListPopup.qml StatusInputListPopup 1.0 StatusInputListPopup.qml
StatusNotification 1.0 StatusNotification.qml
StatusSearchListPopup 1.0 StatusSearchListPopup.qml StatusSearchListPopup 1.0 StatusSearchListPopup.qml
StatusSectionHeadline 1.0 StatusSectionHeadline.qml StatusSectionHeadline 1.0 StatusSectionHeadline.qml
StatusSettingsLineButton 1.0 StatusSettingsLineButton.qml StatusSettingsLineButton 1.0 StatusSettingsLineButton.qml

View File

@ -1,5 +1,6 @@
import QtQuick 2.14 import QtQuick 2.15
import QtQuick.Layouts 1.14 import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import utils 1.0 import utils 1.0
import shared.panels 1.0 import shared.panels 1.0
@ -950,9 +951,10 @@ Loader {
linksComponent: Component { linksComponent: Component {
LinksMessageView { LinksMessageView {
id: linksMessageView id: linksMessageView
linkPreviewModel: root.linkPreviewModel linkPreviewModel: root.linkPreviewModel
gifLinks: root.gifLinks gifLinks: root.gifLinks
playAnimations: root.messageStore.playAnimation playAnimations: Window.window.active && root.messageStore.isChatActive
isOnline: root.rootStore.mainModuleInst.isOnline isOnline: root.rootStore.mainModuleInst.isOnline
highlightLink: delegate.hoveredLink highlightLink: delegate.hoveredLink
onImageClicked: (image, mouse, imageSource, url) => { onImageClicked: (image, mouse, imageSource, url) => {

View File

@ -6,7 +6,6 @@ QtObject {
id: root id: root
property var dragArea property var dragArea
property var applicationWindow
property bool activityPopupOpened: false property bool activityPopupOpened: false
property int settingsSubsection: Constants.settingsSubsection.profile property int settingsSubsection: Constants.settingsSubsection.profile
property int settingsSubSubsection: -1 property int settingsSubSubsection: -1

View File

@ -283,7 +283,6 @@ StatusWindow {
} }
Component.onCompleted: { Component.onCompleted: {
Global.applicationWindow = this;
Style.changeTheme(Universal.System, systemPalette.isCurrentSystemThemeDark()); Style.changeTheme(Universal.System, systemPalette.isCurrentSystemThemeDark());
restoreAppState(); restoreAppState();