refactor(general): qml cleaning
- Selecting `currentIndex` based on the children placed in the `StackLayout` component with id `appView` is sorted out since we were referring to the wrong indexes there in case of walletv2, node and community sections. - Places which call `Utils.getAppSectionIndex` are updated since we don't have that method any more. - Some parts which are not refactored yet are commented.
This commit is contained in:
parent
4b6469c373
commit
3f50ab26b8
|
@ -25,7 +25,7 @@ StatusAppThreePanelLayout {
|
||||||
|
|
||||||
handle: SplitViewHandle { implicitWidth: 5 }
|
handle: SplitViewHandle { implicitWidth: 5 }
|
||||||
|
|
||||||
property var chatSectionModule // Everything here, within this component need to be set based on this property.
|
property var store
|
||||||
|
|
||||||
property var messageStore
|
property var messageStore
|
||||||
|
|
||||||
|
@ -34,17 +34,18 @@ StatusAppThreePanelLayout {
|
||||||
signal profileButtonClicked()
|
signal profileButtonClicked()
|
||||||
signal openAppSearch()
|
signal openAppSearch()
|
||||||
|
|
||||||
Connections {
|
// Not Refactored
|
||||||
target: root.rootStore.chatsModelInst.stickers
|
// Connections {
|
||||||
onStickerPacksLoaded: {
|
// target: root.rootStore.chatsModelInst.stickers
|
||||||
stickersLoaded = true;
|
// onStickerPacksLoaded: {
|
||||||
}
|
// stickersLoaded = true;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
property var onActivated: function () {
|
// property var onActivated: function () {
|
||||||
root.rootStore.chatsModelInst.channelView.restorePreviousActiveChannel();
|
// root.rootStore.chatsModelInst.channelView.restorePreviousActiveChannel();
|
||||||
chatColumn.onActivated();
|
// chatColumn.onActivated();
|
||||||
}
|
// }
|
||||||
// Not Refactored
|
// Not Refactored
|
||||||
property RootStore rootStore: RootStore {
|
property RootStore rootStore: RootStore {
|
||||||
messageStore: root.messageStore
|
messageStore: root.messageStore
|
||||||
|
@ -52,12 +53,12 @@ StatusAppThreePanelLayout {
|
||||||
|
|
||||||
leftPanel: Loader {
|
leftPanel: Loader {
|
||||||
id: contactColumnLoader
|
id: contactColumnLoader
|
||||||
sourceComponent: localAccountSensitiveSettings.communitiesEnabled && root.rootStore.chatsModelInst.communities.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
|
sourceComponent: store.isCommunity()? communtiyColumnComponent : contactsColumnComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
centerPanel: ChatColumnView {
|
centerPanel: ChatColumnView {
|
||||||
id: chatColumn
|
id: chatColumn
|
||||||
rootStore: root.rootStore
|
//rootStore: root.rootStore
|
||||||
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
|
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
|
||||||
|
|
||||||
onOpenAppSearch: {
|
onOpenAppSearch: {
|
||||||
|
@ -99,7 +100,7 @@ StatusAppThreePanelLayout {
|
||||||
id: contactsColumnComponent
|
id: contactsColumnComponent
|
||||||
ContactsColumnView {
|
ContactsColumnView {
|
||||||
// Not Refactored
|
// Not Refactored
|
||||||
store: root.rootStore
|
//store: root.rootStore
|
||||||
onOpenProfileClicked: {
|
onOpenProfileClicked: {
|
||||||
root.profileButtonClicked();
|
root.profileButtonClicked();
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,7 @@ StatusAppThreePanelLayout {
|
||||||
Component {
|
Component {
|
||||||
id: communtiyColumnComponent
|
id: communtiyColumnComponent
|
||||||
CommunityColumnView {
|
CommunityColumnView {
|
||||||
store: root.rootStore
|
store: root.store
|
||||||
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +123,7 @@ StatusAppThreePanelLayout {
|
||||||
id: groupInfoPopupComponent
|
id: groupInfoPopupComponent
|
||||||
GroupInfoPopup {
|
GroupInfoPopup {
|
||||||
// Not Refactored
|
// Not Refactored
|
||||||
store: root.rootStore
|
//store: root.rootStore
|
||||||
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,10 +144,10 @@ StatusAppThreePanelLayout {
|
||||||
//% "Are you sure you want to remove this contact?"
|
//% "Are you sure you want to remove this contact?"
|
||||||
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||||
onConfirmButtonClicked: {
|
onConfirmButtonClicked: {
|
||||||
if (root.rootStore.contactsModuleInst.model.isAdded(chatColumn.contactToRemove)) {
|
// Not Refactored
|
||||||
root.rootStore.contactsModuleInst.model.removeContact(chatColumn.contactToRemove)
|
// if (root.rootStore.profileModelInst.contacts.isAdded(chatColumn.contactToRemove)) {
|
||||||
|
// root.rootStore.profileModelInst.contacts.removeContact(chatColumn.contactToRemove)
|
||||||
}
|
// }
|
||||||
removeContactConfirmationDialog.parentPopup.close();
|
removeContactConfirmationDialog.parentPopup.close();
|
||||||
removeContactConfirmationDialog.close();
|
removeContactConfirmationDialog.close();
|
||||||
}
|
}
|
||||||
|
@ -155,7 +156,7 @@ StatusAppThreePanelLayout {
|
||||||
MessageContextMenuView {
|
MessageContextMenuView {
|
||||||
id: quickActionMessageOptionsMenu
|
id: quickActionMessageOptionsMenu
|
||||||
// Not Refactored
|
// Not Refactored
|
||||||
store: root.rootStore
|
// store: root.rootStore
|
||||||
// reactionModel: root.rootStore.emojiReactionsModel
|
// reactionModel: root.rootStore.emojiReactionsModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,10 @@ Item {
|
||||||
property var idMap: ({})
|
property var idMap: ({})
|
||||||
property Timer timer: Timer { }
|
property Timer timer: Timer { }
|
||||||
property var userList
|
property var userList
|
||||||
property var onActivated: function () {
|
// property var onActivated: function () {
|
||||||
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
// if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
||||||
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
// stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
}
|
// }
|
||||||
|
|
||||||
signal openAppSearch()
|
signal openAppSearch()
|
||||||
|
|
||||||
|
|
|
@ -353,16 +353,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
currentIndex: {
|
currentIndex: {
|
||||||
if(mainModule.activeSection.sectionType === Constants.appSection.chat) {
|
if(mainModule.activeSection.sectionType === Constants.appSection.chat) {
|
||||||
|
return Constants.appViewStackIndex.chat
|
||||||
/*************************************/
|
|
||||||
// This will be refactored later
|
|
||||||
if (chatsModel.communities.activeCommunity.active) {
|
|
||||||
chatLayoutContainer.chatColumn.hideChatInputExtendedArea();
|
|
||||||
chatsModel.communities.activeCommunity.active = false
|
|
||||||
}
|
|
||||||
/*************************************/
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.community) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.community) {
|
||||||
|
|
||||||
|
@ -371,34 +362,32 @@ Item {
|
||||||
var obj = this.children[i];
|
var obj = this.children[i];
|
||||||
if(obj && obj.sectionId == mainModule.activeSection.id)
|
if(obj && obj.sectionId == mainModule.activeSection.id)
|
||||||
{
|
{
|
||||||
/*************************************/
|
|
||||||
// This will be refactored/removed later
|
|
||||||
chatsModel.communities.setActiveCommunity(mainModule.activeSection.id)
|
|
||||||
/*************************************/
|
|
||||||
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
// Should never be here, correct index must be returned from the for loop above
|
||||||
|
console.error("Wrong section type: ", mainModule.activeSection.sectionType,
|
||||||
|
" or section id: ", mainModule.activeSection.id)
|
||||||
|
return Constants.appViewStackIndex.community
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) {
|
||||||
return 1
|
return Constants.appViewStackIndex.wallet
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.walletv2) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.walletv2) {
|
||||||
return 7
|
return Constants.appViewStackIndex.walletv2
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.browser) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.browser) {
|
||||||
return 2
|
return Constants.appViewStackIndex.browser
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.timeline) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.timeline) {
|
||||||
return 3
|
return Constants.appViewStackIndex.timeline
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.profile) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.profile) {
|
||||||
return 4
|
return Constants.appViewStackIndex.profile
|
||||||
}
|
}
|
||||||
else if(mainModule.activeSection.sectionType === Constants.appSection.node) {
|
else if(mainModule.activeSection.sectionType === Constants.appSection.node) {
|
||||||
return 7
|
return Constants.appViewStackIndex.node
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should never end up here
|
// We should never end up here
|
||||||
|
@ -429,12 +418,15 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE:
|
||||||
|
// If we ever change stack layout component order we need to updade
|
||||||
|
// Constants.appViewStackIndex accordingly
|
||||||
|
|
||||||
ChatLayout {
|
ChatLayout {
|
||||||
id: chatLayoutContainer
|
id: chatLayoutContainer
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
messageStore: appMain.rootStore.messageStore
|
|
||||||
onProfileButtonClicked: {
|
onProfileButtonClicked: {
|
||||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
|
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||||
}
|
}
|
||||||
|
@ -444,7 +436,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
chatSectionModule = mainModule.getChatSectionModule()
|
store = mainModule.getChatSectionModule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,12 +499,6 @@ Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|
||||||
UIComponents {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
||||||
Layout.fillHeight: true
|
|
||||||
}
|
|
||||||
|
|
||||||
WalletV2Layout {
|
WalletV2Layout {
|
||||||
id: walletV2LayoutContainer
|
id: walletV2LayoutContainer
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -546,7 +532,7 @@ Item {
|
||||||
// we cannot return QVariant if we pass another parameter in a function call
|
// we cannot return QVariant if we pass another parameter in a function call
|
||||||
// that's why we're using it this way
|
// that's why we're using it this way
|
||||||
mainModule.prepareCommunitySectionModuleForCommunityId(model.id)
|
mainModule.prepareCommunitySectionModuleForCommunityId(model.id)
|
||||||
chatSectionModule = mainModule.getCommunitySectionModule()
|
store = mainModule.getCommunitySectionModule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,19 +547,20 @@ Item {
|
||||||
|
|
||||||
switch(notificationType){
|
switch(notificationType){
|
||||||
case Constants.osNotificationType.newContactRequest:
|
case Constants.osNotificationType.newContactRequest:
|
||||||
appView.currentIndex = Utils.getAppSectionIndex(Constants.chat)
|
appView.currentIndex = Constants.appViewStackIndex.chat
|
||||||
appMain.openContactsPopup()
|
appMain.openContactsPopup()
|
||||||
break
|
break
|
||||||
case Constants.osNotificationType.acceptedContactRequest:
|
case Constants.osNotificationType.acceptedContactRequest:
|
||||||
appView.currentIndex = Utils.getAppSectionIndex(Constants.chat)
|
appView.currentIndex = Constants.appViewStackIndex.chat
|
||||||
break
|
break
|
||||||
case Constants.osNotificationType.joinCommunityRequest:
|
case Constants.osNotificationType.joinCommunityRequest:
|
||||||
case Constants.osNotificationType.acceptedIntoCommunity:
|
case Constants.osNotificationType.acceptedIntoCommunity:
|
||||||
case Constants.osNotificationType.rejectedByCommunity:
|
case Constants.osNotificationType.rejectedByCommunity:
|
||||||
appView.currentIndex = Utils.getAppSectionIndex(Constants.community)
|
// Not Refactored - Need to check what community exactly we need to switch to.
|
||||||
|
// appView.currentIndex = Utils.getAppSectionIndex(Constants.community)
|
||||||
break
|
break
|
||||||
case Constants.osNotificationType.newMessage:
|
case Constants.osNotificationType.newMessage:
|
||||||
appView.currentIndex = Utils.getAppSectionIndex(Constants.chat)
|
appView.currentIndex = Constants.appViewStackIndex.chat
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,7 +659,8 @@ Item {
|
||||||
CreateChannelPopup {
|
CreateChannelPopup {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
isEdit: true
|
isEdit: true
|
||||||
pinnedMessagesPopupComponent: chatLayoutContainer.chatColumn.pinnedMessagesPopupComponent
|
// Not Refactored
|
||||||
|
// pinnedMessagesPopupComponent: chatLayoutContainer.chatColumn.pinnedMessagesPopupComponent
|
||||||
onClosed: {
|
onClosed: {
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,17 @@ QtObject {
|
||||||
readonly property int node: 7
|
readonly property int node: 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property QtObject appViewStackIndex: QtObject {
|
||||||
|
readonly property int chat: 0
|
||||||
|
readonly property int community: 7 // any stack layout children with the index 7 or higher is community
|
||||||
|
readonly property int wallet: 1
|
||||||
|
readonly property int walletv2: 6
|
||||||
|
readonly property int browser: 2
|
||||||
|
readonly property int timeline: 3
|
||||||
|
readonly property int profile: 4
|
||||||
|
readonly property int node: 5
|
||||||
|
}
|
||||||
|
|
||||||
readonly property QtObject osNotificationType: QtObject{
|
readonly property QtObject osNotificationType: QtObject{
|
||||||
readonly property int newContactRequest: 1
|
readonly property int newContactRequest: 1
|
||||||
readonly property int acceptedContactRequest: 2
|
readonly property int acceptedContactRequest: 2
|
||||||
|
|
20
ui/main.qml
20
ui/main.qml
|
@ -80,7 +80,7 @@ StatusWindow {
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
shortcut: "Ctrl+W"
|
shortcut: "Ctrl+W"
|
||||||
enabled: loader.item ? loader.item.currentView !== Utils.getAppSectionIndex(Constants.browser)
|
enabled: loader.item && !!loader.item.appLayout? loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.browser
|
||||||
: true
|
: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
applicationWindow.visible = false;
|
applicationWindow.visible = false;
|
||||||
|
@ -192,15 +192,14 @@ StatusWindow {
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark())
|
Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark())
|
||||||
if (!localAppSettings.appSizeInitialized) {
|
|
||||||
width = Math.min(Screen.desktopAvailableWidth - 125, 1400)
|
|
||||||
height = Math.min(Screen.desktopAvailableHeight - 125, 840)
|
|
||||||
localAppSettings.appSizeInitialized = true
|
|
||||||
}
|
|
||||||
|
|
||||||
setX(Qt.application.screens[0].width / 2 - width / 2);
|
setX(Qt.application.screens[0].width / 2 - width / 2);
|
||||||
setY(Qt.application.screens[0].height / 2 - height / 2);
|
setY(Qt.application.screens[0].height / 2 - height / 2);
|
||||||
|
|
||||||
|
if (!localAppSettings.appSizeInitialized) {
|
||||||
|
width = Screen.desktopAvailableWidth - 125
|
||||||
|
height = Screen.desktopAvailableHeight - 125
|
||||||
|
localAppSettings.appSizeInitialized = true
|
||||||
|
}
|
||||||
applicationWindow.updatePosition();
|
applicationWindow.updatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,11 +420,10 @@ StatusWindow {
|
||||||
|
|
||||||
signal droppedOnValidScreen(var drop)
|
signal droppedOnValidScreen(var drop)
|
||||||
property alias droppedUrls: rptDraggedPreviews.model
|
property alias droppedUrls: rptDraggedPreviews.model
|
||||||
readonly property int chatView: Utils.getAppSectionIndex(Constants.chat)
|
|
||||||
property bool enabled: !drag.source && !!loader.item && !!loader.item.appLayout &&
|
property bool enabled: !drag.source && !!loader.item && !!loader.item.appLayout &&
|
||||||
(
|
(
|
||||||
// in chat view
|
// in chat view
|
||||||
(loader.item.appLayout.appView.currentIndex === chatView &&
|
(loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.chat &&
|
||||||
(
|
(
|
||||||
// in a one-to-one chat
|
// in a one-to-one chat
|
||||||
chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne ||
|
chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne ||
|
||||||
|
@ -433,8 +431,10 @@ StatusWindow {
|
||||||
chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat
|
chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat
|
||||||
)
|
)
|
||||||
) ||
|
) ||
|
||||||
|
// in timeline view
|
||||||
|
loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.timeline ||
|
||||||
// In community section
|
// In community section
|
||||||
loader.item.appLayout.appView.currentIndex === chatsModel.communities.activeCommunity.active
|
chatsModel.communities.activeCommunity.active
|
||||||
)
|
)
|
||||||
|
|
||||||
width: applicationWindow.width
|
width: applicationWindow.width
|
||||||
|
|
|
@ -18,7 +18,6 @@ TabButton {
|
||||||
property int iconRotation: 0
|
property int iconRotation: 0
|
||||||
property string iconSource
|
property string iconSource
|
||||||
property string section
|
property string section
|
||||||
property int sectionIndex: Utils.getAppSectionIndex(section)
|
|
||||||
property bool doNotHandleClick: false
|
property bool doNotHandleClick: false
|
||||||
property bool borderOnChecked: false
|
property bool borderOnChecked: false
|
||||||
property bool useLetterIdenticon: false
|
property bool useLetterIdenticon: false
|
||||||
|
@ -33,8 +32,6 @@ TabButton {
|
||||||
appMain.changeAppSectionBySectionType(section)
|
appMain.changeAppSectionBySectionType(section)
|
||||||
}
|
}
|
||||||
|
|
||||||
checked: sLayout.currentIndex === sectionIndex
|
|
||||||
|
|
||||||
icon.height: 24
|
icon.height: 24
|
||||||
icon.width: 24
|
icon.width: 24
|
||||||
icon.color: {
|
icon.color: {
|
||||||
|
|
Loading…
Reference in New Issue