2022-08-23 08:46:37 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
2022-12-06 14:45:07 +00:00
|
|
|
import shared.controls 1.0
|
2022-08-23 08:46:37 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
|
2022-12-06 14:45:07 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Item {
|
2022-08-23 08:46:37 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property var store
|
2023-01-24 21:49:07 +00:00
|
|
|
property var checkedKeys: []
|
2023-01-12 13:18:52 +00:00
|
|
|
property int type: ExtendedDropdownContent.Type.Assets
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
readonly property bool canGoBack: root.state !== d.listView_depth1_State
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
signal itemClicked(string key, string name, url iconSource)
|
2023-01-18 19:54:14 +00:00
|
|
|
signal navigateDeep(string key, var subItems)
|
2022-08-23 08:46:37 +00:00
|
|
|
|
|
|
|
enum Type{
|
2023-01-12 13:18:52 +00:00
|
|
|
Assets,
|
2022-08-23 08:46:37 +00:00
|
|
|
Collectibles
|
|
|
|
}
|
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
function goBack() {
|
|
|
|
root.state = d.listView_depth1_State
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
function goForward(key, itemName, itemSource, subItems) {
|
|
|
|
d.currentSubitems = subItems
|
|
|
|
d.currentItemKey = key
|
|
|
|
d.currentItemName = itemName
|
|
|
|
d.currentItemSource = itemSource
|
|
|
|
root.state = d.listView_depth2_State
|
|
|
|
}
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property int filterItemsHeight: 36
|
|
|
|
readonly property int filterPopupWidth: 233
|
|
|
|
readonly property int filterPopupHeight: 205
|
|
|
|
|
|
|
|
// Internal management properties
|
|
|
|
property bool isFilterOptionVisible: false
|
|
|
|
readonly property string thumbnailsViewState: "THUMBNAILS"
|
|
|
|
readonly property string listView_depth1_State: "LIST-DEPTH1"
|
|
|
|
readonly property string listView_depth2_State: "LIST-DEPTH2"
|
|
|
|
property var currentModel: root.store.collectiblesModel
|
|
|
|
property var currentSubitems
|
2023-01-18 19:54:14 +00:00
|
|
|
property string currentItemKey: ""
|
2022-08-23 08:46:37 +00:00
|
|
|
property string currentItemName: ""
|
|
|
|
property url currentItemSource: ""
|
|
|
|
|
2022-12-06 14:45:07 +00:00
|
|
|
readonly property SortFilterProxyModel filtered: SortFilterProxyModel {
|
|
|
|
id: collectiblesFilteredModel
|
|
|
|
|
|
|
|
sourceModel: root.store.collectiblesModel
|
|
|
|
|
|
|
|
filters: ExpressionFilter {
|
|
|
|
expression: {
|
|
|
|
searcher.text
|
|
|
|
return name.toLowerCase().includes(searcher.text.toLowerCase())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
function reset() {
|
2023-01-18 19:54:14 +00:00
|
|
|
d.currentItemKey = ""
|
2022-08-23 08:46:37 +00:00
|
|
|
d.currentItemName = ""
|
|
|
|
d.currentItemSource = ""
|
|
|
|
d.currentModel = root.store.collectiblesModel
|
|
|
|
d.currentSubitems = undefined
|
|
|
|
root.state = d.listView_depth1_State
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
state: d.listView_depth1_State
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: d.listView_depth1_State
|
2022-12-06 14:45:07 +00:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: contentLoader
|
2023-01-12 13:18:52 +00:00
|
|
|
sourceComponent: root.type === ExtendedDropdownContent.Type.Assets
|
|
|
|
? assetsListView : collectiblesListView
|
2022-12-06 14:45:07 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: d
|
2023-01-12 13:18:52 +00:00
|
|
|
currentModel: root.type === ExtendedDropdownContent.Type.Assets
|
|
|
|
? root.store.assetsModel : collectiblesFilteredModel//root.store.collectiblesModel
|
2022-12-06 14:45:07 +00:00
|
|
|
isFilterOptionVisible: false
|
|
|
|
}
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: tokenGroupItem
|
|
|
|
visible: false
|
|
|
|
}
|
2022-12-06 14:45:07 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: searcher
|
|
|
|
visible: type === ExtendedDropdownContent.Type.Collectibles
|
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: d.listView_depth2_State
|
2022-12-06 14:45:07 +00:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: contentLoader
|
|
|
|
sourceComponent: collectiblesListView
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: d
|
|
|
|
currentModel: d.currentSubitems
|
|
|
|
isFilterOptionVisible: true
|
|
|
|
}
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: tokenGroupItem
|
|
|
|
visible: true
|
|
|
|
}
|
2022-12-06 14:45:07 +00:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: d.thumbnailsViewState
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: contentLoader
|
|
|
|
sourceComponent: thumbnailsView
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: d
|
|
|
|
currentModel: d.currentSubitems
|
|
|
|
isFilterOptionVisible: true
|
|
|
|
}
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: tokenGroupItem
|
|
|
|
visible: true
|
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: filterButton
|
2022-08-31 12:35:28 +00:00
|
|
|
width: 32
|
|
|
|
height: 32
|
2022-08-30 16:27:00 +00:00
|
|
|
visible: d.isFilterOptionVisible
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
icon.name: "filter"
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.top
|
|
|
|
anchors.bottomMargin: 3
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
filterOptionsPopup.x = filterButton.x + filterButton.width - filterOptionsPopup.width
|
|
|
|
filterOptionsPopup.y = filterButton.y + filterButton.height + 8
|
|
|
|
filterOptionsPopup.open()
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
// Filter options popup:
|
|
|
|
StatusDropdown {
|
|
|
|
id: filterOptionsPopup
|
|
|
|
width: d.filterPopupWidth
|
|
|
|
height: d.filterPopupHeight
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: 8
|
|
|
|
anchors.bottomMargin: 8
|
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: model.count * d.filterItemsHeight
|
|
|
|
model: ListModel {
|
|
|
|
ListElement { text: qsTr("Most viewed"); selected: true }
|
|
|
|
ListElement { text: qsTr("Newest first"); selected: false }
|
|
|
|
ListElement { text: qsTr("Oldest first"); selected: false }
|
|
|
|
}
|
|
|
|
delegate: StatusItemPicker {
|
|
|
|
width: ListView.view.width
|
|
|
|
height: d.filterItemsHeight
|
|
|
|
color: sensor1.containsMouse ? Theme.palette.baseColor4 : "transparent"
|
|
|
|
name: model.text
|
|
|
|
namePixelSize: 13
|
|
|
|
selectorType: StatusItemPicker.SelectorType.RadioButton
|
|
|
|
radioGroup: filterRadioBtnGroup
|
|
|
|
radioButtonSize: StatusRadioButton.Size.Small
|
|
|
|
selected: model.selected
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: sensor1
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: {
|
|
|
|
selected = !selected
|
|
|
|
console.log("TODO: Clicked filter option: " + model.text)
|
|
|
|
filterOptionsPopup.close()
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
// Not visual element to control filter options
|
|
|
|
ButtonGroup {
|
|
|
|
id: filterRadioBtnGroup
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Separator { Layout.fillWidth: true }
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: model.count * d.filterItemsHeight
|
|
|
|
model: ListModel {
|
|
|
|
ListElement { key: "LIST"; text: qsTr("List"); selected: true }
|
|
|
|
ListElement { key: "THUMBNAILS"; text: qsTr("Thumbnails"); selected: false }
|
|
|
|
}
|
|
|
|
delegate: StatusItemPicker {
|
|
|
|
width: ListView.view.width
|
|
|
|
height: d.filterItemsHeight
|
|
|
|
color: sensor2.containsMouse ? Theme.palette.baseColor4 : "transparent"
|
|
|
|
name: model.text
|
|
|
|
namePixelSize: 13
|
|
|
|
selectorType: StatusItemPicker.SelectorType.RadioButton
|
|
|
|
radioGroup: visualizationRadioBtnGroup
|
|
|
|
radioButtonSize: StatusRadioButton.Size.Small
|
|
|
|
selected: model.selected
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: sensor2
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: {
|
|
|
|
selected = !selected
|
|
|
|
if(model.key === "LIST") {
|
|
|
|
root.state = d.listView_depth2_State
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
else if(model.key === "THUMBNAILS") {
|
|
|
|
root.state = d.thumbnailsViewState
|
|
|
|
}
|
|
|
|
filterOptionsPopup.close()
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
// Not visual element to control visualization options
|
|
|
|
ButtonGroup {
|
|
|
|
id: visualizationRadioBtnGroup
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// List elements content
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2022-12-06 14:45:07 +00:00
|
|
|
ColumnLayout {
|
2022-08-30 16:27:00 +00:00
|
|
|
anchors.fill: parent
|
2022-12-06 14:45:07 +00:00
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searcher
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
minimumHeight: 36
|
|
|
|
maximumHeight: 36
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
TokenItem {
|
|
|
|
id: tokenGroupItem
|
2023-01-24 21:49:07 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-24 21:49:07 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
key: d.currentItemKey
|
|
|
|
name: d.currentItemName
|
|
|
|
iconSource: d.currentItemSource
|
2023-01-24 21:49:07 +00:00
|
|
|
|
|
|
|
selected: root.checkedKeys.includes(key)
|
2023-01-18 19:54:14 +00:00
|
|
|
enabled: true
|
|
|
|
onItemClicked: root.itemClicked(d.currentItemKey,
|
|
|
|
d.currentItemName,
|
|
|
|
d.currentItemSource)
|
|
|
|
}
|
|
|
|
|
2022-12-06 14:45:07 +00:00
|
|
|
Loader {
|
|
|
|
id: contentLoader
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2023-01-12 13:18:52 +00:00
|
|
|
id: assetsListView
|
2022-08-23 08:46:37 +00:00
|
|
|
|
|
|
|
ListDropdownContent {
|
|
|
|
headerModel: ListModel {
|
2023-01-12 13:18:52 +00:00
|
|
|
ListElement { key: "MINT"; icon: "add"; iconSize: 16; description: qsTr("Mint asset"); rotation: 0; spacing: 8 }
|
|
|
|
ListElement { key: "IMPORT"; icon: "invite-users"; iconSize: 16; description: qsTr("Import existing asset"); rotation: 180; spacing: 8 }
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
2023-01-11 14:32:11 +00:00
|
|
|
isHeaderVisible: false // TEMPORARILY hidden. These 2 header options will be implemented after MVP.
|
2022-08-23 08:46:37 +00:00
|
|
|
model: d.currentModel
|
2023-01-24 21:49:07 +00:00
|
|
|
checkedKeys: root.checkedKeys
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
onHeaderItemClicked: {
|
2023-01-12 13:18:52 +00:00
|
|
|
if(key === "MINT") console.log("TODO: Mint asset")
|
|
|
|
else if(key === "IMPORT") console.log("TODO: Import existing asset")
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
onItemClicked: root.itemClicked(key, shortName, iconSource)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: collectiblesListView
|
|
|
|
|
|
|
|
ListDropdownContent {
|
|
|
|
isHeaderVisible: root.state === d.listView_depth1_State
|
|
|
|
headerModel: ListModel {
|
|
|
|
ListElement { key: "MINT"; icon: "add"; iconSize: 16; description: qsTr("Mint collectible"); rotation: 0; spacing: 8 }
|
|
|
|
}
|
2022-12-06 14:45:07 +00:00
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
model: d.currentModel
|
2023-01-24 21:49:07 +00:00
|
|
|
checkedKeys: root.checkedKeys
|
2022-12-06 14:45:07 +00:00
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
onHeaderItemClicked: {
|
|
|
|
if(key === "MINT") console.log("TODO: Mint collectible")
|
|
|
|
}
|
|
|
|
onItemClicked: {
|
|
|
|
if(subItems && root.state === d.listView_depth1_State) {
|
|
|
|
// One deep navigation
|
|
|
|
d.currentSubitems = subItems
|
2023-01-18 19:54:14 +00:00
|
|
|
d.currentItemKey = key
|
2022-08-23 08:46:37 +00:00
|
|
|
d.currentItemName = name
|
|
|
|
d.currentItemSource = iconSource
|
|
|
|
root.state = d.listView_depth2_State
|
2023-01-18 19:54:14 +00:00
|
|
|
root.navigateDeep(key, subItems)
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
d.reset()
|
|
|
|
root.itemClicked(key, name, iconSource)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: thumbnailsView
|
|
|
|
|
|
|
|
ThumbnailsDropdownContent {
|
|
|
|
title: d.currentItemName
|
|
|
|
titleImage: d.currentItemSource
|
2022-08-30 16:27:00 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
model: d.currentModel
|
2023-01-24 21:49:07 +00:00
|
|
|
checkedKeys: root.checkedKeys
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
onItemClicked: {
|
|
|
|
d.reset()
|
|
|
|
root.itemClicked(key, name, iconSource)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|