mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -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
|
topMargin: UM.Theme.getSize("double_margin").height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column
|
|
||||||
|
Label
|
||||||
{
|
{
|
||||||
|
id: title
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
top: thumbnail.top
|
top: thumbnail.top
|
||||||
|
@ -101,29 +103,72 @@ Item
|
||||||
leftMargin: UM.Theme.getSize("default_margin").width
|
leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: UM.Theme.getSize("double_margin").width
|
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
|
text: details.name
|
||||||
font: UM.Theme.getFont("large")
|
font: UM.Theme.getFont("large")
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
width: parent.width
|
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
|
Label
|
||||||
{
|
{
|
||||||
text: details.description
|
text: "Last Update:"
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("very_small")
|
||||||
wrapMode: Text.WordWrap
|
color: UM.Theme.getColor("text_medium")
|
||||||
width: parent.width
|
|
||||||
}
|
}
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: "Author: " + details.author_name
|
text: "Author:"
|
||||||
font: UM.Theme.getFont("small")
|
font: UM.Theme.getFont("very_small")
|
||||||
wrapMode: Text.WordWrap
|
color: UM.Theme.getColor("text_medium")
|
||||||
width: parent.width
|
}
|
||||||
// TODO: Add mail icon.
|
}
|
||||||
|
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
|
Label
|
||||||
{
|
{
|
||||||
id: heading
|
id: heading
|
||||||
text: "Community Plugins"
|
text: manager.viewCategory == "material" ? "Maker Choices" : "Community Plugins"
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
|
|
|
@ -26,6 +26,7 @@ Item
|
||||||
height: UM.Theme.getSize("toolbox_thumbnail_small").height
|
height: UM.Theme.getSize("toolbox_thumbnail_small").height
|
||||||
color: "white"
|
color: "white"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
border.color: UM.Theme.getColor("text_medium")
|
||||||
Image {
|
Image {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: UM.Theme.getSize("toolbox_thumbnail_small").width - 26
|
width: UM.Theme.getSize("toolbox_thumbnail_small").width - 26
|
||||||
|
@ -79,7 +80,6 @@ Item
|
||||||
manager.viewSelection = model.id
|
manager.viewSelection = model.id
|
||||||
manager.viewPage = "detail"
|
manager.viewPage = "detail"
|
||||||
manager.filterPackages("id", model.id)
|
manager.filterPackages("id", model.id)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ import QtQuick.Controls 1.4
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
import UM 1.1 as UM
|
import UM 1.1 as UM
|
||||||
|
|
||||||
// TODO: Switch to QtQuick.Controls 2.x and remove QtQuick.Controls.Styles
|
|
||||||
|
|
||||||
ScrollView
|
ScrollView
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
|
@ -19,8 +17,8 @@ ScrollView
|
||||||
Column
|
Column
|
||||||
{
|
{
|
||||||
width: base.width
|
width: base.width
|
||||||
spacing: UM.Theme.getSize("base_unit").height
|
spacing: UM.Theme.getSize("default_margin").height
|
||||||
padding: UM.Theme.getSize("base_unit").height * 2
|
padding: UM.Theme.getSize("double_margin").height
|
||||||
height: childrenRect.height + 2 * padding
|
height: childrenRect.height + 2 * padding
|
||||||
ToolboxDownloadsShowcase
|
ToolboxDownloadsShowcase
|
||||||
{
|
{
|
||||||
|
@ -31,7 +29,7 @@ ScrollView
|
||||||
{
|
{
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
width: parent.width - 2 * parent.padding
|
width: parent.width - 2 * parent.padding
|
||||||
height: UM.Theme.getSize("base_unit").height / 6
|
height: UM.Theme.getSize("default_lining").height
|
||||||
}
|
}
|
||||||
ToolboxDownloadsGrid
|
ToolboxDownloadsGrid
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ Column
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: heading
|
id: heading
|
||||||
text: "Showcase"
|
text: "Featured"
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
|
@ -32,8 +32,10 @@ Column
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolboxDownloadsShowcaseTile {}
|
Repeater
|
||||||
ToolboxDownloadsShowcaseTile {}
|
{
|
||||||
ToolboxDownloadsShowcaseTile {}
|
model: manager.materialShowcaseModel
|
||||||
|
delegate: ToolboxDownloadsShowcaseTile {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,26 @@ Item
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
color: "white"
|
color: "white"
|
||||||
width: UM.Theme.getSize("base_unit").width * 8
|
width: UM.Theme.getSize("toolbox_thumbnail_medium").width
|
||||||
height: UM.Theme.getSize("base_unit").width * 8
|
height: UM.Theme.getSize("toolbox_thumbnail_medium").height
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
border.color: UM.Theme.getColor("text_medium")
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
horizontalCenter: parent.horizontalCenter
|
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
|
Label
|
||||||
{
|
{
|
||||||
text: "Solidworks Integration"
|
text: model.name
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
@ -39,4 +47,22 @@ Item
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
font: UM.Theme.getFont("medium_bold")
|
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._api_url = "https://api-staging.ultimaker.com/cura-packages/v%s" % self._api_version
|
||||||
|
|
||||||
self._package_list_request = None
|
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._download_plugin_reply = None
|
||||||
|
|
||||||
self._network_manager = None
|
self._network_manager = None
|
||||||
|
@ -118,6 +119,7 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
packagesMetadataChanged = pyqtSignal()
|
packagesMetadataChanged = pyqtSignal()
|
||||||
authorsMetadataChanged = pyqtSignal()
|
authorsMetadataChanged = pyqtSignal()
|
||||||
|
showcaseMetadataChanged = pyqtSignal()
|
||||||
|
|
||||||
onDownloadProgressChanged = pyqtSignal()
|
onDownloadProgressChanged = pyqtSignal()
|
||||||
onIsDownloadingChanged = pyqtSignal()
|
onIsDownloadingChanged = pyqtSignal()
|
||||||
|
@ -160,6 +162,7 @@ class Toolbox(QObject, Extension):
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def browsePackages(self):
|
def browsePackages(self):
|
||||||
self._createNetworkManager()
|
self._createNetworkManager()
|
||||||
|
self.requestShowcase()
|
||||||
self.requestPackageList()
|
self.requestPackageList()
|
||||||
|
|
||||||
if not self._dialog:
|
if not self._dialog:
|
||||||
|
@ -173,6 +176,13 @@ class Toolbox(QObject, Extension):
|
||||||
self._package_list_request.setRawHeader(*self._request_header)
|
self._package_list_request.setRawHeader(*self._request_header)
|
||||||
self._network_manager.get(self._package_list_request)
|
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):
|
def _createDialog(self, qml_name):
|
||||||
Logger.log("d", "Creating dialog [%s]", qml_name)
|
Logger.log("d", "Creating dialog [%s]", qml_name)
|
||||||
path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "resources", "qml", 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"]
|
plugin["update_url"] = item["file_location"]
|
||||||
return self._plugins_model
|
return self._plugins_model
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = showcaseMetadataChanged)
|
||||||
|
def materialShowcaseModel(self):
|
||||||
|
return self._showcase_model
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = packagesMetadataChanged)
|
@pyqtProperty(QObject, notify = packagesMetadataChanged)
|
||||||
def packagesModel(self):
|
def packagesModel(self):
|
||||||
return self._packages_model
|
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):
|
if reply_url == "{base_url}/cura/v{version}/packages".format(base_url = self._api_url, version = self._packages_version_number):
|
||||||
try:
|
try:
|
||||||
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||||
print(json_data)
|
|
||||||
# Add metadata to the manager:
|
|
||||||
|
|
||||||
|
|
||||||
# Create packages model with all packages:
|
# Create packages model with all packages:
|
||||||
if not self._packages_model:
|
if not self._packages_model:
|
||||||
|
@ -448,20 +459,33 @@ class Toolbox(QObject, Extension):
|
||||||
# Create authors model with all authors:
|
# Create authors model with all authors:
|
||||||
if not self._authors_model:
|
if not self._authors_model:
|
||||||
self._authors_model = AuthorsModel()
|
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 = []
|
self._authors_metadata = []
|
||||||
for package in self._packages_metadata:
|
for package in self._packages_metadata:
|
||||||
package["author"]["type"] = package["package_type"]
|
package["author"]["type"] = package["package_type"]
|
||||||
print(package["author"])
|
|
||||||
if package["author"] not in self._authors_metadata:
|
if package["author"] not in self._authors_metadata:
|
||||||
self._authors_metadata.append(package["author"])
|
self._authors_metadata.append(package["author"])
|
||||||
self._authors_model.setMetaData(self._authors_metadata)
|
self._authors_model.setMetaData(self._authors_metadata)
|
||||||
self.authorsMetadataChanged.emit()
|
self.authorsMetadataChanged.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except json.decoder.JSONDecodeError:
|
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
|
return
|
||||||
else:
|
else:
|
||||||
# Ignore any operation that is not a get operation
|
# Ignore any operation that is not a get operation
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue