Ghostkeeper e3cd5606f0
Make load more button load more packages
This adds the functionality of the button.

Contributes to issue CURA-8556.
2021-10-21 18:26:29 +02:00

88 lines
2.7 KiB
QML

// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
import QtQuick.Controls 2.15
import Cura 1.7 as Cura
import UM 1.0 as UM
ScrollView
{
clip: true
Column
{
id: pluginColumn
width: parent.width
spacing: UM.Theme.getSize("default_margin").height
Repeater
{
model: Cura.PackageList
{
id: pluginList
}
delegate: Rectangle
{
width: pluginColumn.width
height: UM.Theme.getSize("card").height
color: UM.Theme.getColor("main_background")
radius: UM.Theme.getSize("default_radius").width
Label
{
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: (parent.height - height) / 2
text: model.package.displayName
font: UM.Theme.getFont("medium_bold")
color: UM.Theme.getColor("text")
}
}
}
Button
{
id: loadMoreButton
width: parent.width
height: UM.Theme.getSize("card").height
enabled: pluginList.hasMore && !pluginList.isLoading
onClicked: pluginList.request() //Load next page in plug-in list.
background: Rectangle
{
anchors.fill: parent
radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("main_background")
}
Row
{
anchors.centerIn: parent
spacing: UM.Theme.getSize("thin_margin").width
UM.RecolorImage
{
width: visible ? UM.Theme.getSize("small_button_icon").width : 0
height: UM.Theme.getSize("small_button_icon").height
anchors.verticalCenter: loadMoreLabel.verticalCenter
visible: pluginList.hasMore
source: UM.Theme.getIcon("ArrowDown")
color: UM.Theme.getColor(loadMoreButton.enabled ? "secondary_button_text" : "action_button_disabled_text")
}
Label
{
id: loadMoreLabel
text: pluginList.hasMore ? catalog.i18nc("@button", "Load More") : catalog.i18nc("@button", "No more results to load")
font: UM.Theme.getFont("medium_bold")
color: UM.Theme.getColor(loadMoreButton.enabled ? "secondary_button_text" : "action_button_disabled_text")
}
}
}
}
}