1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.4
import UM 1.5 as UM
import Cura 1.0 as Cura
import "../Account"
import "../ApplicationSwitcher"
Item
{
id: base
implicitHeight: UM.Theme.getSize("main_window_header").height
implicitWidth: UM.Theme.getSize("main_window_header").width
Image
{
id: logo
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.verticalCenter: parent.verticalCenter
source: UM.Theme.getImage("logo")
width: UM.Theme.getSize("logo").width
height: UM.Theme.getSize("logo").height
fillMode: Image.PreserveAspectFit
sourceSize.width: width
sourceSize.height: height
}
ButtonGroup
{
buttons: stagesListContainer.children
}
Row
{
id: stagesListContainer
spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
anchors
{
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
leftMargin: UM.Theme.getSize("default_margin").width
}
// The main window header is dynamically filled with all available stages
Repeater
{
id: stagesHeader
model: UM.StageModel { }
delegate: Button
{
id: stageSelectorButton
text: model.name.toUpperCase()
checkable: true
checked: UM.Controller.activeStage !== null && model.id == UM.Controller.activeStage.stageId
anchors.verticalCenter: parent.verticalCenter
//style: UM.Theme.styles.main_window_header_tab
height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
// This id is required to find the stage buttons through Squish
property string stageId: model.id
hoverEnabled: true
leftPadding: 2 * UM.Theme.getSize("default_margin").width
rightPadding: 2 * UM.Theme.getSize("default_margin").width
// Set top & bottom padding to whatever space is left from height and the size of the text.
bottomPadding: Math.round((height - buttonLabel.contentHeight) / 2)
topPadding: bottomPadding
background: Rectangle
{
radius: UM.Theme.getSize("action_button_radius").width
color:
{
if (stageSelectorButton.checked)
{
return UM.Theme.getColor("main_window_header_button_background_active")
}
else
{
if (stageSelectorButton.hovered)
{
return UM.Theme.getColor("main_window_header_button_background_hovered")
}
return UM.Theme.getColor("main_window_header_button_background_inactive")
}
}
}
contentItem: UM.Label
{
id: buttonLabel
text: stageSelectorButton.text
anchors.centerIn: stageSelectorButton
font: UM.Theme.getFont("medium")
color:
{
if (stageSelectorButton.checked)
{
return UM.Theme.getColor("main_window_header_button_text_active")
}
else
{
if (stageSelectorButton.hovered)
{
return UM.Theme.getColor("main_window_header_button_text_hovered")
}
return UM.Theme.getColor("main_window_header_button_text_inactive")
}
}
}
// This is a trick to assure the activeStage is correctly changed. It doesn't work properly if done in the onClicked (see CURA-6028)
MouseArea
{
anchors.fill: parent
onClicked: UM.Controller.setActiveStage(model.id)
}
}
}
}
// Shortcut button to quick access the Toolbox
Button
{
id: marketplaceButton
text: catalog.i18nc("@action:button", "Marketplace")
height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
onClicked: Cura.Actions.browsePackages.trigger()
hoverEnabled: true
background: Rectangle
{
id: marketplaceButtonBorder
radius: UM.Theme.getSize("action_button_radius").width
color: UM.Theme.getColor("main_window_header_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("primary_text")
Rectangle
{
id: marketplaceButtonFill
anchors.fill: parent
radius: parent.radius
color: UM.Theme.getColor("primary_text")
opacity: marketplaceButton.hovered ? 0.2 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
}
}
contentItem: UM.Label
{
id: label
text: marketplaceButton.text
color: UM.Theme.getColor("primary_text")
width: contentWidth
}
anchors
{
right: applicationSwitcher.left
rightMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
}
Cura.NotificationIcon
{
id: marketplaceNotificationIcon
anchors
{
top: parent.top
right: parent.right
rightMargin: (-0.5 * width) | 0
topMargin: (-0.5 * height) | 0
}
visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
labelText:
{
const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
return itemCount > 9 ? "9+" : itemCount
}
}
}
ApplicationSwitcher
{
id: applicationSwitcher
anchors
{
verticalCenter: parent.verticalCenter
right: accountWidget.left
rightMargin: UM.Theme.getSize("default_margin").width
}
}
AccountWidget
{
id: accountWidget
anchors
{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
}
}
}
|