refactor(@desktop/general): qml `ChatLayout` component added for the `Chat` section and for each community
This commit is contained in:
parent
eca74532ac
commit
0fa88be513
|
@ -130,10 +130,8 @@ method load*(self: Module) =
|
|||
self.view.load()
|
||||
|
||||
if(self.controller.isCommunity()):
|
||||
singletonInstance.engine.setRootContextProperty("communitySectionModule", self.viewVariant)
|
||||
self.buildCommunityUI()
|
||||
else:
|
||||
singletonInstance.engine.setRootContextProperty("chatSectionModule", self.viewVariant)
|
||||
self.buildChatUI()
|
||||
|
||||
self.inputAreaModule.load()
|
||||
|
@ -190,3 +188,6 @@ method activeItemSubItemSet*(self: Module, itemId: string, subItemId: string) =
|
|||
|
||||
self.view.model().setActiveItemSubItem(itemId, subItemId)
|
||||
self.view.activeItemSubItemSet(item, subItem)
|
||||
|
||||
method getChatSection*(self: Module): QVariant =
|
||||
return self.viewVariant
|
|
@ -1,3 +1,5 @@
|
|||
import NimQml
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -6,3 +8,6 @@ method load*(self: AccessInterface) {.base.} =
|
|||
|
||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getChatSection*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -275,3 +275,13 @@ method disableSection*[T](self: Module[T], sectionType: SectionType) =
|
|||
|
||||
method setUserStatus*[T](self: Module[T], status: bool) =
|
||||
self.controller.setUserStatus(status)
|
||||
|
||||
method getChatSection*[T](self: Module[T]): QVariant =
|
||||
return self.chatSectionModule.getChatSection()
|
||||
|
||||
method getCommunitySection*[T](self: Module[T], communityId: string): QVariant =
|
||||
if(not self.communitySectionsModule.contains(communityId)):
|
||||
echo "main-module, unexisting community key: ", communityId
|
||||
return
|
||||
|
||||
return self.communitySectionsModule[communityId].getChatSection()
|
|
@ -1,3 +1,4 @@
|
|||
import NimQml
|
||||
import ../item
|
||||
|
||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
|
@ -11,3 +12,9 @@ method setActiveSection*(self: AccessInterface, item: Item) {.base.} =
|
|||
|
||||
method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getChatSection*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCommunitySection*(self: AccessInterface, communityId: string): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -10,6 +10,7 @@ QtObject:
|
|||
modelVariant: QVariant
|
||||
activeSection: ActiveSection
|
||||
activeSectionVariant: QVariant
|
||||
tmpCommunityId: string # shouldn't be used anywhere except in setCommunitySection/getCommunitySection procs
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.model.delete
|
||||
|
@ -99,3 +100,21 @@ QtObject:
|
|||
|
||||
proc setUserStatus*(self: View, status: bool) {.slot.} =
|
||||
self.delegate.setUserStatus(status)
|
||||
|
||||
# Since we cannot return QVariant from the proc which has arguments, so cannot have proc like this:
|
||||
# getCommunitySection(self: View, communityId: string): QVariant {.slot.}
|
||||
# we're using combinaiton of
|
||||
# setCommunitySection/getCommunitySection procs
|
||||
proc setCommunitySection*(self: View, communityId: string) {.slot.} =
|
||||
self.tmpCommunityId = communityId
|
||||
|
||||
proc getCommunitySection*(self: View): QVariant {.slot.} =
|
||||
var communityVariant = self.delegate.getCommunitySection(self.tmpCommunityId)
|
||||
self.tmpCommunityId = ""
|
||||
if(communityVariant.isNil):
|
||||
return newQVariant()
|
||||
|
||||
return communityVariant
|
||||
|
||||
proc getChatSection*(self: View): QVariant {.slot.} =
|
||||
return self.delegate.getChatSection()
|
|
@ -25,6 +25,8 @@ StatusAppThreePanelLayout {
|
|||
|
||||
handle: SplitViewHandle { implicitWidth: 5 }
|
||||
|
||||
property var chatSectionModule // Everything here, within this component need to be set based on this property.
|
||||
|
||||
property var messageStore
|
||||
|
||||
property alias chatColumn: chatColumn
|
||||
|
|
|
@ -2,6 +2,7 @@ import QtQuick 2.13
|
|||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import QtMultimedia 5.13
|
||||
import Qt.labs.qmlmodels 1.0
|
||||
|
||||
import utils 1.0
|
||||
import shared 1.0
|
||||
|
@ -360,12 +361,21 @@ Item {
|
|||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.community) {
|
||||
|
||||
for(let i = this.children.length - 1; i >=0; i--)
|
||||
{
|
||||
var obj = this.children[i];
|
||||
if(obj && obj.sectionId == mainModule.activeSection.id)
|
||||
{
|
||||
/*************************************/
|
||||
// This will be refactored later
|
||||
// This will be refactored/removed later
|
||||
chatsModel.communities.setActiveCommunity(mainModule.activeSection.id)
|
||||
/*************************************/
|
||||
|
||||
return 99 //Don't know why, but that's how it was in Utils::getAppSectionIndex function.
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) {
|
||||
return 1
|
||||
|
@ -423,6 +433,10 @@ Item {
|
|||
onProfileButtonClicked: {
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
chatSectionModule = mainModule.getChatSection()
|
||||
}
|
||||
}
|
||||
|
||||
WalletLayout {
|
||||
|
@ -496,6 +510,33 @@ Item {
|
|||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
Repeater{
|
||||
model: mainModule.sectionsModel
|
||||
|
||||
delegate: DelegateChooser {
|
||||
id: delegateChooser
|
||||
role: "sectionType"
|
||||
DelegateChoice {
|
||||
roleValue: Constants.appSection.community
|
||||
delegate: ChatLayout {
|
||||
property string sectionId: model.id
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
|
||||
onProfileButtonClicked: {
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
mainModule.setCommunitySection(model.id)
|
||||
chatSectionModule = mainModule.getCommunitySection()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
Loading…
Reference in New Issue