mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Implimented showcase
This commit is contained in:
parent
817b724994
commit
7359554641
7 changed files with 133 additions and 38 deletions
|
@ -92,8 +92,10 @@ Item
|
|||
topMargin: UM.Theme.getSize("double_margin").height
|
||||
}
|
||||
}
|
||||
Column
|
||||
|
||||
Label
|
||||
{
|
||||
id: title
|
||||
anchors
|
||||
{
|
||||
top: thumbnail.top
|
||||
|
@ -101,29 +103,72 @@ Item
|
|||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("double_margin").width
|
||||
bottomMargin: UM.Theme.getSize("default_margin").height
|
||||
}
|
||||
spacing: Math.floor(UM.Theme.getSize("default_margin").height/2)
|
||||
Label
|
||||
{
|
||||
text: details.name
|
||||
font: UM.Theme.getFont("large")
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
height: UM.Theme.getSize("base_unit") * 2
|
||||
}
|
||||
|
||||
Column
|
||||
{
|
||||
id: properties
|
||||
anchors
|
||||
{
|
||||
top: title.bottom
|
||||
left: title.left
|
||||
}
|
||||
spacing: Math.floor(UM.Theme.getSize("default_margin").height / 2)
|
||||
width: childrenRect.width
|
||||
Label
|
||||
{
|
||||
text: "Version:"
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details.description
|
||||
font: UM.Theme.getFont("default")
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
text: "Last Update:"
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: "Author: " + details.author_name
|
||||
font: UM.Theme.getFont("small")
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
// TODO: Add mail icon.
|
||||
text: "Author:"
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
}
|
||||
Column
|
||||
{
|
||||
id: values
|
||||
anchors
|
||||
{
|
||||
top: title.bottom
|
||||
left: properties.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
spacing: Math.floor(UM.Theme.getSize("default_margin").height/2)
|
||||
width: UM.Theme.getSize("base_unit").width * 12
|
||||
Label
|
||||
{
|
||||
text: details.version
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details.generated_time
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details.author_name
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ Column
|
|||
Label
|
||||
{
|
||||
id: heading
|
||||
text: "Community Plugins"
|
||||
text: manager.viewCategory == "material" ? "Maker Choices" : "Community Plugins"
|
||||
width: parent.width
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
font: UM.Theme.getFont("medium")
|
||||
|
|
|
@ -26,6 +26,7 @@ Item
|
|||
height: UM.Theme.getSize("toolbox_thumbnail_small").height
|
||||
color: "white"
|
||||
border.width: 1
|
||||
border.color: UM.Theme.getColor("text_medium")
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
width: UM.Theme.getSize("toolbox_thumbnail_small").width - 26
|
||||
|
@ -79,7 +80,6 @@ Item
|
|||
manager.viewSelection = model.id
|
||||
manager.viewPage = "detail"
|
||||
manager.filterPackages("id", model.id)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ import QtQuick.Controls 1.4
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
import UM 1.1 as UM
|
||||
|
||||
// TODO: Switch to QtQuick.Controls 2.x and remove QtQuick.Controls.Styles
|
||||
|
||||
ScrollView
|
||||
{
|
||||
id: base
|
||||
|
@ -19,8 +17,8 @@ ScrollView
|
|||
Column
|
||||
{
|
||||
width: base.width
|
||||
spacing: UM.Theme.getSize("base_unit").height
|
||||
padding: UM.Theme.getSize("base_unit").height * 2
|
||||
spacing: UM.Theme.getSize("default_margin").height
|
||||
padding: UM.Theme.getSize("double_margin").height
|
||||
height: childrenRect.height + 2 * padding
|
||||
ToolboxDownloadsShowcase
|
||||
{
|
||||
|
@ -31,7 +29,7 @@ ScrollView
|
|||
{
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
width: parent.width - 2 * parent.padding
|
||||
height: UM.Theme.getSize("base_unit").height / 6
|
||||
height: UM.Theme.getSize("default_lining").height
|
||||
}
|
||||
ToolboxDownloadsGrid
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ Column
|
|||
Label
|
||||
{
|
||||
id: heading
|
||||
text: "Showcase"
|
||||
text: "Featured"
|
||||
width: parent.width
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
font: UM.Theme.getFont("medium")
|
||||
|
@ -32,8 +32,10 @@ Column
|
|||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
ToolboxDownloadsShowcaseTile {}
|
||||
ToolboxDownloadsShowcaseTile {}
|
||||
ToolboxDownloadsShowcaseTile {}
|
||||
Repeater
|
||||
{
|
||||
model: manager.materialShowcaseModel
|
||||
delegate: ToolboxDownloadsShowcaseTile {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,26 @@ Item
|
|||
Rectangle
|
||||
{
|
||||
color: "white"
|
||||
width: UM.Theme.getSize("base_unit").width * 8
|
||||
height: UM.Theme.getSize("base_unit").width * 8
|
||||
width: UM.Theme.getSize("toolbox_thumbnail_medium").width
|
||||
height: UM.Theme.getSize("toolbox_thumbnail_medium").height
|
||||
border.width: 1
|
||||
border.color: UM.Theme.getColor("text_medium")
|
||||
anchors
|
||||
{
|
||||
top: parent.top
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
width: UM.Theme.getSize("toolbox_thumbnail_medium").width - 26
|
||||
height: UM.Theme.getSize("toolbox_thumbnail_medium").height - 26
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: model.icon_url || "../images/logobot.svg"
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: "Solidworks Integration"
|
||||
text: model.name
|
||||
anchors
|
||||
{
|
||||
bottom: parent.bottom
|
||||
|
@ -39,4 +47,22 @@ Item
|
|||
color: UM.Theme.getColor("text")
|
||||
font: UM.Theme.getFont("medium_bold")
|
||||
}
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if ( manager.viewCategory == "material" )
|
||||
{
|
||||
manager.viewSelection = model.name
|
||||
manager.viewPage = "author"
|
||||
manager.filterPackages("author_name", model.name)
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.viewSelection = model.id
|
||||
manager.viewPage = "detail"
|
||||
manager.filterPackages("id", model.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,9 @@ class Toolbox(QObject, Extension):
|
|||
self._api_url = "https://api-staging.ultimaker.com/cura-packages/v%s" % self._api_version
|
||||
|
||||
self._package_list_request = None
|
||||
self._download_plugin_request = None
|
||||
self._showcase_request = None
|
||||
|
||||
self._download_plugin_request = None
|
||||
self._download_plugin_reply = None
|
||||
|
||||
self._network_manager = None
|
||||
|
@ -118,6 +119,7 @@ class Toolbox(QObject, Extension):
|
|||
|
||||
packagesMetadataChanged = pyqtSignal()
|
||||
authorsMetadataChanged = pyqtSignal()
|
||||
showcaseMetadataChanged = pyqtSignal()
|
||||
|
||||
onDownloadProgressChanged = pyqtSignal()
|
||||
onIsDownloadingChanged = pyqtSignal()
|
||||
|
@ -160,6 +162,7 @@ class Toolbox(QObject, Extension):
|
|||
@pyqtSlot()
|
||||
def browsePackages(self):
|
||||
self._createNetworkManager()
|
||||
self.requestShowcase()
|
||||
self.requestPackageList()
|
||||
|
||||
if not self._dialog:
|
||||
|
@ -173,6 +176,13 @@ class Toolbox(QObject, Extension):
|
|||
self._package_list_request.setRawHeader(*self._request_header)
|
||||
self._network_manager.get(self._package_list_request)
|
||||
|
||||
def requestShowcase(self):
|
||||
Logger.log("i", "Requesting showcase list")
|
||||
url = QUrl("{base_url}/cura/v{version}/showcase".format(base_url = self._api_url, version = self._packages_version_number))
|
||||
self._showcase_request = QNetworkRequest(url)
|
||||
self._showcase_request.setRawHeader(*self._request_header)
|
||||
self._network_manager.get(self._showcase_request)
|
||||
|
||||
def _createDialog(self, qml_name):
|
||||
Logger.log("d", "Creating dialog [%s]", qml_name)
|
||||
path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "resources", "qml", qml_name)
|
||||
|
@ -364,6 +374,10 @@ class Toolbox(QObject, Extension):
|
|||
plugin["update_url"] = item["file_location"]
|
||||
return self._plugins_model
|
||||
|
||||
@pyqtProperty(QObject, notify = showcaseMetadataChanged)
|
||||
def materialShowcaseModel(self):
|
||||
return self._showcase_model
|
||||
|
||||
@pyqtProperty(QObject, notify = packagesMetadataChanged)
|
||||
def packagesModel(self):
|
||||
return self._packages_model
|
||||
|
@ -434,9 +448,6 @@ class Toolbox(QObject, Extension):
|
|||
if reply_url == "{base_url}/cura/v{version}/packages".format(base_url = self._api_url, version = self._packages_version_number):
|
||||
try:
|
||||
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||
print(json_data)
|
||||
# Add metadata to the manager:
|
||||
|
||||
|
||||
# Create packages model with all packages:
|
||||
if not self._packages_model:
|
||||
|
@ -448,20 +459,33 @@ class Toolbox(QObject, Extension):
|
|||
# Create authors model with all authors:
|
||||
if not self._authors_model:
|
||||
self._authors_model = AuthorsModel()
|
||||
# In the future, this will be its own API call.
|
||||
# TODO: Remove this hacky code once there's an API call for this.
|
||||
self._authors_metadata = []
|
||||
for package in self._packages_metadata:
|
||||
package["author"]["type"] = package["package_type"]
|
||||
print(package["author"])
|
||||
if package["author"] not in self._authors_metadata:
|
||||
self._authors_metadata.append(package["author"])
|
||||
self._authors_model.setMetaData(self._authors_metadata)
|
||||
self.authorsMetadataChanged.emit()
|
||||
|
||||
|
||||
|
||||
except json.decoder.JSONDecodeError:
|
||||
Logger.log("w", "Received an invalid print job state message: Not valid JSON.")
|
||||
Logger.log("w", "Toolbox: Received invalid JSON for package list.")
|
||||
return
|
||||
|
||||
|
||||
elif reply_url == "{base_url}/cura/v{version}/showcase".format(base_url = self._api_url, version = self._packages_version_number):
|
||||
try:
|
||||
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||
# Create packages model with all packages:
|
||||
if not self._showcase_model:
|
||||
self._showcase_model = CuraPackageModel()
|
||||
self._showcase_metadata = json_data["data"]
|
||||
print(self._showcase_metadata)
|
||||
self._showcase_model.setPackagesMetaData(self._showcase_metadata)
|
||||
for package in self._showcase_model.items:
|
||||
print(package)
|
||||
self.showcaseMetadataChanged.emit()
|
||||
except json.decoder.JSONDecodeError:
|
||||
Logger.log("w", "Toolbox: Received invalid JSON for showcase.")
|
||||
return
|
||||
else:
|
||||
# Ignore any operation that is not a get operation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue