Add tooltips for Setup/Monitor and Recommended/Custom tabs

This commit is contained in:
fieldOfView 2016-12-07 19:40:33 +01:00
parent e642b4ebe9
commit 18fb379fbe
2 changed files with 73 additions and 2 deletions

View File

@ -34,6 +34,18 @@ Rectangle
color: UM.Theme.getColor("sidebar"); color: UM.Theme.getColor("sidebar");
UM.I18nCatalog { id: catalog; name:"cura"} UM.I18nCatalog { id: catalog; name:"cura"}
Timer {
id: hoverTimer
interval: 500
repeat: false
property var item
property string text
onTriggered:
{
base.showTooltip(base, {x:1, y:item.y}, text);
}
}
function showTooltip(item, position, text) function showTooltip(item, position, text)
{ {
@ -146,6 +158,21 @@ Rectangle
checkable: true checkable: true
checked: !monitoringPrint checked: !monitoringPrint
exclusiveGroup: sidebarHeaderBarGroup exclusiveGroup: sidebarHeaderBarGroup
property string tooltipText: catalog.i18nc("@tooltip", "<b>Print Setup</b><br/><br/>Edit or review the settings for the active print job.")
onHoveredChanged: {
if (hovered)
{
hoverTimer.item = showSettings
hoverTimer.text = tooltipText
hoverTimer.start();
}
else
{
hoverTimer.stop();
base.hideTooltip();
}
}
style: UM.Theme.styles.sidebar_header_tab style: UM.Theme.styles.sidebar_header_tab
} }
@ -189,6 +216,21 @@ Rectangle
checkable: true checkable: true
checked: monitoringPrint checked: monitoringPrint
exclusiveGroup: sidebarHeaderBarGroup exclusiveGroup: sidebarHeaderBarGroup
property string tooltipText: catalog.i18nc("@tooltip", "<b>Print Monitor</b><br/><br/>Monitor the state of the connected printer and the print job in progress.")
onHoveredChanged: {
if (hovered)
{
hoverTimer.item = showMonitor
hoverTimer.text = tooltipText
hoverTimer.start();
}
else
{
hoverTimer.stop();
base.hideTooltip();
}
}
style: UM.Theme.styles.sidebar_header_tab style: UM.Theme.styles.sidebar_header_tab
} }
@ -262,6 +304,20 @@ Rectangle
checked: base.currentModeIndex == index checked: base.currentModeIndex == index
onClicked: base.currentModeIndex = index onClicked: base.currentModeIndex = index
onHoveredChanged: {
if (hovered)
{
hoverTimer.item = settingsModeSelection
hoverTimer.text = model.tooltipText
hoverTimer.start();
}
else
{
hoverTimer.stop();
base.hideTooltip();
}
}
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
@ -458,8 +514,18 @@ Rectangle
Component.onCompleted: Component.onCompleted:
{ {
modesListModel.append({ text: catalog.i18nc("@title:tab", "Recommended"), item: sidebarSimple, showFilterButton: false }) modesListModel.append({
modesListModel.append({ text: catalog.i18nc("@title:tab", "Custom"), item: sidebarAdvanced, showFilterButton: true }) text: catalog.i18nc("@title:tab", "Recommended"),
tooltipText: catalog.i18nc("@tooltip", "<b>Recommended Print Setup</b><br/><br/>Print with the recommended settings for the selected printer, material and quality."),
item: sidebarSimple,
showFilterButton: false
})
modesListModel.append({
text: catalog.i18nc("@title:tab", "Custom"),
tooltipText: catalog.i18nc("@tooltip", "<b>Custom Print Setup</b><br/><br/>Print with finegrained control over every last bit of the slicing process."),
item: sidebarAdvanced,
showFilterButton: true
})
sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "immediate": true }); sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "immediate": true });
var index = parseInt(UM.Preferences.getValue("cura/active_mode")) var index = parseInt(UM.Preferences.getValue("cura/active_mode"))

View File

@ -29,6 +29,11 @@ UM.PointingRectangle {
} else { } else {
x = position.x - base.width; x = position.x - base.width;
y = position.y - UM.Theme.getSize("tooltip_arrow_margins").height; y = position.y - UM.Theme.getSize("tooltip_arrow_margins").height;
if(y < 0)
{
position.y += -y;
y = 0;
}
} }
base.opacity = 1; base.opacity = 1;
target = Qt.point(40 , position.y + UM.Theme.getSize("tooltip_arrow_margins").height / 2) target = Qt.point(40 , position.y + UM.Theme.getSize("tooltip_arrow_margins").height / 2)