mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 22:13:58 -06:00
Move ToolbarButton and ToolTip from Cura into Uranium. This makes it possible to use new styled ToolbarButton in plugins/Tools for the rotate tool.
Removed the ContentAlignment enum in ToolTip in favour of using the Text.ContentAlignment enum. For some reason references to this enum fail everywhere when ToolTip is moved into Uranium. There is some evil time-wasting magic cast on this component! CURA-8943
This commit is contained in:
parent
901dc55733
commit
3c7498feed
18 changed files with 30 additions and 224 deletions
|
@ -179,7 +179,7 @@ Button
|
|||
cornerSide: Cura.RoundedRectangle.Direction.None
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
visible:
|
||||
|
|
|
@ -5,7 +5,7 @@ import QtQuick 2.7
|
|||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
import UM 1.1 as UM
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ Column
|
|||
tooltip: text
|
||||
fixedWidthMode: true
|
||||
|
||||
toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft
|
||||
toolTipContentAlignment: Text.AlignLeft
|
||||
|
||||
onClicked: UM.Controller.setActiveStage("PreviewStage")
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ Button
|
|||
border.width: UM.Theme.getSize("default_lining").width
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
tooltipText: base.text
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 2.0
|
||||
|
||||
import UM 1.2 as UM
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Cura.ToolbarButton
|
||||
UM.ToolbarButton
|
||||
{
|
||||
id: base
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ Cura.ExpandablePopup
|
|||
onExited: { tooltip.hide() }
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
x: 0
|
||||
|
|
|
@ -188,7 +188,7 @@ Button
|
|||
elideWidth: buttonText.width
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
tooltipText: objectItemButton.text + perObjectSettingsInfo.tooltipText
|
||||
|
|
|
@ -19,7 +19,7 @@ ToolButton
|
|||
property bool valueError: false;
|
||||
property bool valueWarning: false;
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
visible: base.hovered
|
||||
|
|
|
@ -172,7 +172,7 @@ Cura.ExpandablePopup
|
|||
onExited: { tooltip.hide() }
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
UM.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
// 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.5 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 alias arrowSize: backgroundRect.arrowSize
|
||||
property var targetPoint: Qt.point(parent.x, y + Math.round(height/2))
|
||||
|
||||
id: tooltip
|
||||
text: ""
|
||||
delay: 500
|
||||
font: UM.Theme.getFont("default")
|
||||
visible: opacity != 0.0
|
||||
opacity: 0.0 // initially hidden
|
||||
|
||||
Behavior on opacity
|
||||
{
|
||||
NumberAnimation { duration: 100; }
|
||||
}
|
||||
|
||||
onAboutToShow: show()
|
||||
onAboutToHide: hide()
|
||||
|
||||
// If the text is not set, just set the height to 0 to prevent it from showing
|
||||
height: label.contentHeight + 2 * UM.Theme.getSize("thin_margin").width
|
||||
|
||||
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
|
||||
visible: tooltip.height != 0
|
||||
}
|
||||
|
||||
contentItem: UM.Label
|
||||
{
|
||||
id: label
|
||||
text: tooltip.text
|
||||
font: tooltip.font
|
||||
wrapMode: Text.Wrap
|
||||
textFormat: Text.RichText
|
||||
color: UM.Theme.getColor("tooltip_text")
|
||||
}
|
||||
|
||||
function show() {
|
||||
opacity = text != "" ? 1 : 0
|
||||
}
|
||||
|
||||
function hide() {
|
||||
opacity = 0
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
import UM 1.2 as UM
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Item
|
||||
|
@ -53,7 +53,7 @@ Item
|
|||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
delegate: ToolbarButton
|
||||
delegate: UM.ToolbarButton
|
||||
{
|
||||
text: model.name + (model.shortcut ? (" (" + model.shortcut + ")") : "")
|
||||
checkable: true
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
// 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.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Button
|
||||
{
|
||||
id: base
|
||||
|
||||
property alias toolItem: contentItemLoader.sourceComponent
|
||||
|
||||
// These two properties indicate whether the toolbar button is at the top of the toolbar column or at the bottom.
|
||||
// If it is somewhere in the middle, then both has to be false. If there is only one element in the column, then
|
||||
// both properties have to be set to true. This is used to create a rounded corner.
|
||||
property bool isTopElement: false
|
||||
property bool isBottomElement: false
|
||||
|
||||
hoverEnabled: true
|
||||
|
||||
background: Rectangle
|
||||
{
|
||||
implicitWidth: UM.Theme.getSize("button").width
|
||||
implicitHeight: UM.Theme.getSize("button").height
|
||||
color: UM.Theme.getColor("toolbar_background")
|
||||
radius: UM.Theme.getSize("default_radius").width
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: topSquare
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
}
|
||||
height: parent.radius
|
||||
color: parent.color
|
||||
visible: !base.isTopElement
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: bottomSquare
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
height: parent.radius
|
||||
color: parent.color
|
||||
visible: !base.isBottomElement
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: leftSquare
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
width: parent.radius
|
||||
color: parent.color
|
||||
}
|
||||
}
|
||||
contentItem: Rectangle
|
||||
{
|
||||
opacity: parent.enabled ? 1.0 : 0.2
|
||||
implicitWidth: Math.round(UM.Theme.getSize("button").width * 0.75)
|
||||
implicitHeight: Math.round(UM.Theme.getSize("button").height * 0.75)
|
||||
radius: Math.round(width * 0.5)
|
||||
|
||||
color:
|
||||
{
|
||||
if (base.checked && base.hovered)
|
||||
{
|
||||
return UM.Theme.getColor("toolbar_button_active_hover")
|
||||
}
|
||||
else if (base.checked)
|
||||
{
|
||||
return UM.Theme.getColor("toolbar_button_active")
|
||||
}
|
||||
else if(base.hovered)
|
||||
{
|
||||
return UM.Theme.getColor("toolbar_button_hover")
|
||||
}
|
||||
return UM.Theme.getColor("toolbar_background")
|
||||
}
|
||||
Loader
|
||||
{
|
||||
id: contentItemLoader
|
||||
anchors.centerIn: parent
|
||||
width: Math.round(UM.Theme.getSize("button").width / 2)
|
||||
height: Math.round(UM.Theme.getSize("button").height / 2)
|
||||
}
|
||||
}
|
||||
|
||||
Cura.ToolTip
|
||||
{
|
||||
id: tooltip
|
||||
tooltipText: base.text
|
||||
visible: base.hovered
|
||||
}
|
||||
}
|
|
@ -14,10 +14,8 @@ OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml
|
|||
ExpandableComponent 1.0 ExpandableComponent.qml
|
||||
PrinterTypeLabel 1.0 PrinterTypeLabel.qml
|
||||
ViewsSelector 1.0 ViewsSelector.qml
|
||||
ToolbarButton 1.0 ToolbarButton.qml
|
||||
SettingView 1.0 SettingView.qml
|
||||
ProfileMenu 1.0 ProfileMenu.qml
|
||||
ToolTip 1.0 ToolTip.qml
|
||||
|
||||
|
||||
# Cura/WelcomePages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue