mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 21:15:52 +08:00
Merge pull request #4312 from Ultimaker/CURA-5676_add_contacts_toolbox
Cura 5676 add contacts toolbox
This commit is contained in:
commit
8a507c34a3
@ -82,9 +82,16 @@ Item
|
|||||||
}
|
}
|
||||||
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Contact") + ":"
|
text: catalog.i18nc("@label", "Website") + ":"
|
||||||
|
font: UM.Theme.getFont("very_small")
|
||||||
|
color: UM.Theme.getColor("text_medium")
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@label", "Email") + ":"
|
||||||
font: UM.Theme.getFont("very_small")
|
font: UM.Theme.getFont("very_small")
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
}
|
}
|
||||||
@ -100,18 +107,32 @@ Item
|
|||||||
topMargin: UM.Theme.getSize("default_margin").height
|
topMargin: UM.Theme.getSize("default_margin").height
|
||||||
}
|
}
|
||||||
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text:
|
||||||
|
{
|
||||||
|
if (details.website)
|
||||||
|
{
|
||||||
|
return "<a href=\"" + details.website + "\">" + details.website + "</a>"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
font: UM.Theme.getFont("very_small")
|
||||||
|
color: UM.Theme.getColor("text")
|
||||||
|
linkColor: UM.Theme.getColor("text_link")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text:
|
text:
|
||||||
{
|
{
|
||||||
if (details.email)
|
if (details.email)
|
||||||
{
|
{
|
||||||
return "<a href=\"mailto:"+details.email+"\">"+details.name+"</a>"
|
return "<a href=\"mailto:" + details.email + "\">" + details.email + "</a>"
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "<a href=\""+details.website+"\">"+details.name+"</a>"
|
|
||||||
}
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
font: UM.Theme.getFont("very_small")
|
font: UM.Theme.getFont("very_small")
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
|
@ -8,7 +8,18 @@ import UM 1.1 as UM
|
|||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
|
id: base
|
||||||
|
|
||||||
property var packageData
|
property var packageData
|
||||||
|
property var technicalDataSheetUrl: {
|
||||||
|
var link = undefined
|
||||||
|
if ("Technical Data Sheet" in packageData.links)
|
||||||
|
{
|
||||||
|
link = packageData.links["Technical Data Sheet"]
|
||||||
|
}
|
||||||
|
return link
|
||||||
|
}
|
||||||
|
|
||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||||
height: visible ? childrenRect.height : 0
|
height: visible ? childrenRect.height : 0
|
||||||
visible: packageData.type == "material" && packageData.has_configs
|
visible: packageData.type == "material" && packageData.has_configs
|
||||||
@ -132,4 +143,25 @@ Item
|
|||||||
width: Math.floor(table.width * 0.1)
|
width: Math.floor(table.width * 0.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: technical_data_sheet
|
||||||
|
anchors.top: table.bottom
|
||||||
|
anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
|
||||||
|
visible: base.technicalDataSheetUrl !== undefined
|
||||||
|
text:
|
||||||
|
{
|
||||||
|
if (base.technicalDataSheetUrl !== undefined)
|
||||||
|
{
|
||||||
|
return "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg("Technical Data Sheet")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
font: UM.Theme.getFont("very_small")
|
||||||
|
color: UM.Theme.getColor("text")
|
||||||
|
linkColor: UM.Theme.getColor("text_link")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,13 @@ import re
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, pyqtProperty
|
from PyQt5.QtCore import Qt, pyqtProperty
|
||||||
|
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
|
|
||||||
from .ConfigsModel import ConfigsModel
|
from .ConfigsModel import ConfigsModel
|
||||||
|
|
||||||
|
|
||||||
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
|
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
|
||||||
class PackagesModel(ListModel):
|
class PackagesModel(ListModel):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
@ -34,6 +38,8 @@ class PackagesModel(ListModel):
|
|||||||
self.addRoleName(Qt.UserRole + 17, "supported_configs")
|
self.addRoleName(Qt.UserRole + 17, "supported_configs")
|
||||||
self.addRoleName(Qt.UserRole + 18, "download_count")
|
self.addRoleName(Qt.UserRole + 18, "download_count")
|
||||||
self.addRoleName(Qt.UserRole + 19, "tags")
|
self.addRoleName(Qt.UserRole + 19, "tags")
|
||||||
|
self.addRoleName(Qt.UserRole + 20, "links")
|
||||||
|
self.addRoleName(Qt.UserRole + 21, "website")
|
||||||
|
|
||||||
# List of filters for queries. The result is the union of the each list of results.
|
# List of filters for queries. The result is the union of the each list of results.
|
||||||
self._filter = {} # type: Dict[str, str]
|
self._filter = {} # type: Dict[str, str]
|
||||||
@ -45,10 +51,16 @@ class PackagesModel(ListModel):
|
|||||||
def _update(self):
|
def _update(self):
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
for package in self._metadata:
|
if self._metadata is None:
|
||||||
|
Logger.logException("w", "Failed to load packages for Toolbox")
|
||||||
|
self.setItems(items)
|
||||||
|
return
|
||||||
|
|
||||||
|
for package in self._metadata:
|
||||||
has_configs = False
|
has_configs = False
|
||||||
configs_model = None
|
configs_model = None
|
||||||
|
|
||||||
|
links_dict = {}
|
||||||
if "data" in package:
|
if "data" in package:
|
||||||
if "supported_configs" in package["data"]:
|
if "supported_configs" in package["data"]:
|
||||||
if len(package["data"]["supported_configs"]) > 0:
|
if len(package["data"]["supported_configs"]) > 0:
|
||||||
@ -56,6 +68,11 @@ class PackagesModel(ListModel):
|
|||||||
configs_model = ConfigsModel()
|
configs_model = ConfigsModel()
|
||||||
configs_model.setConfigs(package["data"]["supported_configs"])
|
configs_model.setConfigs(package["data"]["supported_configs"])
|
||||||
|
|
||||||
|
# Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier
|
||||||
|
# to process.
|
||||||
|
link_list = package['data']['links'] if 'links' in package['data'] else []
|
||||||
|
links_dict = {d["title"]: d["url"] for d in link_list}
|
||||||
|
|
||||||
if "author_id" not in package["author"] or "display_name" not in package["author"]:
|
if "author_id" not in package["author"] or "display_name" not in package["author"]:
|
||||||
package["author"]["author_id"] = ""
|
package["author"]["author_id"] = ""
|
||||||
package["author"]["display_name"] = ""
|
package["author"]["display_name"] = ""
|
||||||
@ -80,17 +97,19 @@ class PackagesModel(ListModel):
|
|||||||
"has_configs": has_configs,
|
"has_configs": has_configs,
|
||||||
"supported_configs": configs_model,
|
"supported_configs": configs_model,
|
||||||
"download_count": package["download_count"] if "download_count" in package else 0,
|
"download_count": package["download_count"] if "download_count" in package else 0,
|
||||||
"tags": package["tags"] if "tags" in package else []
|
"tags": package["tags"] if "tags" in package else [],
|
||||||
|
"links": links_dict,
|
||||||
|
"website": package["website"] if "website" in package else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Filter on all the key-word arguments.
|
# Filter on all the key-word arguments.
|
||||||
for key, value in self._filter.items():
|
for key, value in self._filter.items():
|
||||||
if key is "tags":
|
if key is "tags":
|
||||||
key_filter = lambda item, value = value: value in item["tags"]
|
key_filter = lambda item, v = value: v in item["tags"]
|
||||||
elif "*" in value:
|
elif "*" in value:
|
||||||
key_filter = lambda candidate, key = key, value = value: self._matchRegExp(candidate, key, value)
|
key_filter = lambda candidate, k = key, v = value: self._matchRegExp(candidate, k, v)
|
||||||
else:
|
else:
|
||||||
key_filter = lambda candidate, key = key, value = value: self._matchString(candidate, key, value)
|
key_filter = lambda candidate, k = key, v = value: self._matchString(candidate, k, v)
|
||||||
items = filter(key_filter, items)
|
items = filter(key_filter, items)
|
||||||
|
|
||||||
# Execute all filters.
|
# Execute all filters.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user