/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/Themes/Ambiance/1.2/PageHeadStyle.qml is in ubuntu-ui-toolkit-theme 1.3.1918+16.04.20160404-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Ubuntu.Components 1.2
import Ubuntu.Components.Popups 1.0
import Ubuntu.Components.ListItems 1.0 as ListItem
import Ubuntu.Components.Styles 1.2 as Style
Style.PageHeadStyle {
id: headerStyle
objectName: "PageHeadStyle" // used in unit tests
contentHeight: units.gu(7)
fontWeight: Font.Light
fontSize: "x-large"
textLeftMargin: units.gu(2)
maximumNumberOfActions: 3
/*!
The color of the buttons in the header.
*/
property color buttonColor: styledItem.config.foregroundColor
/*!
The color of the title text.
*/
property color titleColor: styledItem.config.foregroundColor
/*!
The background color of the tabs panel and the actions overflow panel.
*/
property color panelBackgroundColor: styledItem.panelColor
/*!
The background color of the tapped item in the panel.
*/
property color panelHighlightColor: Theme.palette.selected.background
/*!
The foreground color (icon and text) of actions in the panel.
*/
property color panelForegroundColor: Theme.palette.selected.backgroundText
/*!
The text color of unselected sections and the section divider.
*/
property color sectionColor: Theme.palette.selected.backgroundText
/*!
The text color of the selected section.
*/
property color selectedSectionColor: UbuntuColors.orange
/*!
The background color of the pressed section.
*/
property color sectionHighlightColor: Theme.palette.selected.background
implicitHeight: headerStyle.contentHeight + divider.height
// FIXME: Workaround to get sectionsRepeater.count in autopilot tests,
// see also FIXME in AppHeader where this property is used.
property alias __sections_repeater_for_autopilot: sectionsRepeater
// Used by unit tests and autopilot tests to wait for animations to finish
readonly property bool animating: headerStyle.state == "OUT"
|| leftAnchor.anchors.leftMargin < 0
// for Unity8
// FIXME: Remove this property when we introduce a header preset that does not
// have a separator.
property alias __separator_visible: divider.visible
StyledItem {
id: divider
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
height: sectionsRow.visible ? units.gu(3) : units.gu(2)
// separatorSource and separatorBottomSource are needed for the deprecated
// HeadSeparatorImageStyle.
property url separatorSource: headerStyle.separatorSource
property url separatorBottomSource: headerStyle.separatorBottomSource
// backgroundColor is used in the new HeadDividerStyle
property color backgroundColor: styledItem.dividerColor
style: Theme.createStyleComponent("HeadDividerStyle.qml", divider)
property PageHeadSections sections: styledItem.config.sections
Row {
id: sectionsRow
anchors.centerIn: parent
width: childrenRect.width
height: parent.height
enabled: divider.sections.enabled
visible: divider.sections.model !== undefined
opacity: enabled ? 1.0 : 0.5
Repeater {
id: sectionsRepeater
model: divider.sections.model
objectName: "page_head_sections_repeater"
AbstractButton {
id: sectionButton
anchors.verticalCenter: parent ? parent.verticalCenter : undefined
objectName: "section_button_" + index
enabled: sectionsRow.enabled
width: label.width + units.gu(4)
height: sectionsRow.height + units.gu(2)
property bool selected: index === divider.sections.selectedIndex
onClicked: divider.sections.selectedIndex = index;
Rectangle {
visible: parent.pressed
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
right: parent.right
rightMargin: verticalDividerLine.width
}
height: sectionsRow.height
color: headerStyle.sectionHighlightColor
}
Label {
id: label
text: modelData
fontSize: "small"
anchors.centerIn: sectionButton
horizontalAlignment: Text.AlignHCenter
color: sectionButton.selected ?
headerStyle.selectedSectionColor :
headerStyle.sectionColor
}
// vertical divider line
Rectangle {
id: verticalDividerLine
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
}
height: units.dp(10)
width: units.dp(1)
visible: index < sectionsRepeater.model.length - 1
color: headerStyle.sectionColor
opacity: 0.2
}
}
}
}
}
states: [
State {
name: "IN"
PropertyChanges {
target: allContents
opacity: 1.0
}
},
State {
name: "OUT"
PropertyChanges {
target: allContents
opacity: 0.0
}
}
]
function animateOut() {
state = "OUT";
}
function animateIn() {
state = "IN";
}
signal animateOutFinished()
signal animateInFinished()
transitions: [
Transition {
id: transitionOut
from: "IN"
to: "OUT"
SequentialAnimation {
ParallelAnimation {
UbuntuNumberAnimation {
target: allContents
property: "opacity"
from: 1.0
to: 0.0
}
UbuntuNumberAnimation {
target: leftAnchor
properties: "anchors.leftMargin"
from: 0.0
to: -units.gu(5)
}
UbuntuNumberAnimation {
target: rightAnchor
properties: "anchors.rightMargin"
from: 0
to: -units.gu(5)
}
}
ScriptAction {
script: headerStyle.animateOutFinished()
}
}
},
Transition {
id: transitionIn
from: "OUT"
to: "IN"
SequentialAnimation {
ParallelAnimation {
UbuntuNumberAnimation {
target: allContents
property: "opacity"
from: 0.0
to: 1.0
}
UbuntuNumberAnimation {
target: leftAnchor
properties: "anchors.leftMargin"
from: -units.gu(5)
to: 0
}
UbuntuNumberAnimation {
target: rightAnchor
properties: "anchors.rightMargin"
from: -units.gu(5)
to: 0
}
}
ScriptAction {
script: headerStyle.animateInFinished()
}
}
}
]
Item {
id: allContents
anchors.fill: parent
Item {
id: leftAnchor
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
leftMargin: 0
}
width: 0
}
Item {
id: rightAnchor
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
rightMargin: 0
}
width: 0
}
Item {
id: leftButtonContainer
anchors {
left: leftAnchor.right
top: parent.top
leftMargin: width > 0 ? units.gu(1) : 0
}
width: childrenRect.width
height: headerStyle.contentHeight
PageHeadButton {
id: customBackButton
objectName: "customBackButton"
action: styledItem.config.backAction
visible: null !== styledItem.config.backAction &&
styledItem.config.backAction.visible
color: styledItem.config.foregroundColor
}
PageHeadButton {
id: backButton
objectName: "backButton"
iconName: "back"
visible: styledItem.pageStack !== null &&
styledItem.pageStack !== undefined &&
styledItem.pageStack.depth > 1 &&
!styledItem.config.backAction
text: "back"
color: styledItem.config.foregroundColor
onTriggered: {
styledItem.pageStack.pop();
}
}
PageHeadButton {
id: tabsButton
objectName: "tabsButton"
iconName: "navigation-menu"
visible: styledItem.tabsModel !== null &&
styledItem.tabsModel !== undefined &&
!backButton.visible &&
!customBackButton.visible
text: visible ? styledItem.tabsModel.count + " tabs" : ""
color: headerStyle.buttonColor
onTriggered: PopupUtils.open(tabsPopoverComponent, tabsButton)
Component {
id: tabsPopoverComponent
OverflowPanel {
id: tabsPopover
objectName: "tabsPopover"
callerMargin: -units.gu(1) + units.dp(4)
contentWidth: units.gu(20)
Binding {
target: tabsPopover.__foreground.__styleInstance
property: "color"
value: headerStyle.panelBackgroundColor
when: tabsPopover.__foreground &&
tabsPopover.__foreground.__styleInstance
}
Column {
anchors {
left: parent.left
top: parent.top
right: parent.right
}
Repeater {
model: styledItem.tabsModel
AbstractButton {
objectName: "tabButton" + index
onClicked: {
styledItem.tabsModel.selectedIndex = index;
tabsPopover.hide();
}
implicitHeight: units.gu(6) + bottomDividerLine.height
width: parent ? parent.width : units.gu(31)
Rectangle {
visible: parent.pressed
anchors {
left: parent.left
right: parent.right
top: parent.top
}
height: parent.height - bottomDividerLine.height
color: headerStyle.panelHighlightColor
}
Label {
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: units.dp(-1)
left: parent.left
leftMargin: units.gu(2)
right: parent.right
}
fontSize: "medium"
elide: Text.ElideRight
text: tab.title // FIXME: only "title" doesn't work with i18n.tr(). Why not?
color: headerStyle.panelForegroundColor
}
ListItem.ThinDivider {
id: bottomDividerLine
anchors.bottom: parent.bottom
visible: index < styledItem.tabsModel.count - 1
}
}
}
}
}
}
}
}
Item {
id: foreground
anchors {
left: leftButtonContainer.right
top: parent.top
// don't keep a margin if there is already a button with spacing
leftMargin: leftButtonContainer.width > 0 ? 0 : headerStyle.textLeftMargin
}
width: parent.width - anchors.leftMargin
- leftButtonContainer.anchors.leftMargin - leftButtonContainer.width
- actionsContainer.anchors.rightMargin - actionsContainer.width
height: headerStyle.contentHeight
Label {
objectName: "header_title_label"
LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
visible: !contentsContainer.visible && styledItem.config.preset === ""
anchors {
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
}
text: styledItem.title
font.weight: headerStyle.fontWeight
fontSize: headerStyle.fontSize
color: headerStyle.titleColor
elide: Text.ElideRight
}
Item {
// This Item is used to make the custom header item invisible
// when styledItem.contents is unset and its parent is not updated
// when the bindings below is no longer active
id: contentsContainer
anchors.fill: parent
visible: styledItem.contents || styledItem.config.contents
}
Binding {
target: styledItem.contents
property: "anchors.fill"
value: contentsContainer
when: styledItem.contents
}
Binding {
target: styledItem.contents
property: "parent"
value: contentsContainer
when: styledItem.contents
}
Binding {
target: styledItem.config.contents
property: "parent"
value: contentsContainer
when: styledItem.config.contents && !styledItem.contents
}
}
Row {
id: actionsContainer
property var visibleActions: getVisibleActions(styledItem.config.actions)
function getVisibleActions(actions) {
var visibleActionList = [];
for (var i in actions) {
var action = actions[i];
if (action && action.hasOwnProperty("visible") && action.visible) {
visibleActionList.push(action);
}
}
return visibleActionList;
}
QtObject {
id: numberOfSlots
property int requested: actionsContainer.visibleActions.length
property int left: tabsButton.visible || backButton.visible ||
customBackButton.visible ? 1 : 0
property int right: headerStyle.maximumNumberOfActions - left
property int overflow: actionsOverflowButton.visible ? 1 : 0
property int used: Math.min(right - overflow, requested)
}
anchors {
top: parent.top
right: rightAnchor.left
rightMargin: actionsContainer.width > 0 ? units.gu(1) : 0
}
width: childrenRect.width
height: headerStyle.contentHeight
Repeater {
model: numberOfSlots.used
PageHeadButton {
id: actionButton
objectName: action.objectName + "_header_button"
action: actionsContainer.visibleActions[index]
color: headerStyle.buttonColor
state: styledItem.config.preset === "select" ?
"IconAndLabel" : ""
}
}
PageHeadButton {
id: actionsOverflowButton
objectName: "actions_overflow_button"
visible: numberOfSlots.requested > numberOfSlots.right
// Ensure resetting of X when this button is not visible to avoid
// miscalculation of actionsContainer.width. Fixes bug #1408481.
onVisibleChanged: if (!visible) x = 0
iconName: "contextual-menu"
color: headerStyle.buttonColor
height: actionsContainer.height
onTriggered: PopupUtils.open(actionsOverflowPopoverComponent, actionsOverflowButton)
Component {
id: actionsOverflowPopoverComponent
OverflowPanel {
id: actionsOverflowPopover
objectName: "actions_overflow_popover"
callerMargin: -units.gu(1) + units.dp(4)
contentWidth: units.gu(20)
Binding {
target: actionsOverflowPopover.__foreground.__styleInstance
property: "color"
value: headerStyle.panelBackgroundColor
when: actionsOverflowPopover.__foreground &&
actionsOverflowPopover.__foreground.__styleInstance
}
// Ensure the popover closes when actions change and
// the list item below may be destroyed before its
// onClicked is executed. See bug
// https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1326963
Connections {
target: styledItem.config
onActionsChanged: {
actionsOverflowPopover.hide();
}
}
Connections {
target: styledItem
onConfigChanged: {
actionsOverflowPopover.hide();
}
}
Column {
anchors {
left: parent.left
top: parent.top
right: parent.right
}
Repeater {
id: overflowRepeater
model: numberOfSlots.requested - numberOfSlots.used
AbstractButton {
action: actionsContainer.visibleActions[numberOfSlots.used + index]
objectName: action.objectName + "_header_overflow_button"
onClicked: actionsOverflowPopover.hide()
implicitHeight: units.gu(6) + bottomDividerLine.height
width: parent ? parent.width : units.gu(31)
Rectangle {
visible: parent.pressed
anchors {
left: parent.left
right: parent.right
top: parent.top
}
height: parent.height - bottomDividerLine.height
color: headerStyle.panelHighlightColor
}
Icon {
id: actionIcon
source: action.iconSource
color: headerStyle.panelForegroundColor
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: units.dp(-1)
left: parent.left
leftMargin: units.gu(2)
}
width: units.gu(2)
height: units.gu(2)
opacity: action.enabled ? 1.0 : 0.5
}
Label {
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: units.dp(-1)
left: actionIcon.right
leftMargin: units.gu(2)
right: parent.right
}
fontSize: "small"
elide: Text.ElideRight
text: action.text
color: headerStyle.panelForegroundColor
opacity: action.enabled ? 1.0 : 0.5
}
ListItem.ThinDivider {
id: bottomDividerLine
anchors.bottom: parent.bottom
visible: index !== overflowRepeater.count - 1
}
}
}
}
}
}
}
}
}
}
|