feat(desktop/wallet) Removed dynamic scoping from wallet

Removed all dynamic scoping parts in wallet section plus

- Renamed Config to Global and added more functions there
- Moved changeAppSectionBySectionType function to Global
  and updated all places where is used to call it from
  Global instead
- Moved openLink function to Global and updated all places
  where is used to call it from Global instead
- Moved errorSound to Global, introduced playErrorSound
  function  and updated all places where is used to call
  this function from Global instead

Closes #4245
This commit is contained in:
Alexandra Betouni 2021-12-06 23:10:54 +02:00 committed by Sale Djenic
parent f138fecdd2
commit 336f90a60f
51 changed files with 197 additions and 190 deletions

View File

@ -117,7 +117,7 @@ PopupMenu {
text: qsTrId("settings")
shortcut: "Ctrl+,"
onTriggered: {
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
Global.changeAppSectionBySectionType(Constants.appSection.profile)
// TODO: replace with shared store constant
// Profile/RootStore.browser_settings_id
profileLayoutContainer.changeProfileSection(10)

View File

@ -120,7 +120,7 @@ Item {
text: qsTrId("chat-notification-preferences")
onTriggered: {
activityCenter.close()
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
Global.changeAppSectionBySectionType(Constants.appSection.profile)
// TODO: replace with shared store constant
// Profile/RootStore.notifications_id
profileLayoutContainer.changeProfileSection(7)

View File

@ -37,7 +37,7 @@ StatusModal {
if (rememberChoiceCheckBox.checked) {
localAccountSensitiveSettings.openLinksInStatus = true
}
changeAppSectionBySectionType(Constants.appSection.browser)
Global.changeAppSectionBySectionType(Constants.appSection.browser)
browserLayoutContainer.item.openUrlInNewTab(popup.link)
popup.close()
}

View File

@ -82,7 +82,7 @@ ModalPopup {
cursorShape: "PointingHandCursor"
onClicked: {
popup.profileClicked();
Config.currentMenuTab = 0;
Global.currentMenuTab = 0;
popup.close();
}
}

View File

@ -65,7 +65,7 @@ Item {
// if(root.store.chatsModelInst.communities.activeCommunity.active)
// {
// root.store.chatsModelInst.channelView.joinPublicChat(channelName)
// appMain.changeAppSectionBySectionType(Constants.appSection.chat)
// Global.changeAppSectionBySectionType(Constants.appSection.chat)
// }
return
}
@ -77,7 +77,7 @@ Item {
// Not Refactored Yet
// if(root.store.chatsModelInst.communities.activeCommunity.active) {
// root.store.chatsModelInst.channelView.joinPublicChat(channelName)
// appMain.changeAppSectionBySectionType(Constants.appSection.chat)
// Global.changeAppSectionBySectionType(Constants.appSection.chat)
// }
// root.store.chatsModelInst.channelView.setActiveChannel(channelName);
}
@ -105,7 +105,7 @@ Item {
}
appMain.openLink(link)
Global.openLink(link)
}
onLinkHovered: {

View File

@ -32,7 +32,7 @@ StatusAppTwoPanelLayout {
property int profileContentWidth: Math.max(contentMinWidth, Math.min(profileContainer.width * 0.8, contentMaxWidth))
anchors.fill: parent
currentIndex: Config.currentMenuTab
currentIndex: Global.currentMenuTab
onCurrentIndexChanged: {
if(visibleChildren[0] === ensContainer){

View File

@ -23,7 +23,7 @@ Column {
itemId: model.menu_id
title: model.text
icon.name: model.icon
selected: Config.currentMenuTab === model.menu_id
selected: Global.currentMenuTab === model.menu_id
onClicked: root.menuItemClicked(model)
}
}
@ -37,7 +37,7 @@ Column {
itemId: model.menu_id
title: model.text
icon.name: model.icon
selected: Config.currentMenuTab === model.menu_id
selected: Global.currentMenuTab === model.menu_id
onClicked: root.menuItemClicked(model)
visible: model.ifEnabled !== "browser" || root.browserMenuItemEnabled
badge.value: !mnemonicModule.isBackedUp && settingsMenuDelegate.title === qsTr("Privacy and security")
@ -56,7 +56,7 @@ Column {
itemId: model.menu_id
title: model.text
icon.name: model.icon
selected: Config.currentMenuTab === model.menu_id
selected: Global.currentMenuTab === model.menu_id
visible: model.ifEnabled !== "browser" || root.browserMenuItemEnabled
onClicked: root.menuItemClicked(model)
}

View File

@ -197,10 +197,6 @@ QtObject {
return utilsModelInst.generateAlias(pubKey)
}
function changeAppSectionBySectionType(section) {
appMain.changeAppSectionBySectionType(section)
}
function joinPrivateChat(address) {
chatsModelInst.channelView.joinPrivateChat(address, "");
}

View File

@ -81,7 +81,7 @@ Item {
parent.font.underline = false
}
onClicked: {
appMain.openLink("https://status.im/privacy-policy/")
Global.openLink("https://status.im/privacy-policy/")
}
}
}

View File

@ -259,12 +259,12 @@ Item {
onCountChanged: searchResults.isAddedContact = searchResults.isContactAdded()
onContactClicked: {
root.store.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.store.joinPrivateChat(contact.address)
}
onSendMessageActionTriggered: {
root.store.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.store.joinPrivateChat(contact.address)
}

View File

@ -136,7 +136,7 @@ Item {
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: appMain.openLink("https://status.im/user_guides/pairing_devices.html")
onClicked: Global.openLink("https://status.im/user_guides/pairing_devices.html")
}
}
}

View File

@ -178,7 +178,7 @@ Item {
text: qsTrId("-a-href---1-2--look-up-on-etherscan--a-").arg(root.store.etherscanLink.replace("/tx", "/address")).arg(root.store.getEnsUsernameRegistrar())
anchors.left: parent.left
anchors.right: parent.right
onLinkActivated: appMain.openLink(link)
onLinkActivated: Global.openLink(link)
color: Theme.palette.directColor1
MouseArea {
anchors.fill: parent
@ -202,7 +202,7 @@ Item {
text: qsTrId("-a-href---1-2--look-up-on-etherscan--a-").arg(root.store.etherscanLink.replace("/tx", "/address")).arg(root.ensRegistry)
anchors.left: parent.left
anchors.right: parent.right
onLinkActivated: appMain.openLink(link)
onLinkActivated: Global.openLink(link)
color: Theme.palette.directColor1
MouseArea {
anchors.fill: parent

View File

@ -158,7 +158,7 @@ Item {
parent.font.underline = false
}
onClicked: {
appMain.openLink("https://status.im/docs/FAQs.html")
Global.openLink("https://status.im/docs/FAQs.html")
}
}
}
@ -182,7 +182,7 @@ Item {
parent.font.underline = false
}
onClicked: {
appMain.openLink("https://github.com/status-im/nim-status-client/issues/new")
Global.openLink("https://github.com/status-im/nim-status-client/issues/new")
}
}
}
@ -206,7 +206,7 @@ Item {
parent.font.underline = false
}
onClicked: {
appMain.openLink("https://discuss.status.im/c/features/51")
Global.openLink("https://discuss.status.im/c/features/51")
}
}
}

View File

@ -12,7 +12,7 @@ Item {
property var store
property var changeProfileSection: function (sectionId) {
Config.currentMenuTab = sectionId
Global.currentMenuTab = sectionId
}
StatusNavigationPanelHeadline {
@ -47,7 +47,7 @@ Item {
if (!!menu_item.function_name && menu_item.function_name === "exit") {
return confirmDialog.open()
}
Config.currentMenuTab = menu_item.menu_id
Global.currentMenuTab = menu_item.menu_id
}
}
}

View File

@ -18,7 +18,7 @@ Item {
property bool hideSignPhraseModal: false
function showSigningPhrasePopup(){
if(!hideSignPhraseModal && !localAccountSensitiveSettings.hideSignPhraseModal){
if(!hideSignPhraseModal && !RootStore.hideSignPhraseModal){
signPhrasePopup.open();
}
}
@ -26,7 +26,7 @@ Item {
SignPhraseModal {
id: signPhrasePopup
onRemindLaterClicked: hideSignPhraseModal = true
onAcceptClicked: localAccountSensitiveSettings.hideSignPhraseModal = true
onAcceptClicked: { RootStore.hideSignPhraseModal(true); }
}
SeedPhraseBackupWarning {
@ -73,6 +73,7 @@ Item {
rightPanel: RightTabView {
id: walletContainer
anchors.fill: parent
changeSelectedAccount: leftTab.changeSelectedAccount
}
}
}

View File

@ -8,6 +8,7 @@ import shared.panels 1.0
Item {
id: assetDelegate
property string locale: ""
property string currency: ""
anchors.right: parent.right
@ -49,7 +50,7 @@ Item {
}
StyledText {
id: assetBalance
text: Utils.toLocaleString(balance, localAppSettings.locale) + " " + symbol.toUpperCase()
text: Utils.toLocaleString(balance, locale) + " " + symbol.toUpperCase()
anchors.right: parent.right
anchors.rightMargin: 0
font.pixelSize: 15
@ -58,7 +59,7 @@ Item {
StyledText {
id: assetCurrencyBalance
color: Style.current.secondaryText
text: Utils.toLocaleString(currencyBalance.toFixed(2), localAppSettings.locale) + " " + assetDelegate.currency.toUpperCase()
text: Utils.toLocaleString(currencyBalance.toFixed(2), locale) + " " + assetDelegate.currency.toUpperCase()
anchors.right: parent.right
anchors.rightMargin: 0
anchors.bottom: parent.bottom

View File

@ -13,6 +13,7 @@ Rectangle {
property string ethValue: ""
property bool isHovered: false
property string symbol: ""
property string locale: ""
property bool isIncoming: to === currentAccountAddress
signal launchTransactionModal()
@ -141,7 +142,7 @@ Rectangle {
}
StyledText {
id: timeValue
text: new Date(parseInt(timestamp)*1000).toLocaleString(localAppSettings.locale)
text: new Date(parseInt(timestamp)).toLocaleString(locale)
font.pixelSize: Style.current.primaryTextFontSize
anchors.rightMargin: Style.current.smallPadding
}

View File

@ -8,6 +8,7 @@ import shared.panels 1.0
Rectangle {
id: walletDelegate
property string locale: ""
property string currency: ""
property int selectedAccountIndex
property bool selected: index === selectedAccountIndex
@ -81,7 +82,7 @@ Rectangle {
StyledText {
id: walletBalance
text: {
Utils.toLocaleString(currencyBalance.toFixed(2), localAppSettings.locale, {"currency": true}) + " " + walletDelegate.currency.toUpperCase()
Utils.toLocaleString(currencyBalance.toFixed(2), locale, {"currency": true}) + " " + walletDelegate.currency.toUpperCase()
}
anchors.top: parent.top
anchors.topMargin: Style.current.smallPadding

View File

@ -1,66 +0,0 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import shared 1.0
import "../controls"
Item {
id: collectiblesContainer
property url collectibleIconSource: "CryptoKitties"
property string collectibleName: "CryptoKitties"
property bool collectiblesOpened: false
property var collectiblesModal
property string buttonText: "View in Cryptokitties"
property var getLink: function () {}
property var collectibles: {
if (error) {
return []
}
try {
var result = JSON.parse(collectiblesJSON)
if (typeof result === "string") {
return JSON.parse(result)
}
return result
} catch (e) {
console.error('Error parsing collectibles for:', collectibleName)
console.error('JSON:', collectiblesJSON)
console.error('Error:', e)
return []
}
}
// Adding active instead of just using visible, because visible counts as false when the parent is not visible
property bool active: !!loading || !!error || collectibles.length > 0
signal reloadCollectibles(string collectibleType)
visible: active
width: parent.width
height: visible ? collectiblesHeader.height + collectiblesContent.height : 0
CollectiblesHeader {
id: collectiblesHeader
collectibleName: collectiblesContainer.collectibleName
collectibleIconSource: collectiblesContainer.collectibleIconSource
collectiblesQty: collectibles.length
isLoading: loading
toggleCollectible: function () {
collectiblesContainer.collectiblesOpened = !collectiblesContainer.collectiblesOpened
}
}
CollectiblesContent {
id: collectiblesContent
visible: collectiblesContainer.collectiblesOpened
collectiblesModal: collectiblesContainer.collectiblesModal
buttonText: collectiblesContainer.buttonText
getLink: collectiblesContainer.getLink()
anchors.top: collectiblesHeader.bottom
anchors.topMargin: Style.current.halfPadding
collectibles: collectiblesContainer.collectibles
onReloadCollectibles: reloadCollectibles(collectibleType)
}
}

View File

@ -62,7 +62,7 @@ ScrollView {
anchors.top: somethingWentWrongText.bottom
anchors.topMargin: Style.current.halfPadding
onClicked: {
reloadCollectibleClicked(collectibleType)
reloadCollectibles(collectibleType);
}
}
}

View File

@ -17,6 +17,7 @@ Item {
property var customTokenList
signal toggleVisibleClicked(string symbol)
signal removeCustomTokenTriggered(string address)
signal tokenDetailsTriggered(string address, string name, string symbol, string decimals)
SearchBox {
id: searchBox
@ -101,7 +102,9 @@ Item {
icon.source: Style.svg("make-admin")
//% "Token details"
text: qsTrId("token-details")
onTriggered: addCustomTokenModal.openWithData(address, name, symbol, decimals)
onTriggered: {
modalBody.tokenDetailsTriggered(address, name, symbol, decimals);
}
}
Action {
icon.source: Style.svg("remove-from-group")

View File

@ -15,6 +15,7 @@ import "../stores"
Item {
id: walletHeader
property string locale: ""
property string currency: ""
property var currentAccount
property var changeSelectedAccount
@ -55,7 +56,7 @@ Item {
StyledText {
id: walletBalance
text: {
Utils.toLocaleString(currentAccount.currencyBalance.toFixed(2), localAppSettings.locale, {"currency": true}) + " " + walletHeader.currency.toUpperCase()
Utils.toLocaleString(currentAccount.currencyBalance.toFixed(2), locale, {"currency": true}) + " " + walletHeader.currency.toUpperCase()
}
anchors.left: separatorDot.right
anchors.leftMargin: 8
@ -98,6 +99,12 @@ Item {
onClosed: {
destroy();
}
onAddCustomTokenTriggered: {
addCustomTokenModal.openEditable();
}
onTokenDetailsTriggered: {
addCustomTokenModal.openWithData(address, name, symbol, decimals);
}
}
}

View File

@ -146,8 +146,16 @@ ModalPopup {
text: qsTrId("a-deleted-account-cannot-be-retrieved-later.-only-press-yes-if-you-backed-up-your-key/seed-or-don't-care-about-this-account-anymore")
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
RootStore.deleteAccount(currentAccount.address)// Change active account to the first
onAccepted: {
const error = RootStore.deleteAccount(currentAccount.address)
if (error) {
Global.playErrorSound();
deleteError.text = error
deleteError.open()
return
}
// Change active account to the first
changeSelectedAccount(0)
popup.close();
}
@ -169,7 +177,7 @@ ModalPopup {
MessageDialog {
id: changeError
title: "Changing settings failed"
title: qsTr("Changing settings failed")
icon: StandardIcon.Critical
standardButtons: StandardButton.Ok
}
@ -182,7 +190,7 @@ ModalPopup {
const error = RootStore.updateCurrentAccount(currentAccount.address, accountNameInput.text, accountColorInput.selectedColor);
if (error) {
errorSound.play()
Global.playErrorSound();
changeError.text = error
changeError.open()
return

View File

@ -143,7 +143,7 @@ ModalPopup {
loading = false
if (errMessage) {
errorSound.play();
Global.playErrorSound();
if (Utils.isInvalidPasswordMessage(errMessage)) {
//% "Wrong password"
popup.passwordValidationError = qsTrId("wrong-password")

View File

@ -136,14 +136,14 @@ ModalPopup {
// TODO the loading doesn't work because the function freezes the view. Might need to use threads
loading = true
if (!validate() || !seedPhraseTextArea.validateSeed()) {
errorSound.play()
Global.playErrorSound();
return loading = false
}
const errMessage = RootStore.addAccountsFromSeed(seedPhraseTextArea.textArea.text, passwordInput.text, accountNameInput.text, accountColorInput.selectedColor)
loading = false
if (errMessage) {
errorSound.play();
Global.playErrorSound();
if (Utils.isInvalidPasswordMessage(errMessage)) {
//% "Wrong password"
popup.passwordValidationError = qsTrId("wrong-password")

View File

@ -1,6 +1,6 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtQuick.Dialogs 1.3
import utils 1.0
@ -148,6 +148,13 @@ ModalPopup {
height: addBtn.height
visible: editable
MessageDialog {
id: changeError
title: qsTr("Changing settings failed")
icon: StandardIcon.Critical
standardButtons: StandardButton.Ok
}
StatusButton {
id: addBtn
anchors.top: parent.top
@ -162,10 +169,10 @@ ModalPopup {
const error = RootStore.addCustomToken(addressInput.text, nameInput.text, symbolInput.text, decimalsInput.text);
if (error) {
errorSound.play()
changeError.text = error
changeError.open()
return
Global.playErrorSound();
changeError.text = error;
changeError.open();
return;
}
popup.close();
}

View File

@ -12,6 +12,11 @@ PopupMenu {
width: 260
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
signal generateNewAccountTriggered();
signal addWatchAccountTriggered();
signal enterSeedPhraseTriggered();
signal enterPrivateKeyTriggered();
Action {
//% "Generate an account"
text: qsTrId("generate-a-new-account")
@ -19,7 +24,7 @@ PopupMenu {
icon.width: 19
icon.height: 19
onTriggered: {
generateAccountModal.open()
newAccountMenu.generateNewAccountTriggered();
}
}
Action {
@ -29,7 +34,7 @@ PopupMenu {
icon.width: 19
icon.height: 19
onTriggered: {
addWatchOnlyAccountModal.open()
newAccountMenu.addWatchAccountTriggered();
}
}
Action {
@ -39,7 +44,7 @@ PopupMenu {
icon.width: 19
icon.height: 19
onTriggered: {
addAccountWithSeedModal.open()
newAccountMenu.enterSeedPhraseTriggered();
}
}
Action {
@ -49,7 +54,7 @@ PopupMenu {
icon.width: 19
icon.height: 19
onTriggered: {
addAccountWithPrivateKeydModal.open()
newAccountMenu.enterPrivateKeyTriggered();
}
}
}

View File

@ -108,14 +108,14 @@ ModalPopup {
// TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads
loading = true
if (!validate()) {
errorSound.play()
Global.playErrorSound();
return loading = false
}
const error = RootStore.addWatchOnlyAccount(addressInput.text, accountNameInput.text, accountColorInput.selectedColor);
loading = false
if (error) {
errorSound.play()
Global.playErrorSound();
accountError.text = error
return accountError.open()
}

View File

@ -2,10 +2,9 @@ import QtQuick 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/popups"
import "../../../../shared/panels"
import "../../../../shared/status"
import shared.popups 1.0
import shared.panels 1.0
import shared.status 1.0
// TODO: replace with StatusModal
ModalPopup {
@ -62,8 +61,7 @@ ModalPopup {
anchors.rightMargin: Style.current.padding
text: qsTr("View in Opensea")
onClicked: {
//TOOD improve this to not use dynamic scoping
appMain.openLink(root.permalink);
Global.openLink(root.permalink);
root.close();
}
}

View File

@ -45,7 +45,7 @@ ModalPopup {
text: popup.buttonText
anchors.top: parent.top
onClicked: {
appMain.openLink(popup.buttonLink)
Global.openLink(popup.buttonLink)
popup.close()
}
}

View File

@ -108,7 +108,7 @@ ModalPopup {
// TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads
loading = true
if (!validate()) {
errorSound.play()
Global.playErrorSound();
return loading = false
}
@ -116,7 +116,7 @@ ModalPopup {
console.log(errMessage)
loading = false
if (errMessage) {
errorSound.play();
Global.playErrorSound();
if (Utils.isInvalidPasswordMessage(errMessage)) {
//% "Wrong password"
popup.passwordValidationError = qsTrId("wrong-password")

View File

@ -54,7 +54,7 @@ ModalPopup {
anchors.horizontalCenter: parent.horizontalCenter
width: 240
dropdownWidth: parent.width - (Style.current.padding * 2)
dropdownAlignment: Select.MenuAlignment.Center
dropdownAlignment: StatusSelect.MenuAlignment.Center
onSelectedAccountChanged: {
if (selectedAccount.address) {
qrCodeImage.source = RootStore.getQrCode(selectedAccount.address)

View File

@ -14,7 +14,9 @@ ModalPopup {
id: popup
//% "Manage Assets"
title: qsTrId("manage-assets")
signal addCustomTokenTriggered()
signal tokenDetailsTriggered(string address, string address, string address, string address)
TokenSettingsModalContent {
id: settingsModalContent
anchors.left: parent.left
@ -32,6 +34,9 @@ ModalPopup {
onRemoveCustomTokenTriggered: {
RootStore.removeCustomToken(address)
}
onTokenDetailsTriggered: {
popup.tokenDetailsTriggered(address, name, symbol, decimals);
}
}
footer: StatusButton {
@ -39,6 +44,8 @@ ModalPopup {
//% "Add custom token"
text: qsTrId("add-custom-token")
anchors.top: parent.top
onClicked: addCustomTokenModal.openEditable()
onClicked: {
popup.addCustomTokenTriggered();
}
}
}

View File

@ -4,9 +4,12 @@ import QtQuick 2.13
QtObject {
id: root
property var currentAccount: walletSectionCurrent
property var accounts: walletSectionAccounts.model
property var appSettings: localAppSettings
property var accountSensitiveSettings: localAccountSensitiveSettings
property string locale: appSettings.locale
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
property string currentCurrency: walletSection.currentCurrency
property string totalCurrencyBalance: walletSection.totalCurrencyBalance
@ -60,14 +63,18 @@ QtObject {
property ListModel exampleAssetModel: ListModel {
ListElement {
value: "123 USD"
name: "Ethereum"
symbol: "ETH"
fullTokenName: "Ethereum"
fiatBalanceDisplay: "3423 ETH"
image: "token-icons/eth"
balance: "3423 ETH"
address: "token-icons/eth"
currencyBalance: "123 USD"
}
}
function hideSignPhraseModal(value) {
localAccountSensitiveSettings.hideSignPhraseModal = value;
}
function getLatestBlockNumber() {
// TODO: Move to transaction root module and not wallet
return walletModel.getLatestBlockNumber()

View File

@ -22,9 +22,10 @@ Item {
id: assetListView
spacing: Style.current.padding * 2
anchors.fill: parent
// model: RootStore.exampleAssetModel
//model: RootStore.exampleAssetModel
model: RootStore.assets
delegate: AssetDelegate {
locale: RootStore.locale
currency: RootStore.currentCurrency
}
boundsBehavior: Flickable.StopAtBounds

View File

@ -81,6 +81,7 @@ Item {
model: RootStore.historyTransactions
delegate: TransactionDelegate {
tokens: RootStore.tokens
locale: RootStore.locale
currentAccountAddress: RootStore.currentAccount.address
ethValue: RootStore.hex2Eth(value)
onLaunchTransactionModal: {

View File

@ -92,6 +92,18 @@ Rectangle {
addAccountButton.state = "default";
addAccountButton.checked = false;
}
onGenerateNewAccountTriggered: {
generateAccountModal.open();
}
onAddWatchAccountTriggered: {
addWatchOnlyAccountModal.open();
}
onEnterSeedPhraseTriggered: {
addAccountWithSeedModal.open();
}
onEnterPrivateKeyTriggered: {
addAccountWithPrivateKeydModal.open();
}
}
GenerateAccountModal {
@ -134,6 +146,7 @@ Rectangle {
delegate: WalletDelegate {
currency: RootStore.currentCurrency
locale: RootStore.locale
selectedAccountIndex: walletInfoContainer.selectedAccountIndex
onClicked: {
changeSelectedAccount(index)

View File

@ -16,13 +16,15 @@ import "../panels"
Item {
id: walletContainer
property var changeSelectedAccount
property alias currentTabIndex: walletTabBar.currentIndex
WalletHeader {
id: walletHeader
changeSelectedAccount: leftTab.changeSelectedAccount
currentAccount: RootStore.currentAccount
locale: RootStore.locale
currency: RootStore.currentCurrency
currentAccount: RootStore.currentAccount
changeSelectedAccount: changeSelectedAccount
}
RowLayout {

View File

@ -8,6 +8,7 @@ import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import "../"
import "../../stores"
import "../../controls"
StackDetailBase {

View File

@ -105,8 +105,7 @@ StatusModal {
cursorShape: Qt.PointingHandCursor
onClicked: {
//TOOD improve this to not use dynamic scoping
appMain.openLink(siteUrl);
Global.openLink(siteUrl);
cryptoServicesPopupRoot.close();
}
}

View File

@ -115,8 +115,7 @@ QtObject {
function addAccount(text, model, keyOrSeedValid, accountNameInput) {
root.loadingAccounts = true;
if (!root.validateAddAccountPopup(text, model, keyOrSeedValid, accountNameInput.nameInputValid)) {
//TOOD improve this to not use dynamic scoping
errorSound.play();
Global.playErrorSound();
root.loadingAccounts = false;
} else {
//TODO account color to be verified with design
@ -138,8 +137,7 @@ QtObject {
accountError.text = resultJson.error;
accountError.open();
}
//TOOD improve this to not use dynamic scoping
errorSound.play();
Global.playErrorSound();
return;
}
}

View File

@ -41,8 +41,14 @@ Item {
signal settingsLoaded()
signal openContactsPopup()
function changeAppSectionBySectionType(sectionType) {
mainModule.setActiveSectionBySectionType(sectionType)
Connections {
target: Global
onOpenLinkInBrowser: {
browserLayoutContainer.item.openUrlInNewTab(link);
}
onOpenChooseBrowserPopup: {
appMain.openPopup(chooseBrowserPopupComponent, {link: link})
}
}
function changeAppSectionBySectionId(sectionId) {
@ -115,19 +121,6 @@ Item {
return ""
}
function openLink(link) {
if (localAccountSensitiveSettings.showBrowserSelector) {
appMain.openPopup(chooseBrowserPopupComponent, {link: link})
} else {
if (localAccountSensitiveSettings.openLinksInStatus) {
appMain.changeAppSectionBySectionType(Constants.appSection.browser)
browserLayoutContainer.item.openUrlInNewTab(link)
} else {
Qt.openUrlExternally(link)
}
}
}
function openProfilePopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, parentPopup){
var popup = profilePopupComponent.createObject(appMain);
if(parentPopup){
@ -158,11 +151,6 @@ Item {
}
}
Audio {
id: errorSound
track: "error.mp3"
}
Audio {
id: sendMessageSound
track: "send_message.wav"
@ -429,7 +417,7 @@ Item {
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
onProfileButtonClicked: {
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
Global.changeAppSectionBySectionType(Constants.appSection.profile);
}
onOpenAppSearch: {
@ -522,7 +510,7 @@ Item {
Layout.fillHeight: true
onProfileButtonClicked: {
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
Global.changeAppSectionBySectionType(Constants.appSection.profile);
}
onOpenAppSearch: {
@ -774,19 +762,19 @@ Item {
Action {
shortcut: "Ctrl+1"
onTriggered: changeAppSectionBySectionType(Constants.appSection.chat)
onTriggered: Global.changeAppSectionBySectionType(Constants.appSection.chat)
}
Action {
shortcut: "Ctrl+2"
onTriggered: changeAppSectionBySectionType(Constants.appSection.browser)
onTriggered: Global.changeAppSectionBySectionType(Constants.appSection.browser)
}
Action {
shortcut: "Ctrl+3"
onTriggered: changeAppSectionBySectionType(Constants.appSection.wallet)
onTriggered: Global.changeAppSectionBySectionType(Constants.appSection.wallet)
}
Action {
shortcut: "Ctrl+4, Ctrl+,"
onTriggered: changeAppSectionBySectionType(Constants.appSection.profile)
onTriggered: Global.changeAppSectionBySectionType(Constants.appSection.profile)
}
Action {
shortcut: "Ctrl+K"
@ -837,7 +825,7 @@ Item {
});
}
onClicked: function (index) {
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
chatsModel.channelView.setActiveChannelByIndex(index)
channelPicker.close()
}

View File

@ -64,7 +64,7 @@ ModalPopup {
qsTr("Download") :
qsTr("Ok")
anchors.right: parent.right
onClicked: newVersionAvailable ? appMain.openLink(downloadURL) : close()
onClicked: newVersionAvailable ? Global.openLink(downloadURL) : close()
}
}

View File

@ -125,7 +125,7 @@ Popup {
font.pixelSize: 13
font.weight: Font.Medium
onLinkActivated: {
appMain.openLink(root.link)
Global.openLink(root.link)
root.close()
}
}

View File

@ -65,7 +65,7 @@ Item {
if(root.store.chatsModelInst.communities.activeCommunity.active)
{
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
}
return
}
@ -76,7 +76,7 @@ Item {
{
if(root.store.chatsModelInst.communities.activeCommunity.active) {
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
}
root.store.chatsModelInst.channelView.setActiveChannel(channelName);
}
@ -104,7 +104,7 @@ Item {
}
appMain.openLink(link)
Global.openLink(link)
}
onLinkHovered: {

View File

@ -282,7 +282,7 @@ Column {
return linkData.callback()
}
appMain.openLink(linkData.address)
Global.openLink(linkData.address)
}
}
}
@ -361,7 +361,7 @@ Column {
//% "Enable in Settings"
text: qsTrId("enable-in-settings")
onClicked: {
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
Global.changeAppSectionBySectionType(Constants.appSection.profile)
// TODO: replace with shared store constant
// Profile/RootStore.privacy_and_security_id
profileLayoutContainer.changeProfileSection(3)

View File

@ -255,7 +255,7 @@ StatusPopupMenu {
qsTrId("reply-to")
onTriggered: {
if (root.isProfile) {
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.store.chatsModelInst.channelView.joinPrivateChat(fromAuthor, "")
} else {
showReplyArea()

View File

@ -1,8 +0,0 @@
pragma Singleton
import QtQuick 2.13
QtObject {
property int currentMenuTab: 0
}

View File

@ -0,0 +1,36 @@
pragma Singleton
import QtQuick 2.13
QtObject {
property int currentMenuTab: 0
property var errorSound: Audio {
id: errorSound
track: Qt.resolvedUrl("../assets/audio/error.mp3")
}
property var mainModuleInst: mainModule
signal openLinkInBrowser(string link)
signal openChooseBrowserPopup(string link)
function changeAppSectionBySectionType(sectionType) {
mainModuleInst.setActiveSectionBySectionType(sectionType)
}
function openLink(link) {
if (localAccountSensitiveSettings.showBrowserSelector) {
openChooseBrowserPopup(link);
} else {
if (localAccountSensitiveSettings.openLinksInStatus) {
changeAppSectionBySectionType(Constants.appSection.browser);
openLinkInBrowser(link);
} else {
Qt.openUrlExternally(link);
}
}
}
function playErrorSound() {
errorSound.play();
}
}

View File

@ -1,7 +1,7 @@
singleton Style 1.0 Style.qml
singleton Utils 1.0 Utils.qml
singleton Emoji 1.0 Emoji.qml
singleton Config 1.0 Config.qml
singleton Global 1.0 Global.qml
singleton Constants 1.0 Constants.qml
singleton SelectedMessage 1.0 SelectedMessage.qml
singleton Backpressure 1.0 Backpressure/Backpressure.qml

View File

@ -29,7 +29,7 @@ TabButton {
}
chatsModel.communities.activeCommunity.active = false
appMain.changeAppSectionBySectionType(section)
Global.changeAppSectionBySectionType(section)
}
icon.height: 24