mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 01:09:00 +08:00
Merge branch '4.0' of github.com:Ultimaker/Cura
This commit is contained in:
commit
972be1b54a
@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
@ -39,15 +39,23 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
|||||||
self._machine_manager = self._application.getMachineManager()
|
self._machine_manager = self._application.getMachineManager()
|
||||||
self._quality_manager = Application.getInstance().getQualityManager()
|
self._quality_manager = Application.getInstance().getQualityManager()
|
||||||
|
|
||||||
self._application.globalContainerStackChanged.connect(self._update)
|
self._application.globalContainerStackChanged.connect(self._onChange)
|
||||||
self._machine_manager.activeQualityGroupChanged.connect(self._update)
|
self._machine_manager.activeQualityGroupChanged.connect(self._onChange)
|
||||||
self._machine_manager.extruderChanged.connect(self._update)
|
self._machine_manager.extruderChanged.connect(self._onChange)
|
||||||
self._quality_manager.qualitiesUpdated.connect(self._update)
|
self._quality_manager.qualitiesUpdated.connect(self._onChange)
|
||||||
|
|
||||||
self._layer_height_unit = "" # This is cached
|
self._layer_height_unit = "" # This is cached
|
||||||
|
|
||||||
|
self._update_timer = QTimer() # type: QTimer
|
||||||
|
self._update_timer.setInterval(100)
|
||||||
|
self._update_timer.setSingleShot(True)
|
||||||
|
self._update_timer.timeout.connect(self._update)
|
||||||
|
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
def _onChange(self) -> None:
|
||||||
|
self._update_timer.start()
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ Button
|
|||||||
property alias iconSource: buttonIconLeft.source
|
property alias iconSource: buttonIconLeft.source
|
||||||
property alias textFont: buttonText.font
|
property alias textFont: buttonText.font
|
||||||
property alias cornerRadius: backgroundRect.radius
|
property alias cornerRadius: backgroundRect.radius
|
||||||
property alias tooltip: tooltip.text
|
property alias tooltip: tooltip.tooltipText
|
||||||
property alias cornerSide: backgroundRect.cornerSide
|
property alias cornerSide: backgroundRect.cornerSide
|
||||||
|
|
||||||
property color color: UM.Theme.getColor("primary")
|
property color color: UM.Theme.getColor("primary")
|
||||||
@ -31,6 +31,8 @@ Button
|
|||||||
property alias shadowColor: shadow.color
|
property alias shadowColor: shadow.color
|
||||||
property alias shadowEnabled: shadow.visible
|
property alias shadowEnabled: shadow.visible
|
||||||
|
|
||||||
|
property alias toolTipContentAlignment: tooltip.contentAlignment
|
||||||
|
|
||||||
// This property is used to indicate whether the button has a fixed width or the width would depend on the contents
|
// This property is used to indicate whether the button has a fixed width or the width would depend on the contents
|
||||||
// Be careful when using fixedWidthMode, the translated texts can be too long that they won't fit. In any case,
|
// Be careful when using fixedWidthMode, the translated texts can be too long that they won't fit. In any case,
|
||||||
// we elide the text to the right so the text will be cut off with the three dots at the end.
|
// we elide the text to the right so the text will be cut off with the three dots at the end.
|
||||||
@ -110,11 +112,9 @@ Button
|
|||||||
z: backgroundRect.z - 1
|
z: backgroundRect.z - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip
|
Cura.ToolTip
|
||||||
{
|
{
|
||||||
id: tooltip
|
id: tooltip
|
||||||
text: ""
|
visible: button.hovered
|
||||||
delay: 500
|
|
||||||
visible: text != "" && button.hovered
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -60,7 +60,6 @@ Item
|
|||||||
|
|
||||||
leftPadding: UM.Theme.getSize("narrow_margin").width //Need more space than usual here for wide text.
|
leftPadding: UM.Theme.getSize("narrow_margin").width //Need more space than usual here for wide text.
|
||||||
rightPadding: UM.Theme.getSize("narrow_margin").width
|
rightPadding: UM.Theme.getSize("narrow_margin").width
|
||||||
tooltip: popup.opened ? "" : catalog.i18nc("@info:tooltip", "Select the active output device")
|
|
||||||
iconSource: popup.opened ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom")
|
iconSource: popup.opened ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom")
|
||||||
color: UM.Theme.getColor("action_panel_secondary")
|
color: UM.Theme.getColor("action_panel_secondary")
|
||||||
visible: (devicesModel.deviceCount > 1)
|
visible: (devicesModel.deviceCount > 1)
|
||||||
|
@ -123,6 +123,8 @@ Column
|
|||||||
tooltip: text
|
tooltip: text
|
||||||
fixedWidthMode: true
|
fixedWidthMode: true
|
||||||
|
|
||||||
|
toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft
|
||||||
|
|
||||||
onClicked: UM.Controller.setActiveStage("PreviewStage")
|
onClicked: UM.Controller.setActiveStage("PreviewStage")
|
||||||
visible: UM.Controller.activeStage != null && UM.Controller.activeStage.stageId != "PreviewStage"
|
visible: UM.Controller.activeStage != null && UM.Controller.activeStage.stageId != "PreviewStage"
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ Column
|
|||||||
fixedWidthMode: true
|
fixedWidthMode: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: catalog.i18nc("@button", "Slice")
|
text: catalog.i18nc("@button", "Slice")
|
||||||
|
tooltip: catalog.i18nc("@label", "Start the slicing process")
|
||||||
enabled: widget.backendState != UM.Backend.Error
|
enabled: widget.backendState != UM.Backend.Error
|
||||||
visible: widget.backendState == UM.Backend.NotStarted || widget.backendState == UM.Backend.Error
|
visible: widget.backendState == UM.Backend.NotStarted || widget.backendState == UM.Backend.Error
|
||||||
onClicked: sliceOrStopSlicing()
|
onClicked: sliceOrStopSlicing()
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Controls.Styles 1.1
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
import UM 1.0 as UM
|
import UM 1.0 as UM
|
||||||
|
|
||||||
@ -57,5 +55,6 @@ UM.PointingRectangle {
|
|||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
font: UM.Theme.getFont("default");
|
font: UM.Theme.getFont("default");
|
||||||
color: UM.Theme.getColor("tooltip_text");
|
color: UM.Theme.getColor("tooltip_text");
|
||||||
|
renderType: Text.NativeRendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
resources/qml/ToolTip.qml
Normal file
63
resources/qml/ToolTip.qml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
|
import UM 1.0 as UM
|
||||||
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
|
ToolTip
|
||||||
|
{
|
||||||
|
enum ContentAlignment
|
||||||
|
{
|
||||||
|
AlignLeft,
|
||||||
|
AlignRight
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defines the alignment of the content, by default to the left
|
||||||
|
property int contentAlignment: Cura.ToolTip.ContentAlignment.AlignRight
|
||||||
|
|
||||||
|
property alias tooltipText: tooltip.text
|
||||||
|
property var targetPoint: Qt.point(parent.x, y + Math.round(height/2))
|
||||||
|
|
||||||
|
id: tooltip
|
||||||
|
text: ""
|
||||||
|
delay: 500
|
||||||
|
font: UM.Theme.getFont("default")
|
||||||
|
|
||||||
|
// If the text is not set, just set the height to 0 to prevent it from showing
|
||||||
|
height: text != "" ? label.contentHeight + 2 * UM.Theme.getSize("thin_margin").width: 0
|
||||||
|
|
||||||
|
x:
|
||||||
|
{
|
||||||
|
if (contentAlignment == Cura.ToolTip.ContentAlignment.AlignLeft)
|
||||||
|
{
|
||||||
|
return (label.width + Math.round(UM.Theme.getSize("default_arrow").width * 1.2) + padding * 2) * -1
|
||||||
|
}
|
||||||
|
return parent.width + Math.round(UM.Theme.getSize("default_arrow").width * 1.2 + padding)
|
||||||
|
}
|
||||||
|
|
||||||
|
y: Math.round(parent.height / 2 - label.height / 2 ) - padding
|
||||||
|
|
||||||
|
padding: UM.Theme.getSize("thin_margin").width
|
||||||
|
|
||||||
|
background: UM.PointingRectangle
|
||||||
|
{
|
||||||
|
id: backgroundRect
|
||||||
|
color: UM.Theme.getColor("tooltip")
|
||||||
|
target: Qt.point(targetPoint.x - tooltip.x, targetPoint.y - tooltip.y)
|
||||||
|
arrowSize: UM.Theme.getSize("default_arrow").width
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Label
|
||||||
|
{
|
||||||
|
id: label
|
||||||
|
text: tooltip.text
|
||||||
|
font: tooltip.font
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
textFormat: Text.RichText
|
||||||
|
color: UM.Theme.getColor("tooltip_text")
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
}
|
||||||
|
}
|
@ -96,4 +96,11 @@ Button
|
|||||||
height: UM.Theme.getSize("button_icon").height
|
height: UM.Theme.getSize("button_icon").height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cura.ToolTip
|
||||||
|
{
|
||||||
|
id: tooltip
|
||||||
|
tooltipText: base.text
|
||||||
|
visible: base.hovered
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,5 @@ PrinterTypeLabel 1.0 PrinterTypeLabel.qml
|
|||||||
ViewsSelector 1.0 ViewsSelector.qml
|
ViewsSelector 1.0 ViewsSelector.qml
|
||||||
ToolbarButton 1.0 ToolbarButton.qml
|
ToolbarButton 1.0 ToolbarButton.qml
|
||||||
SettingView 1.0 SettingView.qml
|
SettingView 1.0 SettingView.qml
|
||||||
ProfileMenu 1.0 ProfileMenu.qml
|
ProfileMenu 1.0 ProfileMenu.qml
|
||||||
|
ToolTip 1.0 ToolTip.qml
|
Loading…
x
Reference in New Issue
Block a user