/*************************************************************/ /* */ /* Copyright (C) Microsoft Corporation. All rights reserved. */ /* */ /*************************************************************/ import QtQuick 2.7 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 import QtQuick.Controls.Styles 1.4 import com.microsoft.OneDrive 1.0 import Colors 1.0 import Fonts 1.0 // Header Rectangle // This is the actual colored rectangle which shows as the top element of the Activity center. Rectangle { id: headerBar // Set the color of the header based on state color: Colors.activity_center.list.background height: visible ? ((upToDateStatusRect.visible || syncStatusRect.visible || noNetworkStatusRect.visible || errorsViewHeader.visible ) ? 76 : 52) : 0 property bool errorViewCurrentlyVisible: false property bool useRotatingGear: headerModel.isRotatingGearEnabled anchors.top: parent.top anchors.left: parent.left anchors.leftMargin: 16 anchors.right: parent.right anchors.rightMargin: 16 property int titleTopMargin: 24 property int contextMenuAnchor: titleTopMargin + settingsIconButton.height property int secondaryTextTopMargin: 8 // setFocusOnSubState is called whenever the Header needs to switch active focus when changing views // This is mainly for Accessibility purposes. // // Instead of having the Activity Center Header be the active focus // Set the focus to the sub states if visible // This gives more context and information instead of just the title bar function setFocusOnSubState() { if (upToDateStatusRect.visible) { upToDateStatusRect.forceActiveFocus(); } else if (syncStatusRect.visible) { syncStatusRect.forceActiveFocus(); } else if (noNetworkStatusRect.visible) { noNetworkStatusRect.forceActiveFocus(); } else { titleText.forceActiveFocus(); } } // This is called every time the Error View is loaded. // Set the errors view header as the main focus for Accessibility purposes function setFocusOnErrorView() { errorsViewHeader.forceActiveFocus(); } Rectangle { id: headerTitle anchors.top: parent.top anchors.topMargin: titleTopMargin anchors.left: parent.left anchors.right: parent.right height: 20 color: "transparent" // A small OneDrive cloud icon Image { id: theOneDriveIcon anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left source: "file:///" + imageLocation + "blue_cloud.svg" sourceSize.width: 20 sourceSize.height: 20 width: 20 height: 20 fillMode:Image.PreserveAspectFit } // Account status text on the header bar Text { id: titleText // Aligning to the center of the parent (Icon and title), so that the text is vertically centered next to the icon. elide: Text.ElideRight horizontalAlignment: Text.AlignLeft anchors.left: theOneDriveIcon.right anchors.leftMargin: 10 anchors.right: reportABugIconButton.left anchors.verticalCenter: parent.verticalCenter color: Colors.activity_center.common.text text: headerModel.titleText font.family: Fonts.semibold font.styleName: "Semibold" font.pixelSize: 14 Accessible.role: Accessible.StaticText Accessible.name: titleText.text Accessible.focusable: true } // Send feedback icon next to title bar. // Only visible for Business + Msit users Rectangle { id: reportABugIconButton color : reportABugIconMa.pressed ? Colors.activity_center.settings_button.button_pressed : (reportABugIconMa.containsMouse ? Colors.activity_center.settings_button.button_hover : headerBar.color) property int buttonMargin: 12 width: reportABugIcon.width + buttonMargin height: reportABugIcon.height + buttonMargin visible: headerModel.isReportABugIconVisible border.width: (reportABugIconButton.activeFocus || colorThemeManager.highContrastEnabled) ? 1 : 0 border.color: Colors.activity_center.footer.button_focused_border anchors.verticalCenter: parent.verticalCenter anchors.right: settingsIconButton.left anchors.rightMargin: 3 radius: 3 Image { id: reportABugIcon anchors.centerIn: parent source: "file:///" + imageLocation + "sendFeedbackIcon.svg" sourceSize.width: 20 sourceSize.height: 20 width: 20 height: 20 fillMode:Image.PreserveAspectFit } activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: headerModel.reportBugText Accessible.focusable: true Accessible.onPressAction: { reportBugButtonClicked(true /* isKeyboard */); } Keys.onEnterPressed: reportBugButtonClicked(true /* isKeyboard */); Keys.onReturnPressed: reportBugButtonClicked(true /* isKeyboard */); // Note: Keys.onSpacePressed is not set here as it will cause two space events to be produced. // Look in QML's BasicButton::Keys.onReleased to see the event duplication that causes this (BasicButton is the parent of Button) // So we omit defining the action of space here, since the onReleased event of space will call the onClicked action. Keys.onReleased: { if (event.key === Qt.Key_Space) { reportBugButtonClicked(true /* isKeyboard */) // set event to accepted so that we don't get a duplicated event event.accepted = true; } } MouseArea { id: reportABugIconMa anchors.fill: parent hoverEnabled: true onClicked: { reportBugButtonClicked(false /* isKeyboard */); } } ToolTip { id: reportABugToolTip visible: (reportABugIconMa.containsMouse || reportABugIconButton.activeFocus) delay: 400 contentItem: Text{ height: 14 color: Colors.tool_tip.text text: headerModel.reportBugText font.family: Fonts.standard font.pixelSize: 12 } background: Rectangle { anchors.fill: parent color : (Qt.platform.os === "osx") ? Colors.tool_tip.background_mac : Colors.tool_tip.background border.color: (Qt.platform.os === "osx") ? Colors.activity_center.common.mac_border : Colors.tool_tip.border border.width: 1 } } } // Gear icon on the header title Rectangle { id: settingsIconButton color : settingsMa.pressed ? Colors.activity_center.settings_button.button_pressed : (settingsMa.containsMouse ? Colors.activity_center.settings_button.button_hover : headerBar.color) property int buttonMargin: 12 width: settingsIcon.width + buttonMargin height: settingsIcon.height + buttonMargin border.width: (settingsIconButton.activeFocus || colorThemeManager.highContrastEnabled) ? 1 : 0 border.color: Colors.activity_center.footer.button_focused_border anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right radius: 3 Image { id: settingsIcon anchors.centerIn: parent source: "file:///" + imageLocation + "settingsIcon2.svg" sourceSize.width: 20 sourceSize.height: 20 width: 20 height: 20 fillMode:Image.PreserveAspectFit NumberAnimation on rotation { id: rotationAnimation easing.type: Easing.OutCubic from: -0 to: 360 duration: 1300 loops: 1 running: useRotatingGear ? settingsMa.pressed : false } } activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: headerModel.settingsAccessibleText Accessible.focusable: true Accessible.onPressAction: { moreButtonClicked(true /* isKeyboard */); } Keys.onEnterPressed: moreButtonClicked(true /* isKeyboard */); Keys.onReturnPressed: moreButtonClicked(true /* isKeyboard */); // Note: Keys.onSpacePressed is not set here as it will cause two space events to be produced. // Look in QML's BasicButton::Keys.onReleased to see the event duplication that causes this (BasicButton is the parent of Button) // So we omit defining the action of space here, since the onReleased event of space will call the onClicked action. Keys.onReleased: { if (event.key === Qt.Key_Space) { moreButtonClicked(true /* isKeyboard */) // set event to accepted so that we don't get a duplicated event event.accepted = true; } } MouseArea { id: settingsMa anchors.fill: parent hoverEnabled: true onClicked: { moreButtonClicked(false /* isKeyboard */); } } ToolTip { id: settingsMenuToolTip visible: (settingsMa.containsMouse || settingsIconButton.activeFocus) && !contextMenu.visible delay: 400 contentItem: Text{ height: 14 color: Colors.tool_tip.text text: footerModel.buttonText_More font.family: Fonts.standard font.pixelSize: 12 } background: Rectangle { anchors.fill: parent color : (Qt.platform.os === "osx") ? Colors.tool_tip.background_mac : Colors.tool_tip.background border.color: (Qt.platform.os === "osx") ? Colors.activity_center.common.mac_border : Colors.tool_tip.border border.width: 1 } } } } UpToDateStatusRect { id: upToDateStatusRect objectName: "upToDateStatusRect" visible: headerModel.isUpToDateItemVisible && !errorViewCurrentlyVisible && !syncStatusRect.visible anchors.left: parent.left anchors.right: parent.right anchors.top: headerTitle.bottom anchors.topMargin: secondaryTextTopMargin } SyncStatusRect { id: syncStatusRect objectName: "syncStatusRect" visible: headerModel.isSyncing && !errorViewCurrentlyVisible anchors.top: headerTitle.bottom anchors.topMargin: secondaryTextTopMargin anchors.left: parent.left anchors.right: parent.right } NoNetworkStatusRect { id: noNetworkStatusRect objectName: "noNetworkStatusRect" visible: headerModel.isNoNetworkItemVisible && !errorViewCurrentlyVisible && !upToDateStatusRect.visible && !syncStatusRect.visible anchors.left: parent.left anchors.right: parent.right anchors.top: headerTitle.bottom anchors.topMargin: secondaryTextTopMargin } ErrorsViewHeader { id: errorsViewHeader visible: errorViewCurrentlyVisible anchors.top: headerTitle.bottom anchors.topMargin: secondaryTextTopMargin anchors.left: parent.left anchors.right: parent.right errorClosedCallback : function () { // If a user exists the error view, make sure to switch focus to Header bar for accessibility reasons headerBar.setFocusOnSubState(); } } function reportBugButtonClicked(isKeyboard) { headerModel.HeaderReportBugButtonClicked(); } function moreButtonClicked(isKeyboard) { headerModel.HeaderMoreSettingsClicked(); contextMenu.showMenu(isKeyboard, headerBar); } function showContextMenu() { contextMenu.showMenu(false, headerBar); } // Close the context menu when AC is closed and show it when the taskbar icon is right-clicked Window.onVisibilityChanged: { if (Window.visibility === Window.Hidden) { contextMenu.close(); } } ActivityCenterContextMenu { id: contextMenu instantiator.model: menuItemsModel itemModel: menuItemsModel isRTL: headerModel.isRTL launchAbove: false // Set focus to footer when context menu closed onClosed: { settingsIconButton.forceActiveFocus(); } yAnchor: contextMenuAnchor } }