refactor(@desktop/general): app sections handled within main module
This commit is contained in:
parent
9e567b8fdc
commit
6e3b065d34
|
@ -68,10 +68,8 @@ const LSS_KEY_SHOW_DELETE_MESSAGE_WARNING* = "showDeleteMessageWarning"
|
|||
const DEFAULT_SHOW_DELETE_MESSAGE_WARNING = true
|
||||
const LSS_KEY_DOWNLOAD_CHANNEL_MESSAGES_ENABLED* = "downloadChannelMessagesEnabled"
|
||||
const DEFAULT_DOWNLOAD_CHANNEL_MESSAGES_ENABLED = false
|
||||
const LSS_KEY_LAST_MODE_ACTIVE_TAB* = "lastModeActiveTab"
|
||||
const DEFAULT_LAST_MODE_ACTIVE_TAB = 0
|
||||
const LSS_KEY_LAST_MODE_ACTIVE_COMMUNITY* = "lastModeActiveCommunity"
|
||||
const DEFAULT_LAST_MODE_ACTIVE_COMMUNITY = ""
|
||||
const LSS_KEY_ACTIVE_SECTION* = "activeSection"
|
||||
const DEFAULT_ACTIVE_SECTION = "chat"
|
||||
const LSS_KEY_SHOW_BROWSER_SELECTOR* = "showBrowserSelector"
|
||||
const DEFAULT_SHOW_BROWSER_SELECTOR = true
|
||||
const LSS_KEY_OPEN_LINKS_IN_STATUS* = "openLinksInStatus"
|
||||
|
@ -605,29 +603,18 @@ QtObject:
|
|||
write = setDownloadChannelMessagesEnabled
|
||||
notify = downloadChannelMessagesEnabledChanged
|
||||
|
||||
proc lastModeActiveTabChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getLastModeActiveTab*(self: LocalAccountSensitiveSettings): int {.slot.} =
|
||||
getSettingsProp[int](self, LSS_KEY_LAST_MODE_ACTIVE_TAB, newQVariant(DEFAULT_LAST_MODE_ACTIVE_TAB))
|
||||
proc setLastModeActiveTab*(self: LocalAccountSensitiveSettings, value: int) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_LAST_MODE_ACTIVE_TAB, newQVariant(value)):
|
||||
self.lastModeActiveTabChanged()
|
||||
|
||||
QtProperty[int] lastModeActiveTab:
|
||||
read = getLastModeActiveTab
|
||||
write = setLastModeActiveTab
|
||||
notify = lastModeActiveTabChanged
|
||||
proc activeSectionChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getActiveSection*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_ACTIVE_SECTION, newQVariant(DEFAULT_ACTIVE_SECTION))
|
||||
proc setActiveSection*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_ACTIVE_SECTION, newQVariant(value)):
|
||||
self.activeSectionChanged()
|
||||
|
||||
proc lastModeActiveCommunityChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getLastModeActiveCommunity*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_LAST_MODE_ACTIVE_COMMUNITY, newQVariant(DEFAULT_LAST_MODE_ACTIVE_COMMUNITY))
|
||||
proc setLastModeActiveCommunity*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_LAST_MODE_ACTIVE_COMMUNITY, newQVariant(value)):
|
||||
self.lastModeActiveCommunityChanged()
|
||||
|
||||
QtProperty[string] lastModeActiveCommunity:
|
||||
read = getLastModeActiveCommunity
|
||||
write = setLastModeActiveCommunity
|
||||
notify = lastModeActiveCommunityChanged
|
||||
QtProperty[string] activeSection:
|
||||
read = getActiveSection
|
||||
write = setActiveSection
|
||||
notify = activeSectionChanged
|
||||
|
||||
|
||||
proc showBrowserSelectorChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
|
@ -892,8 +879,7 @@ QtObject:
|
|||
of LSS_KEY_SKIN_COLOR: self.skinColorChanged()
|
||||
of LSS_KEY_SHOW_DELETE_MESSAGE_WARNING: self.showDeleteMessageWarningChanged()
|
||||
of LSS_KEY_DOWNLOAD_CHANNEL_MESSAGES_ENABLED: self.downloadChannelMessagesEnabledChanged()
|
||||
of LSS_KEY_LAST_MODE_ACTIVE_TAB: self.lastModeActiveTabChanged()
|
||||
of LSS_KEY_LAST_MODE_ACTIVE_COMMUNITY: self.lastModeActiveCommunityChanged()
|
||||
of LSS_KEY_ACTIVE_SECTION: self.activeSectionChanged()
|
||||
of LSS_KEY_SHOW_BROWSER_SELECTOR: self.showBrowserSelectorChanged()
|
||||
of LSS_KEY_OPEN_LINKS_IN_STATUS: self.openLinksInStatusChanged()
|
||||
of LSS_KEY_SHOULD_SHOW_FAVORITES_BAR: self.shouldShowFavoritesBarChanged()
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
import NimQml
|
||||
import item
|
||||
|
||||
QtObject:
|
||||
type ActiveSection* = ref object of QObject
|
||||
item: Item
|
||||
|
||||
proc setup(self: ActiveSection) =
|
||||
self.QObject.setup
|
||||
|
||||
proc delete*(self: ActiveSection) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newActiveSection*(): ActiveSection =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc setActiveSectionData*(self: ActiveSection, item: Item) =
|
||||
self.item = item
|
||||
|
||||
proc getId(self: ActiveSection): string {.slot.} =
|
||||
return self.item.id
|
||||
|
||||
QtProperty[string] id:
|
||||
read = getId
|
||||
|
||||
proc getSectionType(self: ActiveSection): int {.slot.} =
|
||||
return self.item.sectionType.int
|
||||
|
||||
QtProperty[int] sectionType:
|
||||
read = getSectionType
|
||||
|
||||
proc getName(self: ActiveSection): string {.slot.} =
|
||||
return self.item.name
|
||||
|
||||
QtProperty[string] name:
|
||||
read = getName
|
||||
|
||||
proc getImage(self: ActiveSection): string {.slot.} =
|
||||
return self.item.image
|
||||
|
||||
QtProperty[string] image:
|
||||
read = getImage
|
||||
|
||||
proc getIcon(self: ActiveSection): string {.slot.} =
|
||||
return self.item.icon
|
||||
|
||||
QtProperty[string] icon:
|
||||
read = getIcon
|
||||
|
||||
proc getColor(self: ActiveSection): string {.slot.} =
|
||||
return self.item.color
|
||||
|
||||
QtProperty[string] color:
|
||||
read = getColor
|
||||
|
||||
proc getHasNotification(self: ActiveSection): bool {.slot.} =
|
||||
return self.item.hasNotification
|
||||
|
||||
QtProperty[int] hasNotification:
|
||||
read = getHasNotification
|
||||
|
||||
proc getNotificationCount(self: ActiveSection): int {.slot.} =
|
||||
return self.item.notificationsCount
|
||||
|
||||
QtProperty[int] notificationCount:
|
||||
read = getNotificationCount
|
||||
|
||||
proc getActive(self: ActiveSection): bool {.slot.} =
|
||||
return self.item.active
|
||||
|
||||
QtProperty[int] active:
|
||||
read = getActive
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import controller_interface
|
||||
import io_interface
|
||||
import item, controller_interface, io_interface
|
||||
import ../../core/global_singleton
|
||||
|
||||
import ../../../app_service/service/settings/service_interface as settings_service
|
||||
|
@ -20,6 +19,7 @@ type
|
|||
keychainService: keychain_service.Service
|
||||
accountsService: accounts_service.ServiceInterface
|
||||
communityService: community_service.ServiceInterface
|
||||
activeSectionId: string
|
||||
|
||||
proc newController*(delegate: io_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
|
@ -53,6 +53,18 @@ method init*(self: Controller) =
|
|||
singletonInstance.localAccountSettings.removeKey(LS_KEY_STORE_TO_KEYCHAIN)
|
||||
self.delegate.emitStoringPasswordError(args.errDescription)
|
||||
|
||||
self.events.on("sectionAvailabilityChanged") do(e:Args):
|
||||
## We will receive here a signal with two fields:
|
||||
## sectionType: int
|
||||
## enabled: bool
|
||||
##
|
||||
## Then we only need to do something like:
|
||||
## if(enabled):
|
||||
## self.delegate.enableSection(sectionType)
|
||||
## else:
|
||||
## self.delegate.disableSection(sectionType)
|
||||
discard
|
||||
|
||||
method getCommunities*(self: Controller): seq[community_service.CommunityDto] =
|
||||
return self.communityService.getCommunities()
|
||||
|
||||
|
@ -81,6 +93,19 @@ method storePassword*(self: Controller, password: string) =
|
|||
|
||||
self.keychainService.storePassword(account.name, password)
|
||||
|
||||
method setActiveSection*(self: Controller, sectionId: string, sectionType: SectionType) =
|
||||
self.activeSectionId = sectionId
|
||||
|
||||
if(sectionType == SectionType.Chat or sectionType != SectionType.Community):
|
||||
# We need to take other actions here, in case of Chat or Community sections like
|
||||
# notify status go that unviewed mentions count is updated and so...
|
||||
# and then in case all is good, notify the view about the chage so it can update the UI
|
||||
echo "deal with appropriate service..."
|
||||
|
||||
singletonInstance.localAccountSensitiveSettings.setActiveSection(self.activeSectionId)
|
||||
|
||||
self.delegate.activeSectionSet(self.activeSectionId)
|
||||
|
||||
method setUserStatus*(self: Controller, status: bool) =
|
||||
self.settingsService.setSendUserStatus(status)
|
||||
singletonInstance.userProfile.setUserStatus(status)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import item
|
||||
import ../../../app_service/service/community/service_interface as community_service
|
||||
|
||||
type
|
||||
|
@ -10,8 +11,7 @@ method delete*(self: AccessInterface) {.base.} =
|
|||
method init*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCommunities*(self: AccessInterface):
|
||||
seq[community_service.CommunityDto] {.base.} =
|
||||
method getCommunities*(self: AccessInterface): seq[community_service.CommunityDto] {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method checkForStoringPassword*(self: AccessInterface) {.base.} =
|
||||
|
@ -20,5 +20,8 @@ method checkForStoringPassword*(self: AccessInterface) {.base.} =
|
|||
method storePassword*(self: AccessInterface, password: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setActiveSection*(self: AccessInterface, sectionId: string, sectionType: SectionType) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -1,59 +1,97 @@
|
|||
import json, strformat
|
||||
|
||||
type
|
||||
SectionType* {.pure.} = enum
|
||||
Chat = 0
|
||||
Community,
|
||||
Wallet,
|
||||
WalletV2,
|
||||
Browser,
|
||||
Timeline,
|
||||
ProfileSettings,
|
||||
NodeManagement
|
||||
|
||||
type
|
||||
Item* = object
|
||||
sectionType: int
|
||||
sectionType: SectionType
|
||||
id: string
|
||||
name: string
|
||||
image: string
|
||||
icon: string
|
||||
color: string
|
||||
mentionsCount: int
|
||||
unviewedMessagesCount: int
|
||||
hasNotification: bool
|
||||
notificationsCount: int
|
||||
active: bool
|
||||
enabled: bool
|
||||
|
||||
proc initItem*(id: string, sectionType: int, name, image = "", icon = "", color = "",
|
||||
mentionsCount:int = 0, unviewedMessagesCount: int = 0): Item =
|
||||
proc initItem*(id: string, sectionType: SectionType, name, image = "", icon = "", color = "", hasNotification = false,
|
||||
notificationsCount: int = 0, active = false, enabled = true): Item =
|
||||
result.id = id
|
||||
result.sectionType = sectionType
|
||||
result.name = name
|
||||
result.image = image
|
||||
result.icon = icon
|
||||
result.color = color
|
||||
result.mentionsCount = mentionsCount
|
||||
result.unviewedMessagesCount = unviewedMessagesCount
|
||||
result.hasNotification = hasNotification
|
||||
result.notificationsCount = notificationsCount
|
||||
result.active = active
|
||||
result.enabled = enabled
|
||||
|
||||
proc isEmpty*(self: Item): bool =
|
||||
return self.id.len == 0
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""MainModuleItem(
|
||||
id: {self.id},
|
||||
sectionType: {self.sectionType},
|
||||
sectionType: {self.sectionType.int},
|
||||
name: {self.name},
|
||||
image: {self.image},
|
||||
icon: {self.icon},
|
||||
color: {self.color},
|
||||
mentionsCount: {self.mentionsCount},
|
||||
unviewedMessagesCount:{self.unviewedMessagesCount}
|
||||
hasNotification: {self.hasNotification},
|
||||
notificationsCount:{self.notificationsCount},
|
||||
active:{self.active},
|
||||
enabled:{self.enabled}
|
||||
]"""
|
||||
|
||||
proc getId*(self: Item): string =
|
||||
return self.id
|
||||
proc id*(self: Item): string {.inline.} =
|
||||
self.id
|
||||
|
||||
proc getSectionType*(self: Item): int =
|
||||
return self.sectionType
|
||||
proc sectionType*(self: Item): SectionType {.inline.} =
|
||||
self.sectionType
|
||||
|
||||
proc getName*(self: Item): string =
|
||||
return self.name
|
||||
proc name*(self: Item): string {.inline.} =
|
||||
self.name
|
||||
|
||||
proc getImage*(self: Item): string =
|
||||
return self.image
|
||||
proc image*(self: Item): string {.inline.} =
|
||||
self.image
|
||||
|
||||
proc getIcon*(self: Item): string =
|
||||
return self.icon
|
||||
proc icon*(self: Item): string {.inline.} =
|
||||
self.icon
|
||||
|
||||
proc getColor*(self: Item): string =
|
||||
return self.color
|
||||
proc color*(self: Item): string {.inline.} =
|
||||
self.color
|
||||
|
||||
proc getMentionsCount*(self: Item): int =
|
||||
return self.mentionsCount
|
||||
proc hasNotification*(self: Item): bool {.inline.} =
|
||||
self.hasNotification
|
||||
|
||||
proc getUnviewedMessagesCount*(self: Item): int =
|
||||
return self.unviewedMessagesCount
|
||||
proc `hasNotification=`*(self: var Item, value: bool) {.inline.} =
|
||||
self.hasNotification = value
|
||||
|
||||
proc notificationsCount*(self: Item): int {.inline.} =
|
||||
self.notificationsCount
|
||||
|
||||
proc `notificationsCount=`*(self: var Item, value: int) {.inline.} =
|
||||
self.notificationsCount = value
|
||||
|
||||
proc active*(self: Item): bool {.inline.} =
|
||||
self.active
|
||||
|
||||
proc `active=`*(self: var Item, value: bool) {.inline.} =
|
||||
self.active = value
|
||||
|
||||
proc enabled*(self: Item): bool {.inline.} =
|
||||
self.enabled
|
||||
|
||||
proc `enabled=`*(self: var Item, value: bool) {.inline.} =
|
||||
self.enabled = value
|
|
@ -10,8 +10,10 @@ type
|
|||
Image
|
||||
Icon
|
||||
Color
|
||||
MentionsCount
|
||||
UnviewedMessagesCount
|
||||
HasNotification
|
||||
NotificationsCount
|
||||
Active
|
||||
Enabled
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
@ -55,8 +57,10 @@ QtObject:
|
|||
ModelRole.Image.int:"image",
|
||||
ModelRole.Icon.int:"icon",
|
||||
ModelRole.Color.int:"color",
|
||||
ModelRole.MentionsCount.int:"mentionsCount",
|
||||
ModelRole.UnviewedMessagesCount.int:"unviewedMessagesCount"
|
||||
ModelRole.HasNotification.int:"hasNotification",
|
||||
ModelRole.NotificationsCount.int:"notificationsCount",
|
||||
ModelRole.Active.int:"active",
|
||||
ModelRole.Enabled.int:"enabled"
|
||||
}.toTable
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -71,21 +75,25 @@ QtObject:
|
|||
|
||||
case enumRole:
|
||||
of ModelRole.Id:
|
||||
result = newQVariant(item.getId())
|
||||
result = newQVariant(item.id)
|
||||
of ModelRole.SectionType:
|
||||
result = newQVariant(item.getSectionType())
|
||||
result = newQVariant(item.sectionType.int)
|
||||
of ModelRole.Name:
|
||||
result = newQVariant(item.getName())
|
||||
result = newQVariant(item.name)
|
||||
of ModelRole.Image:
|
||||
result = newQVariant(item.getImage())
|
||||
result = newQVariant(item.image)
|
||||
of ModelRole.Icon:
|
||||
result = newQVariant(item.getIcon())
|
||||
result = newQVariant(item.icon)
|
||||
of ModelRole.Color:
|
||||
result = newQVariant(item.getColor())
|
||||
of ModelRole.MentionsCount:
|
||||
result = newQVariant(item.getMentionsCount())
|
||||
of ModelRole.UnviewedMessagesCount:
|
||||
result = newQVariant(item.getUnviewedMessagesCount())
|
||||
result = newQVariant(item.color)
|
||||
of ModelRole.HasNotification:
|
||||
result = newQVariant(item.hasNotification)
|
||||
of ModelRole.NotificationsCount:
|
||||
result = newQVariant(item.notificationsCount)
|
||||
of ModelRole.Active:
|
||||
result = newQVariant(item.active)
|
||||
of ModelRole.Enabled:
|
||||
result = newQVariant(item.enabled)
|
||||
|
||||
proc addItem*(self: Model, item: Item) =
|
||||
let parentModelIndex = newQModelIndex()
|
||||
|
@ -95,4 +103,54 @@ QtObject:
|
|||
self.items.add(item)
|
||||
self.endInsertRows()
|
||||
|
||||
self.countChanged()
|
||||
self.countChanged()
|
||||
|
||||
proc getItemById*(self: Model, id: string): Item =
|
||||
for it in self.items:
|
||||
if(it.id == id):
|
||||
return it
|
||||
|
||||
proc getItemBySectionType*(self: Model, sectionType: SectionType): Item =
|
||||
for it in self.items:
|
||||
if(it.sectionType == sectionType):
|
||||
return it
|
||||
|
||||
proc setActiveSection*(self: Model, id: string) =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].active):
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
self.items[i].active = false
|
||||
self.dataChanged(index, index, @[ModelRole.Active.int])
|
||||
|
||||
if(self.items[i].id == id):
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
self.items[i].active = true
|
||||
self.dataChanged(index, index, @[ModelRole.Active.int])
|
||||
|
||||
proc enableDisableSection(self: Model, sectionType: SectionType, value: bool) =
|
||||
if(sectionType != SectionType.Community):
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].sectionType == sectionType):
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
self.items[i].enabled = value
|
||||
self.dataChanged(index, index, @[ModelRole.Enabled.int])
|
||||
else:
|
||||
var topInd = -1
|
||||
var bottomInd = -1
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].sectionType == sectionType):
|
||||
self.items[i].enabled = value
|
||||
if(topInd == -1):
|
||||
topInd = i
|
||||
|
||||
bottomInd = i
|
||||
|
||||
let topIndex = self.createIndex(topInd, 0, nil)
|
||||
let bottomIndex = self.createIndex(bottomInd, 0, nil)
|
||||
self.dataChanged(topIndex, bottomIndex, @[ModelRole.Enabled.int])
|
||||
|
||||
proc enableSection*(self: Model, sectionType: SectionType) =
|
||||
self.enableDisableSection(sectionType, true)
|
||||
|
||||
proc disableSection*(self: Model, sectionType: SectionType) =
|
||||
self.enableDisableSection(sectionType, false)
|
||||
|
|
|
@ -33,15 +33,6 @@ import ../../../app_service/service/privacy/service as privacy_service
|
|||
|
||||
export io_interface
|
||||
|
||||
type
|
||||
SectionType* {.pure.} = enum
|
||||
Chat = 0
|
||||
Community,
|
||||
Wallet,
|
||||
Browser,
|
||||
NodeManagement,
|
||||
ProfileSettings
|
||||
|
||||
type
|
||||
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
||||
delegate: T
|
||||
|
@ -126,31 +117,80 @@ method load*[T](self: Module[T]) =
|
|||
self.controller.init()
|
||||
self.view.load()
|
||||
|
||||
let chatSectionItem = initItem("chat", SectionType.Chat.int, "Chat", "",
|
||||
"chat", "", 0, 0)
|
||||
self.view.addItem(chatSectionItem)
|
||||
var activeSection: Item
|
||||
var activeSectionId = singletonInstance.localAccountSensitiveSettings.getActiveSection()
|
||||
|
||||
echo "=> communitiesSection"
|
||||
# Chat Section
|
||||
let chatSectionItem = initItem("chat", SectionType.Chat, "Chat", "", "chat", "", false, 0, true)
|
||||
self.view.addItem(chatSectionItem)
|
||||
if(activeSectionId == chatSectionItem.id):
|
||||
activeSection = chatSectionItem
|
||||
|
||||
# Community Section
|
||||
let communities = self.controller.getCommunities()
|
||||
for c in communities:
|
||||
self.view.addItem(initItem(c.id, SectionType.Community.int, c.name, c.images.thumbnail, "", c.color, 0, 0))
|
||||
let communitySectionItem = initItem(c.id, SectionType.Community, c.name, c.images.thumbnail, "", c.color, false, 0,
|
||||
false, singletonInstance.localAccountSensitiveSettings.getCommunitiesEnabled())
|
||||
self.view.addItem(communitySectionItem)
|
||||
if(activeSectionId == communitySectionItem.id):
|
||||
activeSection = communitySectionItem
|
||||
|
||||
echo "=> chatSection"
|
||||
# Wallet Section
|
||||
let walletSectionItem = initItem("wallet", SectionType.Wallet, "Wallet", "", "wallet", "", false, 0, false,
|
||||
singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled())
|
||||
self.view.addItem(walletSectionItem)
|
||||
if(activeSectionId == walletSectionItem.id):
|
||||
activeSection = walletSectionItem
|
||||
|
||||
# WalletV2 Section
|
||||
let walletV2SectionItem = initItem("walletV2", SectionType.WalletV2, "WalletV2", "", "cancel", "", false, 0, false,
|
||||
singletonInstance.localAccountSensitiveSettings.getIsWalletV2Enabled())
|
||||
self.view.addItem(walletV2SectionItem)
|
||||
if(activeSectionId == walletV2SectionItem.id):
|
||||
activeSection = walletV2SectionItem
|
||||
|
||||
# Browser Section
|
||||
let browserSectionItem = initItem("browser", SectionType.Browser, "Browser", "", "browser", "", false, 0, false,
|
||||
singletonInstance.localAccountSensitiveSettings.getIsBrowserEnabled())
|
||||
self.view.addItem(browserSectionItem)
|
||||
if(activeSectionId == browserSectionItem.id):
|
||||
activeSection = browserSectionItem
|
||||
|
||||
# Timeline Section
|
||||
let timelineSectionItem = initItem("timeline", SectionType.Timeline, "Timeline", "", "status-update", "", false, 0,
|
||||
false, singletonInstance.localAccountSensitiveSettings.getTimelineEnabled())
|
||||
self.view.addItem(timelineSectionItem)
|
||||
if(activeSectionId == timelineSectionItem.id):
|
||||
activeSection = timelineSectionItem
|
||||
|
||||
# Node Management Section
|
||||
let nodeManagementSectionItem = initItem("nodeManagement", SectionType.NodeManagement, "Node Management", "", "node",
|
||||
"", false, 0, false, singletonInstance.localAccountSensitiveSettings.getNodeManagementEnabled())
|
||||
self.view.addItem(nodeManagementSectionItem)
|
||||
if(activeSectionId == nodeManagementSectionItem.id):
|
||||
activeSection = nodeManagementSectionItem
|
||||
|
||||
# Profile Section
|
||||
let profileSettingsSectionItem = initItem("profileSettings", SectionType.ProfileSettings, "Settings", "",
|
||||
"status-update", "", false, 0, false, true)
|
||||
self.view.addItem(profileSettingsSectionItem)
|
||||
if(activeSectionId == profileSettingsSectionItem.id):
|
||||
activeSection = profileSettingsSectionItem
|
||||
|
||||
# Load all sections
|
||||
self.chatSectionModule.load()
|
||||
for cModule in self.communitySectionsModule.values:
|
||||
cModule.load()
|
||||
|
||||
let walletSectionItem = initItem("wallet", SectionType.Wallet.int, "Wallet", "",
|
||||
"wallet", "", 0, 0)
|
||||
self.view.addItem(chatSectionItem)
|
||||
self.walletSectionModule.load()
|
||||
# self.walletV2SectionModule.load()
|
||||
self.browserSectionModule.load()
|
||||
|
||||
let browserSectionItem = initItem("browser", SectionType.Browser.int, "Browser")
|
||||
self.view.addItem(browserSectionItem)
|
||||
|
||||
# self.timelineSectionModule.load()
|
||||
# self.nodeManagementSectionModule.load()
|
||||
self.profileSectionModule.load()
|
||||
|
||||
# Set active section on app start
|
||||
self.setActiveSection(activeSection)
|
||||
|
||||
proc checkIfModuleDidLoad [T](self: Module[T]) =
|
||||
if self.moduleLoaded:
|
||||
return
|
||||
|
@ -207,5 +247,21 @@ method emitStoringPasswordError*[T](self: Module[T], errorDescription: string) =
|
|||
method emitStoringPasswordSuccess*[T](self: Module[T]) =
|
||||
self.view.emitStoringPasswordSuccess()
|
||||
|
||||
method setActiveSection*[T](self: Module[T], item: Item) =
|
||||
if(item.isEmpty()):
|
||||
echo "section is empty and cannot be made an active one"
|
||||
return
|
||||
|
||||
self.controller.setActiveSection(item.id, item.sectionType)
|
||||
|
||||
method activeSectionSet*[T](self: Module[T], sectionId: string) =
|
||||
self.view.activeSectionSet(sectionId)
|
||||
|
||||
method enableSection*[T](self: Module[T], sectionType: SectionType) =
|
||||
self.view.enableSection(sectionType)
|
||||
|
||||
method disableSection*[T](self: Module[T], sectionType: SectionType) =
|
||||
self.view.disableSection(sectionType)
|
||||
|
||||
method setUserStatus*[T](self: Module[T], status: bool) =
|
||||
self.controller.setUserStatus(status)
|
||||
self.controller.setUserStatus(status)
|
|
@ -2,4 +2,4 @@ type
|
|||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
|
||||
# Since nim doesn't support using concepts in second level nested types we
|
||||
# define delegate interfaces within access interface.
|
||||
# define delegate interfaces within access interface.
|
|
@ -1,9 +1,19 @@
|
|||
import ../item
|
||||
|
||||
method offerToStorePassword*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method emitStoringPasswordError*(self: AccessInterface, errorDescription: string)
|
||||
{.base.} =
|
||||
method emitStoringPasswordError*(self: AccessInterface, errorDescription: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method emitStoringPasswordSuccess*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method activeSectionSet*(self: AccessInterface, sectionId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method enableSection*(self: AccessInterface, sectionType: SectionType) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method disableSection*(self: AccessInterface, sectionType: SectionType) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -1,8 +1,13 @@
|
|||
import ../item
|
||||
|
||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method storePassword*(self: AccessInterface, password: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setActiveSection*(self: AccessInterface, item: Item) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -1,5 +1,5 @@
|
|||
import NimQml
|
||||
import model, item
|
||||
import model, item, active_section
|
||||
import io_interface
|
||||
|
||||
QtObject:
|
||||
|
@ -8,10 +8,14 @@ QtObject:
|
|||
delegate: io_interface.AccessInterface
|
||||
model: Model
|
||||
modelVariant: QVariant
|
||||
activeSection: ActiveSection
|
||||
activeSectionVariant: QVariant
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.model.delete
|
||||
self.modelVariant.delete
|
||||
self.activeSection.delete
|
||||
self.activeSectionVariant.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||
|
@ -20,6 +24,8 @@ QtObject:
|
|||
result.delegate = delegate
|
||||
result.model = newModel()
|
||||
result.modelVariant = newQVariant(result.model)
|
||||
result.activeSection = newActiveSection()
|
||||
result.activeSectionVariant = newQVariant(result.activeSection)
|
||||
|
||||
proc load*(self: View) =
|
||||
# In some point, here, we will setup some exposed main module related things.
|
||||
|
@ -55,5 +61,42 @@ QtObject:
|
|||
proc emitStoringPasswordSuccess*(self: View) =
|
||||
self.storingPasswordSuccess()
|
||||
|
||||
proc activeSectionChanged*(self:View) {.signal.}
|
||||
|
||||
proc getActiveSection(self: View): QVariant {.slot.} =
|
||||
return self.activeSectionVariant
|
||||
|
||||
QtProperty[QVariant] activeSection:
|
||||
read = getActiveSection
|
||||
notify = activeSectionChanged
|
||||
|
||||
proc activeSectionSet*(self: View, sectionId: string) =
|
||||
self.model.setActiveSection(sectionId)
|
||||
|
||||
let item = self.model.getItemById(sectionId)
|
||||
self.activeSection.setActiveSectionData(item)
|
||||
|
||||
self.activeSectionChanged()
|
||||
|
||||
proc setActiveSectionById*(self: View, sectionId: string) {.slot.} =
|
||||
let item = self.model.getItemById(sectionId)
|
||||
self.delegate.setActiveSection(item)
|
||||
|
||||
proc setActiveSectionBySectionType*(self: View, sectionType: int) {.slot.} =
|
||||
## This will try to set a section with passed sectionType to active one, in case of communities the first community
|
||||
## will be set as active one.
|
||||
let item = self.model.getItemBySectionType(sectionType.SectionType)
|
||||
self.delegate.setActiveSection(item)
|
||||
|
||||
proc enableSection*(self: View, sectionType: SectionType) =
|
||||
# Since enable/disable section is possible only from the `Profile` tab, there is no need for setting
|
||||
# `activeSection` in this moment, as it will be in any case set to `ProfileSettings` type.
|
||||
self.model.enableSection(sectionType)
|
||||
|
||||
proc disableSection*(self: View, sectionType: SectionType) =
|
||||
# Since enable/disable section is possible only from the `Profile` tab, there is no need for setting
|
||||
# `activeSection` in this moment, as it will be in any case set to `ProfileSettings` type.
|
||||
self.model.disableSection(sectionType)
|
||||
|
||||
proc setUserStatus*(self: View, status: bool) {.slot.} =
|
||||
self.delegate.setUserStatus(status)
|
||||
self.delegate.setUserStatus(status)
|
|
@ -63,6 +63,7 @@ method load*(self: Module) =
|
|||
self.view.setModelItems(items)
|
||||
|
||||
# set the first account as slected one
|
||||
self.controller.setSelectedAccountKeyUid(items[0].getKeyUid())
|
||||
self.setSelectedAccount(items[0])
|
||||
|
||||
method isLoaded*(self: Module): bool =
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 35d12f444d4e1dacc56f47e25853281477177063
|
||||
Subproject commit d85ed4c3ed95fa1f32d8e50b2746691e5d9e5e4e
|
|
@ -117,7 +117,7 @@ PopupMenu {
|
|||
text: qsTrId("settings")
|
||||
shortcut: "Ctrl+,"
|
||||
onTriggered: {
|
||||
appMain.changeAppSection(Constants.profile)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
|
||||
// TODO: replace with shared store constant
|
||||
// Profile/RootStore.browser_settings_id
|
||||
profileLayoutContainer.changeProfileSection(10)
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
import utils 1.0
|
||||
import "../../../../../shared"
|
||||
import "../../../../../shared/popups"
|
||||
import "../../../../../shared/panels"
|
||||
import "../../../../../shared/status"
|
||||
import ".."
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 64
|
||||
|
||||
Row {
|
||||
id: filterButtons
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.padding
|
||||
height: allBtn.height
|
||||
spacing: Style.current.padding
|
||||
|
||||
StatusButton {
|
||||
id: allBtn
|
||||
//% "All"
|
||||
text: qsTrId("all")
|
||||
type: "secondary"
|
||||
size: "small"
|
||||
highlighted: activityCenter.currentFilter === ActivityCenter.Filter.All
|
||||
onClicked: activityCenter.currentFilter = ActivityCenter.Filter.All
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
id: mentionsBtn
|
||||
//% "Mentions"
|
||||
text: qsTrId("mentions")
|
||||
type: "secondary"
|
||||
enabled: hasMentions
|
||||
size: "small"
|
||||
highlighted: activityCenter.currentFilter === ActivityCenter.Filter.Mentions
|
||||
onClicked: activityCenter.currentFilter = ActivityCenter.Filter.Mentions
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
id: repliesbtn
|
||||
//% "Replies"
|
||||
text: qsTrId("replies")
|
||||
enabled: hasReplies
|
||||
type: "secondary"
|
||||
size: "small"
|
||||
highlighted: activityCenter.currentFilter === ActivityCenter.Filter.Replies
|
||||
onClicked: activityCenter.currentFilter = ActivityCenter.Filter.Replies
|
||||
}
|
||||
|
||||
// StatusButton {
|
||||
// id: contactRequestsBtn
|
||||
// //% "Contact requests"
|
||||
// text: qsTrId("contact-requests")
|
||||
// enabled: hasContactRequests
|
||||
// type: "secondary"
|
||||
// size: "small"
|
||||
// highlighted: activityCenter.currentFilter === ActivityCenter.Filter.ContactRequests
|
||||
// onClicked: activityCenter.currentFilter = ActivityCenter.Filter.ContactRequests
|
||||
// }
|
||||
}
|
||||
|
||||
Row {
|
||||
id: otherButtons
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
height: markAllReadBtn.height
|
||||
spacing: Style.current.padding
|
||||
|
||||
StatusIconButton {
|
||||
id: markAllReadBtn
|
||||
icon.name: "double-check"
|
||||
iconColor: Style.current.primary
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
width: 32
|
||||
height: 32
|
||||
onClicked: {
|
||||
errorText.text = chatsModel.activityNotificationList.markAllActivityCenterNotificationsRead()
|
||||
}
|
||||
|
||||
StatusToolTip {
|
||||
visible: markAllReadBtn.hovered
|
||||
//% "Mark all as Read"
|
||||
text: qsTrId("mark-all-as-read")
|
||||
}
|
||||
}
|
||||
|
||||
StatusContextMenuButton {
|
||||
id: moreActionsBtn
|
||||
onClicked: moreActionsMenu.open()
|
||||
|
||||
// TODO: replace with StatusPopupMenu
|
||||
PopupMenu {
|
||||
id: moreActionsMenu
|
||||
x: moreActionsBtn.width - moreActionsMenu.width
|
||||
y: moreActionsBtn.height + 4
|
||||
|
||||
Action {
|
||||
icon.source: hideReadNotifications ? Style.svg("eye") : Style.svg("eye-barred")
|
||||
icon.width: 16
|
||||
icon.height: 16
|
||||
text: hideReadNotifications ?
|
||||
//% "Show read notifications"
|
||||
qsTrId("show-read-notifications") :
|
||||
//% "Hide read notifications"
|
||||
qsTrId("hide-read-notifications")
|
||||
onTriggered: hideReadNotifications = !hideReadNotifications
|
||||
}
|
||||
Action {
|
||||
icon.source: Style.svg("bell")
|
||||
icon.width: 16
|
||||
icon.height: 16
|
||||
//% "Notification settings"
|
||||
text: qsTrId("chat-notification-preferences")
|
||||
onTriggered: {
|
||||
activityCenter.close()
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
|
||||
// TODO: replace with shared store constant
|
||||
// Profile/RootStore.notifications_id
|
||||
profileLayoutContainer.changeProfileSection(7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: errorText
|
||||
visible: !!text
|
||||
anchors.top: filterButtons.bottom
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
color: Style.current.danger
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ StatusModal {
|
|||
if (rememberChoiceCheckBox.checked) {
|
||||
localAccountSensitiveSettings.openLinksInStatus = true
|
||||
}
|
||||
changeAppSection(Constants.browser)
|
||||
changeAppSectionBySectionType(Constants.appSection.browser)
|
||||
browserLayoutContainer.item.openUrlInNewTab(popup.link)
|
||||
popup.close()
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ Item {
|
|||
if(root.store.chatsModelInst.communities.activeCommunity.active)
|
||||
{
|
||||
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ Item {
|
|||
{
|
||||
if(root.store.chatsModelInst.communities.activeCommunity.active) {
|
||||
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
}
|
||||
root.store.chatsModelInst.channelView.setActiveChannel(channelName);
|
||||
}
|
||||
|
|
|
@ -197,8 +197,8 @@ QtObject {
|
|||
return utilsModelInst.generateAlias(pubKey)
|
||||
}
|
||||
|
||||
function changeAppSection(section) {
|
||||
appMain.changeAppSection(section)
|
||||
function changeAppSectionBySectionType(section) {
|
||||
appMain.changeAppSectionBySectionType(section)
|
||||
}
|
||||
|
||||
function joinPrivateChat(address) {
|
||||
|
|
|
@ -256,12 +256,12 @@ Item {
|
|||
searchString: searchBox.text
|
||||
|
||||
onContactClicked: {
|
||||
root.store.changeAppSection(Constants.chat)
|
||||
root.store.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
root.store.joinPrivateChat(contact.address)
|
||||
}
|
||||
|
||||
onSendMessageActionTriggered: {
|
||||
root.store.changeAppSection(Constants.chat)
|
||||
root.store.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
root.store.joinPrivateChat(contact.address)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import shared.panels 1.0
|
|||
import shared.popups 1.0
|
||||
import shared.status 1.0
|
||||
import "./AppLayouts"
|
||||
import "./AppLayouts/Timeline"
|
||||
import "./AppLayouts/Wallet"
|
||||
import "./AppLayouts/WalletV2"
|
||||
import "./AppLayouts/Chat/popups"
|
||||
|
@ -39,10 +40,12 @@ Item {
|
|||
signal settingsLoaded()
|
||||
signal openContactsPopup()
|
||||
|
||||
function changeAppSection(section) {
|
||||
localAccountSensitiveSettings.lastModeActiveCommunity = ""
|
||||
chatsModel.communities.activeCommunity.active = false
|
||||
appView.currentIndex = Utils.getAppSectionIndex(section)
|
||||
function changeAppSectionBySectionType(sectionType) {
|
||||
mainModule.setActiveSectionBySectionType(sectionType)
|
||||
}
|
||||
|
||||
function changeAppSectionBySectionId(sectionId) {
|
||||
mainModule.setActiveSectionById(sectionId)
|
||||
}
|
||||
|
||||
function getProfileImage(pubkey, isCurrentUser, useLargeImage) {
|
||||
|
@ -57,16 +60,12 @@ Item {
|
|||
|
||||
if (localAccountSensitiveSettings.onlyShowContactsProfilePics) {
|
||||
const isContact = appMain.rootStore.contactsModuleInst.model.list.rowData(index, "isContact")
|
||||
if (isContact === "true") {
|
||||
return appMain.rootStore.contactsModuleInst.model.list.rowData(index, useLargeImage ? "largeImage" : "thumbnailImage")
|
||||
} else {
|
||||
if (isContact === "false") {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return useLargeImage ? appMain.rootStore.chatsModelInst.getProfileImageLarge(pubkey)
|
||||
: appMain.rootStore.chatsModelInst.getProfileThumbnail(pubkey)
|
||||
|
||||
return appMain.rootStore.contactsModuleInst.model.list.rowData(index, useLargeImage ? "largeImage" : "thumbnailImage")
|
||||
}
|
||||
|
||||
function openPopup(popupComponent, params = {}) {
|
||||
|
@ -120,7 +119,7 @@ Item {
|
|||
appMain.openPopup(chooseBrowserPopupComponent, {link: link})
|
||||
} else {
|
||||
if (localAccountSensitiveSettings.openLinksInStatus) {
|
||||
appMain.changeAppSection(Constants.browser)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.browser)
|
||||
browserLayoutContainer.item.openUrlInNewTab(link)
|
||||
} else {
|
||||
Qt.openUrlExternally(link)
|
||||
|
@ -140,7 +139,6 @@ Item {
|
|||
property Component profilePopupComponent: ProfilePopup {
|
||||
id: profilePopup
|
||||
store: rootStore
|
||||
profileStore: appMain.profileStore
|
||||
onClosed: {
|
||||
if(profilePopup.parentPopup){
|
||||
profilePopup.parentPopup.close();
|
||||
|
@ -198,48 +196,63 @@ Item {
|
|||
appNavBar: StatusAppNavBar {
|
||||
height: appMain.height
|
||||
|
||||
navBarChatButton: StatusNavBarTabButton {
|
||||
icon.name: "chat"
|
||||
checked: !chatsModel.communities.activeCommunity.active && appView.currentIndex === Utils.getAppSectionIndex(Constants.chat)
|
||||
//% "Chat"
|
||||
tooltip.text: qsTrId("chat")
|
||||
badge.value: chatsModel.messageView.unreadDirectMessagesAndMentionsCount + profileModel.contacts.contactRequests.count
|
||||
badge.visible: badge.value > 0 || (chatsModel.messageView.unreadMessagesCount > 0 && !checked)
|
||||
badge.anchors.rightMargin: badge.value > 0 ? 0 : 4
|
||||
badge.anchors.topMargin: badge.value > 0 ? 4 : 5
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
|
||||
communityTypeRole: "sectionType"
|
||||
communityTypeValue: Constants.appSection.community
|
||||
sectionModel: mainModule.sectionsModel
|
||||
|
||||
property bool communityAdded: false
|
||||
|
||||
onAboutToUpdateFilteredRegularModel: {
|
||||
communityAdded = false
|
||||
}
|
||||
|
||||
filterRegularItem: function(item) {
|
||||
if(!item.enabled)
|
||||
return false
|
||||
|
||||
if(item.sectionType === Constants.appSection.community)
|
||||
if(communityAdded)
|
||||
return false
|
||||
else
|
||||
communityAdded = true
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
filterCommunityItem: function(item) {
|
||||
return item.sectionType === Constants.appSection.community
|
||||
}
|
||||
|
||||
regularNavBarButton: StatusNavBarTabButton {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
name: model.icon.length > 0? "" : model.name
|
||||
icon.name: model.icon
|
||||
icon.source: model.image
|
||||
tooltip.text: model.name
|
||||
checked: model.active
|
||||
badge.value: model.notificationsCount
|
||||
badge.visible: model.hasNotification
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusBadge.borderColor
|
||||
badge.border.width: 2
|
||||
onClicked: {
|
||||
if (chatsModel.communities.activeCommunity.active) {
|
||||
chatLayoutContainer.chatColumn.hideChatInputExtendedArea();
|
||||
chatsModel.communities.activeCommunity.active = false
|
||||
}
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
changeAppSectionBySectionId(model.id)
|
||||
}
|
||||
}
|
||||
|
||||
navBarCommunityTabButtons.model: localAccountSensitiveSettings.communitiesEnabled && chatsModel.communities.joinedCommunities
|
||||
navBarCommunityTabButtons.delegate: StatusNavBarTabButton {
|
||||
onClicked: {
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
chatsModel.communities.setActiveCommunity(model.id)
|
||||
localAccountSensitiveSettings.lastModeActiveCommunity = model.id
|
||||
}
|
||||
|
||||
communityNavBarButton: StatusNavBarTabButton {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
checked: chatsModel.communities.activeCommunity.active && chatsModel.communities.activeCommunity.id === model.id
|
||||
name: model.name
|
||||
name: model.icon.length > 0? "" : model.name
|
||||
icon.name: model.icon
|
||||
icon.source: model.image
|
||||
tooltip.text: model.name
|
||||
icon.color: model.communityColor
|
||||
icon.source: model.thumbnailImage
|
||||
|
||||
badge.value: model.unviewedMentionsCount + model.requestsCount
|
||||
badge.visible: badge.value > 0 || (!checked && model.unviewedMessagesCount > 0)
|
||||
checked: model.active
|
||||
badge.value: model.notificationsCount
|
||||
badge.visible: model.hasNotification
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusBadge.borderColor
|
||||
badge.border.width: 2
|
||||
badge.anchors.rightMargin: 4
|
||||
badge.anchors.topMargin: 5
|
||||
onClicked: {
|
||||
changeAppSectionBySectionId(model.id)
|
||||
}
|
||||
|
||||
popupMenu: StatusPopupMenu {
|
||||
id: communityContextMenu
|
||||
|
@ -254,8 +267,8 @@ Item {
|
|||
icon.name: "share-ios"
|
||||
enabled: chatsModel.communities.observedCommunity.canManageUsers
|
||||
onTriggered: openPopup(inviteFriendsToCommunityPopup, {
|
||||
community: chatsModel.communities.observedCommunity
|
||||
})
|
||||
community: chatsModel.communities.observedCommunity
|
||||
})
|
||||
}
|
||||
|
||||
StatusMenuItem {
|
||||
|
@ -290,66 +303,11 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
navBarTabButtons: [
|
||||
StatusNavBarTabButton {
|
||||
icon.name: "wallet"
|
||||
//% "Wallet"
|
||||
tooltip.text: qsTrId("wallet")
|
||||
visible: enabled
|
||||
enabled: isExperimental === "1" || localAccountSensitiveSettings.isWalletEnabled
|
||||
checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.wallet)
|
||||
onClicked: appMain.changeAppSection(Constants.wallet)
|
||||
},
|
||||
|
||||
StatusNavBarTabButton {
|
||||
//TODO temporary icon name, switch back to wallet
|
||||
icon.name: "cancel"
|
||||
tooltip.text: qsTr("Wallet v2 - do not use, under active development")
|
||||
visible: enabled
|
||||
enabled: isExperimental === "1" || localAccountSensitiveSettings.isWalletV2Enabled
|
||||
checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.walletv2)
|
||||
onClicked: appMain.changeAppSection(Constants.walletv2)
|
||||
},
|
||||
|
||||
StatusNavBarTabButton {
|
||||
enabled: isExperimental === "1" || localAccountSensitiveSettings.isBrowserEnabled
|
||||
visible: enabled
|
||||
//% "Browser"
|
||||
tooltip.text: qsTrId("browser")
|
||||
icon.name: "browser"
|
||||
checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.browser)
|
||||
onClicked: appMain.changeAppSection(Constants.browser)
|
||||
},
|
||||
|
||||
StatusNavBarTabButton {
|
||||
enabled: isExperimental === "1" || localAccountSensitiveSettings.nodeManagementEnabled
|
||||
visible: enabled
|
||||
tooltip.text: qsTr("Node Management")
|
||||
icon.name: "node"
|
||||
checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.node)
|
||||
onClicked: appMain.changeAppSection(Constants.node)
|
||||
},
|
||||
|
||||
StatusNavBarTabButton {
|
||||
id: profileBtn
|
||||
//% "Settings"
|
||||
tooltip.text: qsTrId("settings")
|
||||
icon.name: "settings"
|
||||
checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.profile)
|
||||
onClicked: appMain.changeAppSection(Constants.profile)
|
||||
|
||||
badge.visible: !mnemonicModule.isBackedUp
|
||||
badge.anchors.rightMargin: 4
|
||||
badge.anchors.topMargin: 5
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
|
||||
badge.border.width: 2
|
||||
}
|
||||
]
|
||||
|
||||
navBarProfileButton: StatusNavBarTabButton {
|
||||
id: profileButton
|
||||
property bool opened: false
|
||||
icon.source: userProfile.thumbnailImage
|
||||
|
||||
icon.source: profileModule.thumbnailImage || ""
|
||||
badge.visible: true
|
||||
badge.anchors.rightMargin: 4
|
||||
badge.anchors.topMargin: 25
|
||||
|
@ -387,7 +345,51 @@ Item {
|
|||
appView: StackLayout {
|
||||
id: appView
|
||||
anchors.fill: parent
|
||||
currentIndex: 0
|
||||
currentIndex: {
|
||||
if(mainModule.activeSection.sectionType === Constants.appSection.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) {
|
||||
|
||||
/*************************************/
|
||||
// This will be refactored later
|
||||
chatsModel.communities.setActiveCommunity(mainModule.activeSection.id)
|
||||
/*************************************/
|
||||
|
||||
return 99 //Don't know why, but that's how it was in Utils::getAppSectionIndex function.
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) {
|
||||
return 1
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.walletv2) {
|
||||
return 7
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.browser) {
|
||||
return 2
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.timeline) {
|
||||
return 3
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.profile) {
|
||||
return 4
|
||||
}
|
||||
else if(mainModule.activeSection.sectionType === Constants.appSection.node) {
|
||||
return 7
|
||||
}
|
||||
|
||||
// We should never end up here
|
||||
console.error("Unknown section type")
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
var obj = this.children[currentIndex];
|
||||
if(!obj)
|
||||
|
@ -401,6 +403,8 @@ Item {
|
|||
browserLayoutContainer.active = true;
|
||||
}
|
||||
|
||||
timelineLayoutContainer.active = obj === timelineLayoutContainer
|
||||
|
||||
if(obj === walletLayoutContainer){
|
||||
walletLayoutContainer.showSigningPhrasePopup();
|
||||
}
|
||||
|
@ -408,7 +412,6 @@ Item {
|
|||
if(obj === walletV2LayoutContainer){
|
||||
walletV2LayoutContainer.showSigningPhrasePopup();
|
||||
}
|
||||
localAccountSensitiveSettings.lastModeActiveTab = currentIndex
|
||||
}
|
||||
|
||||
ChatLayout {
|
||||
|
@ -418,7 +421,7 @@ Item {
|
|||
Layout.fillHeight: true
|
||||
messageStore: appMain.rootStore.messageStore
|
||||
onProfileButtonClicked: {
|
||||
appMain.changeAppSection(Constants.profile);
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,13 +454,27 @@ Item {
|
|||
property var _web3Provider: web3Provider
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: timelineLayoutContainer
|
||||
sourceComponent: Component {
|
||||
TimelineLayout {
|
||||
messageStore: appMain.rootStore.messageStore
|
||||
rootStore: appMain.rootStore
|
||||
}
|
||||
}
|
||||
onLoaded: timelineLayoutContainer.item.onActivated()
|
||||
active: false
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
ProfileLayout {
|
||||
id: profileLayoutContainer
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
globalStore: appMain.rootStore
|
||||
store: appMain.rootStore.profileStore
|
||||
}
|
||||
|
||||
NodeLayout {
|
||||
|
@ -619,12 +636,11 @@ Item {
|
|||
id: toastMessage
|
||||
}
|
||||
|
||||
// ToDo: move this to Global or similar in order to get rid of dynamic scoping
|
||||
// Add SendModal here as it is used by the Wallet as well as the Browser
|
||||
Loader {
|
||||
id: sendModal
|
||||
active: false
|
||||
|
||||
property var selectedAccount
|
||||
function open() {
|
||||
this.active = true
|
||||
this.item.open()
|
||||
|
@ -633,11 +649,6 @@ Item {
|
|||
// this.sourceComponent = undefined // kill an opened instance
|
||||
this.active = false
|
||||
}
|
||||
onLoaded: {
|
||||
if( item && sendModal.selectedAccount) {
|
||||
item.selectFromAccount.selectedAccount = sendModal.selectedAccount
|
||||
}
|
||||
}
|
||||
sourceComponent: SendModal {
|
||||
store: appMain.rootStore
|
||||
onOpened: {
|
||||
|
@ -651,19 +662,19 @@ Item {
|
|||
|
||||
Action {
|
||||
shortcut: "Ctrl+1"
|
||||
onTriggered: changeAppSection(Constants.chat)
|
||||
onTriggered: changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
}
|
||||
Action {
|
||||
shortcut: "Ctrl+2"
|
||||
onTriggered: changeAppSection(Constants.browser)
|
||||
onTriggered: changeAppSectionBySectionType(Constants.appSection.browser)
|
||||
}
|
||||
Action {
|
||||
shortcut: "Ctrl+3"
|
||||
onTriggered: changeAppSection(Constants.wallet)
|
||||
onTriggered: changeAppSectionBySectionType(Constants.appSection.wallet)
|
||||
}
|
||||
Action {
|
||||
shortcut: "Ctrl+4, Ctrl+,"
|
||||
onTriggered: changeAppSection(Constants.profile)
|
||||
onTriggered: changeAppSectionBySectionType(Constants.appSection.profile)
|
||||
}
|
||||
Action {
|
||||
shortcut: "Ctrl+K"
|
||||
|
@ -714,7 +725,7 @@ Item {
|
|||
});
|
||||
}
|
||||
onClicked: function (index) {
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
chatsModel.channelView.setActiveChannelByIndex(index)
|
||||
channelPicker.close()
|
||||
}
|
||||
|
@ -722,10 +733,6 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
appView.currentIndex = localAccountSensitiveSettings.lastModeActiveTab
|
||||
if(!!localAccountSensitiveSettings.lastModeActiveCommunity) {
|
||||
chatsModel.communities.setActiveCommunity(localAccountSensitiveSettings.lastModeActiveCommunity)
|
||||
}
|
||||
// Since https://github.com/status-im/status-desktop/commit/93668ff75
|
||||
// we're hiding the setting to change appearance for compact normal mode
|
||||
// of the UI. For now, compact mode is the new default.
|
||||
|
@ -785,8 +792,3 @@ Item {
|
|||
appMain.settingsLoaded()
|
||||
}
|
||||
}
|
||||
/*##^##
|
||||
Designer {
|
||||
D{i:0;formeditorZoom:1.75;height:770;width:1232}
|
||||
}
|
||||
##^##*/
|
||||
|
|
|
@ -30,12 +30,12 @@ PopupMenu {
|
|||
anchors.top: parent.top
|
||||
anchors.topMargin: 4
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
image.source: userProfile.thumbnailImage || ""
|
||||
image.source: root.store.userProfileInst.thumbnailImage || ""
|
||||
image.isIdenticon: true
|
||||
}
|
||||
StyledText {
|
||||
id: username
|
||||
text: Utils.removeStatusEns(profileModel.ens.preferredUsername || userProfile.username)
|
||||
text: Utils.removeStatusEns(profileModel.ens.preferredUsername || root.store.userProfileInst.username)
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 3
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
|
|
@ -361,7 +361,7 @@ Column {
|
|||
//% "Enable in Settings"
|
||||
text: qsTrId("enable-in-settings")
|
||||
onClicked: {
|
||||
appMain.changeAppSection(Constants.profile)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.profile)
|
||||
// TODO: replace with shared store constant
|
||||
// Profile/RootStore.privacy_and_security_id
|
||||
profileLayoutContainer.changeProfileSection(3)
|
||||
|
|
|
@ -255,7 +255,7 @@ StatusPopupMenu {
|
|||
qsTrId("reply-to")
|
||||
onTriggered: {
|
||||
if (root.isProfile) {
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
appMain.changeAppSectionBySectionType(Constants.appSection.chat)
|
||||
root.store.chatsModelInst.channelView.joinPrivateChat(fromAuthor, "")
|
||||
} else {
|
||||
showReplyArea()
|
||||
|
|
|
@ -3,12 +3,32 @@ pragma Singleton
|
|||
import QtQuick 2.13
|
||||
|
||||
QtObject {
|
||||
property QtObject appState: QtObject {
|
||||
readonly property QtObject appState: QtObject {
|
||||
readonly property int onboarding: 0
|
||||
readonly property int login: 1
|
||||
readonly property int main: 2
|
||||
}
|
||||
|
||||
readonly property QtObject appSection: QtObject {
|
||||
readonly property int chat: 0
|
||||
readonly property int community: 1
|
||||
readonly property int wallet: 2
|
||||
readonly property int walletv2: 3
|
||||
readonly property int browser: 4
|
||||
readonly property int timeline: 5
|
||||
readonly property int profile: 6
|
||||
readonly property int node: 7
|
||||
}
|
||||
|
||||
readonly property QtObject osNotificationType: QtObject{
|
||||
readonly property int newContactRequest: 1
|
||||
readonly property int acceptedContactRequest: 2
|
||||
readonly property int joinCommunityRequest: 3
|
||||
readonly property int acceptedIntoCommunity: 4
|
||||
readonly property int rejectedByCommunity: 5
|
||||
readonly property int newMessage: 6
|
||||
}
|
||||
|
||||
readonly property int communityImported: 0
|
||||
readonly property int communityImportingInProgress: 1
|
||||
readonly property int communityImportingError: 2
|
||||
|
@ -16,6 +36,7 @@ QtObject {
|
|||
readonly property int chatTypeOneToOne: 1
|
||||
readonly property int chatTypePublic: 2
|
||||
readonly property int chatTypePrivateGroupChat: 3
|
||||
readonly property int chatTypeStatusUpdate: 4
|
||||
readonly property int chatTypeCommunity: 6
|
||||
|
||||
readonly property int communityChatPublicAccess: 1
|
||||
|
@ -44,15 +65,6 @@ QtObject {
|
|||
readonly property string lightThemeName: "light"
|
||||
readonly property string darkThemeName: "dark"
|
||||
|
||||
readonly property string chat: "chat"
|
||||
readonly property string wallet: "wallet"
|
||||
readonly property string walletv2: "walletV2"
|
||||
readonly property string browser: "browser"
|
||||
readonly property string profile: "profile"
|
||||
readonly property string node: "node"
|
||||
readonly property string ui: "ui"
|
||||
readonly property string community: "community"
|
||||
|
||||
readonly property int fontSizeXS: 0
|
||||
readonly property int fontSizeS: 1
|
||||
readonly property int fontSizeM: 2
|
||||
|
@ -192,13 +204,4 @@ QtObject {
|
|||
//% "Continuing will require a transaction to connect the username with your current chat key."
|
||||
"connected-different-key": qsTrId("ens-username-connected-with-different-key"),
|
||||
}
|
||||
|
||||
readonly property QtObject osNotificationType: QtObject{
|
||||
readonly property int newContactRequest: 1
|
||||
readonly property int acceptedContactRequest: 2
|
||||
readonly property int joinCommunityRequest: 3
|
||||
readonly property int acceptedIntoCommunity: 4
|
||||
readonly property int rejectedByCommunity: 5
|
||||
readonly property int newMessage: 6
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,25 +125,6 @@ QtObject {
|
|||
`<a href="${link}">${link}</a>`
|
||||
}
|
||||
|
||||
function getAppSectionIndex(section) {
|
||||
let sectionId = -1
|
||||
switch (section) {
|
||||
case Constants.chat: sectionId = 0; break;
|
||||
case Constants.wallet: sectionId = 1; break;
|
||||
case Constants.browser: sectionId = 2; break;
|
||||
case Constants.profile: sectionId = 3; break;
|
||||
case Constants.node: sectionId = 4; break;
|
||||
case Constants.ui: sectionId = 5; break;
|
||||
case Constants.walletv2: sectionId = 6; break;
|
||||
case Constants.community: sectionId = 99; break;
|
||||
}
|
||||
if (sectionId === -1) {
|
||||
console.warn("Unknown section name. Defaulting to chat section")
|
||||
return 0
|
||||
}
|
||||
return sectionId
|
||||
}
|
||||
|
||||
function getDisplayName(publicKey, contactIndex) {
|
||||
if (contactIndex === undefined) {
|
||||
contactIndex = contactsModule.model.list.getContactIndexByPubkey(publicKey)
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtGraphicalEffects 1.13
|
||||
|
||||
import utils 1.0
|
||||
import "../../shared"
|
||||
import "../../shared/panels"
|
||||
import "../../shared/status"
|
||||
|
||||
TabButton {
|
||||
id: control
|
||||
visible: enabled
|
||||
width: 40
|
||||
height: enabled ? 40 : 0
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
property color iconColor: Style.current.secondaryText
|
||||
property color disabledColor: iconColor
|
||||
property int iconRotation: 0
|
||||
property string iconSource
|
||||
property string section
|
||||
property int sectionIndex: Utils.getAppSectionIndex(section)
|
||||
property bool doNotHandleClick: false
|
||||
property bool borderOnChecked: false
|
||||
property bool useLetterIdenticon: false
|
||||
property string name: ""
|
||||
|
||||
onClicked: {
|
||||
if (doNotHandleClick) {
|
||||
return
|
||||
}
|
||||
|
||||
chatsModel.communities.activeCommunity.active = false
|
||||
appMain.changeAppSectionBySectionType(section)
|
||||
}
|
||||
|
||||
checked: sLayout.currentIndex === sectionIndex
|
||||
|
||||
icon.height: 24
|
||||
icon.width: 24
|
||||
icon.color: {
|
||||
if (!enabled) {
|
||||
return control.disabledColor
|
||||
}
|
||||
return (hovered || checked) ? Style.current.blue : control.iconColor
|
||||
}
|
||||
|
||||
onIconChanged: {
|
||||
if (iconSource) {
|
||||
icon.source = iconSource
|
||||
return
|
||||
}
|
||||
|
||||
icon.source = icon.name ? Style.svg(icon.name) : ""
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Loader {
|
||||
active: true
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
sourceComponent: useLetterIdenticon ? letterIdenticon :
|
||||
!!iconSource ? imageIcon : defaultIcon
|
||||
}
|
||||
|
||||
Component {
|
||||
id: defaultIcon
|
||||
SVGImage {
|
||||
id: iconImg
|
||||
source: control.icon.source
|
||||
height: control.icon.height
|
||||
width: control.icon.width
|
||||
fillMode: Image.PreserveAspectFit
|
||||
rotation: control.iconRotation
|
||||
ColorOverlay {
|
||||
anchors.fill: iconImg
|
||||
source: iconImg
|
||||
color: control.icon.color
|
||||
antialiasing: true
|
||||
smooth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: imageIcon
|
||||
RoundedImage {
|
||||
source: iconSource
|
||||
noMouseArea: true
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: letterIdenticon
|
||||
StatusLetterIdenticon {
|
||||
width: 26
|
||||
height: 26
|
||||
letterSize: 15
|
||||
chatName: control.name
|
||||
color: control.iconColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: hovered || (borderOnChecked && checked) ? Style.current.tabButtonBg : "transparent"
|
||||
border.color: Style.current.primary
|
||||
border.width: borderOnChecked && checked ? 1 : 0
|
||||
radius: control.width / 2
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onPressed: mouse.accepted = false
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit d86befc4cdb938c7b18d890ca3d91155d7c892ec
|
||||
Subproject commit 379e803d9467ddb460e3a32cae3455ccb2880d26
|
|
@ -1 +1 @@
|
|||
Subproject commit f091a70a5bf95ec772c8b4d9978e81b8ae89af0c
|
||||
Subproject commit 7176de4ddb3a628a5c3abfcd430010bf0229deb1
|
|
@ -1 +1 @@
|
|||
Subproject commit 7413bbde00a015fe5fca37846448135f1b43b2cf
|
||||
Subproject commit 4eab2fa86b0e901c1018b3b50083f214be163139
|
Loading…
Reference in New Issue