1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add paging support

This commit is contained in:
Elias Steurer 2021-02-20 17:40:26 +01:00
parent fa288b4015
commit 4eba21889d

View File

@ -52,7 +52,8 @@ Item {
background.backgroundImage = steamWorkshop.workshopListModel.getBannerUrl() background.backgroundImage = steamWorkshop.workshopListModel.getBannerUrl()
banner.bannerPublishedFileID = steamWorkshop.workshopListModel.getBannerID() banner.bannerPublishedFileID = steamWorkshop.workshopListModel.getBannerID()
bannerTxtUnderline.numberSubscriber bannerTxtUnderline.numberSubscriber
= steamWorkshop.workshopListModel.getBannerAmountSubscriber() = steamWorkshop.workshopListModel.getBannerAmountSubscriber(
)
} }
} }
@ -99,7 +100,15 @@ Item {
id: scrollView id: scrollView
anchors.fill: parent anchors.fill: parent
contentWidth: parent.width contentWidth: parent.width
contentHeight: gridView.height + header.height + 300 contentHeight: gridView.height + header.height + 150
Behavior on contentHeight {
PropertyAnimation {
duration: 400
property: "contentHeight"
easing.type: Easing.InOutQuart
}
}
onContentYChanged: { onContentYChanged: {
// Calculate parallax scrolling // Calculate parallax scrolling
@ -238,140 +247,149 @@ Item {
cellHeight: 190 cellHeight: 190
height: contentHeight height: contentHeight
interactive: false interactive: false
model: steamWorkshop.workshopListModel model: steamWorkshop.workshopListModel
anchors { anchors {
top: header.bottom top: header.bottom
topMargin: 100 topMargin: 100
left: parent.left left: parent.left
right: parent.right right: parent.right
leftMargin: 50 leftMargin: 45
} }
header: Item { header: Item {
height: 70 height: 70
width: parent.width width: gridView.width - gridView.anchors.leftMargin
property alias searchField: tiSearch property alias searchField: tiSearch
Item { Rectangle {
id: searchWrapper color: Material.backgroundColor
radius: 3
width: parent.width - 10
height: parent.height
anchors.centerIn: parent
width: 400 Item {
height: 50 id: searchWrapper
anchors { width: 400
verticalCenter: parent.verticalCenter height: 50
left: parent.left
}
Rectangle {
anchors.fill: parent
color: Material.theme === Material.Light ? "white" : Qt.darker(
Material.background)
opacity: .95
radius: 3
}
TextField {
id: tiSearch
anchors { anchors {
top: parent.top verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 10
bottom: parent.bottom
left: parent.left left: parent.left
leftMargin: 10 leftMargin: 10
} }
placeholderText: qsTr("Search for Wallpaper and Widgets...")
onTextChanged: timerSearch.restart() Rectangle {
Timer { anchors.fill: parent
id: timerSearch color: Material.theme === Material.Light ? "white" : Qt.darker(
interval: 300 Material.background)
onTriggered: steamWorkshop.workshopListModel.searchWorkshopByText( opacity: .95
tiSearch.text) radius: 3
}
TextField {
id: tiSearch
anchors {
top: parent.top
right: parent.right
rightMargin: 10
bottom: parent.bottom
left: parent.left
leftMargin: 10
}
placeholderText: qsTr("Search for Wallpaper and Widgets...")
onTextChanged: timerSearch.restart()
Timer {
id: timerSearch
interval: 300
onTriggered: steamWorkshop.workshopListModel.searchWorkshopByText(
tiSearch.text)
}
} }
} }
}
Row { Row {
spacing: 20 spacing: 20
anchors { anchors {
left: searchWrapper.right left: searchWrapper.right
leftMargin: 20 leftMargin: 20
right: cbQuerySort.left right: cbQuerySort.left
rightMargin: 20 rightMargin: 20
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
}
Button {
text: qsTr("Open Workshop in Steam")
font.capitalization: Font.Capitalize
font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally(
"steam://url/SteamWorkshopPage/672870")
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 18
icon.height: 18
}
Button {
text: qsTr("Open GameHub in Steam")
font.capitalization: Font.Capitalize
font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally(
"steam://url/GameHub/672870")
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 18
icon.height: 18
}
} }
Button {
text: qsTr("Open Workshop in Steam") ComboBox {
font.capitalization: Font.Capitalize id: cbQuerySort
width: 250
height: searchWrapper.height
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 10
}
textRole: "text"
valueRole: "value"
currentIndex: 2
Layout.preferredHeight: searchWrapper.height
font.family: ScreenPlay.settings.font font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally( onActivated: {
"steam://url/SteamWorkshopPage/672870") steamWorkshop.workshopListModel.searchWorkshop(
icon.source: "qrc:/assets/icons/icon_steam.svg" cbQuerySort.currentValue)
icon.width: 18 }
icon.height: 18 model: [{
"value": SteamEnums.k_EUGCQuery_RankedByVote,
"text": qsTr("Ranked By Vote")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByPublicationDate,
"text": qsTr("Publication Date")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTrend,
"text": qsTr("Ranked By Trend")
}, {
"value": SteamEnums.K_EUGCQuery_FavoritedByFriendsRankedByPublicationDate,
"text": qsTr("Favorited By Friends")
}, {
"value": SteamEnums.K_EUGCQuery_CreatedByFriendsRankedByPublicationDate,
"text": qsTr("Created By Friends")
}, {
"value": SteamEnums.K_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate,
"text": qsTr("Created By Followed Users")
}, {
"value": SteamEnums.K_EUGCQuery_NotYetRated,
"text": qsTr("Not Yet Rated")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTotalVotesAsc,
"text": qsTr("Total VotesAsc")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByVotesUp,
"text": qsTr("Votes Up")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTotalUniqueSubscriptions,
"text": qsTr("Total Unique Subscriptions")
}]
} }
Button {
text: qsTr("Open GameHub in Steam")
font.capitalization: Font.Capitalize
font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally(
"steam://url/GameHub/672870")
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 18
icon.height: 18
}
}
ComboBox {
id: cbQuerySort
width: 250
height: searchWrapper.height
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 50
}
textRole: "text"
valueRole: "value"
currentIndex: 2
Layout.preferredHeight: searchWrapper.height
font.family: ScreenPlay.settings.font
onActivated: {
steamWorkshop.workshopListModel.searchWorkshop(
cbQuerySort.currentValue, 1)
}
model: [{
"value": SteamEnums.k_EUGCQuery_RankedByVote,
"text": qsTr("Ranked By Vote")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByPublicationDate,
"text": qsTr("Publication Date")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTrend,
"text": qsTr("Ranked By Trend")
}, {
"value": SteamEnums.K_EUGCQuery_FavoritedByFriendsRankedByPublicationDate,
"text": qsTr("Favorited By Friends")
}, {
"value": SteamEnums.K_EUGCQuery_CreatedByFriendsRankedByPublicationDate,
"text": qsTr("Created By Friends")
}, {
"value": SteamEnums.K_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate,
"text": qsTr("Created By Followed Users")
}, {
"value": SteamEnums.K_EUGCQuery_NotYetRated,
"text": qsTr("Not Yet Rated")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTotalVotesAsc,
"text": qsTr("Total VotesAsc")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByVotesUp,
"text": qsTr("Votes Up")
}, {
"value": SteamEnums.K_EUGCQuery_RankedByTotalUniqueSubscriptions,
"text": qsTr("Total Unique Subscriptions")
}]
} }
} }
@ -396,6 +414,51 @@ Item {
id: workshopScrollBar id: workshopScrollBar
snapMode: ScrollBar.SnapOnRelease snapMode: ScrollBar.SnapOnRelease
} }
footer: RowLayout {
height: 150
width: parent.width
spacing: 10
Item {
Layout.fillWidth: true
}
Button {
id: btnBack
Layout.alignment: Qt.AlignVCenter
text: qsTr("Back")
enabled: steamWorkshop.workshopListModel.currentPage > 1
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(
steamWorkshop.workshopListModel.currentPage - 1)
steamWorkshop.workshopListModel.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}
Text {
id: txtPage
Layout.alignment: Qt.AlignVCenter
text: steamWorkshop.workshopListModel.currentPage + "/"
+ steamWorkshop.workshopListModel.pages
font.family: ScreenPlay.settings.font
color: Material.primaryTextColor
}
Button {
id: btnForward
Layout.alignment: Qt.AlignVCenter
text: qsTr("Forward")
enabled: steamWorkshop.workshopListModel.currentPage
<= steamWorkshop.workshopListModel.pages - 1
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(
steamWorkshop.workshopListModel.currentPage + 1)
steamWorkshop.workshopListModel.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}
Item {
Layout.fillWidth: true
}
}
} }
} }